diff --git a/config/ameba/chip.cmake b/config/ameba/chip.cmake index f283a1f0d58dd4..015f5bf72f2a9f 100644 --- a/config/ameba/chip.cmake +++ b/config/ameba/chip.cmake @@ -8,6 +8,8 @@ set(chip_c_flags "") set(chip_cpp_flags "") set(chip-gn chip-gn) +set(matter_enable_rotating_id 1) + get_filename_component(CHIP_ROOT ${chip_dir} REALPATH) get_filename_component(CHIP_OUTPUT ${chip_dir_output} REALPATH) get_filename_component(LIB_ROOT ${prj_root}/GCC-RELEASE/project_hp/asdk/lib/application REALPATH) @@ -101,6 +103,7 @@ string(APPEND CHIP_GN_ARGS "ameba_ar = \"arm-none-eabi-ar\"\n") string(APPEND CHIP_GN_ARGS "ameba_cc = \"arm-none-eabi-gcc\"\n") string(APPEND CHIP_GN_ARGS "ameba_cxx = \"arm-none-eabi-c++\"\n") string(APPEND CHIP_GN_ARGS "ameba_cpu = \"ameba\"\n") +string(APPEND CHIP_GN_ARGS "chip_inet_config_enable_ipv4 = false\n") # Build RPC if (matter_enable_rpc) @@ -118,10 +121,13 @@ if (matter_enable_ota_requestor) string(APPEND CHIP_GN_ARGS "chip_enable_ota_requestor = true\n") endif (matter_enable_ota_requestor) -if (CONFIG_ENABLE_ROTATING_DEVICE_ID) - string(APPEND CHIP_GN_ARGS "chip_enable_additional_data_advertising" "true") - string(APPEND CHIP_GN_ARGS "chip_enable_rotating_device_id" "true") -endif() +if (matter_enable_rotating_id) + string(APPEND CHIP_GN_ARGS "chip_enable_additional_data_advertising = true\n") + string(APPEND CHIP_GN_ARGS "chip_enable_rotating_device_id = true\n") +else(matter_enable_rotating_id) + string(APPEND CHIP_GN_ARGS "chip_enable_additional_data_advertising = false\n") + string(APPEND CHIP_GN_ARGS "chip_enable_rotating_device_id = false\n") +endif(matter_enable_rotating_id) file(GENERATE OUTPUT ${CHIP_OUTPUT}/args.gn CONTENT ${CHIP_GN_ARGS}) diff --git a/examples/all-clusters-app/ameba/chip_main.cmake b/examples/all-clusters-app/ameba/chip_main.cmake index ed0270f13e9012..c9bfc1ead25377 100755 --- a/examples/all-clusters-app/ameba/chip_main.cmake +++ b/examples/all-clusters-app/ameba/chip_main.cmake @@ -218,13 +218,12 @@ endif (matter_enable_rpc) list( APPEND chip_main_flags - -DINET_CONFIG_ENABLE_IPV4=1 + -DINET_CONFIG_ENABLE_IPV4=0 -DCHIP_PROJECT=1 -DCHIP_DEVICE_LAYER_TARGET=Ameba -DUSE_ZAP_CONFIG -DCHIP_HAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE= - -DCONFIG_ENABLE_ROTATING_DEVICE_ID=1 -DMATTER_ALL_CLUSTERS_APP=1 ) diff --git a/examples/all-clusters-app/ameba/main/chipinterface.cpp b/examples/all-clusters-app/ameba/main/chipinterface.cpp index bceeec83e598f5..e11e9a0edbe021 100644 --- a/examples/all-clusters-app/ameba/main/chipinterface.cpp +++ b/examples/all-clusters-app/ameba/main/chipinterface.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -56,14 +57,21 @@ using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; using namespace ::chip::System; -namespace { +namespace { // Network Commissioning +constexpr EndpointId kNetworkCommissioningEndpointMain = 0; +constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; + app::Clusters::NetworkCommissioning::Instance - sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::AmebaWiFiDriver::GetInstance())); + sWiFiNetworkCommissioningInstance(kNetworkCommissioningEndpointMain /* Endpoint Id */, + &(NetworkCommissioning::AmebaWiFiDriver::GetInstance())); } // namespace void NetWorkCommissioningInstInit() { sWiFiNetworkCommissioningInstance.Init(); + + // We only have network commissioning on endpoint 0. + emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false); } Identify gIdentify0 = { @@ -102,14 +110,13 @@ AmebaOTAImageProcessor gImageProcessor; extern "C" void amebaQueryImageCmdHandler() { ChipLogProgress(DeviceLayer, "Calling amebaQueryImageCmdHandler"); - static_cast(GetRequestorInstance())->TriggerImmediateQuery(); + PlatformMgr().ScheduleWork([](intptr_t) { GetRequestorInstance()->TriggerImmediateQuery(); }); } extern "C" void amebaApplyUpdateCmdHandler() { ChipLogProgress(DeviceLayer, "Calling amebaApplyUpdateCmdHandler"); - - static_cast(GetRequestorInstance())->ApplyUpdate(); + PlatformMgr().ScheduleWork([](intptr_t) { GetRequestorInstance()->ApplyUpdate(); }); } static void InitOTARequestor(void) @@ -134,6 +141,10 @@ static void InitOTARequestor(void) static void InitServer(intptr_t context) { +#if CONFIG_ENABLE_OTA_REQUESTOR + InitOTARequestor(); +#endif + // Init ZCL Data Model and CHIP App Server chip::Server::GetInstance().Init(); @@ -146,10 +157,6 @@ static void InitServer(intptr_t context) // QR code will be used with CHIP Tool PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); } - -#if CONFIG_ENABLE_OTA_REQUESTOR - InitOTARequestor(); -#endif } extern "C" void ChipTest(void) diff --git a/examples/lighting-app/ameba/chip_main.cmake b/examples/lighting-app/ameba/chip_main.cmake index 209e05f1199b77..f25805d5d1bea0 100755 --- a/examples/lighting-app/ameba/chip_main.cmake +++ b/examples/lighting-app/ameba/chip_main.cmake @@ -75,7 +75,7 @@ target_include_directories( list( APPEND chip_main_flags - -DINET_CONFIG_ENABLE_IPV4=1 + -DINET_CONFIG_ENABLE_IPV4=0 -DCHIP_PROJECT=1 -DCHIP_DEVICE_LAYER_TARGET=Ameba -DUSE_ZAP_CONFIG diff --git a/examples/lighting-app/ameba/main/chipinterface.cpp b/examples/lighting-app/ameba/main/chipinterface.cpp index 44322dbbe4ea2e..67552271f070b3 100644 --- a/examples/lighting-app/ameba/main/chipinterface.cpp +++ b/examples/lighting-app/ameba/main/chipinterface.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -55,14 +56,21 @@ using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; using namespace ::chip::System; -namespace { +namespace { // Network Commissioning +constexpr EndpointId kNetworkCommissioningEndpointMain = 0; +constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; + app::Clusters::NetworkCommissioning::Instance - sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::AmebaWiFiDriver::GetInstance())); + sWiFiNetworkCommissioningInstance(kNetworkCommissioningEndpointMain /* Endpoint Id */, + &(NetworkCommissioning::AmebaWiFiDriver::GetInstance())); } // namespace void NetWorkCommissioningInstInit() { sWiFiNetworkCommissioningInstance.Init(); + + // We only have network commissioning on endpoint 0. + emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false); } #ifdef CONFIG_PLATFORM_8721D @@ -87,14 +95,13 @@ AmebaOTAImageProcessor gImageProcessor; extern "C" void amebaQueryImageCmdHandler() { ChipLogProgress(DeviceLayer, "Calling amebaQueryImageCmdHandler"); - static_cast(GetRequestorInstance())->TriggerImmediateQuery(); + PlatformMgr().ScheduleWork([](intptr_t) { GetRequestorInstance()->TriggerImmediateQuery(); }); } extern "C" void amebaApplyUpdateCmdHandler() { ChipLogProgress(DeviceLayer, "Calling amebaApplyUpdateCmdHandler"); - - static_cast(GetRequestorInstance())->ApplyUpdate(); + PlatformMgr().ScheduleWork([](intptr_t) { GetRequestorInstance()->ApplyUpdate(); }); } static void InitOTARequestor(void) @@ -155,6 +162,10 @@ static Identify gIdentify1 = { static void InitServer(intptr_t context) { +#if CONFIG_ENABLE_OTA_REQUESTOR + InitOTARequestor(); +#endif + // Init ZCL Data Model and CHIP App Server chip::Server::GetInstance().Init(); @@ -167,10 +178,6 @@ static void InitServer(intptr_t context) // QR code will be used with CHIP Tool PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); } - -#if CONFIG_ENABLE_OTA_REQUESTOR - InitOTARequestor(); -#endif } extern "C" void ChipTest(void) @@ -195,10 +202,6 @@ extern "C" void ChipTest(void) chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, 0); statusLED1.Init(STATUS_LED_GPIO_NUM); - -#if CONFIG_ENABLE_OTA_REQUESTOR - InitOTARequestor(); -#endif } bool lowPowerClusterSleep() diff --git a/examples/ota-requestor-app/ameba/chip_main.cmake b/examples/ota-requestor-app/ameba/chip_main.cmake index e1d593035988fb..e791e4f15d9b83 100644 --- a/examples/ota-requestor-app/ameba/chip_main.cmake +++ b/examples/ota-requestor-app/ameba/chip_main.cmake @@ -68,7 +68,7 @@ target_include_directories( list( APPEND chip_main_flags - -DINET_CONFIG_ENABLE_IPV4=1 + -DINET_CONFIG_ENABLE_IPV4=0 -DCHIP_PROJECT=1 -DCHIP_DEVICE_LAYER_TARGET=Ameba -DUSE_ZAP_CONFIG diff --git a/examples/ota-requestor-app/ameba/main/chipinterface.cpp b/examples/ota-requestor-app/ameba/main/chipinterface.cpp index bfb91532a8c1db..1335c5d3da4b7c 100644 --- a/examples/ota-requestor-app/ameba/main/chipinterface.cpp +++ b/examples/ota-requestor-app/ameba/main/chipinterface.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -65,14 +66,21 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; -namespace { +namespace { // Network Commissioning +constexpr EndpointId kNetworkCommissioningEndpointMain = 0; +constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE; + app::Clusters::NetworkCommissioning::Instance - sWiFiNetworkCommissioningInstance(0 /* Endpoint Id */, &(NetworkCommissioning::AmebaWiFiDriver::GetInstance())); + sWiFiNetworkCommissioningInstance(kNetworkCommissioningEndpointMain /* Endpoint Id */, + &(NetworkCommissioning::AmebaWiFiDriver::GetInstance())); } // namespace void NetWorkCommissioningInstInit() { sWiFiNetworkCommissioningInstance.Init(); + + // We only have network commissioning on endpoint 0. + emberAfEndpointEnableDisable(kNetworkCommissioningEndpointSecondary, false); } static DeviceCallbacks EchoCallbacks; @@ -86,14 +94,13 @@ AmebaOTAImageProcessor gImageProcessor; extern "C" void amebaQueryImageCmdHandler() { ChipLogProgress(DeviceLayer, "Calling amebaQueryImageCmdHandler"); - static_cast(GetRequestorInstance())->TriggerImmediateQuery(); + PlatformMgr().ScheduleWork([](intptr_t) { GetRequestorInstance()->TriggerImmediateQuery(); }); } extern "C" void amebaApplyUpdateCmdHandler() { ChipLogProgress(DeviceLayer, "Calling amebaApplyUpdateCmdHandler"); - - static_cast(GetRequestorInstance())->ApplyUpdate(); + PlatformMgr().ScheduleWork([](intptr_t) { GetRequestorInstance()->ApplyUpdate(); }); } static void InitOTARequestor(void) @@ -117,14 +124,14 @@ static void InitOTARequestor(void) static void InitServer(intptr_t context) { + InitOTARequestor(); + // Init ZCL Data Model and CHIP App Server chip::Server::GetInstance().Init(); // Initialize device attestation config SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); NetWorkCommissioningInstInit(); - - InitOTARequestor(); } extern "C" void ChipTest(void) diff --git a/examples/pigweed-app/ameba/chip_main.cmake b/examples/pigweed-app/ameba/chip_main.cmake index 1eca361863b4c5..41761651d828a7 100644 --- a/examples/pigweed-app/ameba/chip_main.cmake +++ b/examples/pigweed-app/ameba/chip_main.cmake @@ -72,7 +72,7 @@ link_directories( list( APPEND chip_main_flags - -DINET_CONFIG_ENABLE_IPV4=1 + -DINET_CONFIG_ENABLE_IPV4=0 -DCHIP_PROJECT=1 -DCHIP_DEVICE_LAYER_TARGET=Ameba -DUSE_ZAP_CONFIG diff --git a/src/platform/Ameba/CHIPPlatformConfig.h b/src/platform/Ameba/CHIPPlatformConfig.h index c77899dd7d7a7b..8b367b08492b24 100644 --- a/src/platform/Ameba/CHIPPlatformConfig.h +++ b/src/platform/Ameba/CHIPPlatformConfig.h @@ -50,6 +50,10 @@ #define CHIP_CONFIG_MAX_PEER_NODES 16 #endif // CHIP_CONFIG_MAX_PEER_NODES +#ifndef CHIP_CONFIG_MAX_FABRICS +#define CHIP_CONFIG_MAX_FABRICS 5 +#endif // CHIP_CONFIG_MAX_FABRICS + #ifndef CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS #define CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS 16 #endif // CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS diff --git a/src/platform/Ameba/InetPlatformConfig.h b/src/platform/Ameba/InetPlatformConfig.h index 3cb97a0c97b459..a69b5815756fc3 100755 --- a/src/platform/Ameba/InetPlatformConfig.h +++ b/src/platform/Ameba/InetPlatformConfig.h @@ -43,5 +43,3 @@ #ifndef INET_CONFIG_NUM_UDP_ENDPOINTS #define INET_CONFIG_NUM_UDP_ENDPOINTS 10 #endif // INET_CONFIG_NUM_UDP_ENDPOINTS - -#define INET_CONFIG_ENABLE_IPV4 1 diff --git a/src/platform/Ameba/KeyValueStoreManagerImpl.cpp b/src/platform/Ameba/KeyValueStoreManagerImpl.cpp index e2b8afbefd4eec..fbab63692619bc 100755 --- a/src/platform/Ameba/KeyValueStoreManagerImpl.cpp +++ b/src/platform/Ameba/KeyValueStoreManagerImpl.cpp @@ -54,14 +54,10 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t if (TRUE == ret) { err = CHIP_NO_ERROR; - if (read_bytes_size) - { - *read_bytes_size = value_size; - } } else { - err = CHIP_ERROR_INTERNAL; + err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; } return err;