diff --git a/examples/lighting-app/p6/src/AppTask.cpp b/examples/lighting-app/p6/src/AppTask.cpp index ddfba4aba5fa9c..f85a59158e2aa4 100644 --- a/examples/lighting-app/p6/src/AppTask.cpp +++ b/examples/lighting-app/p6/src/AppTask.cpp @@ -164,11 +164,10 @@ void AppTask::AppTaskMain(void * pvParameter) while (true) { - BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, pdMS_TO_TICKS(10)); - while (eventReceived == pdTRUE) + BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, portMAX_DELAY); + if (eventReceived == pdTRUE) { sAppTask.DispatchEvent(&event); - eventReceived = xQueueReceive(sAppEventQueue, &event, 0); } // Collect connectivity and configuration state from the CHIP stack. Because @@ -335,7 +334,7 @@ void AppTask::FunctionHandler(AppEvent * aEvent) // FACTORY_RESET_TRIGGER_TIMEOUT to signal factory reset has been initiated. // To cancel factory reset: release the APP_FUNCTION_BUTTON once all LEDs // start blinking within the FACTORY_RESET_CANCEL_WINDOW_TIMEOUT - if (aEvent->ButtonEvent.Action == APP_BUTTON_PRESSED) + if (aEvent->ButtonEvent.Action == APP_BUTTON_RELEASED) { if (!sAppTask.mFunctionTimerActive && sAppTask.mFunction == Function::kNoneSelected) { diff --git a/examples/lock-app/p6/src/AppTask.cpp b/examples/lock-app/p6/src/AppTask.cpp index 0729aea5f97816..94ecddb6a8365e 100644 --- a/examples/lock-app/p6/src/AppTask.cpp +++ b/examples/lock-app/p6/src/AppTask.cpp @@ -161,11 +161,10 @@ void AppTask::AppTaskMain(void * pvParameter) while (true) { - BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, pdMS_TO_TICKS(10)); - while (eventReceived == pdTRUE) + BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, portMAX_DELAY); + if (eventReceived == pdTRUE) { sAppTask.DispatchEvent(&event); - eventReceived = xQueueReceive(sAppEventQueue, &event, 0); } // Collect connectivity and configuration state from the CHIP stack. Because // the CHIP event loop is being run in a separate task, the stack must be @@ -334,7 +333,7 @@ void AppTask::FunctionHandler(AppEvent * event) // FACTORY_RESET_TRIGGER_TIMEOUT to signal factory reset has been initiated. // To cancel factory reset: release the APP_FUNCTION_BUTTON once all LEDs // start blinking within the FACTORY_RESET_CANCEL_WINDOW_TIMEOUT - if (event->ButtonEvent.Action == APP_BUTTON_PRESSED) + if (event->ButtonEvent.Action == APP_BUTTON_RELEASED) { if (!sAppTask.mFunctionTimerActive && sAppTask.mFunction == Function::kNoneSelected) { diff --git a/src/platform/P6/ConnectivityManagerImpl.cpp b/src/platform/P6/ConnectivityManagerImpl.cpp index aed4bb9d679a49..6819e71a76f685 100644 --- a/src/platform/P6/ConnectivityManagerImpl.cpp +++ b/src/platform/P6/ConnectivityManagerImpl.cpp @@ -55,6 +55,11 @@ ConnectivityManagerImpl ConnectivityManagerImpl::sInstance; ConnectivityManager::WiFiStationMode ConnectivityManagerImpl::_GetWiFiStationMode(void) { + uint32_t curWiFiMode; + mWiFiStationMode = (Internal::P6Utils::wifi_get_mode(curWiFiMode) == CHIP_NO_ERROR && + (curWiFiMode == WIFI_MODE_APSTA || curWiFiMode == WIFI_MODE_STA)) + ? kWiFiStationMode_Enabled + : kWiFiStationMode_Disabled; return mWiFiStationMode; } @@ -181,7 +186,6 @@ CHIP_ERROR ConnectivityManagerImpl::_GetAndLogWiFiStatsCounters(void) CHIP_ERROR ConnectivityManagerImpl::_Init() { CHIP_ERROR err = CHIP_NO_ERROR; - cy_rslt_t result = CY_RSLT_SUCCESS; mLastStationConnectFailTime = System::Clock::kZero; mLastAPDemandTime = System::Clock::kZero; mWiFiStationMode = kWiFiStationMode_Disabled; @@ -208,13 +212,8 @@ CHIP_ERROR ConnectivityManagerImpl::_Init() memcpy(wifiConfig.sta.password, CHIP_DEVICE_CONFIG_DEFAULT_STA_PASSWORD, min(strlen(CHIP_DEVICE_CONFIG_DEFAULT_STA_PASSWORD), sizeof(wifiConfig.sta.password))); wifiConfig.sta.security = CHIP_DEVICE_CONFIG_DEFAULT_STA_SECURITY; - result = Internal::P6Utils::p6_wifi_set_config(WIFI_IF_STA, &wifiConfig); - if (result != CY_RSLT_SUCCESS) - { - ChipLogError(DeviceLayer, "p6_wifi_set_config() failed: %d", (int) result); - SuccessOrExit(CHIP_ERROR_INTERNAL); - } - err = CHIP_NO_ERROR; + err = Internal::P6Utils::p6_wifi_set_config(WIFI_IF_STA, &wifiConfig); + SuccessOrExit(err); } // Force AP mode off for now. err = Internal::P6Utils::SetAPMode(false); @@ -323,7 +322,6 @@ CHIP_ERROR ConnectivityManagerImpl::ConfigureWiFiAP() { CHIP_ERROR err = CHIP_NO_ERROR; wifi_config_t wifiConfig; - cy_rslt_t result = CY_RSLT_SUCCESS; memset(&wifiConfig.ap, 0, sizeof(wifi_config_ap_t)); snprintf((char *) wifiConfig.ap.ssid, sizeof(wifiConfig.ap.ssid), "%s-%04X-%04X", CHIP_DEVICE_CONFIG_WIFI_AP_SSID_PREFIX, @@ -336,13 +334,8 @@ CHIP_ERROR ConnectivityManagerImpl::ConfigureWiFiAP() wifiConfig.ap.ip_settings.gateway = ap_mode_ip_settings.gateway; ChipLogProgress(DeviceLayer, "Configuring WiFi AP: SSID %s, channel %u", wifiConfig.ap.ssid, wifiConfig.ap.channel); - result = Internal::P6Utils::p6_wifi_set_config(WIFI_IF_AP, &wifiConfig); - if (result != CY_RSLT_SUCCESS) - { - ChipLogError(DeviceLayer, "p6_wifi_set_config(WIFI_IF_AP) failed: %d", (int) result); - err = CHIP_ERROR_INTERNAL; - SuccessOrExit(err); - } + err = Internal::P6Utils::p6_wifi_set_config(WIFI_IF_AP, &wifiConfig); + SuccessOrExit(err); err = Internal::P6Utils::p6_start_ap(); if (err != CHIP_NO_ERROR) @@ -478,6 +471,9 @@ void ConnectivityManagerImpl::DriveStationState() CHIP_ERROR err = CHIP_NO_ERROR; bool stationConnected; + // Refresh the current station mode by reading the configuration from storage. + GetWiFiStationMode(); + // If the station interface is NOT under application control... if (mWiFiStationMode != kWiFiStationMode_ApplicationControlled) { @@ -609,6 +605,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV4_Assigned; PlatformMgr().PostEventOrDie(&event); + ChipLogProgress(DeviceLayer, "IPv4 Address Assigned : %s", ip4addr_ntoa(netif_ip4_addr(net_interface))); } // Search among the IPv6 addresses assigned to the interface for a Global Unicast // address (2000::/3) that is in the valid state. If such an address is found... @@ -622,6 +619,7 @@ void ConnectivityManagerImpl::UpdateInternetConnectivityState(void) event.Type = DeviceEventType::kInterfaceIpAddressChanged; event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV6_Assigned; PlatformMgr().PostEventOrDie(&event); + ChipLogProgress(DeviceLayer, "IPv6 Address Assigned : %s", ip6addr_ntoa(netif_ip6_addr(net_interface, i))); } } } diff --git a/src/platform/P6/DeviceNetworkProvisioningDelegateImpl.cpp b/src/platform/P6/DeviceNetworkProvisioningDelegateImpl.cpp index 23c1d01f1a5f08..08f8593072584d 100644 --- a/src/platform/P6/DeviceNetworkProvisioningDelegateImpl.cpp +++ b/src/platform/P6/DeviceNetworkProvisioningDelegateImpl.cpp @@ -27,7 +27,6 @@ namespace DeviceLayer { CHIP_ERROR DeviceNetworkProvisioningDelegateImpl::_ProvisionWiFiNetwork(const char * ssid, const char * passwd) { CHIP_ERROR err = CHIP_NO_ERROR; - cy_rslt_t rslt = CY_RSLT_SUCCESS; ChipLogProgress(NetworkProvisioning, "P6NetworkProvisioningDelegate: SSID: %s", ssid); err = ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Disabled); @@ -36,14 +35,10 @@ CHIP_ERROR DeviceNetworkProvisioningDelegateImpl::_ProvisionWiFiNetwork(const ch // Set the wifi configuration wifi_config_t wifi_config; Internal::P6Utils::populate_wifi_config_t(&wifi_config, WIFI_IF_STA, (const cy_wcm_ssid_t *) ssid, - (const cy_wcm_passphrase_t *) passwd, CHIP_DEVICE_CONFIG_DEFAULT_STA_SECURITY); + (const cy_wcm_passphrase_t *) passwd, + (strlen(passwd)) ? CHIP_DEVICE_CONFIG_DEFAULT_STA_SECURITY : CY_WCM_SECURITY_OPEN); - rslt = Internal::P6Utils::p6_wifi_set_config(WIFI_IF_STA, &wifi_config); - if (rslt != CY_RSLT_SUCCESS) - { - err = CHIP_ERROR_INTERNAL; - ChipLogError(DeviceLayer, "p6_wifi_set_config() failed"); - } + err = Internal::P6Utils::p6_wifi_set_config(WIFI_IF_STA, &wifi_config); SuccessOrExit(err); err = ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Enabled); diff --git a/src/platform/P6/P6Config.cpp b/src/platform/P6/P6Config.cpp index d2ad8c7c4e6416..6cfe10aa2f7ebd 100644 --- a/src/platform/P6/P6Config.cpp +++ b/src/platform/P6/P6Config.cpp @@ -73,6 +73,10 @@ const P6Config::Key P6Config::kConfigKey_ActiveLocale = { kConfigNamespace const P6Config::Key P6Config::kConfigKey_Breadcrumb = { kConfigNamespace_ChipConfig, "breadcrumb" }; const P6Config::Key P6Config::kConfigKey_HourFormat = { kConfigNamespace_ChipConfig, "hour-format" }; const P6Config::Key P6Config::kConfigKey_CalendarType = { kConfigNamespace_ChipConfig, "calendar-type" }; +const P6Config::Key P6Config::kConfigKey_WiFiSSID = { kConfigNamespace_ChipConfig, "wifi-ssid" }; +const P6Config::Key P6Config::kConfigKey_WiFiPassword = { kConfigNamespace_ChipConfig, "wifi-password" }; +const P6Config::Key P6Config::kConfigKey_WiFiSecurity = { kConfigNamespace_ChipConfig, "wifi-security" }; +const P6Config::Key P6Config::kConfigKey_WiFiMode = { kConfigNamespace_ChipConfig, "wifimode" }; // Keys stored in the Chip-counters namespace const P6Config::Key P6Config::kCounterKey_RebootCount = { kConfigNamespace_ChipCounters, "reboot-count" }; @@ -212,9 +216,10 @@ bool P6Config::ConfigValueExists(Key key) // Clear out keys in config namespace CHIP_ERROR P6Config::FactoryResetConfig(void) { - const Key * config_keys[] = { &kConfigKey_FabricId, &kConfigKey_ServiceConfig, &kConfigKey_PairedAccountId, - &kConfigKey_ServiceId, &kConfigKey_GroupKeyIndex, &kConfigKey_LastUsedEpochKeyId, - &kConfigKey_FailSafeArmed, &kConfigKey_WiFiStationSecType }; + const Key * config_keys[] = { &kConfigKey_FabricId, &kConfigKey_ServiceConfig, &kConfigKey_PairedAccountId, + &kConfigKey_ServiceId, &kConfigKey_GroupKeyIndex, &kConfigKey_LastUsedEpochKeyId, + &kConfigKey_FailSafeArmed, &kConfigKey_WiFiStationSecType, &kConfigKey_WiFiSSID, + &kConfigKey_WiFiPassword, &kConfigKey_WiFiSecurity, &kConfigKey_WiFiMode }; for (uint32_t i = 0; i < (sizeof(config_keys) / sizeof(config_keys[0])); i++) { diff --git a/src/platform/P6/P6Config.h b/src/platform/P6/P6Config.h index 3b9cffcfe96731..b59b57f07dd951 100644 --- a/src/platform/P6/P6Config.h +++ b/src/platform/P6/P6Config.h @@ -78,6 +78,10 @@ class P6Config static const Key kConfigKey_Breadcrumb; static const Key kConfigKey_HourFormat; static const Key kConfigKey_CalendarType; + static const Key kConfigKey_WiFiSSID; + static const Key kConfigKey_WiFiPassword; + static const Key kConfigKey_WiFiSecurity; + static const Key kConfigKey_WiFiMode; // CHIP Counter keys static const Key kCounterKey_RebootCount; diff --git a/src/platform/P6/P6Utils.cpp b/src/platform/P6/P6Utils.cpp index 3e08a3e6becddc..4c38e6d89ac255 100644 --- a/src/platform/P6/P6Utils.cpp +++ b/src/platform/P6/P6Utils.cpp @@ -43,6 +43,7 @@ #include "lwip/sys.h" #include "lwip/timeouts.h" #include +#include using namespace ::chip::DeviceLayer::Internal; using chip::DeviceLayer::Internal::DeviceNetworkInfo; @@ -104,8 +105,7 @@ CHIP_ERROR P6Utils::IsAPEnabled(bool & apEnabled) bool P6Utils::IsStationProvisioned(void) { wifi_config_t stationConfig; - return (p6_wifi_get_config(WIFI_IF_STA, &stationConfig) == CY_RSLT_SUCCESS && - strlen((const char *) stationConfig.sta.ssid) != 0); + return (p6_wifi_get_config(WIFI_IF_STA, &stationConfig) == CHIP_NO_ERROR && strlen((const char *) stationConfig.sta.ssid) != 0); } CHIP_ERROR P6Utils::IsStationConnected(bool & connected) @@ -153,6 +153,7 @@ CHIP_ERROR P6Utils::EnableStationMode(void) { WiFiMode = WIFI_MODE_STA; } + wifi_set_mode(WiFiMode); return err; } @@ -202,12 +203,64 @@ const char * P6Utils::WiFiModeToStr(wifi_mode_t wifiMode) return "(unknown)"; } } -cy_rslt_t P6Utils::p6_wifi_set_config(wifi_interface_t interface, wifi_config_t * conf) + +CHIP_ERROR P6Utils::GetWiFiSSID(char * buf, size_t bufSize) +{ + size_t num = 0; + return P6Config::ReadConfigValueStr(P6Config::kConfigKey_WiFiSSID, buf, bufSize, num); +} + +CHIP_ERROR P6Utils::StoreWiFiSSID(char * buf) { + return P6Config::WriteConfigValueStr(P6Config::kConfigKey_WiFiSSID, buf); +} + +CHIP_ERROR P6Utils::GetWiFiPassword(char * buf, size_t bufSize) +{ + size_t num = 0; + return P6Config::ReadConfigValueStr(P6Config::kConfigKey_WiFiPassword, buf, bufSize, num); +} + +CHIP_ERROR P6Utils::StoreWiFiPassword(char * buf) +{ + return P6Config::WriteConfigValueStr(P6Config::kConfigKey_WiFiPassword, buf); +} + +CHIP_ERROR P6Utils::GetWiFiSecurityCode(uint32_t & security) +{ + return P6Config::ReadConfigValue(P6Config::kConfigKey_WiFiSecurity, security); +} + +CHIP_ERROR P6Utils::StoreWiFiSecurityCode(uint32_t security) +{ + return P6Config::WriteConfigValue(P6Config::kConfigKey_WiFiSecurity, security); +} + +CHIP_ERROR P6Utils::wifi_get_mode(uint32_t & mode) +{ + return P6Config::ReadConfigValue(P6Config::kConfigKey_WiFiMode, mode); +} + +CHIP_ERROR P6Utils::wifi_set_mode(uint32_t mode) +{ + return P6Config::WriteConfigValue(P6Config::kConfigKey_WiFiMode, mode); +} + +CHIP_ERROR P6Utils::p6_wifi_set_config(wifi_interface_t interface, wifi_config_t * conf) +{ + CHIP_ERROR err = CHIP_NO_ERROR; if (interface == WIFI_IF_STA) { + /* Store Wi-Fi Configurations in Storage */ + err = StoreWiFiSSID((char *) conf->sta.ssid); + SuccessOrExit(err); + + err = StoreWiFiPassword((char *) conf->sta.password); + SuccessOrExit(err); + + err = StoreWiFiSecurityCode(conf->sta.security); + SuccessOrExit(err); populate_wifi_config_t(&wifi_conf, interface, &conf->sta.ssid, &conf->sta.password, conf->sta.security); - ChipLogProgress(DeviceLayer, "STA %s : [%s] [%s] \r\n", __func__, wifi_conf.sta.ssid, wifi_conf.sta.password); } else { @@ -216,17 +269,37 @@ cy_rslt_t P6Utils::p6_wifi_set_config(wifi_interface_t interface, wifi_config_t wifi_conf.ap.ip_settings.ip_address = conf->ap.ip_settings.ip_address; wifi_conf.ap.ip_settings.netmask = conf->ap.ip_settings.netmask; wifi_conf.ap.ip_settings.gateway = conf->ap.ip_settings.gateway; - ChipLogProgress(DeviceLayer, "AP %s : [%s] [%s] channel %d\r\n", __func__, wifi_conf.ap.ssid, wifi_conf.ap.password, - wifi_conf.ap.channel); } - return CY_RSLT_SUCCESS; + +exit: + return err; } -cy_rslt_t P6Utils::p6_wifi_get_config(wifi_interface_t interface, wifi_config_t * conf) +CHIP_ERROR P6Utils::p6_wifi_get_config(wifi_interface_t interface, wifi_config_t * conf) { + uint32 code = 0; + CHIP_ERROR err = CHIP_NO_ERROR; if (interface == WIFI_IF_STA) { - populate_wifi_config_t(conf, interface, &wifi_conf.sta.ssid, &wifi_conf.sta.password, wifi_conf.sta.security); + if (P6Config::ConfigValueExists(P6Config::kConfigKey_WiFiSSID) && + P6Config::ConfigValueExists(P6Config::kConfigKey_WiFiPassword) && + P6Config::ConfigValueExists(P6Config::kConfigKey_WiFiSecurity)) + { + /* Retrieve Wi-Fi Configurations from Storage */ + err = GetWiFiSSID((char *) conf->sta.ssid, sizeof(conf->sta.ssid)); + SuccessOrExit(err); + + err = GetWiFiPassword((char *) conf->sta.password, sizeof(conf->sta.password)); + SuccessOrExit(err); + + err = GetWiFiSecurityCode(code); + SuccessOrExit(err); + conf->sta.security = static_cast(code); + } + else + { + populate_wifi_config_t(conf, interface, &wifi_conf.sta.ssid, &wifi_conf.sta.password, wifi_conf.sta.security); + } } else { @@ -235,20 +308,19 @@ cy_rslt_t P6Utils::p6_wifi_get_config(wifi_interface_t interface, wifi_config_t conf->ap.ip_settings.ip_address = wifi_conf.ap.ip_settings.ip_address; conf->ap.ip_settings.netmask = wifi_conf.ap.ip_settings.netmask; conf->ap.ip_settings.gateway = wifi_conf.ap.ip_settings.gateway; - ChipLogProgress(DeviceLayer, "AP %s [%s] [%s] channel %d\r\n", __func__, wifi_conf.ap.ssid, wifi_conf.ap.password, - wifi_conf.ap.channel); } - return CY_RSLT_SUCCESS; + +exit: + return err; } CHIP_ERROR P6Utils::GetWiFiStationProvision(Internal::DeviceNetworkInfo & netInfo, bool includeCredentials) { - CHIP_ERROR err = CHIP_NO_ERROR; - cy_rslt_t result = CY_RSLT_SUCCESS; + CHIP_ERROR err = CHIP_NO_ERROR; wifi_config_t stationConfig; - result = p6_wifi_get_config(WIFI_IF_STA, &stationConfig); - VerifyOrExit(result == CY_RSLT_SUCCESS, err = CHIP_ERROR_INTERNAL); + err = p6_wifi_get_config(WIFI_IF_STA, &stationConfig); + SuccessOrExit(err); ChipLogProgress(DeviceLayer, "GetWiFiStationProvision"); VerifyOrExit(strlen((const char *) stationConfig.sta.ssid) != 0, err = CHIP_ERROR_INCORRECT_STATE); @@ -274,8 +346,7 @@ CHIP_ERROR P6Utils::GetWiFiStationProvision(Internal::DeviceNetworkInfo & netInf CHIP_ERROR P6Utils::SetWiFiStationProvision(const Internal::DeviceNetworkInfo & netInfo) { - CHIP_ERROR err = CHIP_NO_ERROR; - cy_rslt_t result = CY_RSLT_SUCCESS; + CHIP_ERROR err = CHIP_NO_ERROR; wifi_config_t wifiConfig; ChipLogProgress(DeviceLayer, "SetWiFiStationProvision"); char wifiSSID[kMaxWiFiSSIDLength + 1]; @@ -301,13 +372,7 @@ CHIP_ERROR P6Utils::SetWiFiStationProvision(const Internal::DeviceNetworkInfo & populate_wifi_config_t(&wifiConfig, WIFI_IF_STA, (cy_wcm_ssid_t *) wifiSSID, (cy_wcm_passphrase_t *) netInfo.WiFiKey); // Configure the P6 WiFi interface. - result = p6_wifi_set_config(WIFI_IF_STA, &wifiConfig); - if (result != CY_RSLT_SUCCESS) - { - ChipLogError(DeviceLayer, "p6_wifi_set_config() failed "); - err = CHIP_ERROR_INTERNAL; - } - SuccessOrExit(err); + ReturnLogErrorOnFailure(p6_wifi_set_config(WIFI_IF_STA, &wifiConfig)); ChipLogProgress(DeviceLayer, "WiFi station provision set (SSID: %s)", netInfo.WiFiSSID); @@ -322,7 +387,7 @@ CHIP_ERROR P6Utils::ClearWiFiStationProvision(void) ChipLogProgress(DeviceLayer, "ClearWiFiStationProvision"); // Clear the P6 WiFi station configuration. memset(&stationConfig.sta, 0, sizeof(stationConfig.sta)); - p6_wifi_set_config(WIFI_IF_STA, &stationConfig); + ReturnLogErrorOnFailure(p6_wifi_set_config(WIFI_IF_STA, &stationConfig)); return err; } @@ -355,8 +420,7 @@ CHIP_ERROR P6Utils::p6_wifi_connect(void) memcpy(&connect_param.ap_credentials.password, &stationConfig.sta.password, strlen((char *) stationConfig.sta.password)); connect_param.ap_credentials.security = stationConfig.sta.security; - ChipLogProgress(DeviceLayer, "p6_wifi_connect ssid %s pass %s sec %d \r\n", connect_param.ap_credentials.SSID, - connect_param.ap_credentials.password, connect_param.ap_credentials.security); + ChipLogProgress(DeviceLayer, "Connecting to AP : [%s] \r\n", connect_param.ap_credentials.SSID); result = cy_wcm_connect_ap(&connect_param, &ip_addr); if (result != CY_RSLT_SUCCESS) @@ -391,7 +455,7 @@ CHIP_ERROR P6Utils::p6_start_ap(void) memcpy(&ap_conf.ip_settings, &stationConfig.ap.ip_settings, sizeof(stationConfig.ap.ip_settings)); ap_conf.ap_credentials.security = stationConfig.ap.security; ap_conf.channel = stationConfig.ap.channel; - ChipLogProgress(DeviceLayer, "p6_start_ap %s %s \r\n", ap_conf.ap_credentials.SSID, ap_conf.ap_credentials.password); + ChipLogProgress(DeviceLayer, "p6_start_ap %s \r\n", ap_conf.ap_credentials.SSID); /* Start AP */ result = cy_wcm_start_ap(&ap_conf); diff --git a/src/platform/P6/P6Utils.h b/src/platform/P6/P6Utils.h index 62afdabdc411ec..411d498e211ea5 100644 --- a/src/platform/P6/P6Utils.h +++ b/src/platform/P6/P6Utils.h @@ -204,8 +204,8 @@ class P6Utils static CHIP_ERROR GetWiFiStationProvision(Internal::DeviceNetworkInfo & netInfo, bool includeCredentials); static CHIP_ERROR SetWiFiStationProvision(const Internal::DeviceNetworkInfo & netInfo); static CHIP_ERROR ClearWiFiStationProvision(void); - static cy_rslt_t p6_wifi_get_config(wifi_interface_t interface, wifi_config_t * conf); - static cy_rslt_t p6_wifi_set_config(wifi_interface_t interface, wifi_config_t * conf); + static CHIP_ERROR p6_wifi_get_config(wifi_interface_t interface, wifi_config_t * conf); + static CHIP_ERROR p6_wifi_set_config(wifi_interface_t interface, wifi_config_t * conf); static CHIP_ERROR p6_wifi_disconnect(void); static CHIP_ERROR p6_wifi_connect(void); static CHIP_ERROR p6_start_ap(void); @@ -218,6 +218,14 @@ class P6Utils static CHIP_ERROR ping_init(void); static void unpack_xtlv_buf(const uint8_t * tlv_buf, uint16_t buflen, wl_cnt_ver_30_t * cnt, wl_cnt_ge40mcst_v1_t * cnt_ge40); static void heap_usage(heap_info_t * heap); + static CHIP_ERROR GetWiFiSSID(char * buf, size_t bufSize); + static CHIP_ERROR StoreWiFiSSID(char * buf); + static CHIP_ERROR GetWiFiPassword(char * buf, size_t bufSize); + static CHIP_ERROR StoreWiFiPassword(char * buf); + static CHIP_ERROR GetWiFiSecurityCode(uint32_t & security); + static CHIP_ERROR StoreWiFiSecurityCode(uint32_t security); + static CHIP_ERROR wifi_get_mode(uint32_t & security); + static CHIP_ERROR wifi_set_mode(uint32_t security); }; } // namespace Internal