From 44a3ac9ef1af42235e0290c5473c68878da5f6dd Mon Sep 17 00:00:00 2001 From: wyhong <30567533+wy-hh@users.noreply.github.com> Date: Thu, 19 Jan 2023 22:33:22 +0800 Subject: [PATCH] [Bouffalolab] Update bouffalolab sdk repo 1.6.40 (#24514) * create bl_iot_sdk.gni * update bl_iot_sdk.gni * remove more 702 specific-name * update bl602 * update bl602 & bl702 * update toolchain path * fix issues for bl602 * bl602 mbedtls * correct partition table for bl702 and update sdk sub-repo * update for update sdk * update timer task stack size * update matter for sdk change * remove unused files * update sdk repo * update sdk repo * fix compile error * fix restyle * remove logs * update debug print * update sdk to 1.6.40 * fix restyle --- .../bouffalolab/common/AppTask.cpp | 8 +- .../bouffalolab/bl602/FreeRTOSConfig.h | 14 +- .../bouffalolab/bl702/FreeRTOSConfig.h | 10 +- .../bl702/ldscripts/psram_flash.ld | 4 - .../platform/bouffalolab/common/plat/main.cpp | 8 +- src/platform/bouffalolab/BL602/DnssdImpl.cpp | 324 --------------- .../bouffalolab/BL602/GroupKeyStoreImpl.cpp | 377 ----------------- .../bouffalolab/BL602/GroupKeyStoreImpl.h | 73 ---- .../BL602/NetworkCommissioningWiFiDriver.cpp | 368 ----------------- .../bouffalolab/BL602/PlatformManagerImpl.cpp | 24 +- .../BL602/SoftwareUpdateManagerImpl.cpp | 45 --- .../BL602/SoftwareUpdateManagerImpl.h | 88 ---- .../bouffalolab/BL602/WarmPlatformConfig.h | 39 -- src/platform/bouffalolab/BL602/gatt.xml | 98 ----- src/platform/bouffalolab/BL602/gatt_db.c | 379 ------------------ src/platform/bouffalolab/BL602/gatt_db.h | 42 -- .../BL702/ConfigurationManagerImpl.cpp | 12 +- .../bouffalolab/BL702/PlatformManagerImpl.cpp | 2 + .../BL702/ThreadStackManagerImpl.cpp | 17 +- src/platform/bouffalolab/BL702/bl702Config.h | 38 +- third_party/bouffalolab/bl602/bl_iot_sdk.gni | 24 +- third_party/bouffalolab/bl702/bl_iot_sdk.gni | 53 ++- third_party/bouffalolab/repo | 2 +- 23 files changed, 121 insertions(+), 1928 deletions(-) delete mode 100644 src/platform/bouffalolab/BL602/DnssdImpl.cpp delete mode 100644 src/platform/bouffalolab/BL602/GroupKeyStoreImpl.cpp delete mode 100644 src/platform/bouffalolab/BL602/GroupKeyStoreImpl.h delete mode 100644 src/platform/bouffalolab/BL602/NetworkCommissioningWiFiDriver.cpp delete mode 100644 src/platform/bouffalolab/BL602/SoftwareUpdateManagerImpl.cpp delete mode 100644 src/platform/bouffalolab/BL602/SoftwareUpdateManagerImpl.h delete mode 100644 src/platform/bouffalolab/BL602/WarmPlatformConfig.h delete mode 100644 src/platform/bouffalolab/BL602/gatt.xml delete mode 100644 src/platform/bouffalolab/BL602/gatt_db.c delete mode 100644 src/platform/bouffalolab/BL602/gatt_db.h diff --git a/examples/lighting-app/bouffalolab/common/AppTask.cpp b/examples/lighting-app/bouffalolab/common/AppTask.cpp index 2fe2a403357717..d18f38a3e7371e 100644 --- a/examples/lighting-app/bouffalolab/common/AppTask.cpp +++ b/examples/lighting-app/bouffalolab/common/AppTask.cpp @@ -144,9 +144,6 @@ void PlatformManagerImpl::PlatformInit(void) chip::DeviceLayer::ConnectivityMgr().SetBLEDeviceName("MatterLight"); #if CHIP_ENABLE_OPENTHREAD -#if CONFIG_ENABLE_CHIP_SHELL - cmd_otcli_init(); -#endif ChipLogProgress(NotSpecified, "Initializing OpenThread stack"); ret = ThreadStackMgr().InitThreadStack(); @@ -166,6 +163,11 @@ void PlatformManagerImpl::PlatformInit(void) ChipLogError(NotSpecified, "ConnectivityMgr().SetThreadDeviceType() failed"); appError(ret); } + +#if CONFIG_ENABLE_CHIP_SHELL + cmd_otcli_init(); +#endif + #elif CHIP_DEVICE_CONFIG_ENABLE_WIFI ret = sWiFiNetworkCommissioningInstance.Init(); diff --git a/examples/platform/bouffalolab/bl602/FreeRTOSConfig.h b/examples/platform/bouffalolab/bl602/FreeRTOSConfig.h index 96379643d791e3..b0241d60539624 100644 --- a/examples/platform/bouffalolab/bl602/FreeRTOSConfig.h +++ b/examples/platform/bouffalolab/bl602/FreeRTOSConfig.h @@ -166,9 +166,9 @@ /* Software timer definitions. */ #define configUSE_TIMERS 1 -#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) -#define configTIMER_QUEUE_LENGTH 4 -#define configTIMER_TASK_STACK_DEPTH (400) +#define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 2) +#define configTIMER_QUEUE_LENGTH 10 +#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 4) /* Task priorities. Allow these to be overridden. */ #ifndef uartPRIMARY_PRIORITY @@ -200,7 +200,11 @@ Like all task stack sizes, the value is the number of words, not bytes. */ #define genqGENERIC_QUEUE_TEST_TASK_STACK_SIZE 100 #define recmuRECURSIVE_MUTEX_TEST_TASK_STACK_SIZE 90 +#ifdef __cplusplus +extern "C" void vAssertCalled(void); +#else extern void vAssertCalled(void); +#endif /* Stop if an assertion fails. */ #define configASSERT(x) \ if ((x) == 0) \ @@ -208,7 +212,11 @@ extern void vAssertCalled(void); #if (configUSE_TICKLESS_IDLE != 0) #include "portmacro.h" +#ifdef __cplusplus +extern "C" void vApplicationSleep(TickType_t xExpectedIdleTime); +#else extern void vApplicationSleep(TickType_t xExpectedIdleTime); +#endif #define portSUPPRESS_TICKS_AND_SLEEP(xExpectedIdleTime) vApplicationSleep(xExpectedIdleTime) #endif diff --git a/examples/platform/bouffalolab/bl702/FreeRTOSConfig.h b/examples/platform/bouffalolab/bl702/FreeRTOSConfig.h index 1ef8270183de74..aad73b32e656d8 100644 --- a/examples/platform/bouffalolab/bl702/FreeRTOSConfig.h +++ b/examples/platform/bouffalolab/bl702/FreeRTOSConfig.h @@ -134,7 +134,7 @@ #define configUSE_TIMERS 1 #define configTIMER_TASK_PRIORITY (configMAX_PRIORITIES - 1) #define configTIMER_QUEUE_LENGTH 4 -#define configTIMER_TASK_STACK_DEPTH (400) +#define configTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE * 2) /* Task priorities. Allow these to be overridden. */ #ifndef uartPRIMARY_PRIORITY @@ -159,7 +159,11 @@ to exclude the API function. */ /* Normal assert() semantics without relying on the provision of an assert.h header file. */ +#ifdef __cplusplus +extern "C" void vAssertCalled(void); +#else extern void vAssertCalled(void); +#endif #define configASSERT(x) \ if ((x) == 0) \ vAssertCalled() @@ -179,7 +183,11 @@ Like all task stack sizes, the value is the number of words, not bytes. */ #if (configUSE_TICKLESS_IDLE != 0) #include "portmacro.h" +#ifdef __cplusplus +extern "C" void vApplicationSleep(TickType_t xExpectedIdleTime); +#else extern void vApplicationSleep(TickType_t xExpectedIdleTime); +#endif #define portSUPPRESS_TICKS_AND_SLEEP(xExpectedIdleTime) vApplicationSleep(xExpectedIdleTime) #endif diff --git a/examples/platform/bouffalolab/bl702/ldscripts/psram_flash.ld b/examples/platform/bouffalolab/bl702/ldscripts/psram_flash.ld index a1129242f6c8e1..e8c166222364ca 100644 --- a/examples/platform/bouffalolab/bl702/ldscripts/psram_flash.ld +++ b/examples/platform/bouffalolab/bl702/ldscripts/psram_flash.ld @@ -143,12 +143,8 @@ SECTIONS *(.ble_rsvd_mem) KEEP(*AppTask.cpp.o(.bss.*appStack*)) - KEEP(*main.cpp.o(.bss.*IdleTaskStack*)) KEEP(*main.cpp.o(.bss.*TimerTaskStack*)) - /*KEEP(*MemMonitoring.cpp.o(.bss.*monitoringStack*))*/ - /*KEEP(*out.uart.c.o(.bss.chipUart_var*))*/ - } >hbnram .tcmcode : ALIGN(4) diff --git a/examples/platform/bouffalolab/common/plat/main.cpp b/examples/platform/bouffalolab/common/plat/main.cpp index 8dad0e2a958877..690315082458fe 100644 --- a/examples/platform/bouffalolab/common/plat/main.cpp +++ b/examples/platform/bouffalolab/common/plat/main.cpp @@ -154,7 +154,7 @@ extern "C" void vApplicationGetTimerTaskMemory(StaticTask_t ** ppxTimerTaskTCBBu function then they must be declared static - otherwise they will be allocated on the stack and so not exists after this function exits. */ static StaticTask_t xTimerTaskTCB; - static StackType_t uxTimerTaskStack[configMINIMAL_STACK_SIZE * 3 / 2]; + static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH]; /* Pass out a pointer to the StaticTask_t structure in which the Timer task's state will be stored. */ @@ -166,17 +166,17 @@ extern "C" void vApplicationGetTimerTaskMemory(StaticTask_t ** ppxTimerTaskTCBBu /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. Note that, as the array is necessarily of type StackType_t, configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */ - *pulTimerTaskStackSize = configMINIMAL_STACK_SIZE * 3 / 2; + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; } #if (configUSE_TICK_HOOK != 0) extern "C" void vApplicationTickHook(void) {} #endif -extern "C" void vApplicationSleep(TickType_t xExpectedIdleTime) {} +void vApplicationSleep(TickType_t xExpectedIdleTime) {} extern "C" void user_vAssertCalled(void) __attribute__((weak, alias("vAssertCalled"))); -extern "C" void vAssertCalled(void) +void vAssertCalled(void) { void * ra = (void *) __builtin_return_address(0); diff --git a/src/platform/bouffalolab/BL602/DnssdImpl.cpp b/src/platform/bouffalolab/BL602/DnssdImpl.cpp deleted file mode 100644 index 681f66aaa33657..00000000000000 --- a/src/platform/bouffalolab/BL602/DnssdImpl.cpp +++ /dev/null @@ -1,324 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "lib/dnssd/platform/Dnssd.h" -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip::Dnssd; - -using namespace ::chip::DeviceLayer::Internal; -namespace { - -static constexpr uint32_t kTimeoutMilli = 3000; -static constexpr size_t kMaxResults = 20; -} // namespace - -namespace chip { -namespace Dnssd { - -#define MDNS_MAX_PACKET_SIZE 64 -typedef struct -{ - const char * key; /*!< item key name */ - const char * value; /*!< item value string */ - size_t value_len; -} mdns_txt_item_t; - -typedef struct mdns -{ - struct netif * netif; - uint8_t slot[10]; - uint8_t slot_idx; - int txt_cnt; -} mdns_t; - -#define MDNS_TXT_MAX_LEN 128 -static mdns_t mdns = { NULL, 0, 0, 0, 0 }; -mdns_txt_item_t * items = nullptr; -uint8_t packet[MDNS_TXT_MAX_LEN]; - -static const DnssdService * glservice; - -CHIP_ERROR ChipDnssdInit(DnssdAsyncReturnCallback initCallback, DnssdAsyncReturnCallback errorCallback, void * context) -{ - CHIP_ERROR error = CHIP_NO_ERROR; - - mdns_resp_init(); - mdns.slot_idx = 0; - initCallback(context, error); - - glservice = static_cast(chip::Platform::MemoryCalloc(1, sizeof(DnssdService))); - - return error; -} - -void ChipDnssdShutdown() {} - -static const char * GetProtocolString(DnssdServiceProtocol protocol) -{ - return protocol == DnssdServiceProtocol::kDnssdProtocolTcp ? "_tcp" : "_udp"; -} - -static inline uint8_t _mdns_append_u8(uint8_t * packet, uint16_t * index, uint8_t value) -{ - if (*index >= MDNS_MAX_PACKET_SIZE) - { - return 0; - } - - packet[*index] = value; - *index += 1; - return 1; -} - -static inline int append_one_txt_record_entry(uint8_t * packet, uint16_t * index, mdns_txt_item_t * txt) -{ - if (txt == NULL || txt->key == NULL || packet == NULL) - { - return -1; - } - - size_t key_len = strlen(txt->key); - size_t len = key_len + txt->value_len + (txt->value ? 1 : 0); - if ((*index + len + 1) >= MDNS_MAX_PACKET_SIZE) - { - return 0; - } - - _mdns_append_u8(packet, index, len); - memcpy(packet + *index, txt->key, key_len); - if (txt->value) - { - packet[*index + key_len] = '='; - memcpy(packet + *index + key_len + 1, txt->value, txt->value_len); - } - - *index += len; - - return len + 1; -} - -static void dnssd_txt_resolve(uint8_t * packet, mdns_txt_item_t * txt, int count) -{ - uint16_t index = 0; - - for (int i = 0; i < count; i++) - { - append_one_txt_record_entry(packet, &index, &(txt[i])); - } -} - -static void srv_txt(struct mdns_service * service, void * txt_userdata) -{ - int i, ret; - int index = 0; - - for (i = 0; i < mdns.txt_cnt; i++) - { - ret = mdns_resp_add_service_txtitem(service, &(packet[index + 1]), packet[index]); - if (ret) - { - log_info("send txt failed.\r\n"); - - return; - } - - index = index + packet[index] + 1; - } -} - -static void ota_txt(struct mdns_service * service, void * txt_userdata) -{ - int ret = mdns_resp_add_service_txtitem(service, "version=12345678", 16); - if (ret) - { - log_info("send ota txt failed.\r\n"); - } -} - -static err_t mdns_responder_stop_netifapi_errt_fn(struct netif * netif) -{ - return mdns_responder_stop(netif); -} - -int mdns_responder_ops(struct netif * netif) -{ - int ret, slot = -1; - int protocol = 0; - uint16_t packet_len = 0; - - if (netif == NULL) - { - log_info("netif is NULL\r\n"); - return -1; - } - - if (!(mdns.netif)) - { - mdns.netif = netif; - - ret = mdns_resp_add_netif(netif, glservice->mHostName, 10); - if (ret != 0) - { - mdns_resp_deinit(); - log_info("add netif failed:%d\r\n", ret); - return -1; - } - } - - items = static_cast(chip::Platform::MemoryCalloc(glservice->mTextEntrySize, sizeof(mdns_txt_item_t))); - mdns.txt_cnt = glservice->mTextEntrySize; - for (size_t i = 0; i < glservice->mTextEntrySize; i++) - { - items[i].key = glservice->mTextEntries[i].mKey; - items[i].value = reinterpret_cast(glservice->mTextEntries[i].mData); - items[i].value_len = glservice->mTextEntries[i].mDataSize; - packet_len = packet_len + strlen(items[i].key) + items[i].value_len + 1; - } - - if (MDNS_TXT_MAX_LEN < packet_len) - { - return -1; - } - - dnssd_txt_resolve(packet, items, glservice->mTextEntrySize); - chip::Platform::MemoryFree(items); - - log_info("name = %s nType = %s protocol = %d port = %d \r\n", glservice->mName, glservice->mType, protocol, glservice->mPort); - slot = mdns_resp_add_service(netif, glservice->mName, glservice->mType, static_cast(glservice->mProtocol), - glservice->mPort, 60, srv_txt, NULL); - if (slot < 0) - { - mdns_resp_remove_netif(netif); - mdns_resp_deinit(); - log_info("add server failed:%d\r\n", slot); - return -1; - } - - mdns.slot[mdns.slot_idx] = slot; - mdns.slot_idx++; - mdns_resp_announce(netif); - - return slot; -} - -static err_t mdns_responder_start_netifapi_errt_fn(struct netif * netif) -{ - return mdns_responder_ops(netif); -} - -CHIP_ERROR ChipDnssdPublishService(const DnssdService * service, DnssdPublishCallback callback, void * context) -{ - CHIP_ERROR error = CHIP_NO_ERROR; - struct netif * netif; - int slot; - bool mdns_flag; - - if (!(chip::DeviceLayer::ConnectivityMgrImpl()._IsWiFiStationConnected())) - { - return CHIP_ERROR_NOT_IMPLEMENTED; - } - - if (service) - { - memcpy(glservice, service, sizeof(DnssdService)); - } - - netif = wifi_mgmr_sta_netif_get(); - if (netif == NULL) - { - log_info("find failed\r\n"); - return CHIP_ERROR_INTERNAL; - } - - // mdns_responder_ops(netif); - - slot = netifapi_netif_common(netif, NULL, mdns_responder_start_netifapi_errt_fn); - if (slot < 0) - { - log_info("start mdns failed\r\n"); - return CHIP_ERROR_INTERNAL; - } - - return CHIP_NO_ERROR; -} - -CHIP_ERROR ChipDnssdRemoveServices() -{ - struct netif * netif; - int i = 0; - - netif = wifi_mgmr_sta_netif_get(); - if (netif == NULL) - { - log_info("find failed\r\n"); - return CHIP_ERROR_INTERNAL; - } - - for (i = 0; i < mdns.slot_idx; i++) - { - mdns_resp_del_service(netif, mdns.slot[i]); - } - - mdns.slot_idx = 0; - - return CHIP_NO_ERROR; -} - -CHIP_ERROR ChipDnssdFinalizeServiceUpdate() -{ - return CHIP_NO_ERROR; -} - -CHIP_ERROR ChipDnssdBrowse(const char * /*type*/, DnssdServiceProtocol /*protocol*/, chip::Inet::IPAddressType addressType, - chip::Inet::InterfaceId /*interface*/, DnssdBrowseCallback /*callback*/, void * /*context*/, - intptr_t * /*browseIdentifier*/) -{ - return CHIP_ERROR_NOT_IMPLEMENTED; -} - -CHIP_ERROR ChipDnssdStopBrowse(intptr_t /*browseIdentifier*/) -{ - return CHIP_ERROR_NOT_IMPLEMENTED; -} - -CHIP_ERROR ChipDnssdResolve(DnssdService * /*service*/, chip::Inet::InterfaceId /*interface*/, DnssdResolveCallback /*callback*/, - void * /*context*/) -{ - return CHIP_ERROR_NOT_IMPLEMENTED; -} - -void ChipDnssdResolveNoLongerNeeded(const char * instanceName) {} - -CHIP_ERROR ChipDnssdReconfirmRecord(const char * hostname, chip::Inet::IPAddress address, chip::Inet::InterfaceId interface) -{ - return CHIP_ERROR_NOT_IMPLEMENTED; -} - -} // namespace Dnssd -} // namespace chip diff --git a/src/platform/bouffalolab/BL602/GroupKeyStoreImpl.cpp b/src/platform/bouffalolab/BL602/GroupKeyStoreImpl.cpp deleted file mode 100644 index 295e30f68dd3bf..00000000000000 --- a/src/platform/bouffalolab/BL602/GroupKeyStoreImpl.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019 Nest Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Provides an implementation of the CHIP GroupKeyStore interface - * for platforms based on the Bouffalolab SDK. - */ -/* this file behaves like a config.h, comes first */ -#include - -#include - -using namespace ::chip; -using namespace ::chip::Profiles::Security::AppKeys; - -namespace chip { -namespace DeviceLayer { -namespace Internal { - -CHIP_ERROR GroupKeyStoreImpl::RetrieveGroupKey(uint32_t keyId, ChipGroupKey & key) -{ - CHIP_ERROR err; - - // Iterate over all the GroupKey easyflash records looking for a matching key... - err = ForEachRecord(kConfigKey_GroupKeyBase, kConfigKey_GroupKeyMax, false, - [keyId, &key](const Key & efKey, const size_t & length) -> CHIP_ERROR { - CHIP_ERROR err2; - size_t keyLen; - uint8_t buf[kMaxEncodedKeySize]; // (buf length == 45 bytes) - uint32_t curKeyId; - - // Read the easyflash obj binary data data into the buffer. - err2 = ReadConfigValueBin(efKey, buf, sizeof(buf), keyLen); - - // Decode the CHIP key id for the current key. - err2 = DecodeGroupKeyId(buf, keyLen, curKeyId); - SuccessOrExit(err2); - - // If it matches the key we're looking for... - if (curKeyId == keyId) - { - // Decode the associated key data. - err2 = DecodeGroupKey(buf, keyLen, key); - SuccessOrExit(err2); - - // End the iteration by returning a CHIP_END_OF_INPUT result. - ExitNow(err2 = CHIP_END_OF_INPUT); - } - - exit: - return err2; - }); - - // Modify error code for return. - switch (err) - { - case CHIP_END_OF_INPUT: - err = CHIP_NO_ERROR; // Match found. - break; - case CHIP_NO_ERROR: - err = CHIP_ERROR_KEY_NOT_FOUND; // Match not found. - break; - default: - break; - } - - return err; -} - -CHIP_ERROR GroupKeyStoreImpl::StoreGroupKey(const ChipGroupKey & key) -{ - CHIP_ERROR err; - - // Delete any existing group key with the same id (this may or may not exit). - DeleteGroupKey(key.KeyId); // no error checking here. - - // Iterate over all the GroupKey easyflash records looking for the first - // empty easyflash key where we can store the data. (Note- use arg addNewrecord=true) - err = ForEachRecord(kConfigKey_GroupKeyBase, kConfigKey_GroupKeyMax, true, - [&key](const Key & efKey, const size_t & length) -> CHIP_ERROR { - CHIP_ERROR err2; - size_t keyLen; - uint8_t buf[kMaxEncodedKeySize]; // (buf length == 45 bytes) - - // Encode the key for storage in an easyflash record. - err2 = EncodeGroupKey(key, buf, sizeof(buf), keyLen); - SuccessOrExit(err2); - - // Write the encoded binary data into the easyflash object. - err2 = WriteConfigValueBin(efKey, buf, keyLen); - SuccessOrExit(err2); - - // End the iteration by returning a CHIP_END_OF_INPUT result. - ExitNow(err2 = CHIP_END_OF_INPUT); - - exit: - return err2; - }); - - // Modify error code for return. - switch (err) - { - case CHIP_END_OF_INPUT: - err = CHIP_NO_ERROR; // Key entry was stored. - break; - case CHIP_NO_ERROR: - err = CHIP_ERROR_KEY_NOT_FOUND; // Key entry was not stored. - break; - default: - break; - } - - if (err == CHIP_NO_ERROR) - { -#if CHIP_PROGRESS_LOGGING - { - char extraKeyInfo[32]; - if (ChipKeyId::IsAppEpochKey(key.KeyId)) - { - snprintf(extraKeyInfo, sizeof(extraKeyInfo), ", start time %" PRId32, key.StartTime); - } - else if (ChipKeyId::IsAppGroupMasterKey(key.KeyId)) - { - snprintf(extraKeyInfo, sizeof(extraKeyInfo), ", global id 0x%08" PRIX32, key.GlobalId); - } - else - { - extraKeyInfo[0] = 0; - } - } - -#endif // CHIP_PROGRESS_LOGGING - } - - return err; -} - -CHIP_ERROR GroupKeyStoreImpl::DeleteGroupKey(uint32_t keyId) -{ - CHIP_ERROR err; - - // Iterate over all the GroupKey easyflash records looking for a matching key... - err = ForEachRecord(kConfigKey_GroupKeyBase, kConfigKey_GroupKeyMax, false, - [keyId](const Key & efKey, const size_t & length) -> CHIP_ERROR { - CHIP_ERROR err2; - size_t keyLen; - uint8_t buf[kMaxEncodedKeySize]; // (buf length == 45 bytes) - uint32_t curKeyId; - - // Read the easyflash obj binary data data into the buffer. - err2 = ReadConfigValueBin(efKey, buf, sizeof(buf), keyLen); - SuccessOrExit(err2); - - // Decode the CHIP key id for the current group key. - err2 = DecodeGroupKeyId(buf, keyLen, curKeyId); - SuccessOrExit(err2); - - // If it matches the key we are looking for, delete the easyflash record. - if (curKeyId == keyId) - { - err2 = ClearConfigValue(efKey); - ChipLogProgress(DeviceLayer, "GroupKeyStore: deleting key 0x%08" PRIX32, curKeyId); - - // End the iteration by returning a CHIP_END_OF_INPUT result. - ExitNow(err2 = CHIP_END_OF_INPUT); - } - - exit: - return err2; - }); - - // Modify error code for return. - switch (err) - { - case CHIP_END_OF_INPUT: - err = CHIP_NO_ERROR; // Key entry was deleted. - break; - case CHIP_NO_ERROR: - err = CHIP_ERROR_KEY_NOT_FOUND; // Key entry was not deleted. - break; - default: - break; - } - - return err; -} - -CHIP_ERROR GroupKeyStoreImpl::DeleteGroupKeysOfAType(uint32_t keyType) -{ - CHIP_ERROR err; - - // Iterate over all the GroupKey easyflash records looking for a matching key... - err = ForEachRecord(kConfigKey_GroupKeyBase, kConfigKey_GroupKeyMax, false, - [keyType](const Key & efKey, const size_t & length) -> CHIP_ERROR { - CHIP_ERROR err2; - size_t keyLen; - uint8_t buf[kMaxEncodedKeySize]; // (buf length == 45 bytes) - uint32_t curKeyId; - - // Read the easyflash obj binary data data into the buffer. - err2 = ReadConfigValueBin(efKey, buf, sizeof(buf), keyLen); - SuccessOrExit(err2); - - // Decode the CHIP key id for the current group key. - err2 = DecodeGroupKeyId(buf, keyLen, curKeyId); - SuccessOrExit(err2); - - // If the current key matches the type we are looking for, delete the easyflash record. - if (ChipKeyId::GetType(curKeyId) == keyType) - { - err2 = ClearConfigValue(efKey); - ChipLogProgress(DeviceLayer, "GroupKeyStore: deleting key 0x%08" PRIX32, curKeyId); - } - - exit: - return err2; - }); - - return err; -} - -CHIP_ERROR GroupKeyStoreImpl::EnumerateGroupKeys(uint32_t keyType, uint32_t * keyIds, uint8_t keyIdsArraySize, uint8_t & keyCount) -{ - CHIP_ERROR err; - - keyCount = 0; - - // Iterate over all the GroupKey records looking for keys of the specified type... - err = ForEachRecord(kConfigKey_GroupKeyBase, kConfigKey_GroupKeyMax, false, - [keyType, keyIds, keyIdsArraySize, &keyCount](const Key & efKey, const size_t & length) -> CHIP_ERROR { - CHIP_ERROR err2; - size_t keyLen; - uint8_t buf[kMaxEncodedKeySize]; // (buf length == 45 bytes) - uint32_t curKeyId; - - // Read the easyflash obj binary data data into the buffer. - err2 = ReadConfigValueBin(efKey, buf, sizeof(buf), keyLen); - SuccessOrExit(err2); - - // Decode the CHIP key id for the current group key. - err2 = DecodeGroupKeyId(buf, keyLen, curKeyId); - SuccessOrExit(err2); - - // If the current key matches the type we're looking for, add it to the keyIds array. - if ((keyType == ChipKeyId::kType_None) || (ChipKeyId::GetType(curKeyId) == keyType)) - { - keyIds[keyCount++] = curKeyId; - - // Stop iterating if there's no more room in the keyIds array. - VerifyOrExit(keyCount < keyIdsArraySize, err2 = CHIP_ERROR_BUFFER_TOO_SMALL); - } - - exit: - return err2; - }); - - // Simply return a truncated list if there are more matching keys than will fit in the array. - if (err == CHIP_ERROR_BUFFER_TOO_SMALL) - { - err = CHIP_NO_ERROR; - } - - return err; -} - -CHIP_ERROR GroupKeyStoreImpl::Clear(void) -{ - CHIP_ERROR err; - - // Iterate over all the GroupKey easyflash records deleting each one... - err = ForEachRecord(kConfigKey_GroupKeyBase, kConfigKey_GroupKeyMax, false, - [](const Key & efKey, const size_t & length) -> CHIP_ERROR { - CHIP_ERROR err2; - - err2 = ClearConfigValue(efKey); - SuccessOrExit(err2); - - exit: - return err2; - }); - - return err; -} - -CHIP_ERROR GroupKeyStoreImpl::RetrieveLastUsedEpochKeyId(void) -{ - CHIP_ERROR err; - - err = ReadConfigValue(kConfigKey_LastUsedEpochKeyId, LastUsedEpochKeyId); - if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND) - { - LastUsedEpochKeyId = ChipKeyId::kNone; - err = CHIP_NO_ERROR; - } - return err; -} - -CHIP_ERROR GroupKeyStoreImpl::StoreLastUsedEpochKeyId(void) -{ - return WriteConfigValue(kConfigKey_LastUsedEpochKeyId, LastUsedEpochKeyId); -} - -CHIP_ERROR GroupKeyStoreImpl::Init() -{ - // Nothing to do - return CHIP_NO_ERROR; -} - -CHIP_ERROR GroupKeyStoreImpl::EncodeGroupKey(const ChipGroupKey & key, uint8_t * buf, size_t bufSize, size_t & encodedKeyLen) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - uint8_t * p = buf; - - VerifyOrExit(bufSize >= kFixedEncodedKeySize + key.KeyLen, err = CHIP_ERROR_BUFFER_TOO_SMALL); - - Encoding::LittleEndian::Write32(p, key.KeyId); - Encoding::LittleEndian::Write32(p, key.StartTime); - Encoding::Write8(p, key.KeyLen); - memcpy(p, key.Key, key.KeyLen); - p += key.KeyLen; - - encodedKeyLen = p - buf; - -exit: - return err; -} - -CHIP_ERROR GroupKeyStoreImpl::DecodeGroupKeyId(const uint8_t * encodedKey, size_t encodedKeyLen, uint32_t & keyId) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - - VerifyOrExit(encodedKeyLen >= kFixedEncodedKeySize, err = CHIP_ERROR_INVALID_ARGUMENT); - - keyId = Encoding::LittleEndian::Get32(encodedKey); - -exit: - return err; -} - -CHIP_ERROR GroupKeyStoreImpl::DecodeGroupKey(const uint8_t * encodedKey, size_t encodedKeyLen, ChipGroupKey & key) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - const uint8_t * p = encodedKey; - - VerifyOrExit(encodedKeyLen >= kFixedEncodedKeySize, err = CHIP_ERROR_INVALID_ARGUMENT); - - key.KeyId = Encoding::LittleEndian::Read32(p); - key.StartTime = Encoding::LittleEndian::Read32(p); - key.KeyLen = Encoding::Read8(p); - - VerifyOrExit(encodedKeyLen >= kFixedEncodedKeySize + key.KeyLen, err = CHIP_ERROR_INVALID_ARGUMENT); - - memcpy(key.Key, p, key.KeyLen); - -exit: - return err; -} - -} // namespace Internal -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/bouffalolab/BL602/GroupKeyStoreImpl.h b/src/platform/bouffalolab/BL602/GroupKeyStoreImpl.h deleted file mode 100644 index 5831594dc907b5..00000000000000 --- a/src/platform/bouffalolab/BL602/GroupKeyStoreImpl.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019 Nest Labs, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Provides an implementation of the Chip Group Key Store interface - * for platforms based on the Bouffalolab SDK. - */ - -#include -#include -#include -#include - -namespace chip { -namespace DeviceLayer { -namespace Internal { - -/** - * An implementation of the Chip GroupKeyStoreBase API for platforms based - * on the Bouffalolab SDK. - */ -class GroupKeyStoreImpl final : public ::chip::Profiles::Security::AppKeys::GroupKeyStoreBase, private BL602Config -{ - using ChipGroupKey = ::chip::Profiles::Security::AppKeys::ChipGroupKey; - -public: - CHIP_ERROR Init(); - - CHIP_ERROR RetrieveGroupKey(uint32_t keyId, ChipGroupKey & key) override; - CHIP_ERROR StoreGroupKey(const ChipGroupKey & key) override; - CHIP_ERROR DeleteGroupKey(uint32_t keyId) override; - CHIP_ERROR DeleteGroupKeysOfAType(uint32_t keyType) override; - CHIP_ERROR EnumerateGroupKeys(uint32_t keyType, uint32_t * keyIds, uint8_t keyIdsArraySize, uint8_t & keyCount) override; - CHIP_ERROR Clear(void) override; - CHIP_ERROR RetrieveLastUsedEpochKeyId(void) override; - CHIP_ERROR StoreLastUsedEpochKeyId(void) override; - -private: - static constexpr size_t kFixedEncodedKeySize = 4U + // key id - 4U + // start time / global id - 1U; // key data length - - static constexpr size_t kMaxEncodedKeySize = kFixedEncodedKeySize + ChipGroupKey::MaxKeySize; - - /* Not used - static constexpr uint16_t kGroupKeyFileId = GetFileId(kConfigKey_GroupKey); - static constexpr uint16_t kGroupKeyRecordKey = GetRecordKey(kConfigKey_GroupKey); - */ - - static CHIP_ERROR EncodeGroupKey(const ChipGroupKey & key, uint8_t * buf, size_t bufSize, size_t & encodedKeyLen); - static CHIP_ERROR DecodeGroupKey(const uint8_t * encodedKey, size_t encodedKeyLen, ChipGroupKey & key); - static CHIP_ERROR DecodeGroupKeyId(const uint8_t * encodedKey, size_t encodedKeyLen, uint32_t & keyId); -}; - -} // namespace Internal -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/bouffalolab/BL602/NetworkCommissioningWiFiDriver.cpp b/src/platform/bouffalolab/BL602/NetworkCommissioningWiFiDriver.cpp deleted file mode 100644 index c469c5a90edb01..00000000000000 --- a/src/platform/bouffalolab/BL602/NetworkCommissioningWiFiDriver.cpp +++ /dev/null @@ -1,368 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -using namespace ::chip; -// #if CHIP_DEVICE_CONFIG_ENABLE_WIFI -namespace chip { -namespace DeviceLayer { -namespace NetworkCommissioning { - -namespace { -constexpr char kWiFiSSIDKeyName[] = "wifi-ssid"; -constexpr char kWiFiCredentialsKeyName[] = "wifi-pass"; - -constexpr char blWiFiSSIDKeyName[] = "bl-wifi-ssid"; -constexpr char blWiFiCredentialsKeyName[] = "bl-wifi-pass"; - -static uint8_t WiFiSSIDStr[DeviceLayer::Internal::kMaxWiFiSSIDLength]; -} // namespace - -CHIP_ERROR BLWiFiDriver::Init() -{ - CHIP_ERROR err; - size_t ssidLen = 0; - size_t credentialsLen = 0; - - err = PersistedStorage::KeyValueStoreMgr().Get(kWiFiCredentialsKeyName, mSavedNetwork.credentials, - sizeof(mSavedNetwork.credentials), &credentialsLen); - if (err == CHIP_ERROR_NOT_FOUND) - { - return CHIP_NO_ERROR; - } - - err = PersistedStorage::KeyValueStoreMgr().Get(kWiFiSSIDKeyName, mSavedNetwork.ssid, sizeof(mSavedNetwork.ssid), &ssidLen); - if (err == CHIP_ERROR_NOT_FOUND) - { - return CHIP_NO_ERROR; - } - mSavedNetwork.credentialsLen = credentialsLen; - mSavedNetwork.ssidLen = ssidLen; - - mStagingNetwork = mSavedNetwork; - mpScanCallback = nullptr; - mpConnectCallback = nullptr; - - return err; -} - -void BLWiFiDriver::Shutdown() {} - -CHIP_ERROR BLWiFiDriver::CommitConfiguration() -{ - ReturnErrorOnFailure(PersistedStorage::KeyValueStoreMgr().Put(kWiFiSSIDKeyName, mStagingNetwork.ssid, mStagingNetwork.ssidLen)); - ReturnErrorOnFailure(PersistedStorage::KeyValueStoreMgr().Put(kWiFiCredentialsKeyName, mStagingNetwork.credentials, - mStagingNetwork.credentialsLen)); - mSavedNetwork = mStagingNetwork; - return CHIP_NO_ERROR; -} - -CHIP_ERROR BLWiFiDriver::SaveConfiguration() -{ - if (NULL == mStagingNetwork.ssid || 0 == mStagingNetwork.ssidLen || NULL == mStagingNetwork.credentials || - 0 == mStagingNetwork.credentialsLen) - { - return CHIP_ERROR_KEY_NOT_FOUND; - } - - ReturnErrorOnFailure( - PersistedStorage::KeyValueStoreMgr().Put(blWiFiSSIDKeyName, mStagingNetwork.ssid, mStagingNetwork.ssidLen)); - ReturnErrorOnFailure(PersistedStorage::KeyValueStoreMgr().Put(blWiFiCredentialsKeyName, mStagingNetwork.credentials, - mStagingNetwork.credentialsLen)); - return CHIP_NO_ERROR; -} - -CHIP_ERROR BLWiFiDriver::RevertConfiguration() -{ - mStagingNetwork = mSavedNetwork; - return CHIP_NO_ERROR; -} - -bool BLWiFiDriver::NetworkMatch(const WiFiNetwork & network, ByteSpan networkId) -{ - return networkId.size() == network.ssidLen && memcmp(networkId.data(), network.ssid, network.ssidLen) == 0; -} - -Status BLWiFiDriver::AddOrUpdateNetwork(ByteSpan ssid, ByteSpan credentials) -{ - VerifyOrReturnError(mStagingNetwork.ssidLen == 0 || NetworkMatch(mStagingNetwork, ssid), Status::kBoundsExceeded); - VerifyOrReturnError(credentials.size() <= sizeof(mStagingNetwork.credentials), Status::kOutOfRange); - VerifyOrReturnError(ssid.size() <= sizeof(mStagingNetwork.ssid), Status::kOutOfRange); - - memcpy(mStagingNetwork.credentials, credentials.data(), credentials.size()); - mStagingNetwork.credentialsLen = static_cast(credentials.size()); - - memcpy(mStagingNetwork.ssid, ssid.data(), ssid.size()); - mStagingNetwork.ssidLen = static_cast(ssid.size()); - - return Status::kSuccess; -} - -Status BLWiFiDriver::RemoveNetwork(ByteSpan networkId) -{ - VerifyOrReturnError(NetworkMatch(mStagingNetwork, networkId), Status::kNetworkIDNotFound); - - // Use empty ssid for representing invalid network - mStagingNetwork.ssidLen = 0; - return Status::kSuccess; -} - -Status BLWiFiDriver::ReorderNetwork(ByteSpan networkId, uint8_t index) -{ - // Only one network is supported now - VerifyOrReturnError(index == 0, Status::kOutOfRange); - VerifyOrReturnError(NetworkMatch(mStagingNetwork, networkId), Status::kNetworkIDNotFound); - return Status::kSuccess; -} - -CHIP_ERROR BLWiFiDriver::ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen, const char * key, uint8_t keyLen) -{ - // ReturnErrorOnFailure(ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Disabled)); - - char wifi_ssid[64] = { 0 }; - char passwd[64] = { 0 }; - // Set the wifi configuration - memcpy(wifi_ssid, ssid, ssidLen); - memcpy(passwd, key, keyLen); - wifi_interface_t wifi_interface; - wifi_interface = wifi_mgmr_sta_enable(); - wifi_mgmr_sta_connect(wifi_interface, ssid, passwd, NULL, NULL, 0, 0); - - // Configure the WiFi interface. - ReturnErrorOnFailure(ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Disabled)); - - return ConnectivityMgr().SetWiFiStationMode(ConnectivityManager::kWiFiStationMode_Enabled); -} - -CHIP_ERROR BLWiFiDriver::ReConnectWiFiNetwork(void) -{ - char ssid[64] = { 0 }; - char psk[64] = { 0 }; - size_t ssidLen = 0; - size_t pskLen = 0; - - ReturnErrorOnFailure( - PersistedStorage::KeyValueStoreMgr().Get((const char *) blWiFiSSIDKeyName, (void *) ssid, 64, &ssidLen, 0)); - ReturnErrorOnFailure( - PersistedStorage::KeyValueStoreMgr().Get((const char *) blWiFiCredentialsKeyName, (void *) psk, 64, &pskLen, 0)); - - ConnectWiFiNetwork(ssid, ssidLen, psk, pskLen); - - return CHIP_NO_ERROR; -} - -void BLWiFiDriver::OnConnectWiFiNetwork() -{ - if (mpConnectCallback) - { - mpConnectCallback->OnResult(Status::kSuccess, CharSpan(), 0); - mpConnectCallback = nullptr; - } -} - -void BLWiFiDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * callback) -{ - CHIP_ERROR err = CHIP_NO_ERROR; - Status networkingStatus = Status::kSuccess; - static int save = 0; - - // VerifyOrExit(NetworkMatch(mStagingNetwork, networkId), networkingStatus = Status::kNetworkIDNotFound); - // VerifyOrExit(mpConnectCallback == nullptr, networkingStatus = Status::kUnknownError); - ChipLogProgress(NetworkProvisioning, "BL NetworkCommissioningDelegate: SSID: %.*s", static_cast(networkId.size()), - networkId.data()); - - err = ConnectWiFiNetwork(reinterpret_cast(mStagingNetwork.ssid), mStagingNetwork.ssidLen, - reinterpret_cast(mStagingNetwork.credentials), mStagingNetwork.credentialsLen); - mpConnectCallback = callback; - -exit: - if (err != CHIP_NO_ERROR) - { - networkingStatus = Status::kUnknownError; - } - if (networkingStatus != Status::kSuccess) - { - ChipLogError(NetworkProvisioning, "Failed to connect to WiFi network:%s", chip::ErrorStr(err)); - mpConnectCallback = nullptr; - callback->OnResult(networkingStatus, CharSpan(), 0); - } -} - -#if 0 -CHIP_ERROR ESPWiFiDriver::StartScanWiFiNetworks(ByteSpan ssid) -{ - esp_err_t err = ESP_OK; - if (!ssid.empty()) - { - wifi_scan_config_t scan_config = { 0 }; - memset(WiFiSSIDStr, 0, sizeof(WiFiSSIDStr)); - memcpy(WiFiSSIDStr, ssid.data(), ssid.size()); - scan_config.ssid = WiFiSSIDStr; - err = esp_wifi_scan_start(&scan_config, false); - } - else - { - err = esp_wifi_scan_start(NULL, false); - } - if (err != ESP_OK) - { - return chip::DeviceLayer::Internal::ESP32Utils::MapError(err); - } - return CHIP_NO_ERROR; -} -#endif - -#if 0 -void ESPWiFiDriver::OnScanWiFiNetworkDone() -{ - uint16_t ap_number; - esp_wifi_scan_get_ap_num(&ap_number); - if (!ap_number) - { - ChipLogProgress(DeviceLayer, "No AP found"); - if (mpScanCallback != nullptr) - { - mpScanCallback->OnFinished(Status::kSuccess, CharSpan(), nullptr); - mpScanCallback = nullptr; - } - return; - } - std::unique_ptr ap_buffer_ptr(new wifi_ap_record_t[ap_number]); - if (ap_buffer_ptr == NULL) - { - ChipLogError(DeviceLayer, "can't malloc memory for ap_list_buffer"); - if (mpScanCallback) - { - mpScanCallback->OnFinished(Status::kUnknownError, CharSpan(), nullptr); - mpScanCallback = nullptr; - } - return; - } - wifi_ap_record_t * ap_list_buffer = ap_buffer_ptr.get(); - if (esp_wifi_scan_get_ap_records(&ap_number, ap_list_buffer) == ESP_OK) - { - if (CHIP_NO_ERROR == DeviceLayer::SystemLayer().ScheduleLambda([ap_number, ap_list_buffer]() { - std::unique_ptr auto_free(ap_list_buffer); - ESPScanResponseIterator iter(ap_number, ap_list_buffer); - if (GetInstance().mpScanCallback) - { - GetInstance().mpScanCallback->OnFinished(Status::kSuccess, CharSpan(), &iter); - GetInstance().mpScanCallback = nullptr; - } - else - { - ChipLogError(DeviceLayer, "can't find the ScanCallback function"); - } - })) - { - ap_buffer_ptr.release(); - } - } - else - { - ChipLogError(DeviceLayer, "can't get ap_records "); - if (mpScanCallback) - { - mpScanCallback->OnFinished(Status::kUnknownError, CharSpan(), nullptr); - mpScanCallback = nullptr; - } - } -} -#endif - -void BLWiFiDriver::ScanNetworks(ByteSpan ssid, WiFiDriver::ScanCallback * callback) -{ -#if 0 - if (callback != nullptr) - { - mpScanCallback = callback; - if (StartScanWiFiNetworks(ssid) != CHIP_NO_ERROR) - { - mpScanCallback = nullptr; - callback->OnFinished(Status::kUnknownError, CharSpan(), nullptr); - } - } -#endif -} - -#if 0 -CHIP_ERROR GetConnectedNetwork(Network & network) -{ - wifi_ap_record_t ap_info; - esp_err_t err; - err = esp_wifi_sta_get_ap_info(&ap_info); - if (err != ESP_OK) - { - return chip::DeviceLayer::Internal::ESP32Utils::MapError(err); - } - uint8_t length = strnlen(reinterpret_cast(ap_info.ssid), DeviceLayer::Internal::kMaxWiFiSSIDLength); - if (length > sizeof(network.networkID)) - { - return CHIP_ERROR_INTERNAL; - } - memcpy(network.networkID, ap_info.ssid, length); - network.networkIDLen = length; - return CHIP_NO_ERROR; -} -#endif - -size_t BLWiFiDriver::WiFiNetworkIterator::Count() -{ - return mDriver->mStagingNetwork.ssidLen == 0 ? 0 : 1; -} - -bool BLWiFiDriver::WiFiNetworkIterator::Next(Network & item) -{ -#if 0 - if (mExhausted || mDriver->mStagingNetwork.ssidLen == 0) - { - return false; - } - memcpy(item.networkID, mDriver->mStagingNetwork.ssid, mDriver->mStagingNetwork.ssidLen); - item.networkIDLen = mDriver->mStagingNetwork.ssidLen; - item.connected = false; - mExhausted = true; - - Network connectedNetwork; - CHIP_ERROR err = GetConnectedNetwork(connectedNetwork); - if (err == CHIP_NO_ERROR) - { - if (connectedNetwork.networkIDLen == item.networkIDLen && - memcmp(connectedNetwork.networkID, item.networkID, item.networkIDLen) == 0) - { - item.connected = true; - } - } -#endif - return true; -} - -} // namespace NetworkCommissioning -} // namespace DeviceLayer -} // namespace chip -// #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI diff --git a/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp b/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp index 16fad1b9ffcf5f..86b4421eb751f1 100644 --- a/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp +++ b/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp @@ -77,6 +77,8 @@ static void WifiStaDisconect(void) return; } + ChipLogError(DeviceLayer, "WiFi station disconnect, reason %d.", reason); + switch (reason) { case WLAN_FW_TX_ASSOC_FRAME_ALLOCATE_FAIILURE: @@ -178,14 +180,22 @@ void OnWiFiPlatformEvent(input_event_t * event, void * private_data) case CODE_WIFI_ON_MGMR_DONE: { } break; + case CODE_WIFI_ON_CONNECTED: { + ChipLogProgress(DeviceLayer, "WiFi station connected."); + } + break; case CODE_WIFI_ON_SCAN_DONE: { chip::DeviceLayer::PlatformMgr().LockChipStack(); NetworkCommissioning::BLWiFiDriver::GetInstance().OnScanWiFiNetworkDone(); chip::DeviceLayer::PlatformMgr().UnlockChipStack(); } break; + case CODE_WIFI_ON_CONNECTING: { + ChipLogProgress(DeviceLayer, "WiFi station starts connecting."); + } + break; case CODE_WIFI_ON_DISCONNECT: { - log_info("[APP] [EVT] disconnect %lld, Reason: %s\r\n", aos_now_ms(), wifi_mgmr_status_code_str(event->value)); + ChipLogProgress(DeviceLayer, "WiFi station disconnect, reason %s.", wifi_mgmr_status_code_str(event->value)); chip::DeviceLayer::PlatformMgr().LockChipStack(); WifiStaDisconect(); @@ -193,11 +203,12 @@ void OnWiFiPlatformEvent(input_event_t * event, void * private_data) } break; case CODE_WIFI_CMD_RECONNECT: { - log_info("[APP] [EVT] Reconnect %lld\r\n", aos_now_ms()); + ChipLogProgress(DeviceLayer, "WiFi station reconnect."); } break; case CODE_WIFI_ON_GOT_IP: { - log_info("[APP] [EVT] GOT IP %lld\r\n", aos_now_ms()); + + ChipLogProgress(DeviceLayer, "WiFi station gets IPv4 address."); chip::DeviceLayer::PlatformMgr().LockChipStack(); WifiStaConnected(); @@ -205,14 +216,15 @@ void OnWiFiPlatformEvent(input_event_t * event, void * private_data) } break; case CODE_WIFI_ON_GOT_IP6: { - log_info("[APP] [EVT] GOT IP6 %lld\r\n", aos_now_ms()); + ChipLogProgress(DeviceLayer, "WiFi station gets IPv6 address."); + chip::DeviceLayer::PlatformMgr().LockChipStack(); ConnectivityMgrImpl().OnIPv6AddressAvailable(); chip::DeviceLayer::PlatformMgr().UnlockChipStack(); } break; default: { - log_info("[APP] [EVT] Unknown code %u, %lld\r\n", event->code, aos_now_ms()); + ChipLogProgress(DeviceLayer, "WiFi station gets unknow code %u.", event->code); /*nothing*/ } } @@ -234,7 +246,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) if (1 == stack_wifi_init) { - log_error("Wi-Fi already initialized!\r\n"); + ChipLogError(DeviceLayer, "Wi-Fi already initialized!"); return CHIP_NO_ERROR; } diff --git a/src/platform/bouffalolab/BL602/SoftwareUpdateManagerImpl.cpp b/src/platform/bouffalolab/BL602/SoftwareUpdateManagerImpl.cpp deleted file mode 100644 index 993a009ea7b890..00000000000000 --- a/src/platform/bouffalolab/BL602/SoftwareUpdateManagerImpl.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/* this file behaves like a config.h, comes first */ -#include - -#if CHIP_DEVICE_CONFIG_ENABLE_SOFTWARE_UPDATE_MANAGER - -#include -#include - -#include -#include - -namespace chip { -namespace DeviceLayer { - -SoftwareUpdateManagerImpl SoftwareUpdateManagerImpl::sInstance; - -CHIP_ERROR SoftwareUpdateManagerImpl::_Init(void) -{ - Internal::GenericSoftwareUpdateManagerImpl_BDX::DoInit(); - Internal::GenericSoftwareUpdateManagerImpl::DoInit(); - - return CHIP_NO_ERROR; -} - -} // namespace DeviceLayer -} // namespace chip - -#endif // CHIP_DEVICE_CONFIG_ENABLE_SOFTWARE_UPDATE_MANAGER diff --git a/src/platform/bouffalolab/BL602/SoftwareUpdateManagerImpl.h b/src/platform/bouffalolab/BL602/SoftwareUpdateManagerImpl.h deleted file mode 100644 index 1d2d366611f8c7..00000000000000 --- a/src/platform/bouffalolab/BL602/SoftwareUpdateManagerImpl.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#if CHIP_DEVICE_CONFIG_ENABLE_SOFTWARE_UPDATE_MANAGER - -#include -#include - -namespace chip { -namespace DeviceLayer { - -/** - * Concrete implementation of the SoftwareUpdateManager singleton object for the - * Bouffalolab BL602 platforms. - */ -class SoftwareUpdateManagerImpl final : public SoftwareUpdateManager, - public Internal::GenericSoftwareUpdateManagerImpl, - public Internal::GenericSoftwareUpdateManagerImpl_BDX -{ - // Allow the SoftwareUpdateManager interface class to delegate method calls to - // the implementation methods provided by this class. - friend class SoftwareUpdateManager; - - // Allow the GenericSoftwareUpdateManagerImpl base class to access helper methods - // and types defined on this class. - friend class Internal::GenericSoftwareUpdateManagerImpl; - - // Allow the GenericSoftwareUpdateManagerImpl_BDX base class to access helper methods - // and types defined on this class. - friend class Internal::GenericSoftwareUpdateManagerImpl_BDX; - -public: - // ===== Members for internal use by the following friends. - - friend ::chip::DeviceLayer::SoftwareUpdateManager & SoftwareUpdateMgr(void); - friend SoftwareUpdateManagerImpl & SoftwareUpdateMgrImpl(void); - - static SoftwareUpdateManagerImpl sInstance; - -private: - // ===== Members that implement the SoftwareUpdateManager abstract interface. - - CHIP_ERROR _Init(void); -}; - -/** - * Returns a reference to the public interface of the SoftwareUpdateManager singleton object. - * - * Internal components should use this to access features of the SoftwareUpdateManager object - * that are common to all platforms. - */ -inline SoftwareUpdateManager & SoftwareUpdateMgr(void) -{ - return SoftwareUpdateManagerImpl::sInstance; -} - -/** - * Returns the platform-specific implementation of the SoftwareUpdateManager singleton object. - * - * Internal components can use this to gain access to features of the SoftwareUpdateManager - * that are specific to the BL602 platform. - */ -inline SoftwareUpdateManagerImpl & SoftwareUpdateMgrImpl(void) -{ - return SoftwareUpdateManagerImpl::sInstance; -} - -} // namespace DeviceLayer -} // namespace chip - -#endif // CHIP_DEVICE_CONFIG_ENABLE_SOFTWARE_UPDATE_MANAGER diff --git a/src/platform/bouffalolab/BL602/WarmPlatformConfig.h b/src/platform/bouffalolab/BL602/WarmPlatformConfig.h deleted file mode 100644 index 05665b04a0229b..00000000000000 --- a/src/platform/bouffalolab/BL602/WarmPlatformConfig.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Platform-specific configuration overrides for the Chip - * Addressing and Routing Module (WARM) on BL602 platforms - * using the Bouffalolab SDK. - * - */ - -#pragma once - -// ==================== Platform Adaptations ==================== - -#define WARM_CONFIG_SUPPORT_THREAD 1 -#define WARM_CONFIG_SUPPORT_THREAD_ROUTING 0 -#define WARM_CONFIG_SUPPORT_LEGACY6LOWPAN_NETWORK 0 -#define WARM_CONFIG_SUPPORT_WIFI 0 -#define WARM_CONFIG_SUPPORT_CELLULAR 0 - -// ========== Platform-specific Configuration Overrides ========= - -/* none so far */ diff --git a/src/platform/bouffalolab/BL602/gatt.xml b/src/platform/bouffalolab/BL602/gatt.xml deleted file mode 100644 index 4cc1351b399117..00000000000000 --- a/src/platform/bouffalolab/BL602/gatt.xml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - Abstract: The generic_access service contains generic information about the device. All available Characteristics are readonly. - - - - - Empty Example - - - - - - Abstract: The external appearance of this device. The values are composed of a category (10-bits) and sub-categories (6-bits). - 0000 - - - - - - - Abstract: The Device Information Service exposes manufacturer and/or vendor information about a device. Summary: This service exposes manufacturer information about a device. The Device Information Service is instantiated as a Primary Service. Only one instance of the Device Information Service is exposed on a device. - - - - Abstract: The value of this characteristic is a UTF-8 string representing the name of the manufacturer of the device. - Bouffalolab - - - - - - Abstract: The value of this characteristic is a UTF-8 string representing the model number assigned by the device vendor. - Blue Gecko - - - - - - Abstract: The SYSTEM ID characteristic consists of a structure with two fields. The first field are the LSOs and the second field contains the MSOs. This is a 64-bit structure which consists of a 40-bit manufacturer-defined identifier concatenated with a 24 bit unique Organizationally Unique Identifier (OUI). The OUI is issued by the IEEE Registration Authority (http://standards.ieee.org/regauth/index.html) and is required to be used in accordance with IEEE Standard 802-2001.6 while the least significant 40 bits are manufacturer defined. If System ID generated based on a Bluetooth Device Address, it is required to be done as follows. System ID and the Bluetooth Device Address have a very similar structure: a Bluetooth Device Address is 48 bits in length and consists of a 24 bit Company Assigned Identifier (manufacturer defined identifier) concatenated with a 24 bit Company Identifier (OUI). In order to encapsulate a Bluetooth Device Address as System ID, the Company Identifier is concatenated with 0xFFFE followed by the Company Assigned Identifier of the Bluetooth Address. For more guidelines related to EUI-64, refer to http://standards.ieee.org/develop/regauth/tut/eui64.pdf. Examples: If the system ID is based of a Bluetooth Device Address with a Company Identifier (OUI) is 0x123456 and the Company Assigned Identifier is 0x9ABCDE, then the System Identifier is required to be 0x123456FFFE9ABCDE. - 000102030405 - - - - - - - Abstract: The Bouffalolab OTA Service enables over-the-air firmware update of the device. - - - - Abstract: Bouffalolab OTA Control. - - - - - - - - Custom service - - - - Custom characteristic - 0x00 - - - - - - Custom characteristic - 0x00 - - - - diff --git a/src/platform/bouffalolab/BL602/gatt_db.c b/src/platform/bouffalolab/BL602/gatt_db.c deleted file mode 100644 index 6a4d4977a3a8f1..00000000000000 --- a/src/platform/bouffalolab/BL602/gatt_db.c +++ /dev/null @@ -1,379 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Google LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/******************************************************************** - * Autogenerated file, do not edit. - *******************************************************************/ - -#include "bg_gattdb_def.h" - -#include - -#define GATT_HEADER(F) F -#define GATT_DATA(F) F -GATT_DATA(const uint16_t bg_gattdb_data_uuidtable_16_map[]) = { - 0x2800, 0x2801, 0x2803, 0x1800, 0x2a00, 0x2a01, 0x180a, 0x2a29, 0x2a24, 0x2a23, 0xfff6, 0x1801, 0x2a05, 0x2b2a, 0x2b29, 0x2902, -}; - -GATT_DATA(const uint8_t bg_gattdb_data_uuidtable_128_map[]) = { - 0xf0, 0x19, 0x21, 0xb4, 0x47, 0x8f, 0xa4, 0xbf, 0xa1, 0x4f, 0x63, 0xfd, 0xee, 0xd6, 0x14, 0x1d, - 0x63, 0x60, 0x32, 0xe0, 0x37, 0x5e, 0xa4, 0x88, 0x53, 0x4e, 0x6d, 0xfb, 0x64, 0x35, 0xbf, 0xf7, - 0x11, 0x9d, 0x9f, 0x42, 0x9c, 0x4f, 0x9f, 0x95, 0x59, 0x45, 0x3d, 0x26, 0xf5, 0x2e, 0xee, 0x18, - 0x12, 0x9d, 0x9f, 0x42, 0x9c, 0x4f, 0x9f, 0x95, 0x59, 0x45, 0x3d, 0x26, 0xf5, 0x2e, 0xee, 0x18, -}; - -struct bg_gattdb_buffer_with_len - bg_gattdb_data_attribute_field_27_data = { .len = 1, - .data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - } }; -GATT_DATA(const struct bg_gattdb_attribute_chrvalue bg_gattdb_data_attribute_field_27) = { - .properties = 0x2e, - .index = 6, - .max_len = 247, - .data_varlen = &bg_gattdb_data_attribute_field_27_data, -}; - -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_26) = { .len = 19, - .data = { - 0x2e, 0x1c, 0x00, 0x12, 0x9d, - 0x9f, 0x42, 0x9c, 0x4f, 0x9f, - 0x95, 0x59, 0x45, 0x3d, 0x26, - 0xf5, 0x2e, 0xee, 0x18, - } }; -struct bg_gattdb_buffer_with_len - bg_gattdb_data_attribute_field_25_data = { .len = 1, - .data = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - } }; -GATT_DATA(const struct bg_gattdb_attribute_chrvalue bg_gattdb_data_attribute_field_25) = { - .properties = 0x0a, - .index = 5, - .max_len = 247, - .data_varlen = &bg_gattdb_data_attribute_field_25_data, -}; - -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_24) = { .len = 19, - .data = { - 0x0a, 0x1a, 0x00, 0x11, 0x9d, - 0x9f, 0x42, 0x9c, 0x4f, 0x9f, - 0x95, 0x59, 0x45, 0x3d, 0x26, - 0xf5, 0x2e, 0xee, 0x18, - } }; -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_23) = { .len = 2, - .data = { - 0xf6, - 0xff, - } }; -GATT_DATA(const struct bg_gattdb_attribute_chrvalue bg_gattdb_data_attribute_field_22) = { - .properties = 0x08, - .index = 4, - .max_len = 0, - .data = NULL, -}; - -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_21) = { .len = 19, - .data = { - 0x08, 0x17, 0x00, 0x63, 0x60, - 0x32, 0xe0, 0x37, 0x5e, 0xa4, - 0x88, 0x53, 0x4e, 0x6d, 0xfb, - 0x64, 0x35, 0xbf, 0xf7, - } }; -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_20) = { .len = 16, - .data = { - 0xf0, - 0x19, - 0x21, - 0xb4, - 0x47, - 0x8f, - 0xa4, - 0xbf, - 0xa1, - 0x4f, - 0x63, - 0xfd, - 0xee, - 0xd6, - 0x14, - 0x1d, - } }; -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_19) = { .len = 6, - .data = { - 0x00, - 0x01, - 0x02, - 0x03, - 0x04, - 0x05, - } }; -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_18) = { .len = 5, - .data = { - 0x02, - 0x14, - 0x00, - 0x23, - 0x2a, - } }; -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_17) = { .len = 10, - .data = { - 0x42, - 0x6c, - 0x75, - 0x65, - 0x20, - 0x47, - 0x65, - 0x63, - 0x6b, - 0x6f, - } }; -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_16) = { .len = 5, - .data = { - 0x02, - 0x12, - 0x00, - 0x24, - 0x2a, - } }; -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_15) = { .len = 12, - .data = { - 0x53, - 0x69, - 0x6c, - 0x69, - 0x63, - 0x6f, - 0x6e, - 0x20, - 0x4c, - 0x61, - 0x62, - 0x73, - } }; -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_14) = { .len = 5, - .data = { - 0x02, - 0x10, - 0x00, - 0x29, - 0x2a, - } }; -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_13) = { .len = 2, - .data = { - 0x0a, - 0x18, - } }; -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_12) = { .len = 2, - .data = { - 0x00, - 0x00, - } }; -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_11) = { .len = 5, - .data = { - 0x02, - 0x0d, - 0x00, - 0x01, - 0x2a, - } }; -uint8_t bg_gattdb_data_attribute_field_10_data[13] = { - 0x45, 0x6d, 0x70, 0x74, 0x79, 0x20, 0x45, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, -}; -GATT_DATA(const struct bg_gattdb_attribute_chrvalue bg_gattdb_data_attribute_field_10) = { - .properties = 0x0a, - .index = 3, - .max_len = 13, - .data = bg_gattdb_data_attribute_field_10_data, -}; - -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_9) = { .len = 5, - .data = { - 0x0a, - 0x0b, - 0x00, - 0x00, - 0x2a, - } }; -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_8) = { .len = 2, - .data = { - 0x00, - 0x18, - } }; -uint8_t bg_gattdb_data_attribute_field_7_data[1] = { - 0x00, -}; -GATT_DATA(const struct bg_gattdb_attribute_chrvalue bg_gattdb_data_attribute_field_7) = { - .properties = 0x0a, - .index = 2, - .max_len = 1, - .data = bg_gattdb_data_attribute_field_7_data, -}; - -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_6) = { .len = 5, - .data = { - 0x0a, - 0x08, - 0x00, - 0x29, - 0x2b, - } }; -uint8_t bg_gattdb_data_attribute_field_5_data[16] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -}; -GATT_DATA(const struct bg_gattdb_attribute_chrvalue bg_gattdb_data_attribute_field_5) = { - .properties = 0x02, - .index = 1, - .max_len = 16, - .data = bg_gattdb_data_attribute_field_5_data, -}; - -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_4) = { .len = 5, - .data = { - 0x02, - 0x06, - 0x00, - 0x2a, - 0x2b, - } }; -uint8_t bg_gattdb_data_attribute_field_2_data[4] = { - 0x00, - 0x00, - 0x00, - 0x00, -}; -GATT_DATA(const struct bg_gattdb_attribute_chrvalue bg_gattdb_data_attribute_field_2) = { - .properties = 0x20, - .index = 0, - .max_len = 4, - .data = bg_gattdb_data_attribute_field_2_data, -}; - -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_1) = { .len = 5, - .data = { - 0x20, - 0x03, - 0x00, - 0x05, - 0x2a, - } }; -GATT_DATA(const struct bg_gattdb_buffer_with_len bg_gattdb_data_attribute_field_0) = { .len = 2, - .data = { - 0x01, - 0x18, - } }; -GATT_DATA(const struct bg_gattdb_attribute bg_gattdb_data_attributes_map[]) = { - { .uuid = 0x0000, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_0 }, - { .uuid = 0x0002, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_1 }, - { .uuid = 0x000c, .permissions = 0x800, .caps = 0xffff, .datatype = 0x01, .dynamicdata = &bg_gattdb_data_attribute_field_2 }, - { .uuid = 0x000f, - .permissions = 0x807, - .caps = 0xffff, - .datatype = 0x03, - .configdata = { .flags = 0x02, .index = 0x00, .clientconfig_index = 0x00 } }, - { .uuid = 0x0002, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_4 }, - { .uuid = 0x000d, .permissions = 0x801, .caps = 0xffff, .datatype = 0x01, .dynamicdata = &bg_gattdb_data_attribute_field_5 }, - { .uuid = 0x0002, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_6 }, - { .uuid = 0x000e, .permissions = 0x803, .caps = 0xffff, .datatype = 0x01, .dynamicdata = &bg_gattdb_data_attribute_field_7 }, - { .uuid = 0x0000, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_8 }, - { .uuid = 0x0002, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_9 }, - { .uuid = 0x0004, .permissions = 0x803, .caps = 0xffff, .datatype = 0x01, .dynamicdata = &bg_gattdb_data_attribute_field_10 }, - { .uuid = 0x0002, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_11 }, - { .uuid = 0x0005, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_12 }, - { .uuid = 0x0000, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_13 }, - { .uuid = 0x0002, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_14 }, - { .uuid = 0x0007, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_15 }, - { .uuid = 0x0002, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_16 }, - { .uuid = 0x0008, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_17 }, - { .uuid = 0x0002, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_18 }, - { .uuid = 0x0009, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_19 }, - { .uuid = 0x0000, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_20 }, - { .uuid = 0x0002, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_21 }, - { .uuid = 0x8001, .permissions = 0x802, .caps = 0xffff, .datatype = 0x07, .dynamicdata = &bg_gattdb_data_attribute_field_22 }, - { .uuid = 0x0000, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_23 }, - { .uuid = 0x0002, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_24 }, - { .uuid = 0x8002, .permissions = 0x803, .caps = 0xffff, .datatype = 0x02, .dynamicdata = &bg_gattdb_data_attribute_field_25 }, - { .uuid = 0x0002, .permissions = 0x801, .caps = 0xffff, .datatype = 0x00, .constdata = &bg_gattdb_data_attribute_field_26 }, - { .uuid = 0x8003, .permissions = 0x807, .caps = 0xffff, .datatype = 0x02, .dynamicdata = &bg_gattdb_data_attribute_field_27 }, - { .uuid = 0x000f, - .permissions = 0x807, - .caps = 0xffff, - .datatype = 0x03, - .configdata = { .flags = 0x02, .index = 0x06, .clientconfig_index = 0x01 } }, -}; - -GATT_DATA(const uint16_t bg_gattdb_data_attributes_dynamic_mapping_map[]) = { - 0x0003, 0x0006, 0x0008, 0x000b, 0x0017, 0x001a, 0x001c, -}; - -GATT_DATA(const uint8_t bg_gattdb_data_adv_uuid16_map[]) = { 0x0 }; -GATT_DATA(const uint8_t bg_gattdb_data_adv_uuid128_map[]) = { 0x0 }; -GATT_HEADER(const struct bg_gattdb_def bg_gattdb_data) = { - .attributes = bg_gattdb_data_attributes_map, - .attributes_max = 29, - .uuidtable_16_size = 16, - .uuidtable_16 = bg_gattdb_data_uuidtable_16_map, - .uuidtable_128_size = 4, - .uuidtable_128 = bg_gattdb_data_uuidtable_128_map, - .attributes_dynamic_max = 7, - .attributes_dynamic_mapping = bg_gattdb_data_attributes_dynamic_mapping_map, - .adv_uuid16 = bg_gattdb_data_adv_uuid16_map, - .adv_uuid16_num = 0, - .adv_uuid128 = bg_gattdb_data_adv_uuid128_map, - .adv_uuid128_num = 0, - .caps_mask = 0xffff, - .enabled_caps = 0xffff, -}; - -const struct bg_gattdb_def * bg_gattdb = &bg_gattdb_data; diff --git a/src/platform/bouffalolab/BL602/gatt_db.h b/src/platform/bouffalolab/BL602/gatt_db.h deleted file mode 100644 index 1007bbe901fc3a..00000000000000 --- a/src/platform/bouffalolab/BL602/gatt_db.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Google LLC. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __GATT_DB_H -#define __GATT_DB_H - -#if __cplusplus -extern "C" { -#endif - -#include "bg_gattdb_def.h" - -extern const struct bg_gattdb_def bg_gattdb_data; - -#define gattdb_service_changed_char 3 -#define gattdb_database_hash 6 -#define gattdb_client_support_features 8 -#define gattdb_device_name 11 -#define gattdb_ota_control 23 -#define gattdb_CHIPoBLEChar_Rx 26 -#define gattdb_CHIPoBLEChar_Tx 28 - -#if __cplusplus -} -#endif - -#endif diff --git a/src/platform/bouffalolab/BL702/ConfigurationManagerImpl.cpp b/src/platform/bouffalolab/BL702/ConfigurationManagerImpl.cpp index a6be2c40158d58..d884d752ea5d34 100644 --- a/src/platform/bouffalolab/BL702/ConfigurationManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702/ConfigurationManagerImpl.cpp @@ -48,7 +48,7 @@ CHIP_ERROR ConfigurationManagerImpl::Init() { CHIP_ERROR err; bool failSafeArmed; - uint32_t bootCount = 0; + uint32_t rebootCount = 0; err = Internal::GenericConfigurationManagerImpl::Init(); @@ -76,11 +76,11 @@ CHIP_ERROR ConfigurationManagerImpl::Init() if (BL_RST_HBN != bootCause) { - if (CHIP_NO_ERROR == ReadConfigValue(BL702Config::kCounterKey_BootCount, bootCount)) + if (CHIP_NO_ERROR == ReadConfigValue(BL702Config::kCounterKey_RebootCount, rebootCount)) { - bootCount += 1; + rebootCount += 1; } - WriteConfigValue(BL702Config::kCounterKey_BootCount, bootCount + 1); + WriteConfigValue(BL702Config::kCounterKey_RebootCount, rebootCount + 1); } // If the fail-safe was armed when the device last shutdown, initiate a factory reset. @@ -130,12 +130,12 @@ CHIP_ERROR ConfigurationManagerImpl::WritePersistedStorageValue(::chip::Platform CHIP_ERROR ConfigurationManagerImpl::GetRebootCount(uint32_t & rebootCount) { - return ReadConfigValue(BL702Config::kCounterKey_BootCount, rebootCount); + return ReadConfigValue(BL702Config::kCounterKey_RebootCount, rebootCount); } CHIP_ERROR ConfigurationManagerImpl::StoreRebootCount(uint32_t rebootCount) { - return WriteConfigValue(BL702Config::kCounterKey_BootCount, rebootCount); + return WriteConfigValue(BL702Config::kCounterKey_RebootCount, rebootCount); } CHIP_ERROR ConfigurationManagerImpl::GetTotalOperationalHours(uint32_t & totalOperationalHours) diff --git a/src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp b/src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp index c76b6b688f8a0f..cf770004a27f41 100644 --- a/src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp @@ -26,7 +26,9 @@ #include +extern "C" { #include +} namespace chip { namespace DeviceLayer { diff --git a/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp b/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp index 0fb93c75826058..a89896aa510930 100644 --- a/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp @@ -47,15 +47,13 @@ CHIP_ERROR ThreadStackManagerImpl::_InitThreadStack(void) CHIP_ERROR ThreadStackManagerImpl::InitThreadStack(otInstance * otInst) { CHIP_ERROR err = CHIP_NO_ERROR; + otRadio_opt_t opt; + + opt.byte = 0; + opt.bf.isCoexEnable = true; ot_alarmInit(); -#ifdef OT_THREAD_PORT_1_3 - otRadio_opt_t opt; - opt.byte = 0; ot_radioInit(opt); -#else - ot_radioInit(); -#endif // Initialize the generic implementation base classes. err = GenericThreadStackManagerImpl_FreeRTOS::DoInit(); SuccessOrExit(err); @@ -82,12 +80,7 @@ ot_system_event_t ot_system_event_var = OT_SYSTEM_EVENT_NONE; void otSysProcessDrivers(otInstance * aInstance) { -#ifdef OT_THREAD_PORT_1_3 ot_system_event_t sevent = otrGetNotifyEvent(); -#else - ot_system_event_t sevent = OT_SYSTEM_EVENT_NONE; - OT_GET_NOTIFY(sevent); -#endif ot_alarmTask(sevent); ot_radioTask(sevent); @@ -126,7 +119,6 @@ extern "C" void otPlatFree(void * aPtr) free(aPtr); } -#ifdef OT_THREAD_PORT_1_3 extern "C" uint32_t otrEnterCrit(void) { if (xPortIsInsideInterrupt()) @@ -172,4 +164,3 @@ extern "C" void otrNotifyEvent(ot_system_event_t sevent) otSysEventSignalPending(); } -#endif diff --git a/src/platform/bouffalolab/BL702/bl702Config.h b/src/platform/bouffalolab/BL702/bl702Config.h index dc9450f4986c61..af40b430964a3c 100644 --- a/src/platform/bouffalolab/BL702/bl702Config.h +++ b/src/platform/bouffalolab/BL702/bl702Config.h @@ -53,25 +53,29 @@ class BL702Config static constexpr const char * kConfigKey_UniqueId = ("unique-id"); /** Config keys, which should be droped after a factory reset */ - static constexpr const char * kConfigKey_FabricId = ("fabric-id"); - static constexpr const char * kConfigKey_ServiceConfig = ("service-config"); - static constexpr const char * kConfigKey_PairedAccountId = ("account-id"); - static constexpr const char * kConfigKey_ServiceId = ("service-id"); - static constexpr const char * kConfigKey_FabricSecret = ("fabric-secret"); - static constexpr const char * kConfigKey_HardwareVersion = ("hardware-rev"); - static constexpr const char * kConfigKey_LastUsedEpochKeyId = ("last-ek-id"); - static constexpr const char * kConfigKey_FailSafeArmed = ("fail-safe-armed"); - static constexpr const char * kConfigKey_WiFiStationSecType = ("sta-sec-type"); - static constexpr const char * kConfigKey_RegulatoryLocation = ("regulatory-location"); - static constexpr const char * kConfigKey_CountryCode = ("country-code"); - static constexpr const char * kConfigKey_ActiveLocale = ("active-locale"); - static constexpr const char * kConfigKey_Breadcrumb = ("breadcrumb"); - static constexpr const char * kConfigKey_GroupKeyIndex = ("group-key-index"); - static constexpr const char * kBLConfigKey_wifissid = ("blConfig_wifi-ssid"); - static constexpr const char * kBLConfigKey_wifipassword = ("blConfig_wifi-pwd"); + static constexpr const char * kConfigKey_FabricId = ("fabric-id"); + static constexpr const char * kConfigKey_ServiceConfig = ("service-config"); + static constexpr const char * kConfigKey_PairedAccountId = ("account-id"); + static constexpr const char * kConfigKey_ServiceId = ("service-id"); + static constexpr const char * kConfigKey_FabricSecret = ("fabric-secret"); + static constexpr const char * kConfigKey_HardwareVersion = ("hardware-ver"); + static constexpr const char * kConfigKey_LastUsedEpochKeyId = ("last-ek-id"); + static constexpr const char * kConfigKey_FailSafeArmed = ("fail-safe-armed"); + static constexpr const char * kConfigKey_WiFiStationSecType = ("sta-sec-type"); + static constexpr const char * kConfigKey_OperationalDeviceId = ("op-device-id"); + static constexpr const char * kConfigKey_OperationalDeviceCert = ("op-device-cert"); + static constexpr const char * kConfigKey_OperationalDeviceICACerts = ("op-device-ca-certs"); + static constexpr const char * kConfigKey_OperationalDevicePrivateKey = ("op-device-key"); + static constexpr const char * kConfigKey_RegulatoryLocation = ("regulatory-location"); + static constexpr const char * kConfigKey_CountryCode = ("country-code"); + static constexpr const char * kConfigKey_ActiveLocale = ("active-locale"); + static constexpr const char * kConfigKey_Breadcrumb = ("breadcrumb"); + static constexpr const char * kConfigKey_GroupKeyIndex = ("group-key-index"); + static constexpr const char * kBLConfigKey_wifissid = ("blConfig_wifi-ssid"); + static constexpr const char * kBLConfigKey_wifipassword = ("blConfig_wifi-pwd"); /** Counter Keys, diagnostic information */ - static constexpr const char * kCounterKey_BootCount = ("boot-count"); + static constexpr const char * kCounterKey_RebootCount = ("reboot-count"); static constexpr const char * kCounterKey_TotalOperationalHours = ("total-hours"); static constexpr const char * kCounterKey_UpTime = ("up-time"); diff --git a/third_party/bouffalolab/bl602/bl_iot_sdk.gni b/third_party/bouffalolab/bl602/bl_iot_sdk.gni index 6c684a24a9006a..168731384fb644 100644 --- a/third_party/bouffalolab/bl602/bl_iot_sdk.gni +++ b/third_party/bouffalolab/bl602/bl_iot_sdk.gni @@ -56,12 +56,14 @@ template("bl_iot_sdk") { defines += invoker.defines } - if (defined(invoker.freertos_config)) { - cflags_c = [ - "-include", - rebase_path("${invoker.freertos_config}", root_build_dir), - ] - } + cflags_c = [ + "-include", + rebase_path("${invoker.freertos_config}", root_build_dir), + ] + cflags_cc = [ + "-include", + rebase_path("${invoker.freertos_config}", root_build_dir), + ] } source_set("${sdk_target_name}_soc") { @@ -259,6 +261,7 @@ template("bl_iot_sdk") { "-Wno-old-style-declaration", "-Wno-stringop-overflow", "-Wno-format-truncation", + "-Wno-unused-variable", ] configs += [ ":${sdk_target_name}_config_wifi", @@ -567,9 +570,10 @@ template("bl_iot_sdk") { include_dirs = [ "${bl_iot_sdk_root}/components/network/ble/blestack/src/common", + "${bl_iot_sdk_root}/components/network/ble/blestack/src/common/include", + "${bl_iot_sdk_root}/components/network/ble/blestack/src/common/include/misc", "${bl_iot_sdk_root}/components/network/ble/blestack/src/bl_hci_wrapper", "${bl_iot_sdk_root}/components/network/ble/blestack/src/common/tinycrypt/include/tinycrypt", - "${bl_iot_sdk_root}/components/network/ble/blestack/src/common/include/misc", ] sources = [ @@ -613,6 +617,7 @@ template("bl_iot_sdk") { "-Wno-unused-function", "-Wno-incompatible-pointer-types", "-Wno-discarded-qualifiers", + "-Wno-unused-variable", ] } @@ -660,6 +665,7 @@ template("bl_iot_sdk") { "BL_CHIP_NAME=\"BL602\"", "TD_DIAGNOSIS_STA", "OS_USING_FREERTOS", + "CFG_VIRT_DEV_MAX=1", ] include_dirs = [ "${bl_iot_sdk_root}/components/os/bl_os_adapter/bl_os_adapter/include", @@ -904,6 +910,10 @@ template("bl_iot_sdk") { sources += [ "${bl_iot_sdk_root}/components/network/lwip_dhcpd/dhcp_server_raw.c" ] + cflags_c = [ + "-Wno-incompatible-pointer-types", + "-Wno-sign-compare", + ] configs += [ ":${sdk_target_name}_config_freertos" ] public_configs = [ ":${sdk_target_name}_config", diff --git a/third_party/bouffalolab/bl702/bl_iot_sdk.gni b/third_party/bouffalolab/bl702/bl_iot_sdk.gni index 9e96105373928a..402eec511e7f27 100644 --- a/third_party/bouffalolab/bl702/bl_iot_sdk.gni +++ b/third_party/bouffalolab/bl702/bl_iot_sdk.gni @@ -24,8 +24,6 @@ declare_args() { bl_iot_sdk_root = "${chip_root}/third_party/bouffalolab/repo" enable_cdc_module = false - - thread_port_1_3 = false } assert(bl_iot_sdk_root != "", "bl_iot_sdk_root must be specified") @@ -64,12 +62,14 @@ template("bl_iot_sdk") { defines += invoker.defines } - if (defined(invoker.freertos_config)) { - cflags_c = [ - "-include", - rebase_path("${invoker.freertos_config}", root_build_dir), - ] - } + cflags_c = [ + "-include", + rebase_path("${invoker.freertos_config}", root_build_dir), + ] + cflags_cc = [ + "-include", + rebase_path("${invoker.freertos_config}", root_build_dir), + ] } config("${sdk_target_name}_config_soc") { @@ -239,7 +239,6 @@ template("bl_iot_sdk") { "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_adc.c", "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_boot2.c", "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_chip.c", - "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_cks.c", "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_dma.c", "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_efuse.c", "${bl_iot_sdk_root}/components/platform/hosal/bl702_hal/bl_emac.c", @@ -284,9 +283,7 @@ template("bl_iot_sdk") { "${bl_iot_sdk_root}/components/platform/hosal/sec_common/bl_sec_aes.c", "${bl_iot_sdk_root}/components/platform/hosal/sec_common/bl_sec_common.c", "${bl_iot_sdk_root}/components/platform/hosal/sec_common/bl_sec_pka.c", - - # need update bl_sec_sha.c to fix compile error - # "${bl_iot_sdk_root}/components/platform/hosal/sec_common/bl_sec_sha.c", + "${bl_iot_sdk_root}/components/platform/hosal/sec_common/bl_sec_sha.c", ] cflags_c = [ @@ -296,6 +293,7 @@ template("bl_iot_sdk") { "-Wno-old-style-declaration", "-Wno-stringop-overflow", "-Wno-format-truncation", + "-Wno-shadow", ] configs += [ ":${sdk_target_name}_config_soc", @@ -522,13 +520,14 @@ template("bl_iot_sdk") { "CONFIG_BT_SETTINGS_USE_PRINTK", ] - libs = [ "${bl_iot_sdk_root}/components/network/ble/blecontroller_702_std/lib/libblecontroller_702_std.a" ] + libs = [ "${bl_iot_sdk_root}/components/network/ble/blecontroller_702_m1s1/lib/libblecontroller_702_m1s1.a" ] include_dirs = [ "${bl_iot_sdk_root}/components/network/ble/blestack/src/common", + "${bl_iot_sdk_root}/components/network/ble/blestack/src/common/include", + "${bl_iot_sdk_root}/components/network/ble/blestack/src/common/include/misc", "${bl_iot_sdk_root}/components/network/ble/blestack/src/bl_hci_wrapper", "${bl_iot_sdk_root}/components/network/ble/blestack/src/common/tinycrypt/include/tinycrypt", - "${bl_iot_sdk_root}/components/network/ble/blestack/src/common/include/misc", ] sources = [ @@ -577,9 +576,6 @@ template("bl_iot_sdk") { config("${sdk_target_name}_config_openthread_port") { defines = [ "OT_FREERTOS_ENABLE=1" ] - if (thread_port_1_3) { - defines += [ "OT_THREAD_PORT_1_3" ] - } include_dirs = [ "${chip_root}/platform/bl702", @@ -588,14 +584,12 @@ template("bl_iot_sdk") { "${bl_iot_sdk_root}/components/network/thread/openthread_port/include", ] - if (thread_port_1_3) { - include_dirs += [ - "${bl_iot_sdk_root}/components/network/thread/openthread_utils/include", - ] - } + include_dirs += [ + "${bl_iot_sdk_root}/components/network/thread/openthread_utils/include", + ] } - source_set("${sdk_target_name}_openthread") { + source_set("${sdk_target_name}_openthread_port") { import("//build_overrides/openthread.gni") include_dirs = [ @@ -609,18 +603,17 @@ template("bl_iot_sdk") { "${bl_iot_sdk_root}/components/network/thread/openthread_port/ot_alarm.c", "${bl_iot_sdk_root}/components/network/thread/openthread_port/ot_diag.c", "${bl_iot_sdk_root}/components/network/thread/openthread_port/ot_entropy.c", + "${bl_iot_sdk_root}/components/network/thread/openthread_port/ot_linkmetric.c", "${bl_iot_sdk_root}/components/network/thread/openthread_port/ot_logging.c", "${bl_iot_sdk_root}/components/network/thread/openthread_port/ot_misc.c", "${bl_iot_sdk_root}/components/network/thread/openthread_port/ot_radio.c", "${bl_iot_sdk_root}/components/network/thread/openthread_port/ot_settings.c", ] - libs = [ "${bl_iot_sdk_root}/components/network/lmac154/lib/liblmac154.a" ] - - if (thread_port_1_3) { - sources += [ "${bl_iot_sdk_root}/components/network/thread/openthread_port/ot_linkmetric.c" ] - libs += [ "${bl_iot_sdk_root}/components/network/thread/openthread_utils/lib/libopenthread_utils.a" ] - } + libs = [ + "${bl_iot_sdk_root}/components/network/lmac154/lib/liblmac154.a", + "${bl_iot_sdk_root}/components/network/thread/openthread_utils_bl702/lib/libopenthread_utils_bl702.a", + ] configs += [ ":${sdk_target_name}_config_BSP_Driver", @@ -811,7 +804,7 @@ template("bl_iot_sdk") { ] if (chip_enable_openthread) { - public_deps += [ ":${sdk_target_name}_openthread" ] + public_deps += [ ":${sdk_target_name}_openthread_port" ] } if (chip_enable_wifi) { diff --git a/third_party/bouffalolab/repo b/third_party/bouffalolab/repo index abf04dcdc4ce5f..890577da8b6b1d 160000 --- a/third_party/bouffalolab/repo +++ b/third_party/bouffalolab/repo @@ -1 +1 @@ -Subproject commit abf04dcdc4ce5f94c57b6150d6ba52a22b700880 +Subproject commit 890577da8b6b1d7f1078382e4e320a1e60cc5f60