diff --git a/examples/lock-app/cc32xx/main/AppTask.cpp b/examples/lock-app/cc32xx/main/AppTask.cpp index 18196a25b751aa..40390e66fc2c94 100644 --- a/examples/lock-app/cc32xx/main/AppTask.cpp +++ b/examples/lock-app/cc32xx/main/AppTask.cpp @@ -48,8 +48,6 @@ extern int WiFi_init(); extern void DisplayBanner(); } -/* Application Version and Naming*/ - #define APP_TASK_STACK_SIZE (4096) #define APP_TASK_PRIORITY 4 #define APP_EVENT_QUEUE_SIZE 10 @@ -172,9 +170,6 @@ int AppTask::Init() PLAT_LOG("Print Onboarding Codes"); PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kOnNetwork)); - PLAT_LOG("Start DNS Server"); - chip::app::DnssdServer::Instance().StartServer(); - return 0; } diff --git a/src/platform/cc32xx/CC32XXConfig.cpp b/src/platform/cc32xx/CC32XXConfig.cpp index 173b2864e3c2c0..c5d2370997a054 100644 --- a/src/platform/cc32xx/CC32XXConfig.cpp +++ b/src/platform/cc32xx/CC32XXConfig.cpp @@ -342,7 +342,7 @@ CHIP_ERROR CC32XXConfig::ReadConfigValue(Key key, bool & val) CHIP_ERROR ret; size_t ignore; uint8_t localVal; - cc32xxLog("[%s]", __FUNCTION__); + cc32xxLog("[%s] %s", __FUNCTION__, key.key); ret = ReadConfigValueBin(key, &localVal, sizeof(localVal), ignore); @@ -371,7 +371,7 @@ CHIP_ERROR CC32XXConfig::ReadConfigValueStr(Key key, char * buf, size_t bufSize, CHIP_ERROR CC32XXConfig::ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen) { - cc32xxLog("[%s]", __FUNCTION__); + cc32xxLog("[%s] %s", __FUNCTION__, key.key); CC32XXKVSEntry * pEntry = pList->GetEntryByKey(key.key); @@ -411,6 +411,7 @@ CHIP_ERROR CC32XXConfig::WriteConfigValueStr(Key key, const char * str, size_t s CHIP_ERROR CC32XXConfig::WriteConfigValueBin(Key key, const uint8_t * data, size_t dataLen) { cc32xxLog("[%s]", __FUNCTION__); + CHIP_ERROR err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; err = pList->AddEntryByKey(key.key, data, (uint16_t) dataLen); return err; @@ -418,7 +419,8 @@ CHIP_ERROR CC32XXConfig::WriteConfigValueBin(Key key, const uint8_t * data, size CHIP_ERROR CC32XXConfig::ClearConfigValue(Key key) { - cc32xxLog("[%s]", __FUNCTION__); + cc32xxLog("[%s] %s", __FUNCTION__, key.key); + CHIP_ERROR err = CHIP_NO_ERROR; pList->DeleteEntryByKey(key.key); return err; @@ -426,7 +428,8 @@ CHIP_ERROR CC32XXConfig::ClearConfigValue(Key key) bool CC32XXConfig::ConfigValueExists(Key key) { - cc32xxLog("[%s]", __FUNCTION__); + cc32xxLog("[%s] %s", __FUNCTION__, key.key); + bool ret = false; CC32XXKVSEntry * pEntry = pList->GetEntryByKey(key.key); if (pEntry) @@ -436,7 +439,8 @@ bool CC32XXConfig::ConfigValueExists(Key key) CHIP_ERROR CC32XXConfig::FactoryResetConfig() { - cc32xxLog("[%s]", __FUNCTION__); + cc32xxLog("[%s] ", __FUNCTION__); + while (1) ; CHIP_ERROR err = CHIP_NO_ERROR; @@ -445,7 +449,8 @@ CHIP_ERROR CC32XXConfig::FactoryResetConfig() void CC32XXConfig::RunConfigUnitTest() { - cc32xxLog("[%s]", __FUNCTION__); + cc32xxLog("[%s] ", __FUNCTION__); + // Run common unit test. ::chip::DeviceLayer::Internal::RunConfigUnitTest(); } diff --git a/src/platform/cc32xx/ConnectivityManagerImpl.cpp b/src/platform/cc32xx/ConnectivityManagerImpl.cpp index 3571bca266f70c..f9e5dc12e2ffd1 100644 --- a/src/platform/cc32xx/ConnectivityManagerImpl.cpp +++ b/src/platform/cc32xx/ConnectivityManagerImpl.cpp @@ -37,6 +37,7 @@ #include +#include #include #include #include @@ -46,10 +47,8 @@ extern "C" { #include - #define SLNETCONN_TIMEOUT 0xffff // "infinite" Timeout -extern int LWIP_IF_start(); extern void SlNetConnEventHandler(uint32_t ifID, SlNetConnStatus_e netStatus, void * data); } @@ -67,6 +66,7 @@ using namespace ::chip::System; using namespace ::chip::TLV; extern "C" void cc32xxLog(const char * aFormat, ...); +static struct netif * m_pNetIf = NULL; namespace chip { namespace DeviceLayer { @@ -141,22 +141,26 @@ CHIP_ERROR ConnectivityManagerImpl::_GetAndLogWifiStatsCounters(void) CHIP_ERROR ConnectivityManagerImpl::_Init() { - - cc32xxLog("ConnectivityManagerImpl::_Init()\n\r"); - int rc; - cc32xxLog("Start Wi-Fi\r\n"); - /* Try to connect to AP and go through provisioning (if needed) */ - rc = SlNetConn_start(SLNETCONN_SERVICE_LVL_MAC, SlNetConnEventHandler, SLNETCONN_TIMEOUT, 0); - assert(rc == 0); - - cc32xxLog("Start LWIP IF\n\r"); - rc = LWIP_IF_start(); - if (rc != 0) + cc32xxLog("Start LWIP"); + rc = LWIP_IF_init(_OnLwipEvent, false); + if (rc == 0) { - cc32xxLog("LWIP IF not started, error = ", rc); + m_pNetIf = LWIP_IF_addInterface(); } + if (m_pNetIf == NULL) + { + cc32xxLog("LWIP IF not started, error = %d", rc); + } + else + { + cc32xxLog("Start Wi-Fi"); + /* Try to connect to AP and go through provisioning (if needed) */ + rc = SlNetConn_start(SLNETCONN_SERVICE_LVL_MAC, SlNetConnEventHandler, SLNETCONN_TIMEOUT, 0); + assert(rc == 0); + LWIP_IF_setLinkUp(m_pNetIf); + } return CHIP_NO_ERROR; } @@ -189,10 +193,22 @@ void ConnectivityManagerImpl::_OnWiFiStationProvisionChange() } // ==================== ConnectivityManager Private Methods ==================== +void ConnectivityManagerImpl::_OnLwipEvent(struct netif * pNetIf, NetIfStatus_e status, void * pParams) +{ + switch (status) + { + case E_NETIF_STATUS_IP_ACQUIRED: + PlatformMgr().ScheduleWork(_OnIpAcquired); + break; + default: + break; + } +} -void ConnectivityManagerImpl::DriveStationState() +void ConnectivityManagerImpl::_OnIpAcquired(intptr_t arg) { - cc32xxLog("ConnectivityManagerImpl::DriveStationState()\n\r"); + cc32xxLog("ConnectivityManagerImpl::OnIpAcquired() : Start DNS Server"); + chip::app::DnssdServer::Instance().StartServer(); } void ConnectivityManagerImpl::OnStationConnected() diff --git a/src/platform/cc32xx/ConnectivityManagerImpl.h b/src/platform/cc32xx/ConnectivityManagerImpl.h index bad7e4893c01f9..36b64bb6e73bc1 100644 --- a/src/platform/cc32xx/ConnectivityManagerImpl.h +++ b/src/platform/cc32xx/ConnectivityManagerImpl.h @@ -39,6 +39,10 @@ #endif #include +extern "C" { +#include "lwip_if.h" +} + namespace chip { namespace Inet { @@ -122,16 +126,14 @@ class ConnectivityManagerImpl final : public ConnectivityManager, uint32_t mWiFiAPIdleTimeoutMS; uint16_t mFlags; - void DriveStationState(void); void OnStationConnected(void); void OnStationDisconnected(void); void ChangeWiFiStationState(WiFiStationState newState); - // static void DriveStationState(::chip::System::Layer * aLayer, void * aAppState, ::chip::System::Error aError); - void DriveAPState(void); + static void _OnLwipEvent(struct netif * pNetIf, NetIfStatus_e status, void * pParams); + static void _OnIpAcquired(intptr_t arg); CHIP_ERROR ConfigureWiFiAP(void); void ChangeWiFiAPState(WiFiAPState newState); - // static void DriveAPState(::chip::System::Layer * aLayer, void * aAppState, ::chip::System::Error aError); void UpdateInternetConnectivityState(void); void OnStationIPv4AddressAvailable(); diff --git a/src/platform/cc32xx/InetPlatformConfig.h b/src/platform/cc32xx/InetPlatformConfig.h index c40a4031de6033..7bb1cb784b266f 100644 --- a/src/platform/cc32xx/InetPlatformConfig.h +++ b/src/platform/cc32xx/InetPlatformConfig.h @@ -45,7 +45,7 @@ #endif // INET_CONFIG_NUM_TCP_ENDPOINTS #ifndef INET_CONFIG_NUM_UDP_ENDPOINTS -#define INET_CONFIG_NUM_UDP_ENDPOINTS 4 +#define INET_CONFIG_NUM_UDP_ENDPOINTS 8 #endif // INET_CONFIG_NUM_UDP_ENDPOINTS #endif // INET_PLATFORM_CONFIG_H diff --git a/third_party/ti_simplelink_sdk/repo_cc32xx b/third_party/ti_simplelink_sdk/repo_cc32xx index e5fbefba9c3c3a..13532baa294744 160000 --- a/third_party/ti_simplelink_sdk/repo_cc32xx +++ b/third_party/ti_simplelink_sdk/repo_cc32xx @@ -1 +1 @@ -Subproject commit e5fbefba9c3c3afa9c2c967b713c77e282d560fe +Subproject commit 13532baa2947440ced2f2abefd6a57b478f5100d