From 89fc8211b447584cde6547252bdf15c378582f12 Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Mon, 26 Sep 2022 09:29:04 -0400 Subject: [PATCH 1/6] [Silabs] Add Support for Modules for Matter (#22793) * rename variables to be agnostic from board family * Add support for the BRD4317a * Add support for the mgm24 boards * Add argument to remove LEDs if necessary * Change default value to support multiple board types * Add Support for the BRD4316A * Add Support for BRD4319A * update matter_support submodule * Rename variable in missing location Co-authored-by: Andrei Litvin --- .github/workflows/examples-efr32.yaml | 4 +- .github/workflows/release_artifacts.yaml | 6 +- examples/chef/chef.py | 12 +- examples/chef/efr32/BUILD.gn | 15 +- examples/chef/efr32/src/AppTask.cpp | 6 + examples/light-switch-app/efr32/BUILD.gn | 15 +- .../light-switch-app/efr32/src/AppTask.cpp | 5 +- examples/lighting-app/efr32/BUILD.gn | 17 +- examples/lighting-app/efr32/src/AppTask.cpp | 16 +- examples/lock-app/efr32/BUILD.gn | 15 +- examples/lock-app/efr32/src/AppTask.cpp | 19 +- examples/persistent-storage/efr32/BUILD.gn | 4 +- examples/pigweed-app/efr32/BUILD.gn | 9 +- examples/pigweed-app/efr32/src/main.cpp | 6 +- examples/platform/efr32/BaseApplication.cpp | 32 +++ examples/platform/efr32/ldscripts/mgm24.ld | 243 ++++++++++++++++++ examples/platform/efr32/uart.cpp | 12 +- examples/shell/efr32/BUILD.gn | 4 +- examples/thermostat/efr32/BUILD.gn | 15 +- examples/thermostat/efr32/src/AppTask.cpp | 3 + examples/window-app/efr32/BUILD.gn | 17 +- .../window-app/efr32/include/WindowAppImpl.h | 10 +- .../window-app/efr32/src/WindowAppImpl.cpp | 36 ++- .../images/chip-build-vscode/Dockerfile | 2 +- scripts/build/builders/efr32.py | 2 +- .../build/testdata/build_all_except_host.txt | 224 ++++++++-------- scripts/examples/gn_efr32_example.sh | 18 +- scripts/flashing/efr32_firmware_utils.py | 4 +- src/platform/EFR32/args.gni | 2 +- src/platform/EFR32/wifi_args.gni | 2 +- src/test_driver/efr32/BUILD.gn | 4 +- .../openthread/platforms/efr32/BUILD.gn | 8 +- third_party/silabs/BUILD.gn | 10 +- third_party/silabs/efr32_arm.gni | 7 +- third_party/silabs/efr32_board.gni | 88 ------- third_party/silabs/efr32_sdk.gni | 144 +++++++++-- third_party/silabs/matter_support | 2 +- third_party/silabs/silabs_board.gni | 97 +++++++ 38 files changed, 808 insertions(+), 327 deletions(-) create mode 100644 examples/platform/efr32/ldscripts/mgm24.ld delete mode 100644 third_party/silabs/efr32_board.gni create mode 100644 third_party/silabs/silabs_board.gni diff --git a/.github/workflows/examples-efr32.yaml b/.github/workflows/examples-efr32.yaml index 7c5aad5eedffdd..188c11157ba1f4 100644 --- a/.github/workflows/examples-efr32.yaml +++ b/.github/workflows/examples-efr32.yaml @@ -25,10 +25,10 @@ concurrency: jobs: efr32: name: EFR32 - timeout-minutes: 110 + timeout-minutes: 110 env: - EFR32_BOARD: BRD4161A + SILABS_BOARD: BRD4161A BUILD_TYPE: gn_efr32 runs-on: ubuntu-latest diff --git a/.github/workflows/release_artifacts.yaml b/.github/workflows/release_artifacts.yaml index be9a7807a8e51b..d379868bb54b7f 100644 --- a/.github/workflows/release_artifacts.yaml +++ b/.github/workflows/release_artifacts.yaml @@ -69,7 +69,7 @@ jobs: efr32: name: EFR32 env: - EFR32_BOARD: BRD4161A + SILABS_BOARD: BRD4161A BUILD_DIRECTORY: out/lock_app_debug/BRD4161A runs-on: ubuntu-latest @@ -100,7 +100,7 @@ jobs: .environment/pigweed-venv/*.log - name: Build example EFR32 Lock App run: scripts/examples/gn_efr32_example.sh examples/lock-app/efr32/ - out/lock_app_debug $EFR32_BOARD + out/lock_app_debug $SILABS_BOARD - name: Upload artifact run: | @@ -110,4 +110,4 @@ jobs: --release-tag "${{ github.event.inputs.releaseTag }}" \ --bundle-files $BUILD_DIRECTORY/lock_app.flashbundle.txt \ --working-directory $BUILD_DIRECTORY \ - --bundle-name efr32-$EFR32_BOARD-chip-lock-example + --bundle-name efr32-$SILABS_BOARD-chip-lock-example diff --git a/examples/chef/chef.py b/examples/chef/chef.py index 58d2b246d9f37d..411151a8def953 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -83,7 +83,7 @@ def load_config() -> None: config["silabs-thread"]["GECKO_SDK"] = f"{_REPO_BASE_PATH}third_party/efr32_sdk/repo" config["silabs-thread"]["TTY"] = None config["silabs-thread"]["CU"] = None - config["silabs-thread"]["EFR32_BOARD"] = None + config["silabs-thread"]["SILABS_BOARD"] = None config["ameba"]["AMEBA_SDK"] = None config["ameba"]["MATTER_SDK"] = None config["ameba"]["MODEL"] = 'D' @@ -493,11 +493,11 @@ def main() -> int: pass elif options.build_target == "silabs-thread": flush_print('Path to gecko sdk is configured within Matter.') - if 'EFR32_BOARD' not in config['silabs-thread'] or config['silabs-thread']['EFR32_BOARD'] is None: + if 'SILABS_BOARD' not in config['silabs-thread'] or config['silabs-thread']['SILABS_BOARD'] is None: flush_print( - 'EFR32_BOARD was not configured. Make sure silabs-thread.EFR32_BOARD is set on your config.yaml file') + 'SILABS_BOARD was not configured. Make sure silabs-thread.SILABS_BOARD is set on your config.yaml file') exit(1) - efr32_board = config['silabs-thread']['EFR32_BOARD'] + silabs_board = config['silabs-thread']['SILABS_BOARD'] elif options.build_target == "ameba": if config['ameba']['AMEBA_SDK'] is None: flush_print( @@ -669,7 +669,7 @@ def main() -> int: f'{_REPO_BASE_PATH}/scripts/examples/gn_efr32_example.sh') efr32_cmd_args.append('./') efr32_cmd_args.append(f'out/{options.sample_device_type_name}') - efr32_cmd_args.append(f'{efr32_board}') + efr32_cmd_args.append(f'{silabs_board}') efr32_cmd_args.append( f'\'sample_name=\"{options.sample_device_type_name}\"\'') if sw_ver_string: @@ -808,7 +808,7 @@ def main() -> int: elif (options.build_target == "silabs-thread") or (options.build_target == "silabs-wifi"): shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}/efr32") shell.run_cmd( - f"python3 out/{options.sample_device_type_name}/{efr32_board}/chip-efr32-chef-example.flash.py") + f"python3 out/{options.sample_device_type_name}/{silabs_board}/chip-efr32-chef-example.flash.py") shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}") elif (options.build_target == "ameba"): diff --git a/examples/chef/efr32/BUILD.gn b/examples/chef/efr32/BUILD.gn index 82eec623267b03..0458f433b7ede4 100644 --- a/examples/chef/efr32/BUILD.gn +++ b/examples/chef/efr32/BUILD.gn @@ -92,9 +92,9 @@ chip_data_model("chef-common") { is_server = true } -# ThunderBoards and Explorer Kit (No LCD) -if (efr32_board == "BRD4166A" || efr32_board == "BRD2601B" || - efr32_board == "BRD2703A") { +# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) +if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || + silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { show_qr_code = false disable_lcd = true } @@ -135,7 +135,7 @@ efr32_sdk("sdk") { ] defines = [ - "BOARD_ID=${efr32_board}", + "BOARD_ID=${silabs_board}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", @@ -182,7 +182,6 @@ efr32_executable("chef_app") { sources = [ "${examples_plat_dir}/BaseApplication.cpp", - "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/efr32_utils.cpp", "${examples_plat_dir}/heap_4_silabs.c", "${examples_plat_dir}/init_efrPlatform.cpp", @@ -193,6 +192,10 @@ efr32_executable("chef_app") { "src/main.cpp", ] + if (use_wstk_leds) { + sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] + } + if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli || use_wf200 || use_rs911x) { sources += [ "${examples_plat_dir}/uart.cpp" ] @@ -312,7 +315,7 @@ efr32_executable("chef_app") { defines += [ "HEAP_MONITORING" ] } - ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld" + ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/chef/efr32/src/AppTask.cpp b/examples/chef/efr32/src/AppTask.cpp index 0ba9b8aa4e08e0..9b2593f4736ef8 100644 --- a/examples/chef/efr32/src/AppTask.cpp +++ b/examples/chef/efr32/src/AppTask.cpp @@ -20,8 +20,11 @@ #include "AppTask.h" #include "AppConfig.h" #include "AppEvent.h" + +#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" #include "sl_simple_led_instances.h" +#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -52,7 +55,10 @@ #include +#ifdef ENABLE_WSTK_LEDS #define SYSTEM_STATE_LED &sl_led_led0 +#endif // ENABLE_WSTK_LEDS + #define APP_FUNCTION_BUTTON &sl_button_btn0 using namespace chip; diff --git a/examples/light-switch-app/efr32/BUILD.gn b/examples/light-switch-app/efr32/BUILD.gn index 2833eefc47c8a6..f9a87873a5b36d 100644 --- a/examples/light-switch-app/efr32/BUILD.gn +++ b/examples/light-switch-app/efr32/BUILD.gn @@ -85,9 +85,9 @@ if (chip_enable_wifi) { enable_openthread_cli = false } -# ThunderBoards and Explorer Kit (No LCD) -if (efr32_board == "BRD4166A" || efr32_board == "BRD2601B" || - efr32_board == "BRD2703A") { +# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) +if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || + silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { show_qr_code = false disable_lcd = true } @@ -128,7 +128,7 @@ efr32_sdk("sdk") { ] defines = [ - "BOARD_ID=${efr32_board}", + "BOARD_ID=${silabs_board}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", @@ -175,7 +175,6 @@ efr32_executable("light_switch_app") { sources = [ "${examples_plat_dir}/BaseApplication.cpp", - "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/efr32_utils.cpp", "${examples_plat_dir}/heap_4_silabs.c", "${examples_plat_dir}/init_efrPlatform.cpp", @@ -186,6 +185,10 @@ efr32_executable("light_switch_app") { "src/main.cpp", ] + if (use_wstk_leds) { + sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] + } + if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli || use_wf200 || use_rs911x) { sources += [ "${examples_plat_dir}/uart.cpp" ] @@ -314,7 +317,7 @@ efr32_executable("light_switch_app") { defines += [ "HEAP_MONITORING" ] } - ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld" + ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/light-switch-app/efr32/src/AppTask.cpp b/examples/light-switch-app/efr32/src/AppTask.cpp index 83ac3ac8c94ec7..9fddca1d1aa98c 100644 --- a/examples/light-switch-app/efr32/src/AppTask.cpp +++ b/examples/light-switch-app/efr32/src/AppTask.cpp @@ -24,9 +24,12 @@ #include "AppTask.h" #include "AppConfig.h" #include "AppEvent.h" -#include "LEDWidget.h" #include "binding-handler.h" + +#ifdef ENABLE_WSTK_LEDS +#include "LEDWidget.h" #include "sl_simple_led_instances.h" +#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" diff --git a/examples/lighting-app/efr32/BUILD.gn b/examples/lighting-app/efr32/BUILD.gn index ad9c9f0feeaa0d..4a9ffa08a3a298 100644 --- a/examples/lighting-app/efr32/BUILD.gn +++ b/examples/lighting-app/efr32/BUILD.gn @@ -85,9 +85,9 @@ if (chip_enable_wifi) { enable_openthread_cli = false } -# ThunderBoards and Explorer Kit (No LCD) -if (efr32_board == "BRD4166A" || efr32_board == "BRD2601B" || - efr32_board == "BRD2703A") { +# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) +if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || + silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { show_qr_code = false disable_lcd = true } @@ -95,7 +95,7 @@ if (efr32_board == "BRD4166A" || efr32_board == "BRD2601B" || # WiFi settings if (chip_enable_wifi) { # disabling LCD for MG24 for wifi - if (efr32_board == "BRD4186A" || efr32_board == "BRD4187A") { + if (silabs_board == "BRD4186A" || silabs_board == "BRD4187A") { show_qr_code = false disable_lcd = true } @@ -133,7 +133,7 @@ efr32_sdk("sdk") { ] defines = [ - "BOARD_ID=${efr32_board}", + "BOARD_ID=${silabs_board}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", @@ -180,7 +180,6 @@ efr32_executable("lighting_app") { sources = [ "${examples_plat_dir}/BaseApplication.cpp", - "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/efr32_utils.cpp", "${examples_plat_dir}/heap_4_silabs.c", "${examples_plat_dir}/init_efrPlatform.cpp", @@ -191,6 +190,10 @@ efr32_executable("lighting_app") { "src/main.cpp", ] + if (use_wstk_leds) { + sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] + } + if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli || use_wf200 || use_rs911x) { sources += [ "${examples_plat_dir}/uart.cpp" ] @@ -324,7 +327,7 @@ efr32_executable("lighting_app") { defines += [ "HEAP_MONITORING" ] } - ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld" + ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/lighting-app/efr32/src/AppTask.cpp b/examples/lighting-app/efr32/src/AppTask.cpp index 89963785b8f02b..820cbe7049f44f 100644 --- a/examples/lighting-app/efr32/src/AppTask.cpp +++ b/examples/lighting-app/efr32/src/AppTask.cpp @@ -20,9 +20,12 @@ #include "AppTask.h" #include "AppConfig.h" #include "AppEvent.h" -#include "LEDWidget.h" +#ifdef ENABLE_WSTK_LEDS +#include "LEDWidget.h" #include "sl_simple_led_instances.h" +#endif // ENABLE_WSTK_LEDS + #include #include #include @@ -43,8 +46,11 @@ #include +#ifdef ENABLE_WSTK_LEDS #define SYSTEM_STATE_LED &sl_led_led0 #define LIGHT_LED &sl_led_led1 +#endif // ENABLE_WSTK_LEDS + #define APP_FUNCTION_BUTTON &sl_button_btn0 #define APP_LIGHT_SWITCH &sl_button_btn1 @@ -52,7 +58,10 @@ using namespace chip; using namespace ::chip::DeviceLayer; namespace { + +#ifdef ENABLE_WSTK_LEDS LEDWidget sLightLED; +#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; @@ -147,8 +156,10 @@ CHIP_ERROR AppTask::Init() LightMgr().SetCallbacks(ActionInitiated, ActionCompleted); +#ifdef ENABLE_WSTK_LEDS sLightLED.Init(LIGHT_LED); sLightLED.Set(LightMgr().IsLightOn()); +#endif // ENABLE_WSTK_LEDS return err; } @@ -266,7 +277,10 @@ void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor) // Action initiated, update the light led bool lightOn = aAction == LightingManager::ON_ACTION; EFR32_LOG("Turning light %s", (lightOn) ? "On" : "Off") + +#ifdef ENABLE_WSTK_LEDS sLightLED.Set(lightOn); +#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(lightOn); diff --git a/examples/lock-app/efr32/BUILD.gn b/examples/lock-app/efr32/BUILD.gn index d633e177a36b17..77df63b61c1868 100644 --- a/examples/lock-app/efr32/BUILD.gn +++ b/examples/lock-app/efr32/BUILD.gn @@ -85,9 +85,9 @@ if (chip_enable_wifi) { enable_openthread_cli = false } -# ThunderBoards and Explorer Kit (No LCD) -if (efr32_board == "BRD4166A" || efr32_board == "BRD2601B" || - efr32_board == "BRD2703A") { +# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) +if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || + silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { show_qr_code = false disable_lcd = true } @@ -128,7 +128,7 @@ efr32_sdk("sdk") { ] defines = [ - "BOARD_ID=${efr32_board}", + "BOARD_ID=${silabs_board}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", @@ -174,7 +174,6 @@ efr32_executable("lock_app") { sources = [ "${examples_plat_dir}/BaseApplication.cpp", - "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/efr32_utils.cpp", "${examples_plat_dir}/heap_4_silabs.c", "${examples_plat_dir}/init_efrPlatform.cpp", @@ -185,6 +184,10 @@ efr32_executable("lock_app") { "src/main.cpp", ] + if (use_wstk_leds) { + sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] + } + if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli || use_wf200 || use_rs911x) { sources += [ "${examples_plat_dir}/uart.cpp" ] @@ -315,7 +318,7 @@ efr32_executable("lock_app") { defines += [ "HEAP_MONITORING" ] } - ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld" + ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/lock-app/efr32/src/AppTask.cpp b/examples/lock-app/efr32/src/AppTask.cpp index 33a331c752920b..c39b109fb6a2af 100644 --- a/examples/lock-app/efr32/src/AppTask.cpp +++ b/examples/lock-app/efr32/src/AppTask.cpp @@ -20,14 +20,19 @@ #include "AppTask.h" #include "AppConfig.h" #include "AppEvent.h" + +#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" +#include "sl_simple_led_instances.h" +#endif // ENABLE_WSTK_LEDS + #ifdef DISPLAY_ENABLED #include "lcd.h" #ifdef QR_CODE_ENABLED #include "qrcodegen.h" #endif // QR_CODE_ENABLED #endif // DISPLAY_ENABLED -#include "sl_simple_led_instances.h" + #include #include #include @@ -52,8 +57,11 @@ #include +#ifdef ENABLE_WSTK_LEDS #define SYSTEM_STATE_LED &sl_led_led0 #define LOCK_STATE_LED &sl_led_led1 +#endif // ENABLE_WSTK_LEDS + #define APP_FUNCTION_BUTTON &sl_button_btn0 #define APP_LOCK_SWITCH &sl_button_btn1 @@ -67,7 +75,9 @@ using namespace ::chip::DeviceLayer::Internal; using namespace EFR32DoorLock::LockInitParams; namespace { +#ifdef ENABLE_WSTK_LEDS LEDWidget sLockLED; +#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; } // namespace @@ -227,9 +237,11 @@ CHIP_ERROR AppTask::Init() LockMgr().SetCallbacks(ActionInitiated, ActionCompleted); +#ifdef ENABLE_WSTK_LEDS // Initialize LEDs sLockLED.Init(LOCK_STATE_LED); sLockLED.Set(state.Value() == DlLockState::kUnlocked); +#endif // ENABLE_WSTK_LEDS chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast(nullptr)); @@ -362,10 +374,13 @@ void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor) { bool locked = (aAction == LockManager::LOCK_ACTION); EFR32_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock"); +#ifdef ENABLE_WSTK_LEDS sLockLED.Set(!locked); +#endif // ENABLE_WSTK_LEDS + #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(locked); -#endif +#endif // DISPLAY_ENABLED } if (aActor == AppEvent::kEventType_Button) diff --git a/examples/persistent-storage/efr32/BUILD.gn b/examples/persistent-storage/efr32/BUILD.gn index 5669830c3d11ec..f44fdb86872197 100644 --- a/examples/persistent-storage/efr32/BUILD.gn +++ b/examples/persistent-storage/efr32/BUILD.gn @@ -40,7 +40,7 @@ efr32_sdk("sdk") { "${chip_root}/src/lib", ] - defines = [ "BOARD_ID=${efr32_board}" ] + defines = [ "BOARD_ID=${silabs_board}" ] } efr32_executable("persistent_storage") { @@ -63,7 +63,7 @@ efr32_executable("persistent_storage") { "include", ] - ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld" + ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/pigweed-app/efr32/BUILD.gn b/examples/pigweed-app/efr32/BUILD.gn index 22ebc5d95bc042..cdc2bcacbc8fa8 100644 --- a/examples/pigweed-app/efr32/BUILD.gn +++ b/examples/pigweed-app/efr32/BUILD.gn @@ -40,7 +40,7 @@ efr32_sdk("sdk") { ] defines = [ - "BOARD_ID=${efr32_board}", + "BOARD_ID=${silabs_board}", "HAL_VCOM_ENABLE=1", "EFR32_LOG_ENABLED=1", "PW_RPC_ENABLED", @@ -53,7 +53,6 @@ efr32_executable("pigweed_app") { sources = [ "${chip_root}/examples/common/pigweed/RpcService.cpp", "${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", - "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/PigweedLogger.cpp", "${examples_plat_dir}/heap_4_silabs.c", "${examples_plat_dir}/init_efrPlatform.cpp", @@ -61,6 +60,10 @@ efr32_executable("pigweed_app") { "src/main.cpp", ] + if (use_wstk_leds) { + sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] + } + deps = [ ":sdk", "$dir_pw_assert", @@ -73,7 +76,7 @@ efr32_executable("pigweed_app") { include_dirs = [ "${chip_root}/examples/common/pigweed/efr32" ] - ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld" + ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/pigweed-app/efr32/src/main.cpp b/examples/pigweed-app/efr32/src/main.cpp index 4c6331450985ab..3ac349372f8856 100644 --- a/examples/pigweed-app/efr32/src/main.cpp +++ b/examples/pigweed-app/efr32/src/main.cpp @@ -16,10 +16,14 @@ */ #include "AppConfig.h" -#include "LEDWidget.h" #include "init_efrPlatform.h" #include "sl_system_kernel.h" +#ifdef ENABLE_WSTK_LEDS +#include "LEDWidget.h" +#include "sl_simple_led_instances.h" +#endif // ENABLE_WSTK_LEDS + #include "pw_rpc/echo_service_nanopb.h" #include "pw_sys_io/sys_io.h" #include "pw_sys_io_efr32/init.h" diff --git a/examples/platform/efr32/BaseApplication.cpp b/examples/platform/efr32/BaseApplication.cpp index 2970f3c1a29fd0..3f8f584d87fe77 100644 --- a/examples/platform/efr32/BaseApplication.cpp +++ b/examples/platform/efr32/BaseApplication.cpp @@ -24,8 +24,11 @@ #include "AppConfig.h" #include "AppEvent.h" #include "AppTask.h" + +#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" #include "sl_simple_led_instances.h" +#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -72,7 +75,9 @@ #define APP_EVENT_QUEUE_SIZE 10 #define EXAMPLE_VENDOR_ID 0xcafe +#ifdef ENABLE_WSTK_LEDS #define SYSTEM_STATE_LED &sl_led_led0 +#endif // ENABLE_WSTK_LEDS #define APP_FUNCTION_BUTTON &sl_button_btn0 @@ -91,7 +96,9 @@ TimerHandle_t sLightTimer; TaskHandle_t sAppTaskHandle; QueueHandle_t sAppEventQueue; +#ifdef ENABLE_WSTK_LEDS LEDWidget sStatusLED; +#endif // ENABLE_WSTK_LEDS #ifdef SL_WIFI app::Clusters::NetworkCommissioning::Instance @@ -205,8 +212,10 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj) EFR32_LOG("Current Software Version: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); +#ifdef ENABLE_WSTK_LEDS LEDWidget::InitGpio(); sStatusLED.Init(SYSTEM_STATE_LED); +#endif // ENABLE_WSTK_LEDS ConfigurationMgr().LogDeviceConfig(); @@ -264,10 +273,12 @@ void BaseApplication::FunctionEventHandler(AppEvent * aEvent) mFunction = kFunction_FactoryReset; +#ifdef ENABLE_WSTK_LEDS // Turn off all LEDs before starting blink to make sure blink is // co-ordinated. sStatusLED.Set(false); sStatusLED.Blink(500); +#endif // ENABLE_WSTK_LEDS } else if (mFunctionTimerActive && mFunction == kFunction_FactoryReset) { @@ -323,21 +334,29 @@ void BaseApplication::LightEventHandler() { if ((gIdentifyptr != nullptr) && (gIdentifyptr->mActive)) { +#ifdef ENABLE_WSTK_LEDS sStatusLED.Blink(250, 250); +#endif // ENABLE_WSTK_LEDS } else if (sIdentifyEffect != EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT) { if (sIdentifyEffect == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK) { +#ifdef ENABLE_WSTK_LEDS sStatusLED.Blink(50, 50); +#endif // ENABLE_WSTK_LEDS } if (sIdentifyEffect == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE) { +#ifdef ENABLE_WSTK_LEDS sStatusLED.Blink(1000, 1000); +#endif // ENABLE_WSTK_LEDS } if (sIdentifyEffect == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY) { +#ifdef ENABLE_WSTK_LEDS sStatusLED.Blink(300, 700); +#endif // ENABLE_WSTK_LEDS } } #if !(defined(CHIP_DEVICE_CONFIG_ENABLE_SED) && CHIP_DEVICE_CONFIG_ENABLE_SED) @@ -345,25 +364,35 @@ void BaseApplication::LightEventHandler() { if (sIsAttached) { +#ifdef ENABLE_WSTK_LEDS sStatusLED.Set(true); +#endif // ENABLE_WSTK_LEDS } else { +#ifdef ENABLE_WSTK_LEDS sStatusLED.Blink(950, 50); +#endif } } else if (sHaveBLEConnections) { +#ifdef ENABLE_WSTK_LEDS sStatusLED.Blink(100, 100); +#endif // ENABLE_WSTK_LEDS } else { +#ifdef ENABLE_WSTK_LEDS sStatusLED.Blink(50, 950); +#endif // ENABLE_WSTK_LEDS } #endif // CHIP_DEVICE_CONFIG_ENABLE_SED } +#ifdef ENABLE_WSTK_LEDS sStatusLED.Animate(); +#endif // ENABLE_WSTK_LEDS } void BaseApplication::ButtonHandler(AppEvent * aEvent) @@ -466,7 +495,10 @@ void BaseApplication::StartStatusLEDTimer() void BaseApplication::StopStatusLEDTimer() { +#ifdef ENABLE_WSTK_LEDS sStatusLED.Set(false); +#endif // ENABLE_WSTK_LEDS + if (xTimerStop(sLightTimer, 100) != pdPASS) { EFR32_LOG("Light Time start failed"); diff --git a/examples/platform/efr32/ldscripts/mgm24.ld b/examples/platform/efr32/ldscripts/mgm24.ld new file mode 100644 index 00000000000000..b057a9af720a7a --- /dev/null +++ b/examples/platform/efr32/ldscripts/mgm24.ld @@ -0,0 +1,243 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * 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 gcc_EFR32MG24.ld + * @brief GNU Linker Script for Cortex-M based device + * @version V2.2.0 + * @date 16. December 2020 + * Linker script for Silicon Labs EFR32MG24 devices + ******************************************************************************* + * # License + * Copyright 2022 Silicon Laboratories, Inc. www.silabs.com + ******************************************************************************* + * + * SPDX-License-Identifier: Zlib + * + * The licensor of this software is Silicon Laboratories Inc. + * + * This software is provided 'as-is', without any express or implied + * warranty. In no event will the authors be held liable for any damages + * arising from the use of this software. + * + * Permission is granted to anyone to use this software for any purpose, + * including commercial applications, and to alter it and redistribute it + * freely, subject to the following restrictions: + * + * 1. The origin of this software must not be misrepresented; you must not + * claim that you wrote the original software. If you use this software + * in a product, an acknowledgment in the product documentation would be + * appreciated but is not required. + * 2. Altered source versions must be plainly marked as such, and must not be + * misrepresented as being the original software. + * 3. This notice may not be removed or altered from any source distribution. + * + ******************************************************************************/ + +MEMORY +{ + FLASH (rx) : ORIGIN = 0x08006000, LENGTH = 0x17A000 + RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x40000 +} + +/* Linker script to place sections and symbol values. Should be used together + * with other linker script that defines memory regions FLASH and RAM. + * It references following symbols, which must be defined in code: + * Reset_Handler : Entry of reset handler + * + * It defines following symbols, which code can use without definition: + * __exidx_start + * __exidx_end + * __copy_table_start__ + * __copy_table_end__ + * __zero_table_start__ + * __zero_table_end__ + * __etext + * __data_start__ + * __preinit_array_start + * __preinit_array_end + * __init_array_start + * __init_array_end + * __fini_array_start + * __fini_array_end + * __data_end__ + * __bss_start__ + * __bss_end__ + * __end__ + * end + * __HeapLimit + * __StackLimit + * __StackTop + * __stack + * __StackSeal (only if ARMv8-M stack sealing is used) + */ + +ENTRY(Reset_Handler) + +SECTIONS +{ + .text : + { + KEEP(*(.vectors)) + *(.text*) + + KEEP(*(.init)) + KEEP(*(.fini)) + + /* .ctors */ + *crtbegin.o(.ctors) + *crtbegin?.o(.ctors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors) + *(SORT(.ctors.*)) + *(.ctors) + + /* .dtors */ + *crtbegin.o(.dtors) + *crtbegin?.o(.dtors) + *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors) + *(SORT(.dtors.*)) + *(.dtors) + + *(.rodata*) + + KEEP(*(.eh_frame*)) + } > FLASH + .ARM.extab : + { + *(.ARM.extab* .gnu.linkonce.armextab.*) + } > FLASH + + __exidx_start = .; + .ARM.exidx : + { + *(.ARM.exidx* .gnu.linkonce.armexidx.*) + } > FLASH + __exidx_end = .; + + .copy.table : + { + . = ALIGN(4); + __copy_table_start__ = .; + + LONG (__etext) + LONG (__data_start__) + LONG ((__data_end__ - __data_start__) / 4) + + __copy_table_end__ = .; + } > FLASH + + .zero.table : + { + . = ALIGN(4); + __zero_table_start__ = .; + __zero_table_end__ = .; + __etext = ALIGN(4); + } > FLASH + + .data : AT (__etext) + { + __data_start__ = .; + *(vtable) + *(.data*) + . = ALIGN (4); + PROVIDE (__ram_func_section_start = .); + *(.ram) + PROVIDE (__ram_func_section_end = .); + + . = ALIGN(4); + /* preinit data */ + PROVIDE_HIDDEN (__preinit_array_start = .); + KEEP(*(.preinit_array)) + PROVIDE_HIDDEN (__preinit_array_end = .); + + . = ALIGN(4); + /* init data */ + PROVIDE_HIDDEN (__init_array_start = .); + KEEP(*(SORT(.init_array.*))) + KEEP(*(.init_array)) + PROVIDE_HIDDEN (__init_array_end = .); + + . = ALIGN(4); + /* finit data */ + PROVIDE_HIDDEN (__fini_array_start = .); + KEEP(*(SORT(.fini_array.*))) + KEEP(*(.fini_array)) + PROVIDE_HIDDEN (__fini_array_end = .); + + KEEP(*(.jcr*)) + . = ALIGN(4); + /* All data end */ + __data_end__ = .; + + } > RAM + + .bss : + { + . = ALIGN(4); + __bss_start__ = .; + *(.bss) + *(.bss.*) + *(COMMON) + . = ALIGN(4); + __bss_end__ = .; + } > RAM AT > RAM + + .heap (COPY): + { + __HeapBase = .; + __end__ = .; + end = __end__; + _end = __end__; + KEEP(*(.heap*)) + __HeapLimit = .; + } > RAM + + __main_flash_end__ = ORIGIN(FLASH) + LENGTH(FLASH); + + /* .stack_dummy section doesn't contains any symbols. It is only + * used for linker to calculate size of stack sections, and assign + * values to stack symbols later */ + .stack_dummy (COPY): + { + KEEP(*(.stack*)) + /* KEEP(*(.stackseal*))*/ + } > RAM + + /* Set stack top to end of RAM, and stack limit move down by + * size of stack_dummy section */ + __StackTop = ORIGIN(RAM) + LENGTH(RAM); + __StackLimit = __StackTop - SIZEOF(.stack_dummy); + PROVIDE(__stack = __StackTop); + + .nvm (DSECT) : { + KEEP(*(.simee*)) + } > FLASH + + /* Last page of flash is reserved for the manufacturing token space */ + linker_nvm_end = __main_flash_end__ - 8192; + linker_nvm_begin = linker_nvm_end - SIZEOF(.nvm); + linker_nvm_size = SIZEOF(.nvm); + __nvm3Base = linker_nvm_begin; + __attestation_credentials_base = linker_nvm_end; + + /* Check if data + heap + stack exceeds RAM limit */ + /*ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")*/ + ASSERT( (linker_nvm_begin + SIZEOF(.nvm)) <= __main_flash_end__, "NVM3 is excessing the flash size !") + + /* Check if FLASH usage exceeds FLASH size */ + ASSERT( LENGTH(FLASH) >= (__etext + SIZEOF(.data)), "FLASH memory overflowed !") +} diff --git a/examples/platform/efr32/uart.cpp b/examples/platform/efr32/uart.cpp index 548416d177ce16..8a99a7a457ce31 100644 --- a/examples/platform/efr32/uart.cpp +++ b/examples/platform/efr32/uart.cpp @@ -26,7 +26,7 @@ extern "C" { #include "em_usart.h" #include "sl_board_control.h" #include "sl_uartdrv_instances.h" -#ifdef EFR32MG24 +#if (defined(EFR32MG24) || defined(MGM24)) #include "sl_uartdrv_eusart_vcom_config.h" #else #include "sl_uartdrv_usart_vcom_config.h" @@ -44,7 +44,7 @@ extern "C" { #define MIN(A, B) ((A) < (B) ? (A) : (B)) #endif -#ifdef EFR32MG24 +#if (defined(EFR32MG24) || defined(MGM24)) #define HELPER1(x) EUSART##x##_RX_IRQn #else #define HELPER1(x) USART##x##_RX_IRQn @@ -52,7 +52,7 @@ extern "C" { #define HELPER2(x) HELPER1(x) -#ifdef EFR32MG24 +#if (defined(EFR32MG24) || defined(MGM24)) #define HELPER3(x) EUSART##x##_RX_IRQHandler #else #define HELPER3(x) USART##x##_RX_IRQHandler @@ -61,7 +61,7 @@ extern "C" { #define HELPER4(x) HELPER3(x) // On MG24 boards VCOM runs on the EUSART device, MG12 uses the UART device -#ifdef EFR32MG24 +#if (defined(EFR32MG24) || defined(MGM24)) #define USART_IRQ HELPER2(SL_UARTDRV_EUSART_VCOM_PERIPHERAL_NO) #define USART_IRQHandler HELPER4(SL_UARTDRV_EUSART_VCOM_PERIPHERAL_NO) #define vcom_handle sl_uartdrv_eusart_vcom_handle @@ -221,7 +221,7 @@ void uartConsoleInit(void) NVIC_ClearPendingIRQ(USART_IRQ); NVIC_EnableIRQ(USART_IRQ); -#ifdef EFR32MG24 +#if (defined(EFR32MG24) || defined(MGM24)) // Clear previous RX interrupts EUSART_IntClear(SL_UARTDRV_EUSART_VCOM_PERIPHERAL, EUSART_IF_RXFL); @@ -246,7 +246,7 @@ void USART_IRQHandler(void) otSysEventSignalPending(); #endif -#ifdef EFR32MG24 +#if (defined(EFR32MG24) || defined(MGM24)) EUSART_IntClear(SL_UARTDRV_EUSART_VCOM_PERIPHERAL, EUSART_IF_RXFL); #endif } diff --git a/examples/shell/efr32/BUILD.gn b/examples/shell/efr32/BUILD.gn index 33bbfac5e4573d..78719ff5b492f5 100644 --- a/examples/shell/efr32/BUILD.gn +++ b/examples/shell/efr32/BUILD.gn @@ -47,7 +47,7 @@ efr32_sdk("sdk") { ] defines = [ - "BOARD_ID=${efr32_board}", + "BOARD_ID=${silabs_board}", "OPENTHREAD_CONFIG_CLI_TRANSPORT=OT_CLI_TRANSPORT_CONSOLE", ] } @@ -85,7 +85,7 @@ efr32_executable("shell_app") { defines += [ "HEAP_MONITORING" ] } - ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld" + ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/thermostat/efr32/BUILD.gn b/examples/thermostat/efr32/BUILD.gn index e787b107e26d3c..3c4190218c68c6 100644 --- a/examples/thermostat/efr32/BUILD.gn +++ b/examples/thermostat/efr32/BUILD.gn @@ -82,9 +82,9 @@ if (chip_enable_wifi) { enable_openthread_cli = false } -# ThunderBoards and Explorer Kit (No LCD) -if (efr32_board == "BRD4166A" || efr32_board == "BRD2601B" || - efr32_board == "BRD2703A") { +# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) +if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || + silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { show_qr_code = false disable_lcd = true } @@ -125,7 +125,7 @@ efr32_sdk("sdk") { ] defines = [ - "BOARD_ID=${efr32_board}", + "BOARD_ID=${silabs_board}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", @@ -172,7 +172,6 @@ efr32_executable("thermostat_app") { sources = [ "${examples_plat_dir}/BaseApplication.cpp", - "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/efr32_utils.cpp", "${examples_plat_dir}/heap_4_silabs.c", "${examples_plat_dir}/init_efrPlatform.cpp", @@ -182,6 +181,10 @@ efr32_executable("thermostat_app") { "src/main.cpp", ] + if (use_wstk_leds) { + sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] + } + if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli || use_wf200 || use_rs911x) { sources += [ "${examples_plat_dir}/uart.cpp" ] @@ -305,7 +308,7 @@ efr32_executable("thermostat_app") { defines += [ "HEAP_MONITORING" ] } - ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld" + ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/thermostat/efr32/src/AppTask.cpp b/examples/thermostat/efr32/src/AppTask.cpp index 793e79f3ab8145..2b518669162649 100644 --- a/examples/thermostat/efr32/src/AppTask.cpp +++ b/examples/thermostat/efr32/src/AppTask.cpp @@ -24,8 +24,11 @@ #include "AppTask.h" #include "AppConfig.h" #include "AppEvent.h" + +#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" #include "sl_simple_led_instances.h" +#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" diff --git a/examples/window-app/efr32/BUILD.gn b/examples/window-app/efr32/BUILD.gn index a993091d59da1b..5b781828462497 100644 --- a/examples/window-app/efr32/BUILD.gn +++ b/examples/window-app/efr32/BUILD.gn @@ -81,9 +81,9 @@ if (chip_enable_wifi) { enable_openthread_cli = false } -# ThunderBoards and Explorer Kit (No LCD) -if (efr32_board == "BRD4166A" || efr32_board == "BRD2601B" || - efr32_board == "BRD2703A") { +# ThunderBoards, Explorer Kit and MGM240L do not support LCD (No LCD) +if (silabs_board == "BRD4166A" || silabs_board == "BRD2601B" || + silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { show_qr_code = false disable_lcd = true } @@ -91,7 +91,7 @@ if (efr32_board == "BRD4166A" || efr32_board == "BRD2601B" || # WiFi settings if (chip_enable_wifi) { # disabling LCD for MG24 for wifi - if (efr32_board == "BRD4186C" || efr32_board == "BRD4187C") { + if (silabs_board == "BRD4186C" || silabs_board == "BRD4187C") { show_qr_code = false disable_lcd = true } @@ -129,7 +129,7 @@ efr32_sdk("sdk") { ] defines = [ - "BOARD_ID=${efr32_board}", + "BOARD_ID=${silabs_board}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE=${setupPinCode}", "CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR=${setupDiscriminator}", "OTA_PERIODIC_TIMEOUT=${OTA_periodic_query_timeout}", @@ -172,7 +172,6 @@ efr32_executable("window_app") { defines = [] sources = [ - "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/efr32_utils.cpp", "${examples_plat_dir}/heap_4_silabs.c", "${examples_plat_dir}/init_efrPlatform.cpp", @@ -183,6 +182,10 @@ efr32_executable("window_app") { "src/main.cpp", ] + if (use_wstk_leds) { + sources += [ "${examples_plat_dir}/LEDWidget.cpp" ] + } + if (chip_build_libshell || enable_openthread_cli || use_wf200 || use_rs911x) { sources += [ "${examples_plat_dir}/uart.cpp" ] } @@ -268,7 +271,7 @@ efr32_executable("window_app") { sources += [ "${examples_plat_dir}/MemMonitoring.cpp" ] } - ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld" + ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/examples/window-app/efr32/include/WindowAppImpl.h b/examples/window-app/efr32/include/WindowAppImpl.h index 8bfbe8ead0b7be..a43f68ed85f6ef 100644 --- a/examples/window-app/efr32/include/WindowAppImpl.h +++ b/examples/window-app/efr32/include/WindowAppImpl.h @@ -18,7 +18,12 @@ #pragma once #include -#include + +#ifdef ENABLE_WSTK_LEDS +#include "LEDWidget.h" +#include "sl_simple_led_instances.h" +#endif // ENABLE_WSTK_LEDS + #include #include #include @@ -79,8 +84,11 @@ class WindowAppImpl : public WindowApp void DispatchEventAttributeChange(chip::EndpointId endpoint, chip::AttributeId attribute); TaskHandle_t mHandle = nullptr; QueueHandle_t mQueue = nullptr; + +#ifdef ENABLE_WSTK_LEDS LEDWidget mStatusLED; LEDWidget mActionLED; +#endif // ENABLE_WSTK_LEDS // Get QR Code and emulate its content using NFC tag char mQRCodeBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1]; diff --git a/examples/window-app/efr32/src/WindowAppImpl.cpp b/examples/window-app/efr32/src/WindowAppImpl.cpp index c4a1d3fd6762b8..7f9eeaca724f0d 100644 --- a/examples/window-app/efr32/src/WindowAppImpl.cpp +++ b/examples/window-app/efr32/src/WindowAppImpl.cpp @@ -28,7 +28,11 @@ #include #endif // QR_CODE_ENABLED #include + +#ifdef ENABLE_WSTK_LEDS #include +#endif // ENABLE_WSTK_LEDS + #include #ifdef SL_WIFI @@ -198,9 +202,11 @@ CHIP_ERROR WindowAppImpl::Init() } // Initialize LEDs +#ifdef ENABLE_WSTK_LEDS LEDWidget::InitGpio(); mStatusLED.Init(APP_STATE_LED); mActionLED.Init(APP_ACTION_LED); +#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED slLCD.Init(); @@ -370,17 +376,21 @@ void WindowAppImpl::UpdateLEDs() Cover & cover = GetCover(); if (mResetWarning) { +#ifdef ENABLE_WSTK_LEDS mStatusLED.Set(false); mStatusLED.Blink(500); mActionLED.Set(false); mActionLED.Blink(500); +#endif // ENABLE_WSTK_LEDS } else { if (mState.isWinking) { +#ifdef ENABLE_WSTK_LEDS mStatusLED.Blink(200, 200); +#endif // ENABLE_WSTK_LEDS } else #if CHIP_ENABLE_OPENTHREAD @@ -390,10 +400,22 @@ void WindowAppImpl::UpdateLEDs() #endif { +#ifdef ENABLE_WSTK_LEDS mStatusLED.Blink(950, 50); +#endif // ENABLE_WSTK_LEDS + } + else if (mState.haveBLEConnections) + { +#ifdef ENABLE_WSTK_LEDS + mStatusLED.Blink(100, 100); +#endif // ENABLE_WSTK_LEDS + } + else + { +#ifdef ENABLE_WSTK_LEDS + mStatusLED.Blink(50, 950); +#endif // ENABLE_WSTK_LEDS } - else if (mState.haveBLEConnections) { mStatusLED.Blink(100, 100); } - else { mStatusLED.Blink(50, 950); } // Action LED NPercent100ths current; @@ -411,19 +433,27 @@ void WindowAppImpl::UpdateLEDs() if (OperationalState::Stall != cover.mLiftOpState) { +#ifdef ENABLE_WSTK_LEDS mActionLED.Blink(100); +#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsUpOrOpen == liftLimit) { +#ifdef ENABLE_WSTK_LEDS mActionLED.Set(true); +#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsDownOrClose == liftLimit) { +#ifdef ENABLE_WSTK_LEDS mActionLED.Set(false); +#endif // ENABLE_WSTK_LEDS } else { +#ifdef ENABLE_WSTK_LEDS mActionLED.Blink(1000); +#endif // ENABLE_WSTK_LEDS } } } @@ -472,8 +502,10 @@ void WindowAppImpl::UpdateLCD() void WindowAppImpl::OnMainLoop() { +#ifdef ENABLE_WSTK_LEDS mStatusLED.Animate(); mActionLED.Animate(); +#endif // ENABLE_WSTK_LEDS } //------------------------------------------------------------------------------ diff --git a/integrations/docker/images/chip-build-vscode/Dockerfile b/integrations/docker/images/chip-build-vscode/Dockerfile index 45d4c834df00e8..bbb1521693903e 100644 --- a/integrations/docker/images/chip-build-vscode/Dockerfile +++ b/integrations/docker/images/chip-build-vscode/Dockerfile @@ -75,7 +75,7 @@ ENV AMEBA_PATH=/opt/ameba/ambd_sdk_with_chip_non_NDA ENV ANDROID_HOME=/opt/android/sdk ENV ANDROID_NDK_HOME=/opt/android/android-ndk-r21b ENV CY_TOOLS_PATHS="/opt/ModusToolbox/tools_2.4" -ENV EFR32_BOARD=BRD4161A +ENV SILABS_BOARD=BRD4161A ENV IDF_PATH=/opt/espressif/esp-idf/ ENV IDF_TOOLS_PATH=/opt/espressif/tools ENV IMX_SDK_ROOT=/opt/fsl-imx-xwayland/5.15-kirkstone/ diff --git a/scripts/build/builders/efr32.py b/scripts/build/builders/efr32.py index d4a536a1e80ca2..34979314923751 100644 --- a/scripts/build/builders/efr32.py +++ b/scripts/build/builders/efr32.py @@ -117,7 +117,7 @@ def __init__(self, root=app.BuildRoot(root), runner=runner) self.app = app - self.extra_gn_options = ['efr32_board="%s"' % board.GnArgName()] + self.extra_gn_options = ['silabs_board="%s"' % board.GnArgName()] if enable_rpcs: self.extra_gn_options.append('is_debug=false import("//with_pw_rpc.gni")') diff --git a/scripts/build/testdata/build_all_except_host.txt b/scripts/build/testdata/build_all_except_host.txt index efacf03b4af51c..ebfb4ad3070bae 100644 --- a/scripts/build/testdata/build_all_except_host.txt +++ b/scripts/build/testdata/build_all_except_host.txt @@ -200,340 +200,340 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/ota-requestor-app/infineon/cyw30739 --args=chip_progress_logging=false {out}/cyw30739-cyw930739m2evb_01-ota-requestor-no-progress-logging # Generating efr32-brd4161a-light -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-light +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4161A"' {out}/efr32-brd4161a-light # Generating efr32-brd4161a-light-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4161A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4161a-light-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4161A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4161a-light-rpc # Generating efr32-brd4161a-light-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4161A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4161a-light-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4161A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4161a-light-rpc-with-ota-requestor # Generating efr32-brd4161a-light-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4161A" chip_enable_ota_requestor=true' {out}/efr32-brd4161a-light-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4161A" chip_enable_ota_requestor=true' {out}/efr32-brd4161a-light-with-ota-requestor # Generating efr32-brd4161a-lock -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-lock +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4161A"' {out}/efr32-brd4161a-lock # Generating efr32-brd4161a-lock-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4161A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4161a-lock-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4161A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4161a-lock-rpc # Generating efr32-brd4161a-lock-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4161A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4161a-lock-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4161A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4161a-lock-rpc-with-ota-requestor # Generating efr32-brd4161a-lock-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4161A" chip_enable_ota_requestor=true' {out}/efr32-brd4161a-lock-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4161A" chip_enable_ota_requestor=true' {out}/efr32-brd4161a-lock-with-ota-requestor # Generating efr32-brd4161a-switch -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-switch +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4161A"' {out}/efr32-brd4161a-switch # Generating efr32-brd4161a-switch-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4161A" chip_enable_ota_requestor=true' {out}/efr32-brd4161a-switch-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4161A" chip_enable_ota_requestor=true' {out}/efr32-brd4161a-switch-with-ota-requestor # Generating efr32-brd4161a-unit-test -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-unit-test +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4161A"' {out}/efr32-brd4161a-unit-test # Generating efr32-brd4161a-unit-test-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4161A" chip_enable_ota_requestor=true' {out}/efr32-brd4161a-unit-test-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4161A" chip_enable_ota_requestor=true' {out}/efr32-brd4161a-unit-test-with-ota-requestor # Generating efr32-brd4161a-window-covering -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4161A"' {out}/efr32-brd4161a-window-covering +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4161A"' {out}/efr32-brd4161a-window-covering # Generating efr32-brd4161a-window-covering-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4161A" chip_enable_ota_requestor=true' {out}/efr32-brd4161a-window-covering-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4161A" chip_enable_ota_requestor=true' {out}/efr32-brd4161a-window-covering-with-ota-requestor # Generating efr32-brd4163a-light -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4163A"' {out}/efr32-brd4163a-light +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4163A"' {out}/efr32-brd4163a-light # Generating efr32-brd4163a-light-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4163A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4163a-light-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4163A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4163a-light-rpc # Generating efr32-brd4163a-light-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4163A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4163a-light-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4163A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4163a-light-rpc-with-ota-requestor # Generating efr32-brd4163a-light-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4163A" chip_enable_ota_requestor=true' {out}/efr32-brd4163a-light-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4163A" chip_enable_ota_requestor=true' {out}/efr32-brd4163a-light-with-ota-requestor # Generating efr32-brd4163a-lock -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4163A"' {out}/efr32-brd4163a-lock +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4163A"' {out}/efr32-brd4163a-lock # Generating efr32-brd4163a-lock-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4163A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4163a-lock-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4163A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4163a-lock-rpc # Generating efr32-brd4163a-lock-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4163A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4163a-lock-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4163A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4163a-lock-rpc-with-ota-requestor # Generating efr32-brd4163a-lock-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4163A" chip_enable_ota_requestor=true' {out}/efr32-brd4163a-lock-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4163A" chip_enable_ota_requestor=true' {out}/efr32-brd4163a-lock-with-ota-requestor # Generating efr32-brd4163a-switch -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4163A"' {out}/efr32-brd4163a-switch +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4163A"' {out}/efr32-brd4163a-switch # Generating efr32-brd4163a-switch-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4163A" chip_enable_ota_requestor=true' {out}/efr32-brd4163a-switch-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4163A" chip_enable_ota_requestor=true' {out}/efr32-brd4163a-switch-with-ota-requestor # Generating efr32-brd4163a-unit-test -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4163A"' {out}/efr32-brd4163a-unit-test +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4163A"' {out}/efr32-brd4163a-unit-test # Generating efr32-brd4163a-unit-test-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4163A" chip_enable_ota_requestor=true' {out}/efr32-brd4163a-unit-test-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4163A" chip_enable_ota_requestor=true' {out}/efr32-brd4163a-unit-test-with-ota-requestor # Generating efr32-brd4163a-window-covering -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4163A"' {out}/efr32-brd4163a-window-covering +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4163A"' {out}/efr32-brd4163a-window-covering # Generating efr32-brd4163a-window-covering-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4163A" chip_enable_ota_requestor=true' {out}/efr32-brd4163a-window-covering-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4163A" chip_enable_ota_requestor=true' {out}/efr32-brd4163a-window-covering-with-ota-requestor # Generating efr32-brd4164a-light -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4164A"' {out}/efr32-brd4164a-light +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4164A"' {out}/efr32-brd4164a-light # Generating efr32-brd4164a-light-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4164A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4164a-light-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4164A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4164a-light-rpc # Generating efr32-brd4164a-light-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4164A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4164a-light-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4164A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4164a-light-rpc-with-ota-requestor # Generating efr32-brd4164a-light-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4164A" chip_enable_ota_requestor=true' {out}/efr32-brd4164a-light-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4164A" chip_enable_ota_requestor=true' {out}/efr32-brd4164a-light-with-ota-requestor # Generating efr32-brd4164a-lock -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4164A"' {out}/efr32-brd4164a-lock +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4164A"' {out}/efr32-brd4164a-lock # Generating efr32-brd4164a-lock-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4164A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4164a-lock-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4164A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4164a-lock-rpc # Generating efr32-brd4164a-lock-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4164A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4164a-lock-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4164A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4164a-lock-rpc-with-ota-requestor # Generating efr32-brd4164a-lock-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4164A" chip_enable_ota_requestor=true' {out}/efr32-brd4164a-lock-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4164A" chip_enable_ota_requestor=true' {out}/efr32-brd4164a-lock-with-ota-requestor # Generating efr32-brd4164a-switch -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4164A"' {out}/efr32-brd4164a-switch +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4164A"' {out}/efr32-brd4164a-switch # Generating efr32-brd4164a-switch-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4164A" chip_enable_ota_requestor=true' {out}/efr32-brd4164a-switch-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4164A" chip_enable_ota_requestor=true' {out}/efr32-brd4164a-switch-with-ota-requestor # Generating efr32-brd4164a-unit-test -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4164A"' {out}/efr32-brd4164a-unit-test +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4164A"' {out}/efr32-brd4164a-unit-test # Generating efr32-brd4164a-unit-test-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4164A" chip_enable_ota_requestor=true' {out}/efr32-brd4164a-unit-test-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4164A" chip_enable_ota_requestor=true' {out}/efr32-brd4164a-unit-test-with-ota-requestor # Generating efr32-brd4164a-window-covering -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4164A"' {out}/efr32-brd4164a-window-covering +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4164A"' {out}/efr32-brd4164a-window-covering # Generating efr32-brd4164a-window-covering-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4164A" chip_enable_ota_requestor=true' {out}/efr32-brd4164a-window-covering-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4164A" chip_enable_ota_requestor=true' {out}/efr32-brd4164a-window-covering-with-ota-requestor # Generating efr32-brd4166a-light -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4166A"' {out}/efr32-brd4166a-light +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4166A"' {out}/efr32-brd4166a-light # Generating efr32-brd4166a-light-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4166A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4166a-light-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4166A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4166a-light-rpc # Generating efr32-brd4166a-light-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4166A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4166a-light-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4166A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4166a-light-rpc-with-ota-requestor # Generating efr32-brd4166a-light-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4166A" chip_enable_ota_requestor=true' {out}/efr32-brd4166a-light-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4166A" chip_enable_ota_requestor=true' {out}/efr32-brd4166a-light-with-ota-requestor # Generating efr32-brd4166a-lock -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4166A"' {out}/efr32-brd4166a-lock +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4166A"' {out}/efr32-brd4166a-lock # Generating efr32-brd4166a-lock-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4166A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4166a-lock-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4166A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4166a-lock-rpc # Generating efr32-brd4166a-lock-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4166A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4166a-lock-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4166A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4166a-lock-rpc-with-ota-requestor # Generating efr32-brd4166a-lock-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4166A" chip_enable_ota_requestor=true' {out}/efr32-brd4166a-lock-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4166A" chip_enable_ota_requestor=true' {out}/efr32-brd4166a-lock-with-ota-requestor # Generating efr32-brd4166a-switch -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4166A"' {out}/efr32-brd4166a-switch +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4166A"' {out}/efr32-brd4166a-switch # Generating efr32-brd4166a-switch-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4166A" chip_enable_ota_requestor=true' {out}/efr32-brd4166a-switch-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4166A" chip_enable_ota_requestor=true' {out}/efr32-brd4166a-switch-with-ota-requestor # Generating efr32-brd4166a-unit-test -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4166A"' {out}/efr32-brd4166a-unit-test +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4166A"' {out}/efr32-brd4166a-unit-test # Generating efr32-brd4166a-unit-test-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4166A" chip_enable_ota_requestor=true' {out}/efr32-brd4166a-unit-test-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4166A" chip_enable_ota_requestor=true' {out}/efr32-brd4166a-unit-test-with-ota-requestor # Generating efr32-brd4166a-window-covering -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4166A"' {out}/efr32-brd4166a-window-covering +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4166A"' {out}/efr32-brd4166a-window-covering # Generating efr32-brd4166a-window-covering-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4166A" chip_enable_ota_requestor=true' {out}/efr32-brd4166a-window-covering-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4166A" chip_enable_ota_requestor=true' {out}/efr32-brd4166a-window-covering-with-ota-requestor # Generating efr32-brd4170a-light -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4170A"' {out}/efr32-brd4170a-light +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4170A"' {out}/efr32-brd4170a-light # Generating efr32-brd4170a-light-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4170A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4170a-light-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4170A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4170a-light-rpc # Generating efr32-brd4170a-light-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4170A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4170a-light-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4170A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4170a-light-rpc-with-ota-requestor # Generating efr32-brd4170a-light-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4170A" chip_enable_ota_requestor=true' {out}/efr32-brd4170a-light-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4170A" chip_enable_ota_requestor=true' {out}/efr32-brd4170a-light-with-ota-requestor # Generating efr32-brd4170a-lock -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4170A"' {out}/efr32-brd4170a-lock +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4170A"' {out}/efr32-brd4170a-lock # Generating efr32-brd4170a-lock-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4170A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4170a-lock-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4170A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4170a-lock-rpc # Generating efr32-brd4170a-lock-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4170A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4170a-lock-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4170A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4170a-lock-rpc-with-ota-requestor # Generating efr32-brd4170a-lock-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4170A" chip_enable_ota_requestor=true' {out}/efr32-brd4170a-lock-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4170A" chip_enable_ota_requestor=true' {out}/efr32-brd4170a-lock-with-ota-requestor # Generating efr32-brd4170a-switch -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4170A"' {out}/efr32-brd4170a-switch +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4170A"' {out}/efr32-brd4170a-switch # Generating efr32-brd4170a-switch-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4170A" chip_enable_ota_requestor=true' {out}/efr32-brd4170a-switch-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4170A" chip_enable_ota_requestor=true' {out}/efr32-brd4170a-switch-with-ota-requestor # Generating efr32-brd4170a-unit-test -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4170A"' {out}/efr32-brd4170a-unit-test +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4170A"' {out}/efr32-brd4170a-unit-test # Generating efr32-brd4170a-unit-test-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4170A" chip_enable_ota_requestor=true' {out}/efr32-brd4170a-unit-test-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4170A" chip_enable_ota_requestor=true' {out}/efr32-brd4170a-unit-test-with-ota-requestor # Generating efr32-brd4170a-window-covering -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4170A"' {out}/efr32-brd4170a-window-covering +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4170A"' {out}/efr32-brd4170a-window-covering # Generating efr32-brd4170a-window-covering-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4170A" chip_enable_ota_requestor=true' {out}/efr32-brd4170a-window-covering-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4170A" chip_enable_ota_requestor=true' {out}/efr32-brd4170a-window-covering-with-ota-requestor # Generating efr32-brd4186a-light -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4186A"' {out}/efr32-brd4186a-light +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4186A"' {out}/efr32-brd4186a-light # Generating efr32-brd4186a-light-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4186A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4186a-light-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4186A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4186a-light-rpc # Generating efr32-brd4186a-light-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4186A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4186a-light-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4186A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4186a-light-rpc-with-ota-requestor # Generating efr32-brd4186a-light-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4186A" chip_enable_ota_requestor=true' {out}/efr32-brd4186a-light-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4186A" chip_enable_ota_requestor=true' {out}/efr32-brd4186a-light-with-ota-requestor # Generating efr32-brd4186a-lock -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4186A"' {out}/efr32-brd4186a-lock +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4186A"' {out}/efr32-brd4186a-lock # Generating efr32-brd4186a-lock-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4186A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4186a-lock-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4186A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4186a-lock-rpc # Generating efr32-brd4186a-lock-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4186A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4186a-lock-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4186A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4186a-lock-rpc-with-ota-requestor # Generating efr32-brd4186a-lock-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4186A" chip_enable_ota_requestor=true' {out}/efr32-brd4186a-lock-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4186A" chip_enable_ota_requestor=true' {out}/efr32-brd4186a-lock-with-ota-requestor # Generating efr32-brd4186a-switch -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4186A"' {out}/efr32-brd4186a-switch +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4186A"' {out}/efr32-brd4186a-switch # Generating efr32-brd4186a-switch-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4186A" chip_enable_ota_requestor=true' {out}/efr32-brd4186a-switch-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4186A" chip_enable_ota_requestor=true' {out}/efr32-brd4186a-switch-with-ota-requestor # Generating efr32-brd4186a-unit-test -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4186A"' {out}/efr32-brd4186a-unit-test +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4186A"' {out}/efr32-brd4186a-unit-test # Generating efr32-brd4186a-unit-test-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4186A" chip_enable_ota_requestor=true' {out}/efr32-brd4186a-unit-test-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4186A" chip_enable_ota_requestor=true' {out}/efr32-brd4186a-unit-test-with-ota-requestor # Generating efr32-brd4186a-window-covering -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4186A"' {out}/efr32-brd4186a-window-covering +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4186A"' {out}/efr32-brd4186a-window-covering # Generating efr32-brd4186a-window-covering-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4186A" chip_enable_ota_requestor=true' {out}/efr32-brd4186a-window-covering-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4186A" chip_enable_ota_requestor=true' {out}/efr32-brd4186a-window-covering-with-ota-requestor # Generating efr32-brd4187a-light -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4187A"' {out}/efr32-brd4187a-light +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4187A"' {out}/efr32-brd4187a-light # Generating efr32-brd4187a-light-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4187A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4187a-light-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4187A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4187a-light-rpc # Generating efr32-brd4187a-light-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4187A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4187a-light-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4187A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4187a-light-rpc-with-ota-requestor # Generating efr32-brd4187a-light-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4187A" chip_enable_ota_requestor=true' {out}/efr32-brd4187a-light-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4187A" chip_enable_ota_requestor=true' {out}/efr32-brd4187a-light-with-ota-requestor # Generating efr32-brd4187a-lock -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4187A"' {out}/efr32-brd4187a-lock +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4187A"' {out}/efr32-brd4187a-lock # Generating efr32-brd4187a-lock-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4187A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4187a-lock-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4187A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4187a-lock-rpc # Generating efr32-brd4187a-lock-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4187A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4187a-lock-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4187A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4187a-lock-rpc-with-ota-requestor # Generating efr32-brd4187a-lock-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4187A" chip_enable_ota_requestor=true' {out}/efr32-brd4187a-lock-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4187A" chip_enable_ota_requestor=true' {out}/efr32-brd4187a-lock-with-ota-requestor # Generating efr32-brd4187a-switch -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4187A"' {out}/efr32-brd4187a-switch +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4187A"' {out}/efr32-brd4187a-switch # Generating efr32-brd4187a-switch-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4187A" chip_enable_ota_requestor=true' {out}/efr32-brd4187a-switch-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4187A" chip_enable_ota_requestor=true' {out}/efr32-brd4187a-switch-with-ota-requestor # Generating efr32-brd4187a-unit-test -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4187A"' {out}/efr32-brd4187a-unit-test +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4187A"' {out}/efr32-brd4187a-unit-test # Generating efr32-brd4187a-unit-test-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4187A" chip_enable_ota_requestor=true' {out}/efr32-brd4187a-unit-test-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4187A" chip_enable_ota_requestor=true' {out}/efr32-brd4187a-unit-test-with-ota-requestor # Generating efr32-brd4187a-window-covering -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4187A"' {out}/efr32-brd4187a-window-covering +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4187A"' {out}/efr32-brd4187a-window-covering # Generating efr32-brd4187a-window-covering-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4187A" chip_enable_ota_requestor=true' {out}/efr32-brd4187a-window-covering-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4187A" chip_enable_ota_requestor=true' {out}/efr32-brd4187a-window-covering-with-ota-requestor # Generating efr32-brd4304a-light -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4304A"' {out}/efr32-brd4304a-light +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4304A"' {out}/efr32-brd4304a-light # Generating efr32-brd4304a-light-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4304A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4304a-light-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4304A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4304a-light-rpc # Generating efr32-brd4304a-light-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4304A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4304a-light-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4304A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4304a-light-rpc-with-ota-requestor # Generating efr32-brd4304a-light-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=efr32_board="BRD4304A" chip_enable_ota_requestor=true' {out}/efr32-brd4304a-light-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/efr32 '--args=silabs_board="BRD4304A" chip_enable_ota_requestor=true' {out}/efr32-brd4304a-light-with-ota-requestor # Generating efr32-brd4304a-lock -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4304A"' {out}/efr32-brd4304a-lock +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4304A"' {out}/efr32-brd4304a-lock # Generating efr32-brd4304a-lock-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4304A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4304a-lock-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4304A" is_debug=false import("//with_pw_rpc.gni")' {out}/efr32-brd4304a-lock-rpc # Generating efr32-brd4304a-lock-rpc-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4304A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4304a-lock-rpc-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4304A" is_debug=false import("//with_pw_rpc.gni") chip_enable_ota_requestor=true' {out}/efr32-brd4304a-lock-rpc-with-ota-requestor # Generating efr32-brd4304a-lock-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=efr32_board="BRD4304A" chip_enable_ota_requestor=true' {out}/efr32-brd4304a-lock-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/efr32 '--args=silabs_board="BRD4304A" chip_enable_ota_requestor=true' {out}/efr32-brd4304a-lock-with-ota-requestor # Generating efr32-brd4304a-switch -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4304A"' {out}/efr32-brd4304a-switch +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4304A"' {out}/efr32-brd4304a-switch # Generating efr32-brd4304a-switch-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=efr32_board="BRD4304A" chip_enable_ota_requestor=true' {out}/efr32-brd4304a-switch-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/light-switch-app/efr32 '--args=silabs_board="BRD4304A" chip_enable_ota_requestor=true' {out}/efr32-brd4304a-switch-with-ota-requestor # Generating efr32-brd4304a-unit-test -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4304A"' {out}/efr32-brd4304a-unit-test +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4304A"' {out}/efr32-brd4304a-unit-test # Generating efr32-brd4304a-unit-test-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=efr32_board="BRD4304A" chip_enable_ota_requestor=true' {out}/efr32-brd4304a-unit-test-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4304A" chip_enable_ota_requestor=true' {out}/efr32-brd4304a-unit-test-with-ota-requestor # Generating efr32-brd4304a-window-covering -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4304A"' {out}/efr32-brd4304a-window-covering +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4304A"' {out}/efr32-brd4304a-window-covering # Generating efr32-brd4304a-window-covering-with-ota-requestor -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=efr32_board="BRD4304A" chip_enable_ota_requestor=true' {out}/efr32-brd4304a-window-covering-with-ota-requestor +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/window-app/efr32 '--args=silabs_board="BRD4304A" chip_enable_ota_requestor=true' {out}/efr32-brd4304a-window-covering-with-ota-requestor # Generating esp32-c3devkit-all-clusters mkdir -p {out}/esp32-c3devkit-all-clusters diff --git a/scripts/examples/gn_efr32_example.sh b/scripts/examples/gn_efr32_example.sh index 2169332984236d..4bebc12c8de996 100755 --- a/scripts/examples/gn_efr32_example.sh +++ b/scripts/examples/gn_efr32_example.sh @@ -35,7 +35,7 @@ env USE_WIFI=false SILABS_THREAD_TARGET=\""../silabs:ot-efr32-cert"\" -USAGE="./scripts/examples/gn_efr32_example.sh []" +USAGE="./scripts/examples/gn_efr32_example.sh []" if [ "$#" == "0" ]; then echo "Build script for EFR32 Matter apps @@ -48,7 +48,7 @@ if [ "$#" == "0" ]; then Desired location for the output files - + Identifier of the board for which this app is built Currently Supported : BRD4161A @@ -115,7 +115,7 @@ else OUTDIR=$2 if [ "$#" -gt "2" ]; then - EFR32_BOARD=$3 + SILABS_BOARD=$3 shift fi @@ -171,22 +171,22 @@ else esac done - if [ -z "$EFR32_BOARD" ]; then - echo "EFR32_BOARD not defined" + if [ -z "$SILABS_BOARD" ]; then + echo "SILABS_BOARD not defined" exit 1 fi - BUILD_DIR=$OUTDIR/$EFR32_BOARD + BUILD_DIR=$OUTDIR/$SILABS_BOARD echo BUILD_DIR="$BUILD_DIR" if [ "$USE_WIFI" == true ]; then - gn gen --check --fail-on-unused-args --export-compile-commands --root="$ROOT" --dotfile="$ROOT"/build_for_wifi_gnfile.gn --args="efr32_board=\"$EFR32_BOARD\" $optArgs" "$BUILD_DIR" + gn gen --check --fail-on-unused-args --export-compile-commands --root="$ROOT" --dotfile="$ROOT"/build_for_wifi_gnfile.gn --args="silabs_board=\"$SILABS_BOARD\" $optArgs" "$BUILD_DIR" else # thread build # if [ -z "$optArgs" ]; then - gn gen --check --fail-on-unused-args --export-compile-commands --root="$ROOT" --args="efr32_board=\"$EFR32_BOARD\"" "$BUILD_DIR" + gn gen --check --fail-on-unused-args --export-compile-commands --root="$ROOT" --args="silabs_board=\"$SILABS_BOARD\"" "$BUILD_DIR" else - gn gen --check --fail-on-unused-args --export-compile-commands --root="$ROOT" --args="efr32_board=\"$EFR32_BOARD\" $optArgs" "$BUILD_DIR" + gn gen --check --fail-on-unused-args --export-compile-commands --root="$ROOT" --args="silabs_board=\"$SILABS_BOARD\" $optArgs" "$BUILD_DIR" fi fi ninja -v -C "$BUILD_DIR"/ diff --git a/scripts/flashing/efr32_firmware_utils.py b/scripts/flashing/efr32_firmware_utils.py index d04e106f894c6d..989cc97f19ca32 100755 --- a/scripts/flashing/efr32_firmware_utils.py +++ b/scripts/flashing/efr32_firmware_utils.py @@ -77,8 +77,8 @@ """, }, 'device': { - 'help': 'Device family or platform to target', - 'default': 'EFR32', + 'help': 'Device family or platform to target (EFR32 or MGM240)', + 'default': None, 'alias': ['-d'], 'argparse': { 'metavar': 'DEVICE' diff --git a/src/platform/EFR32/args.gni b/src/platform/EFR32/args.gni index 7b80e77e100190..4d61e8341d8ce0 100644 --- a/src/platform/EFR32/args.gni +++ b/src/platform/EFR32/args.gni @@ -19,7 +19,7 @@ import("//build_overrides/pigweed.gni") import("${chip_root}/examples/platform/efr32/args.gni") import("${chip_root}/src/crypto/crypto.gni") -# ARM architecture flags will be set based on efr32_family. +# ARM architecture flags will be set based on silabs_family. arm_platform_config = "${efr32_sdk_build_root}/efr32_arm.gni" mbedtls_target = "${efr32_sdk_build_root}:efr32_sdk" diff --git a/src/platform/EFR32/wifi_args.gni b/src/platform/EFR32/wifi_args.gni index 328b0c06f85f46..46a00ac6964b04 100644 --- a/src/platform/EFR32/wifi_args.gni +++ b/src/platform/EFR32/wifi_args.gni @@ -20,7 +20,7 @@ import("//build_overrides/pigweed.gni") import("${chip_root}/examples/platform/efr32/args.gni") import("${chip_root}/src/crypto/crypto.gni") -# ARM architecture flags will be set based on efr32_family. +# ARM architecture flags will be set based on silabs_family. arm_platform_config = "${efr32_sdk_build_root}/efr32_arm.gni" mbedtls_target = "${efr32_sdk_build_root}:efr32_sdk" diff --git a/src/test_driver/efr32/BUILD.gn b/src/test_driver/efr32/BUILD.gn index 1d6f87637a99db..f26103d64a7657 100644 --- a/src/test_driver/efr32/BUILD.gn +++ b/src/test_driver/efr32/BUILD.gn @@ -54,7 +54,7 @@ efr32_sdk("sdk") { ] defines = [ - "BOARD_ID=${efr32_board}", + "BOARD_ID=${silabs_board}", "EFR32_LOG_ENABLED=1", "PW_RPC_ENABLED", @@ -105,7 +105,7 @@ efr32_executable("efr32_device_tests") { include_dirs = [ "${chip_root}/examples/common/pigweed/efr32" ] - ldscript = "${examples_plat_dir}/ldscripts/${efr32_family}.ld" + ldscript = "${examples_plat_dir}/ldscripts/${silabs_family}.ld" inputs = [ ldscript ] diff --git a/third_party/openthread/platforms/efr32/BUILD.gn b/third_party/openthread/platforms/efr32/BUILD.gn index b6dba5b98d4351..89546a7f7daf1f 100644 --- a/third_party/openthread/platforms/efr32/BUILD.gn +++ b/third_party/openthread/platforms/efr32/BUILD.gn @@ -16,21 +16,21 @@ import("//build_overrides/chip.gni") import("//build_overrides/efr32_sdk.gni") import("//build_overrides/openthread.gni") -import("${efr32_sdk_build_root}/efr32_board.gni") import("${efr32_sdk_build_root}/efr32_sdk.gni") +import("${efr32_sdk_build_root}/silabs_board.gni") openthread_efr32_root = "${chip_root}/third_party/openthread/ot-efr32" config("openthread_efr32_config") { defines = [ "RADIO_CONFIG_DMP_SUPPORT=1", - "${efr32_board}=1", - "${efr32_mcu}", + "${silabs_board}=1", + "${silabs_mcu}", ] include_dirs = [ "${chip_root}/examples/platform/efr32", - "${sdk_support_root}/matter/efr32/${efr32_family}/${efr32_board}", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}", "${openthread_efr32_root}/src/src", ] } diff --git a/third_party/silabs/BUILD.gn b/third_party/silabs/BUILD.gn index 552fbe923e352f..5ac5159b925968 100644 --- a/third_party/silabs/BUILD.gn +++ b/third_party/silabs/BUILD.gn @@ -61,14 +61,14 @@ if (use_silabs_thread_lib) { config("openthread_efr32_config") { defines = [ "RADIO_CONFIG_DMP_SUPPORT=1", - "${efr32_board}=1", - "${efr32_mcu}", + "${silabs_board}=1", + "${silabs_mcu}", "OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=\"openthread-core-efr32-config-check.h\"", ] include_dirs = [ "${chip_root}/examples/platform/efr32", - "${sdk_support_root}/matter/efr32/${efr32_family}/${efr32_board}", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}", "${sl_ot_efr32_root}/src/src", "${sl_openthread_root}/src/", ] @@ -153,8 +153,8 @@ if (use_silabs_thread_lib) { public_configs += [ "${sl_openthread_root}:openthread_${XTD}_config" ] libs = [ - "${sl_ot_efr32_root}/libs/libsl_ot_stack_${XTD}_${COAP_API}${efr32_family}_gcc.a", - "${sl_ot_efr32_root}/libs/libsl_platform_${XTD}_dmp_${efr32_family}_gcc.a", + "${sl_ot_efr32_root}/libs/libsl_ot_stack_${XTD}_${COAP_API}${silabs_family}_gcc.a", + "${sl_ot_efr32_root}/libs/libsl_platform_${XTD}_dmp_${silabs_family}_gcc.a", ] } } diff --git a/third_party/silabs/efr32_arm.gni b/third_party/silabs/efr32_arm.gni index 19d26c3fd4c532..e1696309677ae2 100644 --- a/third_party/silabs/efr32_arm.gni +++ b/third_party/silabs/efr32_arm.gni @@ -12,15 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("efr32_board.gni") +import("silabs_board.gni") -if (efr32_family == "efr32mg12") { +if (silabs_family == "efr32mg12") { arm_arch = "armv7e-m" arm_abi = "aapcs" arm_cpu = "cortex-m4" arm_float_abi = "softfp" arm_fpu = "fpv4-sp-d16" -} else if (efr32_family == "efr32mg21" || efr32_family == "efr32mg24") { +} else if (silabs_family == "efr32mg21" || silabs_family == "efr32mg24" || + silabs_family == "mgm24") { arm_arch = "armv8-m.main+dsp" arm_abi = "aapcs" arm_cpu = "cortex-m33" diff --git a/third_party/silabs/efr32_board.gni b/third_party/silabs/efr32_board.gni deleted file mode 100644 index 3de8aa1337bc6a..00000000000000 --- a/third_party/silabs/efr32_board.gni +++ /dev/null @@ -1,88 +0,0 @@ -# Copyright (c) 2020 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. - -declare_args() { - # EFR32 board used - efr32_board = "" -} - -if (efr32_board == "") { - efr32_board = getenv("EFR32_BOARD") -} - -assert(efr32_board != "", "efr32_board must be specified") - -# Differentiate between boards -# - BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm -# - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm -# - BRD4163A / SLWSTK6000B / Dual band Wireless Starter Kit / 2.4GHz@19dBm, 868MHz@19dBm -# - BRD4164A / SLWSTK6000B / Dual band Wireless Starter Kit / 2.4GHz@19dBm, 915MHz@19dBm -# - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm -# - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, 915MHz@19dBm, 868MHz@19dBm -# - BRD4180A / SLWSTK6006A / MG21 Module / 2.4GHz@20dBm -# - BRD4186A / SLWSTK6006A / MG24 / Wireless Starter Kit / 2.4GHz@10dBm -# - BRD4187A / SLWSTK6006A / MG24 / Wireless Starter Kit / 2.4GHz@20dBm - -board_defines = [] - -if (efr32_board == "BRD4304A") { - efr32_family = "efr32mg12" - efr32_mcu = "EFR32MG12P432F1024GM48" - enable_fem = true - board_defines += [ "PAL_RTCC_CLOCK_LFRCO" ] -} else if (efr32_board == "BRD4161A") { - efr32_family = "efr32mg12" - efr32_mcu = "EFR32MG12P432F1024GL125" -} else if (efr32_board == "BRD4162A") { - efr32_family = "efr32mg12" - efr32_mcu = "EFR32MG12P332F1024GL125" -} else if (efr32_board == "BRD4163A") { - efr32_family = "efr32mg12" - efr32_mcu = "EFR32MG12P433F1024GL125" -} else if (efr32_board == "BRD4164A") { - efr32_family = "efr32mg12" - efr32_mcu = "EFR32MG12P433F1024GL125" -} else if (efr32_board == "BRD4166A") { - efr32_family = "efr32mg12" - efr32_mcu = "EFR32MG12P332F1024GL125" -} else if (efr32_board == "BRD4170A") { - efr32_family = "efr32mg12" - efr32_mcu = "EFR32MG12P433F1024GM68" -} else if (efr32_board == "BRD4180A") { - assert( - false, - "The board ${efr32_board} not currently supported due to RAM limitation") - efr32_family = "efr32mg21" - efr32_mcu = "EFR32MG21A020F1024IM32" -} else if (efr32_board == "BRD4186A" || efr32_board == "BRD4187A") { - print("RevA is deprecated, We suggest using BRD4186C (rev C)") - efr32_family = "efr32mg24" - efr32_mcu = "EFR32MG24A010F1536GM48" -} else if (efr32_board == "BRD4186C") { - efr32_family = "efr32mg24" - efr32_mcu = "EFR32MG24B210F1536IM48" -} else if (efr32_board == "BRD4187C") { - efr32_family = "efr32mg24" - efr32_mcu = "EFR32MG24B220F1536IM48" -} else if (efr32_board == "BRD2601B") { - efr32_family = "efr32mg24" - efr32_mcu = "EFR32MG24B310F1536IM48" -} else if (efr32_board == "BRD2703A") { - efr32_family = "efr32mg24" - efr32_mcu = "EFR32MG24B020F1536IM48" -} else { - print( - "Please provide a valid value for EFR32_BOARD env variable (currently supported BRD4304A, BRD4161A, BRD4163A, BRD4164A BRD4166A, BRD4170A, BRD4186C, BRD4187C, BRD2601B, BRD2703A)") - assert(false, "The board ${efr32_board} is unsupported") -} diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index c9742f1f9d7f72..22fa2d0aac59b9 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -18,26 +18,35 @@ import("//build_overrides/jlink.gni") import("//build_overrides/mbedtls.gni") import("${chip_root}/src/lib/lib.gni") -import("efr32_board.gni") +import("silabs_board.gni") declare_args() { # Location of the efr32 SDK. efr32_sdk_root = "${chip_root}/third_party/silabs/gecko_sdk" sdk_support_root = "${chip_root}/third_party/silabs/matter_support" - #Build openthread with prebuilt silabs lib + # Build openthread with prebuilt silabs lib use_silabs_thread_lib = false enable_openthread_cli = true - kvs_max_entries = 75 + kvs_max_entries = 75 use_external_flash = true } -# Explorer Kit does not have external flash -if (efr32_board == "BRD2703A") { +# Explorer Kit and MGM240L do not have external flash +if (silabs_board == "BRD2703A" || silabs_board == "BRD4319A") { use_external_flash = false } +# Enable LEDs by default +use_wstk_leds = true + +# Board does not support LEDs and Buttons at the same time +if (silabs_board == "BRD4317A" || silabs_board == "BRD4316A" || + silabs_board == "BRD4319A") { + use_wstk_leds = false +} + assert(efr32_sdk_root != "", "efr32_sdk_root must be specified") # Defines an efr32 SDK build target. @@ -82,7 +91,6 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/CMSIS/RTOS2/Include", "${efr32_sdk_root}/platform/common/inc", "${efr32_sdk_root}/platform/driver/button/inc", - "${efr32_sdk_root}/platform/driver/leddrv/inc", "${efr32_sdk_root}/platform/emdrv/common/inc", "${efr32_sdk_root}/platform/emdrv/gpiointerrupt/inc", "${efr32_sdk_root}/platform/emdrv/dmadrv/config", @@ -142,8 +150,8 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/", "${efr32_sdk_root}/util/third_party/freertos/cmsis/Include", "${efr32_sdk_root}/util/third_party/freertos/kernel/include", - "${sdk_support_root}/matter/efr32/${efr32_family}/${efr32_board}/config", - "${sdk_support_root}/matter/efr32/${efr32_family}/${efr32_board}/autogen", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/config", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen", ] # Note that we're setting the mbedTLS and PSA configuration files through a @@ -166,8 +174,8 @@ template("efr32_sdk") { "CORTEXM3", "MICRO=EMBER_MICRO_CORTEXM3_EFR32", "PLAT=EMBER_PLATFORM_CORTEXM3", - "${efr32_mcu}=1", - "${efr32_board}=1", + "${silabs_mcu}=1", + "${silabs_board}=1", "SL_SUPRESS_DEPRECATION_WARNINGS_SDK_3_1", "__HEAP_SIZE=0", "SL_CATALOG_FREERTOS_KERNEL_PRESENT=1", @@ -183,6 +191,12 @@ template("efr32_sdk") { defines += board_defines + if (use_wstk_leds) { + _include_dirs += [ "${efr32_sdk_root}/platform/driver/leddrv/inc" ] + + defines += [ "ENABLE_WSTK_LEDS" ] + } + if (defined(invoker.enable_sleepy_device)) { if (invoker.enable_sleepy_device) { defines += [ @@ -227,7 +241,7 @@ template("efr32_sdk") { ] } - if (efr32_family == "efr32mg12") { + if (silabs_family == "efr32mg12") { _include_dirs += [ "${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG12P/Include", "${efr32_sdk_root}/platform/radio/rail_lib/chip/efr32/efr32xg1x", @@ -244,7 +258,7 @@ template("efr32_sdk") { ] defines += [ "EFR32MG12" ] - } else if (efr32_family == "efr32mg21") { + } else if (silabs_family == "efr32mg21") { _include_dirs += [ "${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG21/Include", "${efr32_sdk_root}/platform/radio/rail_lib/chip/efr32/efr32xg2x", @@ -265,7 +279,7 @@ template("efr32_sdk") { "EFR32MG21", "EFR32_SERIES2_CONFIG1_MICRO", ] - } else if (efr32_family == "efr32mg24") { + } else if (silabs_family == "efr32mg24") { _include_dirs += [ "${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG24/Include", "${efr32_sdk_root}/platform/radio/rail_lib/chip/efr32/efr32xg2x", @@ -286,7 +300,39 @@ template("efr32_sdk") { "EFR32MG24", "EFR32_SERIES2_CONFIG4_MICRO", ] + } else if (silabs_family == "mgm24") { + _include_dirs += [ + "${efr32_sdk_root}/platform/Device/SiliconLabs/MGM24/Include", + "${efr32_sdk_root}/platform/radio/rail_lib/chip/efr32/efr32xg2x", + "${efr32_sdk_root}/platform/radio/rail_lib/protocol/ble", + "${efr32_sdk_root}/platform/radio/rail_lib/protocol/ieee802154", + "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/GCC/ARM_CM33_NTZ/non_secure", + "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions/efr32xg24", + "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions/efr32xg24/config", + "${efr32_sdk_root}/platform/service/device_init/config/s2/", + ] + + libs += [ + "${sdk_support_root}/protocol/bluetooth/lib/EFR32MG24/GCC/libapploader.a", + "${sdk_support_root}/protocol/bluetooth/lib/EFR32MG24/GCC/libbluetooth.a", + "${sdk_support_root}/platform/radio/rail_lib/autogen/librail_release/librail_multiprotocol_module_efr32xg24_gcc_release.a", + "${sdk_support_root}/platform/emdrv/nvm3/lib/libnvm3_CM33_gcc.a", + ] + + if (silabs_mcu == "MGM240PB32VNA") { + libs += [ "${sdk_support_root}/platform/radio/rail_lib/autogen/librail_release/librail_config_mgm240pb32vna_gcc.a" ] + } else if (silabs_mcu == "MGM240PB22VNA") { + libs += [ "${sdk_support_root}/platform/radio/rail_lib/autogen/librail_release/librail_config_mgm240pb22vna_gcc.a" ] + } else if (silabs_mcu == "MGM240L022RNF") { + libs += [ "${sdk_support_root}/platform/radio/rail_lib/autogen/librail_release/librail_config_mgm240l022rnf_gcc.a" ] + } + + defines += [ + "MGM24", + "EFR32_SERIES2_CONFIG4_MICRO", + ] } + if (use_wf200) { _include_dirs += [ "${efr32_sdk_root}/platform/radio/wifi/wfx_fmac_driver", @@ -307,7 +353,7 @@ template("efr32_sdk") { "-Wno-shadow", ] - if (efr32_family == "efr32mg24") { + if (silabs_family == "efr32mg24" || silabs_family == "mgm24") { cflags += [ "-mcmse" ] } @@ -348,10 +394,6 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/common/src/sl_slist.c", "${efr32_sdk_root}/platform/driver/button/src/sl_button.c", "${efr32_sdk_root}/platform/driver/button/src/sl_simple_button.c", - "${efr32_sdk_root}/platform/driver/leddrv/src/sl_led.c", - "${efr32_sdk_root}/platform/driver/leddrv/src/sl_pwm_led.c", - "${efr32_sdk_root}/platform/driver/leddrv/src/sl_simple_led.c", - "${efr32_sdk_root}/platform/driver/leddrv/src/sl_simple_rgb_pwm_led.c", "${efr32_sdk_root}/platform/emdrv/dmadrv/src/dmadrv.c", "${efr32_sdk_root}/platform/emdrv/gpiointerrupt/src/gpiointerrupt.c", "${efr32_sdk_root}/platform/emdrv/nvm3/src/nvm3_default.c", @@ -511,13 +553,22 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/freertos/kernel/stream_buffer.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/tasks.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/timers.c", - "${sdk_support_root}/matter/efr32/${efr32_family}/${efr32_board}/autogen/sl_board_default_init.c", - "${sdk_support_root}/matter/efr32/${efr32_family}/${efr32_board}/autogen/sl_device_init_clocks.c", - "${sdk_support_root}/matter/efr32/${efr32_family}/${efr32_board}/autogen/sl_event_handler.c", - "${sdk_support_root}/matter/efr32/${efr32_family}/${efr32_board}/autogen/sl_simple_button_instances.c", - "${sdk_support_root}/matter/efr32/${efr32_family}/${efr32_board}/autogen/sl_simple_led_instances.c", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_board_default_init.c", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_device_init_clocks.c", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_event_handler.c", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_simple_button_instances.c", ] + if (use_wstk_leds) { + sources += [ + "${efr32_sdk_root}/platform/driver/leddrv/src/sl_led.c", + "${efr32_sdk_root}/platform/driver/leddrv/src/sl_pwm_led.c", + "${efr32_sdk_root}/platform/driver/leddrv/src/sl_simple_led.c", + "${efr32_sdk_root}/platform/driver/leddrv/src/sl_simple_rgb_pwm_led.c", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_simple_led_instances.c", + ] + } + if (defined(invoker.enable_sleepy_device)) { if (invoker.enable_sleepy_device) { sources += [ "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/SiliconLabs/tick_power_manager.c" ] @@ -543,7 +594,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/emlib/src/em_eusart.c", "${efr32_sdk_root}/platform/emlib/src/em_leuart.c", "${efr32_sdk_root}/platform/emlib/src/em_usart.c", - "${sdk_support_root}/matter/efr32/${efr32_family}/${efr32_board}/autogen/sl_uartdrv_init.c", + "${sdk_support_root}/matter/efr32/${silabs_family}/${silabs_board}/autogen/sl_uartdrv_init.c", ] if (defined(invoker.use_external_flash) && use_external_flash) { @@ -580,7 +631,7 @@ template("efr32_sdk") { ] } - if (efr32_family == "efr32mg12") { + if (silabs_family == "efr32mg12") { sources += [ "${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG12P/Source/startup_efr32mg12p.c", "${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG12P/Source/system_efr32mg12p.c", @@ -590,7 +641,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_lfxo_s1.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/GCC/ARM_CM4F/port.c", ] - } else if (efr32_family == "efr32mg21") { + } else if (silabs_family == "efr32mg21") { sources += [ "${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG21/Source/startup_efr32mg21.c", "${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG21/Source/system_efr32mg21.c", @@ -629,7 +680,7 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/GCC/ARM_CM33_NTZ/non_secure/port.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c", ] - } else if (efr32_family == "efr32mg24") { + } else if (silabs_family == "efr32mg24") { sources += [ "${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG24/Source/startup_efr32mg24.c", "${efr32_sdk_root}/platform/Device/SiliconLabs/EFR32MG24/Source/system_efr32mg24.c", @@ -669,6 +720,45 @@ template("efr32_sdk") { "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/GCC/ARM_CM33_NTZ/non_secure/port.c", "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c", ] + } else if (silabs_family == "mgm24") { + sources += [ + "${efr32_sdk_root}/platform/Device/SiliconLabs/MGM24/Source/startup_mgm24.c", + "${efr32_sdk_root}/platform/Device/SiliconLabs/MGM24/Source/system_mgm24.c", + "${efr32_sdk_root}/platform/radio/rail_lib/plugin/pa-conversions/pa_curves_efr32.c", + "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_dcdc_s2.c", + "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_emu_s2.c", + "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_hfxo_mgm24.c", + "${efr32_sdk_root}/platform/service/device_init/src/sl_device_init_lfxo_s2.c", + "${efr32_sdk_root}/platform/service/hfxo_manager/src/sl_hfxo_manager_hal_s2.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_attestation.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_cipher.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_entropy.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_hash.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_key_derivation.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_key_handling.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_signature.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/se_manager/src/sl_se_manager_util.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_mbedtls_support/src/se_aes.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_mbedtls_support/src/se_jpake.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_protocol_crypto/src/sli_radioaes_management.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_aead.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_cipher.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_key_derivation.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_key_management.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_driver_mac.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_opaque_driver_aead.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_opaque_driver_cipher.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_opaque_driver_mac.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_opaque_key_derivation.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_transparent_driver_aead.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_transparent_driver_cipher.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_transparent_driver_hash.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_transparent_driver_mac.c", + "${efr32_sdk_root}/util/third_party/crypto/sl_component/sl_psa_driver/src/sli_se_transparent_key_derivation.c", + "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/GCC/ARM_CM33_NTZ/non_secure/port.c", + "${efr32_sdk_root}/util/third_party/freertos/kernel/portable/GCC/ARM_CM33_NTZ/non_secure/portasm.c", + ] } public_deps = [ diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 2425fb72cacd54..48483a67a123a4 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 2425fb72cacd540df505f11e7de81e6270ed1c40 +Subproject commit 48483a67a123a4ecd72bbd4f4a201e49ad18e8fd diff --git a/third_party/silabs/silabs_board.gni b/third_party/silabs/silabs_board.gni new file mode 100644 index 00000000000000..b5fe904a1e9561 --- /dev/null +++ b/third_party/silabs/silabs_board.gni @@ -0,0 +1,97 @@ +# Copyright (c) 2020 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. + +declare_args() { + # EFR32 board used + silabs_board = "" +} + +if (silabs_board == "") { + silabs_board = getenv("SILABS_BOARD") +} + +assert(silabs_board != "", "silabs_board must be specified") + +# Differentiate between boards +# - BRD4304A / SLWSTK6000B / MGM12P Module / 2.4GHz@19dBm +# - BRD4161A / SLWSTK6000B / Wireless Starter Kit / 2.4GHz@19dBm +# - BRD4163A / SLWSTK6000B / Dual band Wireless Starter Kit / 2.4GHz@19dBm, 868MHz@19dBm +# - BRD4164A / SLWSTK6000B / Dual band Wireless Starter Kit / 2.4GHz@19dBm, 915MHz@19dBm +# - BRD4166A / SLTB004A / Thunderboard Sense 2 / 2.4GHz@10dBm +# - BRD4170A / SLWSTK6000B / Multiband Wireless Starter Kit / 2.4GHz@19dBm, 915MHz@19dBm, 868MHz@19dBm +# - BRD4180A / SLWSTK6006A / MG21 Module / 2.4GHz@20dBm +# - BRD4186A / SLWSTK6006A / MG24 / Wireless Starter Kit / 2.4GHz@10dBm +# - BRD4187A / SLWSTK6006A / MG24 / Wireless Starter Kit / 2.4GHz@20dBm + +board_defines = [] + +if (silabs_board == "BRD4304A") { + silabs_family = "efr32mg12" + silabs_mcu = "EFR32MG12P432F1024GM48" + enable_fem = true + board_defines += [ "PAL_RTCC_CLOCK_LFRCO" ] +} else if (silabs_board == "BRD4161A") { + silabs_family = "efr32mg12" + silabs_mcu = "EFR32MG12P432F1024GL125" +} else if (silabs_board == "BRD4162A") { + silabs_family = "efr32mg12" + silabs_mcu = "EFR32MG12P332F1024GL125" +} else if (silabs_board == "BRD4163A") { + silabs_family = "efr32mg12" + silabs_mcu = "EFR32MG12P433F1024GL125" +} else if (silabs_board == "BRD4164A") { + silabs_family = "efr32mg12" + silabs_mcu = "EFR32MG12P433F1024GL125" +} else if (silabs_board == "BRD4166A") { + silabs_family = "efr32mg12" + silabs_mcu = "EFR32MG12P332F1024GL125" +} else if (silabs_board == "BRD4170A") { + silabs_family = "efr32mg12" + silabs_mcu = "EFR32MG12P433F1024GM68" +} else if (silabs_board == "BRD4180A") { + assert( + false, + "The board ${silabs_board} not currently supported due to RAM limitation") + silabs_family = "efr32mg21" + silabs_mcu = "EFR32MG21A020F1024IM32" +} else if (silabs_board == "BRD4186A" || silabs_board == "BRD4187A") { + print("RevA is deprecated, We suggest using BRD4186C (rev C)") + silabs_family = "efr32mg24" + silabs_mcu = "EFR32MG24A010F1536GM48" +} else if (silabs_board == "BRD4186C") { + silabs_family = "efr32mg24" + silabs_mcu = "EFR32MG24B210F1536IM48" +} else if (silabs_board == "BRD4187C") { + silabs_family = "efr32mg24" + silabs_mcu = "EFR32MG24B220F1536IM48" +} else if (silabs_board == "BRD2601B") { + silabs_family = "efr32mg24" + silabs_mcu = "EFR32MG24B310F1536IM48" +} else if (silabs_board == "BRD2703A") { + silabs_family = "efr32mg24" + silabs_mcu = "EFR32MG24B020F1536IM48" +} else if (silabs_board == "BRD4316A") { + silabs_family = "mgm24" + silabs_mcu = "MGM240PB22VNA" +} else if (silabs_board == "BRD4317A") { + silabs_family = "mgm24" + silabs_mcu = "MGM240PB32VNA" +} else if (silabs_board == "BRD4319A") { + silabs_family = "mgm24" + silabs_mcu = "MGM240L022RNF" +} else { + print( + "Please provide a valid value for SILABS_BOARD env variable (currently supported BRD4304A, BRD4161A, BRD4163A, BRD4164A BRD4166A, BRD4170A, BRD4186C, BRD4187C, BRD2601B, BRD2703A, BRD4317A)") + assert(false, "The board ${silabs_board} is unsupported") +} From 1ddf6ad9edac9efcd38ab9ffb69c51619e24e0e3 Mon Sep 17 00:00:00 2001 From: Martin Turon Date: Mon, 26 Sep 2022 14:15:12 +0000 Subject: [PATCH 2/6] [session][test] Extend TestSessionManagerDispatch with group test (#22769) * [session][test] Add group message test vector. * [session][test] Add short payload secure unicast message test vector. * [restyle] * [test] Resolve review comments. Decouple TestInjectGroupSession from nl_unit. * [test] Fix group name string too large. --- .../tests/TestSessionManagerDispatch.cpp | 132 ++++++++++++++++-- 1 file changed, 123 insertions(+), 9 deletions(-) diff --git a/src/transport/tests/TestSessionManagerDispatch.cpp b/src/transport/tests/TestSessionManagerDispatch.cpp index 6ebbbfbfb651ff..5cd224c9f4c443 100644 --- a/src/transport/tests/TestSessionManagerDispatch.cpp +++ b/src/transport/tests/TestSessionManagerDispatch.cpp @@ -24,6 +24,7 @@ #define CHIP_ENABLE_TEST_ENCRYPTED_BUFFER_API // Up here in case some other header // includes SessionManager.h indirectly +#include #include #include #include @@ -49,6 +50,12 @@ using namespace chip; using namespace chip::Inet; using namespace chip::Transport; using namespace chip::Test; +using namespace chip::Credentials; + +using GroupInfo = GroupDataProvider::GroupInfo; +using GroupKey = GroupDataProvider::GroupKey; +using KeySet = GroupDataProvider::KeySet; +using SecurityPolicy = GroupDataProvider::SecurityPolicy; using TestContext = chip::Test::LoopbackTransportManager; @@ -80,12 +87,13 @@ struct MessageTestEntry uint16_t sessionId; NodeId peerNodeId; - FabricIndex fabricIndex; + GroupId groupId; + NodeId sourceNodeId; }; struct MessageTestEntry theMessageTestVector[] = { { - .name = "secure pase message", + .name = "secure pase message (no payload)", .peerAddr = "::1", .payload = "", @@ -100,19 +108,80 @@ struct MessageTestEntry theMessageTestVector[] = { .encryptedLength = 30, .privacyLength = 30, + // TODO(#22830): unicast message tests must use test key currently .encryptKey = "\x5e\xde\xd2\x44\xe5\x53\x2b\x3c\xdc\x23\x40\x9d\xba\xd0\x52\xd2", .nonce = "\x00\x39\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", - .sessionId = 0x0bb8, // 3000 - .peerNodeId = 0x0000000000000000ULL, - .fabricIndex = 1, + .sessionId = 0x0bb8, // 3000 + .peerNodeId = 0x0000000000000000ULL, + }, + { + .name = "secure pase message (short payload)", + .peerAddr = "::1", + + .payload = "\x11\x22\x33\x44\x55", + .plain = "\x00\xb8\x0b\x00\x39\x30\x00\x00\x05\x64\xee\x0e\x20\x7d\x11\x22\x33\x44\x55", + .encrypted = "\x00\xb8\x0b\x00\x39\x30\x00\x00\x5a\x98\x9a\xe4\x2e\x8d\x0f\x7f\x88\x5d\xfb" + "\x2f\xaa\x89\x49\xcf\x73\x0a\x57\x28\xe0\x35\x46\x10\xa0\xc4\xa7", // Includes MIC + .privacy = "\x00\xb8\x0b\x00\x39\x30\x00\x00\x5a\x98\x9a\xe4\x2e\x8d\x0f\x7f\x88\x5d\xfb" + "\x2f\xaa\x89\x49\xcf\x73\x0a\x57\x28\xe0\x35\x46\x10\xa0\xc4\xa7", // Includes MIC + + .payloadLength = 5, + .plainLength = 19, + .encryptedLength = 35, + .privacyLength = 35, + + // TODO(#22830): unicast message tests must use test key currently + .encryptKey = "\x5e\xde\xd2\x44\xe5\x53\x2b\x3c\xdc\x23\x40\x9d\xba\xd0\x52\xd2", + + .nonce = "\x00\x39\x30\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", + + .sessionId = 0x0bb8, // 3000 + .peerNodeId = 0x0000000000000000ULL, + }, + { + .name = "secure group message (no privacy)", + .peerAddr = "::1", + + .payload = "", + + .plain = "\06\x7d\xdb\x01\x78\x56\x34\x12\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x01\x64\xee\x0e\x20\x7d", + .encrypted = "\x06\x7d\xdb\x01\x78\x56\x34\x12\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x65\xc7\x67\xbc\x6c\xda" + "\x01\x06\xc9\x80\x13\x23\x90\x0e\x9b\x3c\xe6\xd4\xbb\x03\x27\xd6", // Includes MIC + .privacy = "\x06\x7d\xdb\x01\x78\x56\x34\x12\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x65\xc7\x67\xbc\x6c\xda" + "\x01\x06\xc9\x80\x13\x23\x90\x0e\x9b\x3c\xe6\xd4\xbb\x03\x27\xd6", // Includes MIC + + .payloadLength = 0, + .plainLength = 24, + .encryptedLength = 40, + .privacyLength = 40, + + .encryptKey = "\xca\x92\xd7\xa0\x94\x2d\x1a\x51\x1a\x0e\x26\xad\x07\x4f\x4c\x2f", + .privacyKey = "\xbf\xe9\xda\x01\x6a\x76\x53\x65\xf2\xdd\x97\xa9\xf9\x39\xe4\x25", + .epochKey = "\xb0\xb1\xb2\xb3\xb4\xb5\xb6\xb7\xb8\xb9\xba\xbb\xbc\xbd\xbe\xbf", + + .nonce = "\x01\x78\x56\x34\x12\x01\x00\x00\x00\x00\x00\x00\x00", + .privacyNonce = "\xdb\x7d\x23\x90\x0e\x9b\x3c\xe6\xd4\xbb\x03\x27\xd6", + + .sessionId = 0xdb7d, // 56189 + .peerNodeId = 0x0000000000000000ULL, + .groupId = 2, + .sourceNodeId = 0x0000000000000002ULL, }, }; const uint16_t theMessageTestVectorLength = sizeof(theMessageTestVector) / sizeof(theMessageTestVector[0]); // Just enough init to replace a ton of boilerplate +constexpr FabricIndex kFabricIndex = kMinValidFabricIndex; +constexpr size_t kGroupIndex = 0; + +constexpr uint16_t kMaxGroupsPerFabric = 5; +constexpr uint16_t kMaxGroupKeysPerFabric = 8; + +static chip::TestPersistentStorageDelegate sStorageDelegate; +static GroupDataProviderImpl sProvider(kMaxGroupsPerFabric, kMaxGroupKeysPerFabric); class FabricTableHolder { public: @@ -129,6 +198,13 @@ class FabricTableHolder ReturnErrorOnFailure(mOpKeyStore.Init(&mStorage)); ReturnErrorOnFailure(mOpCertStore.Init(&mStorage)); + // Initialize Group Data Provider + sProvider.SetStorageDelegate(&sStorageDelegate); + // sProvider.SetListener(&chip::app::TestGroups::sListener); + ReturnErrorOnFailure(sProvider.Init()); + Credentials::SetGroupDataProvider(&sProvider); + + // Initialize Fabric Table chip::FabricTable::InitParams initParams; initParams.storage = &mStorage; initParams.operationalKeystore = &mOpKeyStore; @@ -165,7 +241,7 @@ class TestSessionManagerCallback : public SessionMessageDelegate NL_TEST_ASSERT(mSuite, dataLength == expectLength); NL_TEST_ASSERT(mSuite, memcmp(msgBuf->Start(), testEntry.payload, dataLength) == 0); - ChipLogProgress(Test, "TestSessionManagerDispatch[%d] PASS", mTestVectorIndex); + ChipLogProgress(Test, "::: TestSessionManagerDispatch[%d] PASS", mTestVectorIndex); } void ResetTest(unsigned testVectorIndex) @@ -203,6 +279,39 @@ void TestSessionManagerInit(nlTestSuite * inSuite, TestContext & ctx, SessionMan &fabricTableHolder.GetFabricTable())); } +// constexpr chip::FabricId kFabricId1 = 0x2906C908D115D362; +static const uint8_t kCompressedFabricIdBuffer1[] = { 0x87, 0xe1, 0xb0, 0x04, 0xe2, 0x35, 0xa1, 0x30 }; +constexpr ByteSpan kCompressedFabricId1(kCompressedFabricIdBuffer1); + +CHIP_ERROR InjectGroupSessionWithTestKey(SessionHolder & sessionHolder, MessageTestEntry & testEntry) +{ + constexpr uint16_t kKeySetIndex = 0x0; + + GroupId groupId = testEntry.groupId; + GroupDataProvider * provider = GetGroupDataProvider(); + + static KeySet sKeySet(kKeySetIndex, SecurityPolicy::kTrustFirst, 1); + static GroupKey sGroupKeySet(groupId, kKeySetIndex); + static GroupInfo sGroupInfo(groupId, "Name Matter Not"); + static Transport::IncomingGroupSession sSessionBobToFriends(groupId, kFabricIndex, testEntry.sourceNodeId); + + if (testEntry.epochKey) + { + memcpy(sKeySet.epoch_keys[0].key, testEntry.epochKey, 16); + sKeySet.epoch_keys[0].start_time = 0; + sGroupInfo.group_id = groupId; + sGroupKeySet.group_id = groupId; + + ReturnErrorOnFailure(provider->SetKeySet(kFabricIndex, kCompressedFabricId1, sKeySet)); + ReturnErrorOnFailure(provider->SetGroupKeyAt(kFabricIndex, kGroupIndex, sGroupKeySet)); + ReturnErrorOnFailure(provider->SetGroupInfoAt(kFabricIndex, kGroupIndex, sGroupInfo)); + } + + sessionHolder = SessionHandle(sSessionBobToFriends); + + return CHIP_NO_ERROR; +} + void TestSessionManagerDispatch(nlTestSuite * inSuite, void * inContext) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -219,6 +328,7 @@ void TestSessionManagerDispatch(nlTestSuite * inSuite, void * inContext) Transport::PeerAddress peer(Transport::PeerAddress::UDP(addr, CHIP_PORT)); SessionHolder aliceToBobSession; + SessionHolder testGroupSession; callback.mSuite = inSuite; for (unsigned i = 0; i < theMessageTestVectorLength; i++) @@ -228,20 +338,24 @@ void TestSessionManagerDispatch(nlTestSuite * inSuite, void * inContext) ChipLogProgress(Test, "===> TestSessionManagerDispatch[%d] '%s': sessionId=0x%04x", i, testEntry.name, testEntry.sessionId); + // TODO(#22830): inject raw keys rather than always defaulting to test key + // TODO: switch on session type + // Inject Sessions err = sessionManager.InjectPaseSessionWithTestKey(aliceToBobSession, testEntry.sessionId, testEntry.peerNodeId, - testEntry.sessionId, testEntry.fabricIndex, peer, + testEntry.sessionId, kFabricIndex, peer, CryptoContext::SessionRole::kResponder); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + err = InjectGroupSessionWithTestKey(testGroupSession, testEntry); + NL_TEST_ASSERT(inSuite, CHIP_NO_ERROR == err); + const char * plain = testEntry.plain; const ByteSpan expectedPlain(reinterpret_cast(plain), testEntry.plainLength); const char * privacy = testEntry.privacy; chip::System::PacketBufferHandle msg = chip::MessagePacketBuffer::NewWithData(reinterpret_cast(privacy), testEntry.privacyLength); - // TODO: inject raw keys rather than always defaulting to test key - const PeerAddress peerAddress = AddressFromString(testEntry.peerAddr); sessionManager.OnMessageReceived(peerAddress, std::move(msg)); NL_TEST_ASSERT(inSuite, callback.NumMessagesReceived() > 0); From 490b9e27cd43e2ab0fc6cc4b1a0ea47ecad0cdcd Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Mon, 26 Sep 2022 18:44:56 +0200 Subject: [PATCH 3/6] Do not raise exception when listing targets (#22868) --- scripts/build/builders/host.py | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/scripts/build/builders/host.py b/scripts/build/builders/host.py index a599b0f6e6c3cf..faa664b558c15d 100644 --- a/scripts/build/builders/host.py +++ b/scripts/build/builders/host.py @@ -226,9 +226,6 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, self.extra_gn_options = [] self.build_env = {} - if board == HostBoard.ARM64: - self.build_env['PKG_CONFIG_PATH'] = os.path.join(self.SysRootPath('SYSROOT_AARCH64'), 'lib/aarch64-linux-gnu/pkgconfig') - if enable_rpcs: self.extra_gn_options.append('import("//with_pw_rpc.gni")') @@ -348,6 +345,9 @@ def GnBuildArgs(self): raise Exception('Unknown host board type: %r' % self) def GnBuildEnv(self): + if self.board == HostBoard.ARM64: + self.build_env['PKG_CONFIG_PATH'] = os.path.join( + self.SysRootPath('SYSROOT_AARCH64'), 'lib/aarch64-linux-gnu/pkgconfig') return self.build_env def SysRootPath(self, name): @@ -366,20 +366,26 @@ def PreBuildCommand(self): if self.app == HostApp.TESTS and self.use_coverage: self._Execute(['ninja', '-C', self.output_dir, 'default'], title="Build-only") self._Execute(['find', os.path.join(self.output_dir, 'obj/src/'), '-depth', - '-name', 'tests', '-exec', 'rm -rf {} \;'], title="Cleanup unit tests") - self._Execute(['lcov', '--initial', '--capture', '--directory', os.path.join(self.output_dir, 'obj'), '--exclude', os.path.join(self.chip_dir, 'zzz_generated/*'), '--exclude', os.path.join(self.chip_dir, 'third_party/*'), '--exclude', '/usr/include/*', - '--output-file', os.path.join(self.coverage_dir, 'lcov_base.info')], title="Initial coverage baseline") + '-name', 'tests', '-exec', 'rm -rf {} \\;'], title="Cleanup unit tests") + self._Execute(['lcov', '--initial', '--capture', '--directory', os.path.join(self.output_dir, 'obj'), + '--exclude', os.path.join(self.chip_dir, 'zzz_generated/*'), + '--exclude', os.path.join(self.chip_dir, 'third_party/*'), + '--exclude', '/usr/include/*', + '--output-file', os.path.join(self.coverage_dir, 'lcov_base.info')], title="Initial coverage baseline") def PostBuildCommand(self): if self.app == HostApp.TESTS and self.use_coverage: - self._Execute(['lcov', '--capture', '--directory', os.path.join(self.output_dir, 'obj'), '--exclude', os.path.join(self.chip_dir, 'zzz_generated/*'), '--exclude', os.path.join(self.chip_dir, 'third_party/*'), '--exclude', '/usr/include/*', - '--output-file', os.path.join(self.coverage_dir, 'lcov_test.info')], title="Update coverage") + self._Execute(['lcov', '--capture', '--directory', os.path.join(self.output_dir, 'obj'), + '--exclude', os.path.join(self.chip_dir, 'zzz_generated/*'), + '--exclude', os.path.join(self.chip_dir, 'third_party/*'), + '--exclude', '/usr/include/*', + '--output-file', os.path.join(self.coverage_dir, 'lcov_test.info')], title="Update coverage") self._Execute(['lcov', '--add-tracefile', os.path.join(self.coverage_dir, 'lcov_base.info'), '--add-tracefile', os.path.join(self.coverage_dir, 'lcov_test.info'), '--output-file', os.path.join(self.coverage_dir, 'lcov_final.info') ], title="Final coverage info") self._Execute(['genhtml', os.path.join(self.coverage_dir, 'lcov_final.info'), '--output-directory', - os.path.join(self.coverage_dir, 'html')], title="HTML coverage") + os.path.join(self.coverage_dir, 'html')], title="HTML coverage") def build_outputs(self): outputs = {} From 797ca40e1a3a0acf183bea29d67959cc0fb173cc Mon Sep 17 00:00:00 2001 From: jczhang777 <101778393+jczhang777@users.noreply.github.com> Date: Tue, 27 Sep 2022 01:15:51 +0800 Subject: [PATCH 4/6] Update flash tool, add mac os flash tool,add ipv6 get addr hook,update readme ,add board link,update ble impl, fix support phone commission (#22798) * change properties of C2 Characteristic of BLE GATT to indication * change properties of C2 Characteristic of BLE GATT to indication for BL702 * update supported boards * [BL602] 1.Update flash tool, 2.Add ipv6 get ip hook * [BL602] Fix board led onoff * update README.md * correct spell * update workflow build * [BL602] Update flash tool name * Restyled by prettier-markdown * [BL602] Remove not use code * Restyled by clang-format * [BL616] Restyled * Sync ZCL State to LightingManager State setting * Restyled by clang-format * fix license conflict * fix license conflict-1 * fix license conflict-2 * specifiy bfbl_iot_tool version * [BL602] Delete not use code Co-authored-by: wyhong Co-authored-by: Restyled.io Co-authored-by: wyhong <30567533+wy-hh@users.noreply.github.com> Co-authored-by: shchen-Lab Co-authored-by: shchen-Lab <75290921+shchen-Lab@users.noreply.github.com> --- .github/workflows/examples-bouffalolab.yaml | 8 +- .../lighting-app/bouffalolab/bl602/BUILD.gn | 3 + .../lighting-app/bouffalolab/bl602/README.md | 5 +- .../bouffalolab/bl602/include/AppTask.h | 1 + .../bl602/include/CHIPDeviceManager.h | 4 +- .../bouffalolab/bl602/src/AppTask.cpp | 15 + .../bouffalolab/bl602/src/DeviceCallbacks.cpp | 13 +- .../lighting-app/bouffalolab/bl702/README.md | 62 +-- .../bl602/route_hook/bl_route_hook.c | 206 +++++++++ .../bl602/route_hook/bl_route_hook.h | 10 + .../bl602/route_hook/bl_route_table.c | 174 ++++++++ .../bl602/route_hook/bl_route_table.h | 76 ++++ scripts/build/build/targets.py | 6 +- scripts/build/builders/bouffalolab.py | 7 +- .../testdata/all_targets_except_host.txt | 6 +- .../build/testdata/build_all_except_host.txt | 28 +- .../glob_star_targets_except_host.txt | 6 +- scripts/examples/gn_bouffalolab_example.sh | 2 +- scripts/requirements.bouffalolab.txt | 2 +- .../bouffalolab/BL602/BLEManagerImpl.cpp | 411 ++++++++++-------- .../bouffalolab/BL602/BLEManagerImpl.h | 33 +- .../BL602/CHIPDevicePlatformEvent.h | 19 +- .../BL602/ConnectivityManagerImpl.cpp | 10 + .../BL602/ConnectivityManagerImpl.h | 1 + src/platform/bouffalolab/BL602/DnssdImpl.cpp | 12 - .../bouffalolab/BL602/PlatformManagerImpl.cpp | 5 + .../bouffalolab/BL702/BLEManagerImpl.cpp | 173 +++++--- .../bouffalolab/BL702/BLEManagerImpl.h | 28 +- src/platform/bouffalolab/BL702/BUILD.gn | 3 +- .../bouffalolab/BL702/BlePlatformConfig.h | 5 +- .../BL702/CHIPDevicePlatformConfig.h | 5 +- .../BL702/CHIPDevicePlatformEvent.h | 20 +- .../bouffalolab/BL702/CHIPPlatformConfig.h | 13 +- src/platform/bouffalolab/BL702/CHIPmemory.cpp | 10 +- .../BL702/ConfigurationManagerImpl.cpp | 13 +- .../BL702/ConfigurationManagerImpl.h | 11 +- .../BL702/ConnectivityManagerImpl.cpp | 11 +- .../BL702/ConnectivityManagerImpl.h | 10 +- .../DeviceNetworkProvisioningDelegateImpl.cpp | 4 +- .../DeviceNetworkProvisioningDelegateImpl.h | 4 +- .../BL702/DiagnosticDataProviderImpl.cpp | 10 +- .../BL702/DiagnosticDataProviderImpl.h | 9 +- .../bouffalolab/BL702/InetPlatformConfig.h | 12 +- .../BL702/KeyValueStoreManagerImpl.cpp | 8 +- .../BL702/KeyValueStoreManagerImpl.h | 8 +- src/platform/bouffalolab/BL702/Logging.cpp | 17 +- .../BL702/OTAImageProcessorImpl.cpp | 3 +- .../bouffalolab/BL702/OTAImageProcessorImpl.h | 3 +- .../bouffalolab/BL702/PlatformManagerImpl.cpp | 11 +- .../bouffalolab/BL702/PlatformManagerImpl.h | 10 +- .../bouffalolab/BL702/SystemPlatformConfig.h | 12 +- .../BL702/ThreadStackManagerImpl.cpp | 13 +- .../BL702/ThreadStackManagerImpl.h | 13 +- .../bouffalolab/BL702/bl702Config.cpp | 10 +- src/platform/bouffalolab/BL702/bl702Config.h | 10 +- third_party/bouffalolab/bl602/bl602_sdk.gni | 5 + third_party/bouffalolab/repo | 2 +- 57 files changed, 1023 insertions(+), 568 deletions(-) create mode 100644 examples/platform/bouffalolab/bl602/route_hook/bl_route_hook.c create mode 100644 examples/platform/bouffalolab/bl602/route_hook/bl_route_hook.h create mode 100644 examples/platform/bouffalolab/bl602/route_hook/bl_route_table.c create mode 100644 examples/platform/bouffalolab/bl602/route_hook/bl_route_table.h diff --git a/.github/workflows/examples-bouffalolab.yaml b/.github/workflows/examples-bouffalolab.yaml index b50a0bb5d30d3c..4f32c97aaf424e 100644 --- a/.github/workflows/examples-bouffalolab.yaml +++ b/.github/workflows/examples-bouffalolab.yaml @@ -56,17 +56,17 @@ jobs: timeout-minutes: 30 run: | ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light build" + "./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-light build" .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl702 bl702 lighting-app \ - out/bouffalolab-BL706-IoT-DVK-BL706C-22-light/chip-bl702-lighting-example.out /tmp/bloat_reports/ + out/bouffalolab-BL706-IoT-DVK-light/chip-bl702-lighting-example.out /tmp/bloat_reports/ - name: Build example BL702 Lighting App with RPCs timeout-minutes: 30 run: | ./scripts/run_in_build_env.sh \ - "./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc build" + "./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-light-rpc build" .environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py bl702 bl702+rpc lighting-app \ - out/bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc/chip-bl702-lighting-example.out /tmp/bloat_reports/ + out/bouffalolab-BL706-IoT-DVK-light-rpc/chip-bl702-lighting-example.out /tmp/bloat_reports/ - name: Uploading Size Reports uses: actions/upload-artifact@v2 diff --git a/examples/lighting-app/bouffalolab/bl602/BUILD.gn b/examples/lighting-app/bouffalolab/bl602/BUILD.gn index b63a569da40842..a00a5a47503269 100644 --- a/examples/lighting-app/bouffalolab/bl602/BUILD.gn +++ b/examples/lighting-app/bouffalolab/bl602/BUILD.gn @@ -81,6 +81,8 @@ bl602_executable("lighting_app") { sources = [ #"${bl602_project_dir}/include/CHIPProjectConfig.h", "${examples_plat_dir}/InitPlatform.cpp", + "${examples_plat_dir}/route_hook/bl_route_hook.c", + "${examples_plat_dir}/route_hook/bl_route_table.c", "include/CHIPProjectConfig.h", "src/AppTask.cpp", "src/CHIPDeviceManager.cpp", @@ -162,6 +164,7 @@ bl602_executable("lighting_app") { include_dirs += [ "${chip_root}/examples/common", "${chip_root}/examples/common/pigweed/bouffalolab/bl602", + "${examples_plat_dir}/route_hook", ] } diff --git a/examples/lighting-app/bouffalolab/bl602/README.md b/examples/lighting-app/bouffalolab/bl602/README.md index d82959afd7a19d..1c66c73ecc5c83 100644 --- a/examples/lighting-app/bouffalolab/bl602/README.md +++ b/examples/lighting-app/bouffalolab/bl602/README.md @@ -3,7 +3,8 @@ This example functions as a wifi light bulb device type, with on/off capabilities. The steps were verified on BL602-IoT-Matter-V1 board. -BL602-IoT-Matter-V1 board: +BL602-IoT-Matter-V1 board and +[purchase link](https://www.amazon.com/dp/B0B9ZVGXD8): ## Initial setup @@ -66,7 +67,7 @@ The steps in this document were validated on Ubuntu 18.04 and 20.04. ``` cd third_party/bouffalolab/repo/tools/flash_tool - ./bflb_iot_tool --chipname=BL602 --baudrate=115200 --port=/dev/ttyACM0 --pt=chips/bl602/partition/partition_cfg_4M.toml --dts=chips/bl602/device_tree/bl_factory_params_IoTKitA_40M.dts --firmware=../../../../../out/bl602-light/chip-bl602-lighting-example.bin + ./bflb_iot_tool-ubuntu --chipname=BL602 --baudrate=115200 --port=/dev/ttyACM0 --pt=chips/bl602/partition/partition_cfg_4M.toml --dts=chips/bl602/device_tree/bl_factory_params_IoTKitA_40M.dts --firmware=../../../../../out/bl602-light/chip-bl602-lighting-example.bin ``` ``` diff --git a/examples/lighting-app/bouffalolab/bl602/include/AppTask.h b/examples/lighting-app/bouffalolab/bl602/include/AppTask.h index 097d040c55702c..b88d3b628311f0 100644 --- a/examples/lighting-app/bouffalolab/bl602/include/AppTask.h +++ b/examples/lighting-app/bouffalolab/bl602/include/AppTask.h @@ -49,6 +49,7 @@ class AppTask void PostEvent(const AppEvent * event); void ButtonEventHandler(uint8_t btnIdx, uint8_t btnAction); void LightStateUpdateEventHandler(void); + void LightStateInit(void); private: friend AppTask & GetAppTask(void); diff --git a/examples/lighting-app/bouffalolab/bl602/include/CHIPDeviceManager.h b/examples/lighting-app/bouffalolab/bl602/include/CHIPDeviceManager.h index 641d3e0394deb2..6fb4b28d3bc8fc 100644 --- a/examples/lighting-app/bouffalolab/bl602/include/CHIPDeviceManager.h +++ b/examples/lighting-app/bouffalolab/bl602/include/CHIPDeviceManager.h @@ -70,8 +70,8 @@ class DLL_EXPORT CHIPDeviceManagerCallbacks * @param size size of the attribute * @param value pointer to the new value */ - void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, - uint8_t type, uint16_t size, uint8_t * value) + virtual void PostAttributeChangeCallback(chip::EndpointId endpoint, chip::ClusterId clusterId, chip::AttributeId attributeId, + uint8_t type, uint16_t size, uint8_t * value) {} // virtual ~CHIPDeviceManagerCallbacks(); }; diff --git a/examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp b/examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp index 62bb09cb5b928b..cd865f515b85e4 100644 --- a/examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp +++ b/examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp @@ -153,6 +153,7 @@ CHIP_ERROR AppTask::Init() PrintOnboardingCodes(chip::RendezvousInformationFlag(chip::RendezvousInformationFlag::kBLE)); InitButtons(); + #if PW_RPC_ENABLED chip::rpc::Init(); #endif @@ -576,10 +577,24 @@ void AppTask::LightStateUpdateEventHandler(void) { statusLED.SetBrightness(0); statusLED.Set(0); + PostLightActionRequest(AppEvent::kEventType_Light, LightingManager::OFF_ACTION); } else { statusLED.SetBrightness(level); + PostLightActionRequest(AppEvent::kEventType_Light, LightingManager::ON_ACTION); } } while (0); } + +void AppTask::LightStateInit(void) +{ + uint8_t onoff = 1; + uint8_t level = 254; + EndpointId endpoint = 1; + + emberAfWriteAttribute(endpoint, ZCL_LEVEL_CONTROL_CLUSTER_ID, ZCL_CURRENT_LEVEL_ATTRIBUTE_ID, (uint8_t *) &level, + ZCL_INT8U_ATTRIBUTE_TYPE); + + emberAfWriteAttribute(endpoint, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, (uint8_t *) &onoff, ZCL_BOOLEAN_ATTRIBUTE_TYPE); +} diff --git a/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp b/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp index 87d3cd73c767a8..79440c9dba1089 100644 --- a/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp +++ b/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp @@ -37,6 +37,7 @@ #include #include #include +#include using namespace ::chip; using namespace ::chip::Inet; @@ -47,7 +48,6 @@ uint32_t identifyTimerCount; constexpr uint32_t kIdentifyTimerDelayMS = 250; static LEDWidget statusLED1; -// static LEDWidget statusLED2; void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_t arg) { @@ -67,6 +67,7 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ case DeviceEventType::kCommissioningComplete: log_info("Commissioning complete\r\n"); + GetAppTask().LightStateInit(); break; case DeviceEventType::kWiFiConnectivityChange: @@ -85,6 +86,12 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_ // newly selected address. chip::app::DnssdServer::Instance().StartServer(); } + + if (event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned) + { + ChipLogProgress(DeviceLayer, "Initializing route hook..."); + bl_route_hook_init(); + } break; } } @@ -125,15 +132,11 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event if (event->InternetConnectivityChange.IPv4 == kConnectivity_Established) { log_info("IPv4 Server ready...\r\n"); - // TODO - // wifiLED.Set(true); chip::app::DnssdServer::Instance().StartServer(); } else if (event->InternetConnectivityChange.IPv4 == kConnectivity_Lost) { log_info("Lost IPv4 connectivity...\r\n"); - // TODO - // wifiLED.Set(false); } if (event->InternetConnectivityChange.IPv6 == kConnectivity_Established) { diff --git a/examples/lighting-app/bouffalolab/bl702/README.md b/examples/lighting-app/bouffalolab/bl702/README.md index 0339fcedf3052d..f02b1b84758f86 100644 --- a/examples/lighting-app/bouffalolab/bl702/README.md +++ b/examples/lighting-app/bouffalolab/bl702/README.md @@ -1,14 +1,14 @@ -# CHIP BL702 Lighting App Example +# CHIP BL70X Lighting App Example -## Supported Hardware +BL70X is highly integrated BLE and IEEE 802.15.4 combo chip for IoT +applications, and BL702 is a general name for BL70X family. -Current supported develop boards: +This example is powered by BL706 and functions as a Thread light bulb device +type, with on/off, level and color capabilities. The steps were verified with +following boards: -- BL702-IoT-DVK -- BL706-IoT-DVK -- BL706-NIGHT-LIGHT - > Note, please make sure both of flash and `PSRAM` shipped with develop - > board/device are at lease 2MB. + - BL706-IoT-DVK + - BL706-NIGHT-LIGHT ## Build @@ -49,29 +49,19 @@ Current supported develop boards: ./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-IoT-DVK ``` - - Build lighting-app for board BL702-IOT-DVK module_type is - `BL706C-22` by default. Please execute the following command to - build lighting-app for BL702-IoT-DVK with module `BL702` - - ```shell - ./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL702-IoT-DVK module_type="BL702" - ``` - - Build lighting-app for board BL706-NIGHT-LIGHT - ```shell - ./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-NIGHT-LIGHT module_type="BL702" - ``` - - > Note, please check which module is used on the board. + ```shell + ./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-NIGHT-LIGHT + ``` - - With UART shell command support: + - With UART shell command enabled: ```shell ./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-IoT-DVK chip_build_libshell=true ``` - - With pigweed RPC support: + - With pigweed RPC enabled: ```shell ./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-IoT-DVK 'import("//with_pw_rpc.gni")' ``` @@ -79,21 +69,37 @@ Current supported develop boards: - Build with `build_examples.py` - - Build for BL702-IoT-DVK, BL706-IoT-DVK and BL706-NIGHT-LIGHT as - following commands. + - Build for BL706-IoT-DVK and BL706-NIGHT-LIGHT as following commands. ```shell - ./scripts/build/build_examples.py --target bouffalolab-BL702-IoT-DVK-light build ./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light build ./scripts/build/build_examples.py --target bouffalolab-BL706-NIGHT-LIGHT-light build ``` - - Build with pigweed RPC support as following commands. + - Build with pigweed RPC enabled as following commands. ```shell - ./scripts/build/build_examples.py --target bouffalolab-BL702-IoT-DVK-light-rpc build ./scripts/build/build_examples.py --target bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc build ``` +- Build options + + - Build options list There are some build options for function and debug + purpose as below. + - `chip_build_libshell`, whether to enable shell command line. It is + set to false by default. + - `baudrate`, UART baudrate for log output or shell command line. + - `enable_psram`, whether to enable `PSRAM`. It is set to true by + default. + - How to use Before using these build options, please check whether they + are available to configure in BUILD.gn file under example application + folder. + - build with `build_examples.py` Modify value of build options in + BUILD.gn file under example application folder. + - build with gn_bouffalolab_example.sh Input build options, such as + ``` + ./scripts/examples/gn_bouffalolab_example.sh lighting-app out/debug BL706-IoT-DVK chip_build_libshell=true + ``` + - Download image - Using script `chip-bl702-lighting-example.flash.py`. diff --git a/examples/platform/bouffalolab/bl602/route_hook/bl_route_hook.c b/examples/platform/bouffalolab/bl602/route_hook/bl_route_hook.c new file mode 100644 index 00000000000000..230cccadd52657 --- /dev/null +++ b/examples/platform/bouffalolab/bl602/route_hook/bl_route_hook.c @@ -0,0 +1,206 @@ +#include +#include + +#include "bl_route_hook.h" +#include "bl_route_table.h" +#include "utils_log.h" + +#include "lwip/icmp6.h" +#include "lwip/mld6.h" +#include "lwip/netif.h" +#include "lwip/prot/icmp6.h" +#include "lwip/prot/ip6.h" +#include "lwip/prot/nd6.h" +#include "lwip/raw.h" + +typedef struct bl_route_hook_t +{ + struct netif * netif; + struct raw_pcb * pcb; + struct bl_route_hook_t * next; +} bl_route_hook_t; + +PACK_STRUCT_BEGIN +struct rio_header_t +{ + PACK_STRUCT_FLD_8(u8_t type); + PACK_STRUCT_FLD_8(u8_t length); + PACK_STRUCT_FLD_8(u8_t prefix_length); + PACK_STRUCT_FLD_8(u8_t preference); + PACK_STRUCT_FIELD(u32_t route_lifetime); +} PACK_STRUCT_STRUCT; +PACK_STRUCT_END + +typedef struct rio_header_t rio_header_t; + +static bl_route_hook_t * s_hooks; + +static bool is_self_address(struct netif * netif, const ip6_addr_t * addr) +{ + for (size_t i = 0; i < LWIP_ARRAYSIZE(netif->ip6_addr); i++) + { + if (ip6_addr_isvalid(netif_ip6_addr_state(netif, i)) && + memcmp(addr->addr, netif_ip6_addr(netif, i)->addr, sizeof(addr->addr)) == 0) + { + return true; + } + } + return false; +} + +static void ra_recv_handler(struct netif * netif, const uint8_t * icmp_payload, uint16_t payload_len, const ip6_addr_t * src_addr) +{ + if (payload_len < sizeof(struct ra_header)) + { + return; + } + icmp_payload += sizeof(struct ra_header); + payload_len -= sizeof(struct ra_header); + + while (payload_len >= 2) + { + uint8_t opt_type = icmp_payload[0]; + uint8_t opt_len = icmp_payload[1] << 3; + + if (opt_type == ND6_OPTION_TYPE_ROUTE_INFO && opt_len >= sizeof(rio_header_t) && !is_self_address(netif, src_addr) && + payload_len >= opt_len) + { + rio_header_t rio_header; + memcpy(&rio_header, icmp_payload, sizeof(rio_header)); + + // skip if prefix is longer than IPv6 address. + if (rio_header.prefix_length > 128) + { + break; + } + uint8_t prefix_len_bytes = (rio_header.prefix_length + 7) / 8; + int8_t preference = -2 * ((rio_header.preference >> 4) & 1) + (((rio_header.preference) >> 3) & 1); + const uint8_t * rio_data = &icmp_payload[sizeof(rio_header_t)]; + uint8_t rio_data_len = opt_len - sizeof(rio_header_t); + + log_info("Received RIO\n"); + if (rio_data_len >= prefix_len_bytes) + { + ip6_addr_t prefix; + bl_route_entry_t route; + + memset(&prefix, 0, sizeof(prefix)); + memcpy(&prefix.addr, rio_data, prefix_len_bytes); + route.netif = netif; + route.gateway = *src_addr; + route.prefix_length = rio_header.prefix_length; + route.prefix = prefix; + route.preference = preference; + route.lifetime_seconds = lwip_ntohl(rio_header.route_lifetime); + log_info("prefix %s lifetime %u\n", ip6addr_ntoa(&prefix), route.lifetime_seconds); + if (bl_route_table_add_route_entry(&route) == NULL) + { + log_error("Failed to add route table entry\n"); + } + else + { + log_info("Added entry to route table\n"); + } + } + } + icmp_payload += opt_len; + payload_len -= opt_len; + } +} + +static uint8_t icmp6_raw_recv_handler(void * arg, struct raw_pcb * pcb, struct pbuf * p, const ip_addr_t * addr) +{ + uint8_t * icmp_payload = NULL; + uint16_t icmp_payload_len; + struct ip6_hdr * ip6_header = (struct ip6_hdr *) p->payload; + struct icmp6_hdr * icmp6_header; + ip6_addr_t src; + ip6_addr_t dest; + bl_route_hook_t * hook = (bl_route_hook_t *) arg; + + memcpy(src.addr, ip6_header->src.addr, sizeof(src.addr)); + memcpy(dest.addr, ip6_header->dest.addr, sizeof(dest.addr)); +#if LWIP_IPV6_SCOPES + src.zone = 0; +#endif + + if (p->tot_len != p->len) + { + log_error("Ignore segmented ICMP packet\n"); + return 0; + } + if (p->tot_len <= sizeof(struct ip6_hdr) + sizeof(struct icmp6_hdr)) + { + log_error("Ignore invalid ICMP packet\n"); + return 0; + } + if (!ip6_addr_islinklocal(&dest) && !ip6_addr_isallnodes_linklocal(&dest) && !ip6_addr_isallrouters_linklocal(&dest)) + { + return 0; + } + + icmp_payload_len = p->tot_len - sizeof(struct ip6_hdr); + icmp_payload = p->payload + sizeof(struct ip6_hdr); + + icmp6_header = (struct icmp6_hdr *) icmp_payload; + if (icmp6_header->type == ICMP6_TYPE_RA) + { + ra_recv_handler(hook->netif, icmp_payload, icmp_payload_len, &src); + } + return 0; +} + +int8_t bl_route_hook_init() +{ + struct netif * lwip_netif = wifi_mgmr_sta_netif_get(); + ip_addr_t router_group = IPADDR6_INIT_HOST(0xFF020000, 0, 0, 0x02); + bl_route_hook_t * hook = NULL; + uint8_t ret = 0; + + if (lwip_netif == NULL) + { + log_error("Invalid network interface\n"); + return -1; + } + + for (bl_route_hook_t * iter = s_hooks; iter != NULL; iter++) + { + if (iter->netif == lwip_netif) + { + log_error("Hook already installed on netif, skip...\n"); + return 0; + } + } + + hook = (bl_route_hook_t *) malloc(sizeof(bl_route_hook_t)); + if (hook == NULL) + { + log_error("Cannot allocate hook\n"); + return -1; + } + + if (mld6_joingroup_netif(lwip_netif, ip_2_ip6(&router_group)) != ERR_OK) + { + log_error("Failed to join multicast group\n"); + ret = -1; + goto exit; + } + + hook->netif = lwip_netif; + hook->pcb = raw_new_ip_type(IPADDR_TYPE_V6, IP6_NEXTH_ICMP6); + hook->pcb->flags |= RAW_FLAGS_MULTICAST_LOOP; + hook->pcb->chksum_reqd = 1; + // The ICMPv6 header checksum offset + hook->pcb->chksum_offset = 2; + raw_bind_netif(hook->pcb, lwip_netif); + raw_recv(hook->pcb, icmp6_raw_recv_handler, hook); + hook->next = s_hooks; + s_hooks = hook; + +exit: + if (ret != 0 && hook != NULL) + { + free(hook); + } + return ret; +} diff --git a/examples/platform/bouffalolab/bl602/route_hook/bl_route_hook.h b/examples/platform/bouffalolab/bl602/route_hook/bl_route_hook.h new file mode 100644 index 00000000000000..80c8bfec06a56a --- /dev/null +++ b/examples/platform/bouffalolab/bl602/route_hook/bl_route_hook.h @@ -0,0 +1,10 @@ +#include +#ifdef __cplusplus +extern "C" { +#endif + +int8_t bl_route_hook_init(void); + +#ifdef __cplusplus +} +#endif diff --git a/examples/platform/bouffalolab/bl602/route_hook/bl_route_table.c b/examples/platform/bouffalolab/bl602/route_hook/bl_route_table.c new file mode 100644 index 00000000000000..4d2c90129712bf --- /dev/null +++ b/examples/platform/bouffalolab/bl602/route_hook/bl_route_table.c @@ -0,0 +1,174 @@ +#include "bl_route_table.h" +#include +#include + +#include "lwip/ip6_addr.h" +#include "lwip/netif.h" +#include "lwip/timeouts.h" + +#define MAX_RIO_ROUTE 20 +#define MAX_RIO_TIMEOUT UINT32_MAX / (1000 * 4) // lwIP defined reasonable timeout value + +static bl_route_entry_t s_route_entries[MAX_RIO_ROUTE]; + +static bl_route_entry_t * find_route_entry(const bl_route_entry_t * route_entry) +{ + for (size_t i = 0; i < LWIP_ARRAYSIZE(s_route_entries); i++) + { + if (s_route_entries[i].netif == NULL) + { + break; + } + if (s_route_entries[i].netif == route_entry->netif && s_route_entries[i].prefix_length == route_entry->prefix_length && + memcmp(s_route_entries[i].gateway.addr, route_entry->gateway.addr, sizeof(route_entry->gateway.addr)) == 0 && + memcmp(s_route_entries[i].prefix.addr, route_entry->prefix.addr, route_entry->prefix_length / 8) == 0) + { + return &s_route_entries[i]; + } + } + return NULL; +} + +static bl_route_entry_t * find_empty_route_entry(void) +{ + for (size_t i = 0; i < LWIP_ARRAYSIZE(s_route_entries); i++) + { + if (s_route_entries[i].netif == NULL) + { + return &s_route_entries[i]; + } + } + return NULL; +} + +static void route_timeout_handler(void * arg) +{ + bl_route_entry_t * route = (bl_route_entry_t *) arg; + + bl_route_table_remove_route_entry(route); +} + +bl_route_entry_t * bl_route_table_add_route_entry(const bl_route_entry_t * route_entry) +{ + if (route_entry == NULL || (route_entry->lifetime_seconds > MAX_RIO_TIMEOUT && route_entry->lifetime_seconds != UINT32_MAX)) + { + return NULL; + } + + bl_route_entry_t * entry = find_route_entry(route_entry); + + if (entry == NULL) + { + entry = find_empty_route_entry(); + if (entry == NULL) + { + return NULL; + } + entry->netif = route_entry->netif; + entry->gateway = route_entry->gateway; + ip6_addr_assign_zone(&entry->gateway, IP6_UNICAST, entry->netif); + entry->prefix = route_entry->prefix; + entry->prefix_length = route_entry->prefix_length; + } + else + { + sys_untimeout(route_timeout_handler, entry); + } + entry->preference = route_entry->preference; + entry->lifetime_seconds = route_entry->lifetime_seconds; + if (entry->lifetime_seconds != UINT32_MAX) + { + sys_timeout(entry->lifetime_seconds * 1000, route_timeout_handler, entry); + } + return entry; +} + +int8_t bl_route_table_remove_route_entry(bl_route_entry_t * route_entry) +{ + if (route_entry < &s_route_entries[0] || route_entry > &s_route_entries[LWIP_ARRAYSIZE(s_route_entries)]) + { + return -1; + } + route_entry->netif = NULL; + for (bl_route_entry_t * moved = route_entry; moved < &s_route_entries[LWIP_ARRAYSIZE(s_route_entries) - 1]; moved++) + { + *moved = *(moved + 1); + if (moved->netif == NULL) + { + break; + } + } + return 0; +} + +static inline bool is_better_route(const bl_route_entry_t * lhs, const bl_route_entry_t * rhs) +{ + if (rhs == NULL) + { + return true; + } + if (lhs == NULL) + { + return false; + } + return (lhs->prefix_length > rhs->prefix_length) || + (lhs->prefix_length == rhs->prefix_length && lhs->preference > rhs->preference); +} + +static inline bool route_match(const bl_route_entry_t * route, const ip6_addr_t * dest) +{ + return memcmp(dest, route->prefix.addr, route->prefix_length / 8) == 0; +} + +struct netif * lwip_hook_ip6_route(const ip6_addr_t * src, const ip6_addr_t * dest) +{ + bl_route_entry_t * route = NULL; + + for (size_t i = 0; i < LWIP_ARRAYSIZE(s_route_entries); i++) + { + if (s_route_entries[i].netif == NULL) + { + break; + } + if (route_match(&s_route_entries[i], dest) && is_better_route(&s_route_entries[i], route)) + { + route = &s_route_entries[i]; + } + } + + if (route) + { + return route->netif; + } + else + { + return NULL; + } +} + +const ip6_addr_t * lwip_hook_nd6_get_gw(struct netif * netif, const ip6_addr_t * dest) +{ + bl_route_entry_t * route = NULL; + + for (size_t i = 0; i < LWIP_ARRAYSIZE(s_route_entries); i++) + { + if (s_route_entries[i].netif == NULL) + { + break; + } + if (s_route_entries[i].netif == netif && route_match(&s_route_entries[i], dest) && + is_better_route(&s_route_entries[i], route)) + { + route = &s_route_entries[i]; + } + } + + if (route) + { + return &route->gateway; + } + else + { + return NULL; + } +} diff --git a/examples/platform/bouffalolab/bl602/route_hook/bl_route_table.h b/examples/platform/bouffalolab/bl602/route_hook/bl_route_table.h new file mode 100644 index 00000000000000..eaf0f4f8c5ec63 --- /dev/null +++ b/examples/platform/bouffalolab/bl602/route_hook/bl_route_table.h @@ -0,0 +1,76 @@ +#include + +#include "lwip/ip6_addr.h" +#include "lwip/netif.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Route table entry + * + */ +typedef struct +{ + ip6_addr_t prefix; + uint8_t prefix_length; + ip6_addr_t gateway; + int8_t preference; + uint32_t lifetime_seconds; + struct netif * netif; +} bl_route_entry_t; + +/** + * @brief Adds an entry to the route table + * + * @param[in] route_entry The route entry to be added + * + * @return + * - The pointer to the added route entry on success + * - NULL on failure + * + */ +bl_route_entry_t * bl_route_table_add_route_entry(const bl_route_entry_t * route_entry); + +/** + * @brief Removes an entry from the route table + * + * @param[in] route_entry The route entry to be removed + * + * @return + * - 0 + * - -1 The provided route_entry is not in the route table. + * + */ +int8_t bl_route_table_remove_route_entry(bl_route_entry_t * route_entry); + +/** + * @brief The lwIP ip6 route hook, called by the lwIP function ip6_route when sending packets. + * + * @param[in] src The source address + * @param[in] dest The destination address + * + * @return + * - The target interface when route found + * - NULL when route not found + * + */ +struct netif * lwip_hook_ip6_route(const ip6_addr_t * src, const ip6_addr_t * dest); + +/** + * @brief The lwIP gateway hook, called by the lwIP when deciding next hop. + * + * @param[in] netif The output network interface + * @param[in] dest The destination address + * + * @return + * - The gateway address when route found + * - NULL when route not found + * + */ +const ip6_addr_t * lwip_hook_nd6_get_gw(struct netif * netif, const ip6_addr_t * dest); + +#ifdef __cplusplus +} +#endif diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 02ef6b7c369bae..648b053c6bff54 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -621,10 +621,8 @@ def Bl602Targets(): def BouffalolabTargets(): target = Target('bouffalolab', BouffalolabBuilder) - yield target.Extend('BL706-IoT-DVK-BL706C-22-light', board=BouffalolabBoard.BL706_IoT_DVK, app=BouffalolabApp.LIGHT, enable_rpcs=False, module_type="BL706C-22") - yield target.Extend('BL702-IoT-DVK-light', board=BouffalolabBoard.BL702_IoT_DVK, app=BouffalolabApp.LIGHT, enable_rpcs=False, module_type="BL702") - yield target.Extend('BL706-IoT-DVK-BL706C-22-light-rpc', board=BouffalolabBoard.BL706_IoT_DVK, app=BouffalolabApp.LIGHT, enable_rpcs=True, module_type="BL706C-22") - yield target.Extend('BL702-IoT-DVK-light-rpc', board=BouffalolabBoard.BL702_IoT_DVK, app=BouffalolabApp.LIGHT, enable_rpcs=True, module_type="BL702") + yield target.Extend('BL706-IoT-DVK-light', board=BouffalolabBoard.BL706_IoT_DVK, app=BouffalolabApp.LIGHT, enable_rpcs=False, module_type="BL706C-22") + yield target.Extend('BL706-IoT-DVK-light-rpc', board=BouffalolabBoard.BL706_IoT_DVK, app=BouffalolabApp.LIGHT, enable_rpcs=True, module_type="BL706C-22") yield target.Extend('BL706-NIGHT-LIGHT-light', board=BouffalolabBoard.BL706_NIGHT_LIGHT, app=BouffalolabApp.LIGHT, enable_rpcs=False, module_type="BL702") diff --git a/scripts/build/builders/bouffalolab.py b/scripts/build/builders/bouffalolab.py index 8e7fdeedfb93ce..b391251093653f 100644 --- a/scripts/build/builders/bouffalolab.py +++ b/scripts/build/builders/bouffalolab.py @@ -43,14 +43,11 @@ def FlashBundleName(self): class BouffalolabBoard(Enum): BL706_IoT_DVK = 1 - BL702_IoT_DVK = 2 - BL706_NIGHT_LIGHT = 3 + BL706_NIGHT_LIGHT = 2 def GnArgName(self): if self == BouffalolabBoard.BL706_IoT_DVK: return 'BL706-IoT-DVK' - elif self == BouffalolabBoard.BL702_IoT_DVK: - return 'BL702-IoT-DVK' elif self == BouffalolabBoard.BL706_NIGHT_LIGHT: return 'BL706-NIGHT-LIGHT' else: @@ -63,7 +60,7 @@ def __init__(self, root, runner, app: BouffalolabApp = BouffalolabApp.LIGHT, - board: BouffalolabBoard = BouffalolabBoard.BL702_IoT_DVK, + board: BouffalolabBoard = BouffalolabBoard.BL706_IoT_DVK, enable_rpcs: bool = False, module_type: str = "BL706C-22", ): diff --git a/scripts/build/testdata/all_targets_except_host.txt b/scripts/build/testdata/all_targets_except_host.txt index 1252a0dae7f059..c30e44fc41b5e6 100644 --- a/scripts/build/testdata/all_targets_except_host.txt +++ b/scripts/build/testdata/all_targets_except_host.txt @@ -18,10 +18,8 @@ android-x64-tv-server android-x86-chip-tool android-x86-tv-server bl602-light -bouffalolab-BL702-IoT-DVK-light -bouffalolab-BL702-IoT-DVK-light-rpc -bouffalolab-BL706-IoT-DVK-BL706C-22-light -bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc +bouffalolab-BL706-IoT-DVK-light +bouffalolab-BL706-IoT-DVK-light-rpc bouffalolab-BL706-NIGHT-LIGHT-light cc13x2x7_26x2x7-all-clusters cc13x2x7_26x2x7-all-clusters-minimal diff --git a/scripts/build/testdata/build_all_except_host.txt b/scripts/build/testdata/build_all_except_host.txt index ebfb4ad3070bae..d6548b7e44ffa6 100644 --- a/scripts/build/testdata/build_all_except_host.txt +++ b/scripts/build/testdata/build_all_except_host.txt @@ -151,17 +151,11 @@ bash -c 'yes | TEST_ANDROID_HOME/tools/bin/sdkmanager --licenses >/dev/null' # Generating bl602-light gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl602 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" bl602_board="BL-HWC-G1"' {out}/bl602-light -# Generating bouffalolab-BL702-IoT-DVK-light -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl702 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" board="BL702-IoT-DVK" module_type="BL702"' {out}/bouffalolab-BL702-IoT-DVK-light +# Generating bouffalolab-BL706-IoT-DVK-light +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl702 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" board="BL706-IoT-DVK" module_type="BL706C-22"' {out}/bouffalolab-BL706-IoT-DVK-light -# Generating bouffalolab-BL702-IoT-DVK-light-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl702 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" board="BL702-IoT-DVK" module_type="BL702" import("//with_pw_rpc.gni")' {out}/bouffalolab-BL702-IoT-DVK-light-rpc - -# Generating bouffalolab-BL706-IoT-DVK-BL706C-22-light -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl702 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" board="BL706-IoT-DVK" module_type="BL706C-22"' {out}/bouffalolab-BL706-IoT-DVK-BL706C-22-light - -# Generating bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl702 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" board="BL706-IoT-DVK" module_type="BL706C-22" import("//with_pw_rpc.gni")' {out}/bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc +# Generating bouffalolab-BL706-IoT-DVK-light-rpc +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl702 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" board="BL706-IoT-DVK" module_type="BL706C-22" import("//with_pw_rpc.gni")' {out}/bouffalolab-BL706-IoT-DVK-light-rpc # Generating bouffalolab-BL706-NIGHT-LIGHT-light gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lighting-app/bouffalolab/bl702 '--args=custom_toolchain="{root}/../../examples/platform/bouffalolab/common/toolchain:riscv_gcc" board="BL706-NIGHT-LIGHT" module_type="BL702"' {out}/bouffalolab-BL706-NIGHT-LIGHT-light @@ -1559,17 +1553,11 @@ cp {out}/android-x86-tv-server/lib/TvApp.jar {root}/examples/tv-app/android/App/ # Building bl602-light ninja -C {out}/bl602-light -# Building bouffalolab-BL702-IoT-DVK-light -ninja -C {out}/bouffalolab-BL702-IoT-DVK-light - -# Building bouffalolab-BL702-IoT-DVK-light-rpc -ninja -C {out}/bouffalolab-BL702-IoT-DVK-light-rpc - -# Building bouffalolab-BL706-IoT-DVK-BL706C-22-light -ninja -C {out}/bouffalolab-BL706-IoT-DVK-BL706C-22-light +# Building bouffalolab-BL706-IoT-DVK-light +ninja -C {out}/bouffalolab-BL706-IoT-DVK-light -# Building bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc -ninja -C {out}/bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc +# Building bouffalolab-BL706-IoT-DVK-light-rpc +ninja -C {out}/bouffalolab-BL706-IoT-DVK-light-rpc # Building bouffalolab-BL706-NIGHT-LIGHT-light ninja -C {out}/bouffalolab-BL706-NIGHT-LIGHT-light diff --git a/scripts/build/testdata/glob_star_targets_except_host.txt b/scripts/build/testdata/glob_star_targets_except_host.txt index 04111a9ba7b770..ecf21d637c058a 100644 --- a/scripts/build/testdata/glob_star_targets_except_host.txt +++ b/scripts/build/testdata/glob_star_targets_except_host.txt @@ -18,10 +18,8 @@ android-x64-tv-server android-x86-chip-tool android-x86-tv-server bl602-light -bouffalolab-BL702-IoT-DVK-light -bouffalolab-BL702-IoT-DVK-light-rpc -bouffalolab-BL706-IoT-DVK-BL706C-22-light -bouffalolab-BL706-IoT-DVK-BL706C-22-light-rpc +bouffalolab-BL706-IoT-DVK-light +bouffalolab-BL706-IoT-DVK-light-rpc bouffalolab-BL706-NIGHT-LIGHT-light cc13x2x7_26x2x7-all-clusters cc13x2x7_26x2x7-all-clusters-minimal diff --git a/scripts/examples/gn_bouffalolab_example.sh b/scripts/examples/gn_bouffalolab_example.sh index 3dd3a0c34da6cd..f04307607ba30b 100755 --- a/scripts/examples/gn_bouffalolab_example.sh +++ b/scripts/examples/gn_bouffalolab_example.sh @@ -31,7 +31,7 @@ source "$MATTER_ROOT/scripts/activate.sh" # export PATH="$BL_IOT_SDK_PATH/toolchain/riscv/Darwin/bin:$PATH" # fi -bl702_boards=("BL702-IoT-DVK" "BL706-IoT-DVK" "BL706-NIGHT-LIGHT") +bl702_boards=("BL706-IoT-DVK" "BL706-NIGHT-LIGHT") bl702_modules=("BL702" "BL706C-22") bl702_module_type="BL706C-22" diff --git a/scripts/requirements.bouffalolab.txt b/scripts/requirements.bouffalolab.txt index 20ecc8ba62dba7..ceda55f866c282 100644 --- a/scripts/requirements.bouffalolab.txt +++ b/scripts/requirements.bouffalolab.txt @@ -1 +1 @@ -bflb-iot-tool \ No newline at end of file +bflb-iot-tool>=1.8.0 ; platform_machine != 'aarch64' and sys_platform == 'linux' \ No newline at end of file diff --git a/src/platform/bouffalolab/BL602/BLEManagerImpl.cpp b/src/platform/bouffalolab/BL602/BLEManagerImpl.cpp index cf00d6a00095ce..825a28f4cdb1e1 100644 --- a/src/platform/bouffalolab/BL602/BLEManagerImpl.cpp +++ b/src/platform/bouffalolab/BL602/BLEManagerImpl.cpp @@ -15,18 +15,11 @@ * limitations under the License. */ -/** - * @file - * Provides an implementation of the BLEManager singleton object - * for the BL602 platform. - */ - #define __ZEPHYR__ 1 #include #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE -// #include #include "BLEManagerImpl.h" #include @@ -34,27 +27,16 @@ #include #include #include +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +#include +#endif extern "C" { -// #include #include - -#if 0 -// BaseType_t xPortIsInsideInterrupt(void) __attribute__((weak, alias("_xPortIsInsideInterrupt"))); -// BaseType_t _xPortIsInsideInterrupt(void) -BaseType_t xPortIsInsideInterrupt(void) -{ - return TrapNetCounter ? 1 : 0; -} -#endif } #include #include -// #include -// #include -// #include -// #include using namespace ::chip; using namespace ::chip::Ble; @@ -64,132 +46,98 @@ namespace chip { namespace DeviceLayer { namespace Internal { -namespace { - const bt_uuid_128 UUID128_CHIPoBLEChar_RX = BT_UUID_INIT_128(0x11, 0x9D, 0x9F, 0x42, 0x9C, 0x4F, 0x9F, 0x95, 0x59, 0x45, 0x3D, 0x26, 0xF5, 0x2E, 0xEE, 0x18); const bt_uuid_128 UUID128_CHIPoBLEChar_TX = BT_UUID_INIT_128(0x12, 0x9D, 0x9F, 0x42, 0x9C, 0x4F, 0x9F, 0x95, 0x59, 0x45, 0x3D, 0x26, 0xF5, 0x2E, 0xEE, 0x18); bt_uuid_16 UUID16_CHIPoBLEService = BT_UUID_INIT_16(0xFFF6); -// #define UUID128_CHIPoBLEChar_RX BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x119d9f42, 0x9c4f, 0x9f95, 0x5945, 0x3d26f52eee18)) -// #define UUID128_CHIPoBLEChar_TX BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x129d9f42, 0x9c4f, 0x9f95, 0x5945, 0x3d26f52eee18)) -// #define UUID16_CHIPoBLEService BT_UUID_DECLARE_16(0xFFF6) - const ChipBleUUID chipUUID_CHIPoBLEChar_RX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0x3D, 0x45, 0x59, 0x95, 0x9F, 0x4F, 0x9C, 0x42, 0x9F, 0x9D, 0x11 } }; const ChipBleUUID chipUUID_CHIPoBLEChar_TX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0x3D, 0x45, 0x59, 0x95, 0x9F, 0x4F, 0x9C, 0x42, 0x9F, 0x9D, 0x12 } }; +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +const bt_uuid_128 UUID128_CHIPoBLEChar_C3 = + BT_UUID_INIT_128(0x04, 0x8F, 0x21, 0x83, 0x8A, 0x74, 0x7D, 0xB8, 0xF2, 0x45, 0x72, 0x87, 0x38, 0x02, 0x63, 0x64); +#endif _bt_gatt_ccc CHIPoBLEChar_TX_CCC = BT_GATT_CCC_INITIALIZER(nullptr, BLEManagerImpl::HandleTXCCCWrite, nullptr); -// clang-format off - -BT_GATT_SERVICE_DEFINE(_3_CHIPoBLE_Service, +struct bt_gatt_attr sChipoBleAttributes[] = { BT_GATT_PRIMARY_SERVICE(&UUID16_CHIPoBLEService.uuid), - BT_GATT_CHARACTERISTIC(&UUID128_CHIPoBLEChar_RX.uuid, - BT_GATT_CHRC_WRITE | BT_GATT_CHRC_WRITE_WITHOUT_RESP, - BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, - nullptr, BLEManagerImpl::HandleRXWrite, nullptr), - BT_GATT_CHARACTERISTIC(&UUID128_CHIPoBLEChar_TX.uuid, - BT_GATT_CHRC_NOTIFY, - BT_GATT_PERM_NONE, - nullptr, nullptr, nullptr), - BT_GATT_CCC_MANAGED(&CHIPoBLEChar_TX_CCC, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE) -); - -// static struct bt_gatt_attr attr = BT_GATT_PRIMARY_SERVICE(UUID16_CHIPoBLEService); + BT_GATT_CHARACTERISTIC(&UUID128_CHIPoBLEChar_RX.uuid, BT_GATT_CHRC_WRITE | BT_GATT_CHRC_WRITE_WITHOUT_RESP, + BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, nullptr, BLEManagerImpl::HandleRXWrite, nullptr), + BT_GATT_CHARACTERISTIC(&UUID128_CHIPoBLEChar_TX.uuid, BT_GATT_CHRC_INDICATE, BT_GATT_PERM_NONE, nullptr, nullptr, nullptr), + BT_GATT_CCC_MANAGED(&CHIPoBLEChar_TX_CCC, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE), +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + BT_GATT_CHARACTERISTIC(&UUID128_CHIPoBLEChar_C3.uuid, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, BLEManagerImpl::HandleC3Read, + nullptr, nullptr), +#endif +}; -// clang-format on +struct bt_gatt_service sChipoBleService = { + .attrs = sChipoBleAttributes, + .attr_count = sizeof(sChipoBleAttributes) / sizeof(sChipoBleAttributes[0]), +}; -// Index of the CCC descriptor in the CHIPoBLE_Service array of attributes. -// This value should be adjusted accordingly if the service declaration changes. -constexpr int kCHIPoBLE_CCC_AttributeIndex = 3; +static const int kCHIPoBLE_CCC_AttributeIndex = 3; -void InitRandomStaticAddress() +CHIP_ERROR InitRandomStaticAddress() { -#if !CONFIG_BT_PRIVACY // When the BT privacy feature is disabled, generate a random static address once per boot. // This must be done before bt_enable() has been called. bt_addr_le_t addr; int error = bt_addr_le_create_static(&addr); - VerifyOrReturn(error == 0, ChipLogError(DeviceLayer, "Failed to create BLE address: %d", error)); + if (error) + { + ChipLogError(DeviceLayer, "Failed to create BLE address: %d", error); + return System::MapErrorZephyr(error); + } error = bt_id_create(&addr, nullptr); - VerifyOrReturn(error == 0, ChipLogError(DeviceLayer, "Failed to create BLE identity: %d", error)); - - ChipLogProgress(DeviceLayer, "BLE address was set to %02X:%02X:%02X:%02X:%02X:%02X", addr.a.val[5], addr.a.val[4], - addr.a.val[3], addr.a.val[2], addr.a.val[1], addr.a.val[0]); -#endif -} -} // unnamed namespace - -BLEManagerImpl BLEManagerImpl::sInstance; - -static void bt_enable_cb(int err) -{ - log_info("err: %d\r\n", err); - if (!err) + if (error < 0) { - log_info("trace\r\n"); - // ble_cli_register(); - // log_info("trace\r\n"); + ChipLogError(DeviceLayer, "Failed to create BLE identity: %d", error); + return System::MapErrorZephyr(error); } -} -// static extern "C" void ble_stack_start(void) -static void ble_stack_start(void) -{ - log_info("trace\r\n"); - // Initialize BLE controller - ble_controller_init(configMAX_PRIORITIES - 1); - log_info("trace\r\n"); - // Initialize BLE Host stack - hci_driver_init(); - log_info("trace\r\n"); - bt_enable(bt_enable_cb); - log_info("trace\r\n"); + ChipLogProgress(DeviceLayer, "BLE address: %02X:%02X:%02X:%02X:%02X:%02X", addr.a.val[5], addr.a.val[4], addr.a.val[3], + addr.a.val[2], addr.a.val[1], addr.a.val[0]); + return CHIP_NO_ERROR; } +BLEManagerImpl BLEManagerImpl::sInstance; + CHIP_ERROR BLEManagerImpl::_Init() { - CHIP_ERROR err; - log_info("trace\r\n"); mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Enabled; mFlags.ClearAll().Set(Flags::kAdvertisingEnabled, CHIP_DEVICE_CONFIG_CHIPOBLE_ENABLE_ADVERTISING_AUTOSTART); mFlags.Set(Flags::kFastAdvertisingEnabled, true); mGAPConns = 0; - log_info("trace\r\n"); memset(mSubscribedConns, 0, sizeof(mSubscribedConns)); - InitRandomStaticAddress(); - log_info("trace\r\n"); - // err = bt_enable(NULL); - // log_info("err: %d\r\n", err); - // VerifyOrExit(err == CHIP_NO_ERROR, err = MapErrorZephyr(err)); - ble_stack_start(); + ReturnErrorOnFailure(InitRandomStaticAddress()); + + ble_controller_init(configMAX_PRIORITIES - 1); + hci_driver_init(); + bt_enable(NULL); memset(&mConnCallbacks, 0, sizeof(mConnCallbacks)); mConnCallbacks.connected = HandleConnect; mConnCallbacks.disconnected = HandleDisconnect; - log_info("trace\r\n"); bt_conn_cb_register(&mConnCallbacks); - log_info("trace\r\n"); // Initialize the CHIP BleLayer. - err = BleLayer::Init(this, this, &DeviceLayer::SystemLayer()); - log_info("err: %d\r\n", err); + ReturnErrorOnFailure(BleLayer::Init(this, this, &DeviceLayer::SystemLayer())); PlatformMgr().ScheduleWork(DriveBLEState, 0); - log_info("trace\r\n"); -exit: - return err; + return CHIP_NO_ERROR; } void BLEManagerImpl::DriveBLEState(intptr_t arg) @@ -201,8 +149,6 @@ void BLEManagerImpl::DriveBLEState() { CHIP_ERROR err = CHIP_NO_ERROR; - ChipLogDetail(DeviceLayer, "In DriveBLEState"); - // Perform any initialization actions that must occur after the CHIP task is running. if (!mFlags.Has(Flags::kAsyncInitCompleted)) { @@ -227,11 +173,27 @@ void BLEManagerImpl::DriveBLEState() SuccessOrExit(err); } } - // Otherwise, stop advertising if currently active. else { - err = StopAdvertising(); - SuccessOrExit(err); + if (mFlags.Has(Flags::kAdvertising)) + { + err = StopAdvertising(); + SuccessOrExit(err); + } + + // If no connections are active unregister also CHIPoBLE GATT service + if (NumConnections() == 0 && mFlags.Has(Flags::kChipoBleGattServiceRegister)) + { + // Unregister CHIPoBLE service to not allow discovering it when pairing is disabled. + if (bt_gatt_service_unregister(&sChipoBleService) != 0) + { + ChipLogError(DeviceLayer, "Failed to unregister CHIPoBLE GATT service"); + } + else + { + mFlags.Clear(Flags::kChipoBleGattServiceRegister); + } + } } exit: @@ -251,35 +213,54 @@ struct BLEManagerImpl::ServiceData CHIP_ERROR BLEManagerImpl::StartAdvertising(void) { int err = 0; - const char * deviceName = bt_get_name(); - const uint8_t advFlags = BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR; const bool isAdvertisingRerun = mFlags.Has(Flags::kAdvertising); // At first run always select fast advertising, on the next attempt slow down interval. - const uint16_t intervalMin = mFlags.Has(Flags::kFastAdvertisingEnabled) ? CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN + const uint32_t intervalMin = mFlags.Has(Flags::kFastAdvertisingEnabled) ? CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MIN : CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MIN; - const uint16_t intervalMax = mFlags.Has(Flags::kFastAdvertisingEnabled) ? CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX + const uint32_t intervalMax = mFlags.Has(Flags::kFastAdvertisingEnabled) ? CHIP_DEVICE_CONFIG_BLE_FAST_ADVERTISING_INTERVAL_MAX : CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX; - // bt_le_adv_param advParams = - // BT_LE_ADV_PARAM_INIT(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME, intervalMin, intervalMax, nullptr); bt_le_adv_param advParams; advParams.id = BT_ID_DEFAULT; advParams.options = BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME; advParams.interval_min = intervalMin; advParams.interval_max = intervalMax; - // Define advertising data + // Define advertising and, if BLE device name is set, scan response data ServiceData serviceData; - bt_data ad[] = { BT_DATA(BT_DATA_FLAGS, &advFlags, sizeof(advFlags)), - BT_DATA(BT_DATA_SVC_DATA16, &serviceData, sizeof(serviceData)), - BT_DATA(BT_DATA_NAME_COMPLETE, deviceName, static_cast(strlen(deviceName))) }; + const uint8_t advFlags = BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR; + const bt_data advertisingData[] = { BT_DATA(BT_DATA_FLAGS, &advFlags, sizeof(advFlags)), + BT_DATA(BT_DATA_SVC_DATA16, &serviceData, sizeof(serviceData)) }; + + const char * deviceName = bt_get_name(); + const uint8_t deviceNameSize = static_cast(strlen(deviceName)); + const bt_data scanResponseData[] = { BT_DATA(BT_DATA_NAME_COMPLETE, deviceName, deviceNameSize) }; + const bt_data * scanResponseDataPtr = deviceNameSize > 0 ? scanResponseData : nullptr; + const size_t scanResponseDataLen = deviceNameSize > 0 ? sizeof(scanResponseData) / sizeof(scanResponseData[0]) : 0u; + + // Register dynamically CHIPoBLE GATT service + if (!mFlags.Has(Flags::kChipoBleGattServiceRegister)) + { + err = bt_gatt_service_register(&sChipoBleService); + + if (err != 0) + ChipLogError(DeviceLayer, "Failed to register CHIPoBLE GATT service"); + + VerifyOrReturnError(err == 0, MapErrorZephyr(err)); + + mFlags.Set(Flags::kChipoBleGattServiceRegister); + } // Initialize service data static_assert(sizeof(serviceData) == 10, "Size of BLE advertisement data changed! Was that intentional?"); chip::Encoding::LittleEndian::Put16(serviceData.uuid, UUID16_CHIPoBLEService.val); ReturnErrorOnFailure(ConfigurationMgr().GetBLEDeviceIdentificationInfo(serviceData.deviceIdInfo)); +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + ReturnErrorOnFailure(PrepareC3CharData()); +#endif + if (!isAdvertisingRerun) { #if CONFIG_BT_PRIVACY @@ -296,7 +277,8 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) err = bt_le_adv_stop(); VerifyOrReturnError(err == 0, MapErrorZephyr(err)); - err = bt_le_adv_start(&advParams, ad, ARRAY_SIZE(ad), nullptr, 0u); + err = bt_le_adv_start(&advParams, advertisingData, sizeof(advertisingData) / sizeof(advertisingData[0]), scanResponseDataPtr, + scanResponseDataLen); VerifyOrReturnError(err == 0, MapErrorZephyr(err)); // Transition to the Advertising state... @@ -311,7 +293,7 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Started; - PlatformMgr().PostEvent(&advChange); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&advChange)); } if (mFlags.Has(Flags::kFastAdvertisingEnabled)) @@ -344,7 +326,7 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void) ChipDeviceEvent advChange; advChange.Type = DeviceEventType::kCHIPoBLEAdvertisingChange; advChange.CHIPoBLEAdvertisingChange.Result = kActivity_Stopped; - PlatformMgr().PostEvent(&advChange); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&advChange)); } // Cancel timer event changing CHIPoBLE advertisement interval @@ -356,20 +338,18 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void) CHIP_ERROR BLEManagerImpl::_SetAdvertisingEnabled(bool val) { - CHIP_ERROR err = CHIP_NO_ERROR; - - VerifyOrExit(mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, err = CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); + VerifyOrReturnError(mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_NotSupported, + CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); if (mFlags.Has(Flags::kAdvertisingEnabled) != val) { - ChipLogDetail(DeviceLayer, "SetAdvertisingEnabled(%s)", val ? "true" : "false"); + ChipLogDetail(DeviceLayer, "CHIPoBLE advertising set to %s", val ? "on" : "off"); mFlags.Set(Flags::kAdvertisingEnabled, val); PlatformMgr().ScheduleWork(DriveBLEState, 0); } -exit: - return err; + return CHIP_NO_ERROR; } CHIP_ERROR BLEManagerImpl::_SetAdvertisingMode(BLEAdvertisingMode mode) @@ -399,7 +379,7 @@ CHIP_ERROR BLEManagerImpl::_GetDeviceName(char * buf, size_t bufSize) CHIP_ERROR BLEManagerImpl::_SetDeviceName(const char * deviceName) { - if (mServiceMode != ConnectivityManager::kCHIPoBLEServiceMode_NotSupported) + if (mServiceMode == ConnectivityManager::kCHIPoBLEServiceMode_NotSupported) { return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } @@ -419,7 +399,7 @@ CHIP_ERROR BLEManagerImpl::HandleGAPConnect(const ChipDeviceEvent * event) } else { - ChipLogProgress(DeviceLayer, "BLE connection failed (reason: 0x%02x)", connEvent->HciResult); + ChipLogError(DeviceLayer, "BLE connection failed (reason: 0x%02x)", connEvent->HciResult); } ChipLogProgress(DeviceLayer, "Current number of connections: %u/%u", NumConnections(), CONFIG_BT_MAX_CONN); @@ -440,7 +420,7 @@ CHIP_ERROR BLEManagerImpl::HandleGAPDisconnect(const ChipDeviceEvent * event) mGAPConns--; - // If notifications were enabled for this connection, record that they are now disabled and + // If indications were enabled for this connection, record that they are now disabled and // notify the BLE Layer of a disconnect. if (UnsetSubscribed(connEvent->BtConn)) { @@ -468,6 +448,10 @@ CHIP_ERROR BLEManagerImpl::HandleGAPDisconnect(const ChipDeviceEvent * event) ChipLogProgress(DeviceLayer, "Current number of connections: %u/%u", NumConnections(), CONFIG_BT_MAX_CONN); + ChipDeviceEvent disconnectEvent; + disconnectEvent.Type = DeviceEventType::kCHIPoBLEConnectionClosed; + ReturnErrorOnFailure(PlatformMgr().PostEvent(&disconnectEvent)); + // Force a reconfiguration of advertising in case we switched to non-connectable mode when // the BLE connection was established. mFlags.Set(Flags::kAdvertisingRefreshNeeded); @@ -482,8 +466,8 @@ CHIP_ERROR BLEManagerImpl::HandleTXCharCCCDWrite(const ChipDeviceEvent * event) ChipLogDetail(DeviceLayer, "ConnId: 0x%02x, New CCCD value: 0x%04x", bt_conn_index(writeEvent->BtConn), writeEvent->Value); - // If the client has requested to enable notifications and if it is not yet subscribed - if (writeEvent->Value != 0 && SetSubscribed(writeEvent->BtConn)) + // If the client has requested to enable indications and if it is not yet subscribed + if (writeEvent->Value == BT_GATT_CCC_INDICATE && SetSubscribed(writeEvent->BtConn)) { // Alert the BLE layer that CHIPoBLE "subscribe" has been received and increment the bt_conn reference counter. HandleSubscribeReceived(writeEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_TX); @@ -495,7 +479,7 @@ CHIP_ERROR BLEManagerImpl::HandleTXCharCCCDWrite(const ChipDeviceEvent * event) { ChipDeviceEvent conEstEvent; conEstEvent.Type = DeviceEventType::kCHIPoBLEConnectionEstablished; - PlatformMgr().PostEvent(&conEstEvent); + ReturnErrorOnFailure(PlatformMgr().PostEvent(&conEstEvent)); } } else @@ -513,30 +497,64 @@ CHIP_ERROR BLEManagerImpl::HandleTXCharCCCDWrite(const ChipDeviceEvent * event) CHIP_ERROR BLEManagerImpl::HandleRXCharWrite(const ChipDeviceEvent * event) { - const BleRXWriteEventType * writeEvent = &event->Platform.BleRXWriteEvent; + const BleC1WriteEventType * c1WriteEvent = &event->Platform.BleC1WriteEvent; - ChipLogDetail(DeviceLayer, "Write request received for CHIPoBLE RX (ConnId 0x%02x)", bt_conn_index(writeEvent->BtConn)); + ChipLogDetail(DeviceLayer, "Write request received for CHIPoBLE RX characteristic (ConnId 0x%02x)", + bt_conn_index(c1WriteEvent->BtConn)); - HandleWriteReceived(writeEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_RX, - PacketBufferHandle::Adopt(writeEvent->Data)); - bt_conn_unref(writeEvent->BtConn); + HandleWriteReceived(c1WriteEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_RX, + PacketBufferHandle::Adopt(c1WriteEvent->Data)); + bt_conn_unref(c1WriteEvent->BtConn); return CHIP_NO_ERROR; } CHIP_ERROR BLEManagerImpl::HandleTXCharComplete(const ChipDeviceEvent * event) { - const BleTXCompleteEventType * completeEvent = &event->Platform.BleTXCompleteEvent; + const BleC2IndDoneEventType * c2IndDoneEvent = &event->Platform.BleC2IndDoneEvent; - ChipLogDetail(DeviceLayer, "Notification for CHIPoBLE TX done (ConnId 0x%02x)", bt_conn_index(completeEvent->BtConn)); + ChipLogDetail(DeviceLayer, "Indication for CHIPoBLE TX characteristic done (ConnId 0x%02x, result 0x%02x)", + bt_conn_index(c2IndDoneEvent->BtConn), c2IndDoneEvent->Result); - // Signal the BLE Layer that the outstanding notification is complete. - HandleIndicationConfirmation(completeEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_TX); - bt_conn_unref(completeEvent->BtConn); + // Signal the BLE Layer that the outstanding indication is complete. + HandleIndicationConfirmation(c2IndDoneEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_TX); + bt_conn_unref(c2IndDoneEvent->BtConn); return CHIP_NO_ERROR; } +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +CHIP_ERROR BLEManagerImpl::PrepareC3CharData() +{ + CHIP_ERROR err = CHIP_NO_ERROR; + BitFlags additionalDataFields; + AdditionalDataPayloadGeneratorParams additionalDataPayloadParams; + +#if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID) + uint8_t rotatingDeviceIdUniqueId[ConfigurationManager::kRotatingDeviceIDUniqueIDLength] = {}; + MutableByteSpan rotatingDeviceIdUniqueIdSpan(rotatingDeviceIdUniqueId); + + err = DeviceLayer::GetDeviceInstanceInfoProvider()->GetRotatingDeviceIdUniqueId(rotatingDeviceIdUniqueIdSpan); + SuccessOrExit(err); + err = ConfigurationMgr().GetLifetimeCounter(additionalDataPayloadParams.rotatingDeviceIdLifetimeCounter); + SuccessOrExit(err); + additionalDataPayloadParams.rotatingDeviceIdUniqueId = rotatingDeviceIdUniqueIdSpan; + additionalDataFields.Set(AdditionalDataFields::RotatingDeviceId); +#endif /* CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID) */ + + err = AdditionalDataPayloadGenerator().generateAdditionalDataPayload(additionalDataPayloadParams, c3CharDataBufferHandle, + additionalDataFields); + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to generate TLV encoded Additional Data (%s)", __func__); + } + + return err; +} +#endif + void BLEManagerImpl::HandleBLEAdvertisementIntervalChange(System::Layer * layer, void * param) { BLEMgr().SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising); @@ -561,29 +579,21 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) err = HandleTXCharCCCDWrite(event); break; - case DeviceEventType::kPlatformZephyrBleRXWrite: + case DeviceEventType::kPlatformZephyrBleC1WriteEvent: err = HandleRXCharWrite(event); break; - case DeviceEventType::kPlatformZephyrBleTXComplete: + case DeviceEventType::kPlatformZephyrBleC2IndDoneEvent: err = HandleTXCharComplete(event); break; - case DeviceEventType::kServiceProvisioningChange: - // Force the advertising state to be refreshed to reflect new provisioning state. - mFlags.Set(Flags::kAdvertisingRefreshNeeded); - - DriveBLEState(); - - break; - default: break; } if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "Disabling CHIPoBLE service due to error: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "Disabling CHIPoBLE service due to error: %" CHIP_ERROR_FORMAT, err.Format()); mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Disabled; PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -597,7 +607,7 @@ uint16_t BLEManagerImpl::_NumConnections(void) bool BLEManagerImpl::CloseConnection(BLE_CONNECTION_OBJECT conId) { ChipLogProgress(DeviceLayer, "Closing BLE GATT connection (ConnId %02x)", bt_conn_index((bt_conn *) conId)); - return bt_conn_disconnect(conId, BT_HCI_ERR_REMOTE_USER_TERM_CONN) == 0; + return bt_conn_disconnect((bt_conn *) conId, BT_HCI_ERR_REMOTE_USER_TERM_CONN) == 0; } uint16_t BLEManagerImpl::GetMTU(BLE_CONNECTION_OBJECT conId) const @@ -620,30 +630,30 @@ bool BLEManagerImpl::UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, cons bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId, PacketBufferHandle pBuf) { - log_info("\r\n"); - CHIP_ERROR err = CHIP_NO_ERROR; - int status = 0; - uint8_t index = bt_conn_index((bt_conn *) conId); - bt_gatt_notify_params * params = &mNotifyParams[index]; + CHIP_ERROR err = CHIP_NO_ERROR; + int status = 0; + uint8_t index = bt_conn_index(conId); + bt_gatt_indicate_params * params = &mIndicateParams[index]; - VerifyOrExit(IsSubscribed((bt_conn *) conId) == true, err = CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrExit(IsSubscribed(conId) == true, err = CHIP_ERROR_INVALID_ARGUMENT); - ChipLogDetail(DeviceLayer, "Sending notification for CHIPoBLE TX (ConnId %02x, len %u)", index, pBuf->DataLength()); + ChipLogDetail(DeviceLayer, "Sending indication for CHIPoBLE TX characteristic (ConnId %02x, len %u)", index, + pBuf->DataLength()); - params->uuid = nullptr; - params->attr = &_3_CHIPoBLE_Service.attrs[kCHIPoBLE_CCC_AttributeIndex]; - params->data = pBuf->Start(); - params->len = pBuf->DataLength(); - params->func = HandleTXCompleted; - params->user_data = nullptr; + params->uuid = nullptr; + params->attr = &sChipoBleAttributes[kCHIPoBLE_CCC_AttributeIndex]; + params->func = HandleTXIndicated; + params->data = pBuf->Start(); + params->len = pBuf->DataLength(); - status = bt_gatt_notify_cb(conId, params); + status = bt_gatt_indicate(conId, params); VerifyOrExit(status == 0, err = MapErrorZephyr(status)); exit: if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "Sending notification for CHIPoBLE TX failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "BLEManagerImpl::SendIndication() failed: %." CHIP_ERROR_FORMAT, err.Format()); + ChipLogError(DeviceLayer, "BLEManagerImpl::SendIndication() failed: %d", status); } return err == CHIP_NO_ERROR; @@ -672,7 +682,7 @@ bool BLEManagerImpl::SendReadResponse(BLE_CONNECTION_OBJECT conId, BLE_READ_REQU void BLEManagerImpl::NotifyChipConnectionClosed(BLE_CONNECTION_OBJECT conId) { - // Intentionally empty. + CloseConnection(conId); } bool BLEManagerImpl::IsSubscribed(bt_conn * conn) @@ -686,6 +696,8 @@ bool BLEManagerImpl::SetSubscribed(bt_conn * conn) bool isSubscribed = mSubscribedConns[index]; mSubscribedConns[index] = true; + ChipLogError(DeviceLayer, "BLEManagerImpl::SetSubscribed %u", index); + // If we were not subscribed previously, increment the reference counter of the connection. if (!isSubscribed) { @@ -716,23 +728,12 @@ ssize_t BLEManagerImpl::HandleRXWrite(struct bt_conn * conId, const struct bt_ga ChipDeviceEvent event; PacketBufferHandle packetBuf = PacketBufferHandle::NewWithData(buf, len); - // Unfortunately the Zephyr logging macros end up assigning uint16_t - // variables to uint16_t:10 fields, which triggers integer conversion - // warnings. And treating the Zephyr headers as system headers does not - // help, apparently. Just turn off that warning around this log call. -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" - // LOG_HEXDUMP_DBG(buf, len, "Rx char write"); - blog_debug_hexdump("Rx char write", buf, len); -#pragma GCC diagnostic pop - - // If successful... if (!packetBuf.IsNull()) { // Arrange to post a CHIPoBLERXWriteEvent event to the CHIP queue. - event.Type = DeviceEventType::kPlatformZephyrBleRXWrite; - event.Platform.BleRXWriteEvent.BtConn = bt_conn_ref(conId); - event.Platform.BleRXWriteEvent.Data = std::move(packetBuf).UnsafeRelease(); + event.Type = DeviceEventType::kPlatformZephyrBleC1WriteEvent; + event.Platform.BleC1WriteEvent.BtConn = bt_conn_ref(conId); + event.Platform.BleC1WriteEvent.Data = std::move(packetBuf).UnsafeRelease(); } // If we failed to allocate a buffer, post a kPlatformZephyrBleOutOfBuffersEvent event. @@ -741,7 +742,7 @@ ssize_t BLEManagerImpl::HandleRXWrite(struct bt_conn * conId, const struct bt_ga event.Type = DeviceEventType::kPlatformZephyrBleOutOfBuffersEvent; } - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventOrDie(&event); return len; } @@ -750,53 +751,85 @@ bool BLEManagerImpl::HandleTXCCCWrite(struct bt_conn * conId, const struct bt_ga { ChipDeviceEvent event; - if (value != BT_GATT_CCC_NOTIFY && value != 0) + if (value != BT_GATT_CCC_INDICATE && value != 0) { - // return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); - return false; + return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } event.Type = DeviceEventType::kPlatformZephyrBleCCCWrite; event.Platform.BleCCCWriteEvent.BtConn = bt_conn_ref(conId); event.Platform.BleCCCWriteEvent.Value = value; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventOrDie(&event); - return true; + return sizeof(value); } -void BLEManagerImpl::HandleTXCompleted(struct bt_conn * conId, void * /* param */) +void BLEManagerImpl::HandleTXIndicated(struct bt_conn * conId, IndicationAttrType, uint8_t err) { ChipDeviceEvent event; - event.Type = DeviceEventType::kPlatformZephyrBleTXComplete; - event.Platform.BleTXCompleteEvent.BtConn = bt_conn_ref(conId); + event.Type = DeviceEventType::kPlatformZephyrBleC2IndDoneEvent; + event.Platform.BleC2IndDoneEvent.BtConn = bt_conn_ref(conId); + event.Platform.BleC2IndDoneEvent.Result = err; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventOrDie(&event); } void BLEManagerImpl::HandleConnect(struct bt_conn * conId, uint8_t err) { ChipDeviceEvent event; + PlatformMgr().LockChipStack(); + + // Don't handle BLE connecting events when it is not related to CHIPoBLE + VerifyOrExit(sInstance.mFlags.Has(Flags::kChipoBleGattServiceRegister), ); + event.Type = DeviceEventType::kPlatformZephyrBleConnected; event.Platform.BleConnEvent.BtConn = bt_conn_ref(conId); event.Platform.BleConnEvent.HciResult = err; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventOrDie(&event); + +exit: + PlatformMgr().UnlockChipStack(); } void BLEManagerImpl::HandleDisconnect(struct bt_conn * conId, uint8_t reason) { ChipDeviceEvent event; + PlatformMgr().LockChipStack(); + + // Don't handle BLE disconnecting events when it is not related to CHIPoBLE + VerifyOrExit(sInstance.mFlags.Has(Flags::kChipoBleGattServiceRegister), ); + event.Type = DeviceEventType::kPlatformZephyrBleDisconnected; event.Platform.BleConnEvent.BtConn = bt_conn_ref(conId); event.Platform.BleConnEvent.HciResult = reason; - PlatformMgr().PostEvent(&event); + PlatformMgr().PostEventOrDie(&event); + +exit: + PlatformMgr().UnlockChipStack(); } +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +ssize_t BLEManagerImpl::HandleC3Read(struct bt_conn * conId, const struct bt_gatt_attr * attr, void * buf, uint16_t len, + uint16_t offset) +{ + ChipLogDetail(DeviceLayer, "Read request received for CHIPoBLE C3 (ConnId 0x%02x)", bt_conn_index(conId)); + + if (sInstance.c3CharDataBufferHandle.IsNull()) + { + return 0; + } + + return bt_gatt_attr_read(conId, attr, buf, len, offset, sInstance.c3CharDataBufferHandle->Start(), + sInstance.c3CharDataBufferHandle->DataLength()); +} +#endif + } // namespace Internal } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/bouffalolab/BL602/BLEManagerImpl.h b/src/platform/bouffalolab/BL602/BLEManagerImpl.h index 33ab32a4078cd6..0f9ff7666a1c1e 100644 --- a/src/platform/bouffalolab/BL602/BLEManagerImpl.h +++ b/src/platform/bouffalolab/BL602/BLEManagerImpl.h @@ -1,6 +1,6 @@ /* - * - * Copyright (c) 2020-2021 Project CHIP Authors + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,12 +15,6 @@ * limitations under the License. */ -/** - * @file - * Provides an implementation of the BLEManager singleton object - * for the BL602 platform. - */ - #pragma once #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE @@ -38,7 +32,7 @@ namespace Internal { using namespace chip::Ble; /** - * Concrete implementation of the BLEManager singleton object for the BL602 platform. + * Concrete implementation of the BLEManager singleton object for the BL702 platform. */ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePlatformDelegate, private BleApplicationDelegate { @@ -48,7 +42,9 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla private: // ===== Members that implement the BLEManager internal interface. - + using IndicationAttrType = + std::conditional_t::value, + bt_gatt_indicate_params *, const bt_gatt_attr *>; CHIP_ERROR _Init(void); void _Shutdown() {} bool _IsAdvertisingEnabled(void); @@ -90,6 +86,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla kAdvertising = 0x0008, /**< The system is currently CHIPoBLE advertising. */ kAdvertisingRefreshNeeded = 0x0010, /**< The advertising state/configuration has changed, but the SoftDevice has yet to be updated. */ + kChipoBleGattServiceRegister = 0x0020, /**< The system has currently CHIPoBLE GATT service registered. */ }; struct ServiceData; @@ -98,8 +95,11 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla uint16_t mGAPConns; CHIPoBLEServiceMode mServiceMode; bool mSubscribedConns[CONFIG_BT_MAX_CONN]; - bt_gatt_notify_params mNotifyParams[CONFIG_BT_MAX_CONN]; + bt_gatt_indicate_params mIndicateParams[CONFIG_BT_MAX_CONN]; bt_conn_cb mConnCallbacks; +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + PacketBufferHandle c3CharDataBufferHandle; +#endif void DriveBLEState(void); CHIP_ERROR ConfigureAdvertising(void); @@ -110,6 +110,9 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla CHIP_ERROR HandleRXCharWrite(const ChipDeviceEvent * event); CHIP_ERROR HandleTXCharCCCDWrite(const ChipDeviceEvent * event); CHIP_ERROR HandleTXCharComplete(const ChipDeviceEvent * event); +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + CHIP_ERROR PrepareC3CharData(); +#endif bool IsSubscribed(bt_conn * conn); bool SetSubscribed(bt_conn * conn); bool UnsetSubscribed(bt_conn * conn); @@ -118,7 +121,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla static void DriveBLEState(intptr_t arg); // Below callbacks run from the system workqueue context and have a limited stack capacity. - static void HandleTXCompleted(bt_conn * conn, void * param); + static void HandleTXIndicated(bt_conn * conn, IndicationAttrType attr, uint8_t err); static void HandleConnect(bt_conn * conn, uint8_t err); static void HandleDisconnect(bt_conn * conn, uint8_t reason); static void HandleBLEAdvertisementIntervalChange(System::Layer * layer, void * param); @@ -135,6 +138,10 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla static ssize_t HandleRXWrite(bt_conn * conn, const bt_gatt_attr * attr, const void * buf, uint16_t len, uint16_t offset, uint8_t flags); static bool HandleTXCCCWrite(bt_conn * conn, const bt_gatt_attr * attr, uint16_t value); + +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + static ssize_t HandleC3Read(struct bt_conn * conn, const struct bt_gatt_attr * attr, void * buf, uint16_t len, uint16_t offset); +#endif }; /** @@ -152,7 +159,7 @@ inline BLEManager & BLEMgr(void) * Returns the platform-specific implementation of the BLEManager singleton object. * * Internal components can use this to gain access to features of the BLEManager - * that are specific to the BL602 platform. + * that are specific to the BL702 platform. */ inline BLEManagerImpl & BLEMgrImpl(void) { diff --git a/src/platform/bouffalolab/BL602/CHIPDevicePlatformEvent.h b/src/platform/bouffalolab/BL602/CHIPDevicePlatformEvent.h index 76bd2bcdc0476c..1342cc24ac2830 100644 --- a/src/platform/bouffalolab/BL602/CHIPDevicePlatformEvent.h +++ b/src/platform/bouffalolab/BL602/CHIPDevicePlatformEvent.h @@ -34,7 +34,7 @@ namespace DeviceLayer { namespace DeviceEventType { /** - * Enumerates BL602 platform-specific event types that are visible to the application. + * Enumerates Zephyr platform-specific event types that are visible to the application. */ enum PublicPlatformSpecificEventTypes { @@ -42,7 +42,7 @@ enum PublicPlatformSpecificEventTypes }; /** - * Enumerates BL602 platform-specific event types that are internal to the chip Device Layer. + * Enumerates Zephyr platform-specific event types that are internal to the chip Device Layer. */ enum InternalPlatformSpecificEventTypes { @@ -50,8 +50,8 @@ enum InternalPlatformSpecificEventTypes kPlatformZephyrBleConnected, kPlatformZephyrBleDisconnected, kPlatformZephyrBleCCCWrite, - kPlatformZephyrBleRXWrite, - kPlatformZephyrBleTXComplete, + kPlatformZephyrBleC1WriteEvent, + kPlatformZephyrBleC2IndDoneEvent, kPlatformZephyrBleOutOfBuffersEvent, }; @@ -69,19 +69,20 @@ struct BleCCCWriteEventType uint16_t Value; }; -struct BleRXWriteEventType +struct BleC1WriteEventType { bt_conn * BtConn; ::chip::System::PacketBuffer * Data; }; -struct BleTXCompleteEventType +struct BleC2IndDoneEventType { bt_conn * BtConn; + uint8_t Result; }; /** - * Represents platform-specific event information for the BL602 platform. + * Represents platform-specific event information for BL602 platforms. */ struct ChipDevicePlatformEvent final { @@ -89,8 +90,8 @@ struct ChipDevicePlatformEvent final { BleConnEventType BleConnEvent; BleCCCWriteEventType BleCCCWriteEvent; - BleRXWriteEventType BleRXWriteEvent; - BleTXCompleteEventType BleTXCompleteEvent; + BleC1WriteEventType BleC1WriteEvent; + BleC2IndDoneEventType BleC2IndDoneEvent; }; }; diff --git a/src/platform/bouffalolab/BL602/ConnectivityManagerImpl.cpp b/src/platform/bouffalolab/BL602/ConnectivityManagerImpl.cpp index 99aef24aac007e..02d296c492abd9 100644 --- a/src/platform/bouffalolab/BL602/ConnectivityManagerImpl.cpp +++ b/src/platform/bouffalolab/BL602/ConnectivityManagerImpl.cpp @@ -165,5 +165,15 @@ void ConnectivityManagerImpl::ChangeWiFiStationState(WiFiStationState newState) } } +void ConnectivityManagerImpl::OnIPv6AddressAvailable() +{ + ChipLogProgress(DeviceLayer, "IPv6 addr available."); + + ChipDeviceEvent event; + event.Type = DeviceEventType::kInterfaceIpAddressChanged; + event.InterfaceIpAddressChanged.Type = InterfaceIpChangeType::kIpV6_Assigned; + PlatformMgr().PostEventOrDie(&event); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/bouffalolab/BL602/ConnectivityManagerImpl.h b/src/platform/bouffalolab/BL602/ConnectivityManagerImpl.h index 692a4ae16ed1f9..3efacc02c75043 100644 --- a/src/platform/bouffalolab/BL602/ConnectivityManagerImpl.h +++ b/src/platform/bouffalolab/BL602/ConnectivityManagerImpl.h @@ -75,6 +75,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, void WifiStationStateChange(void); void OnStationConnected(void); void ChangeWiFiStationState(WiFiStationState newState); + void OnIPv6AddressAvailable(); private: // ===== Members that implement the ConnectivityManager abstract interface. diff --git a/src/platform/bouffalolab/BL602/DnssdImpl.cpp b/src/platform/bouffalolab/BL602/DnssdImpl.cpp index 15e2c984c272e8..398bfbfa5caf65 100644 --- a/src/platform/bouffalolab/BL602/DnssdImpl.cpp +++ b/src/platform/bouffalolab/BL602/DnssdImpl.cpp @@ -224,18 +224,6 @@ int mdns_responder_ops(struct netif * netif) mdns.slot_idx++; mdns_resp_announce(netif); -#if 0 - // for ota - slot = - mdns_resp_add_service(netif, "MATTER OTA", "_ota", static_cast(glservice->mProtocol), 3333, 1000, ota_txt, NULL); - if (slot < 0) - { - mdns_resp_remove_netif(netif); - mdns_resp_deinit(); - log_info("ota mdns fail.\r\n"); - } -#endif - return slot; } diff --git a/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp b/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp index 930ff9cd292bdf..8524bc51f4a0a7 100644 --- a/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp +++ b/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp @@ -203,6 +203,11 @@ void OnWiFiPlatformEvent(input_event_t * event, void * private_data) WifiStaConnected(); } break; + case CODE_WIFI_ON_GOT_IP6: { + log_info("[APP] [EVT] GOT IP6 %lld\r\n", aos_now_ms()); + ConnectivityMgrImpl().OnIPv6AddressAvailable(); + } + break; default: { log_info("[APP] [EVT] Unknown code %u, %lld\r\n", event->code, aos_now_ms()); /*nothing*/ diff --git a/src/platform/bouffalolab/BL702/BLEManagerImpl.cpp b/src/platform/bouffalolab/BL702/BLEManagerImpl.cpp index 72be562a444a7c..2a90fdf646aaba 100644 --- a/src/platform/bouffalolab/BL702/BLEManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702/BLEManagerImpl.cpp @@ -15,12 +15,6 @@ * limitations under the License. */ -/** - * @file - * Provides an implementation of the BLEManager singleton object - * for the BL702 platform. - */ - #define __ZEPHYR__ 1 #include @@ -32,6 +26,9 @@ #include #include #include +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +#include +#endif extern "C" { #include @@ -59,6 +56,10 @@ const ChipBleUUID chipUUID_CHIPoBLEChar_RX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0 const ChipBleUUID chipUUID_CHIPoBLEChar_TX = { { 0x18, 0xEE, 0x2E, 0xF5, 0x26, 0x3D, 0x45, 0x59, 0x95, 0x9F, 0x4F, 0x9C, 0x42, 0x9F, 0x9D, 0x12 } }; +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +const bt_uuid_128 UUID128_CHIPoBLEChar_C3 = + BT_UUID_INIT_128(0x04, 0x8F, 0x21, 0x83, 0x8A, 0x74, 0x7D, 0xB8, 0xF2, 0x45, 0x72, 0x87, 0x38, 0x02, 0x63, 0x64); +#endif _bt_gatt_ccc CHIPoBLEChar_TX_CCC = BT_GATT_CCC_INITIALIZER(nullptr, BLEManagerImpl::HandleTXCCCWrite, nullptr); @@ -66,8 +67,12 @@ struct bt_gatt_attr sChipoBleAttributes[] = { BT_GATT_PRIMARY_SERVICE(&UUID16_CHIPoBLEService.uuid), BT_GATT_CHARACTERISTIC(&UUID128_CHIPoBLEChar_RX.uuid, BT_GATT_CHRC_WRITE | BT_GATT_CHRC_WRITE_WITHOUT_RESP, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE, nullptr, BLEManagerImpl::HandleRXWrite, nullptr), - BT_GATT_CHARACTERISTIC(&UUID128_CHIPoBLEChar_TX.uuid, BT_GATT_CHRC_NOTIFY, BT_GATT_PERM_NONE, nullptr, nullptr, nullptr), - BT_GATT_CCC_MANAGED(&CHIPoBLEChar_TX_CCC, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE) + BT_GATT_CHARACTERISTIC(&UUID128_CHIPoBLEChar_TX.uuid, BT_GATT_CHRC_INDICATE, BT_GATT_PERM_NONE, nullptr, nullptr, nullptr), + BT_GATT_CCC_MANAGED(&CHIPoBLEChar_TX_CCC, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE), +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + BT_GATT_CHARACTERISTIC(&UUID128_CHIPoBLEChar_C3.uuid, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, BLEManagerImpl::HandleC3Read, + nullptr, nullptr), +#endif }; struct bt_gatt_service sChipoBleService = { @@ -251,6 +256,10 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) chip::Encoding::LittleEndian::Put16(serviceData.uuid, UUID16_CHIPoBLEService.val); ReturnErrorOnFailure(ConfigurationMgr().GetBLEDeviceIdentificationInfo(serviceData.deviceIdInfo)); +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + ReturnErrorOnFailure(PrepareC3CharData()); +#endif + if (!isAdvertisingRerun) { #if CONFIG_BT_PRIVACY @@ -410,7 +419,7 @@ CHIP_ERROR BLEManagerImpl::HandleGAPDisconnect(const ChipDeviceEvent * event) mGAPConns--; - // If notifications were enabled for this connection, record that they are now disabled and + // If indications were enabled for this connection, record that they are now disabled and // notify the BLE Layer of a disconnect. if (UnsetSubscribed(connEvent->BtConn)) { @@ -456,8 +465,8 @@ CHIP_ERROR BLEManagerImpl::HandleTXCharCCCDWrite(const ChipDeviceEvent * event) ChipLogDetail(DeviceLayer, "ConnId: 0x%02x, New CCCD value: 0x%04x", bt_conn_index(writeEvent->BtConn), writeEvent->Value); - // If the client has requested to enable notifications and if it is not yet subscribed - if (writeEvent->Value != 0 && SetSubscribed(writeEvent->BtConn)) + // If the client has requested to enable indications and if it is not yet subscribed + if (writeEvent->Value == BT_GATT_CCC_INDICATE && SetSubscribed(writeEvent->BtConn)) { // Alert the BLE layer that CHIPoBLE "subscribe" has been received and increment the bt_conn reference counter. HandleSubscribeReceived(writeEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_TX); @@ -487,30 +496,64 @@ CHIP_ERROR BLEManagerImpl::HandleTXCharCCCDWrite(const ChipDeviceEvent * event) CHIP_ERROR BLEManagerImpl::HandleRXCharWrite(const ChipDeviceEvent * event) { - const BleRXWriteEventType * writeEvent = &event->Platform.BleRXWriteEvent; + const BleC1WriteEventType * c1WriteEvent = &event->Platform.BleC1WriteEvent; - ChipLogDetail(DeviceLayer, "Write request received for CHIPoBLE RX (ConnId 0x%02x)", bt_conn_index(writeEvent->BtConn)); + ChipLogDetail(DeviceLayer, "Write request received for CHIPoBLE RX characteristic (ConnId 0x%02x)", + bt_conn_index(c1WriteEvent->BtConn)); - HandleWriteReceived(writeEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_RX, - PacketBufferHandle::Adopt(writeEvent->Data)); - bt_conn_unref(writeEvent->BtConn); + HandleWriteReceived(c1WriteEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_RX, + PacketBufferHandle::Adopt(c1WriteEvent->Data)); + bt_conn_unref(c1WriteEvent->BtConn); return CHIP_NO_ERROR; } CHIP_ERROR BLEManagerImpl::HandleTXCharComplete(const ChipDeviceEvent * event) { - const BleTXCompleteEventType * completeEvent = &event->Platform.BleTXCompleteEvent; + const BleC2IndDoneEventType * c2IndDoneEvent = &event->Platform.BleC2IndDoneEvent; - ChipLogDetail(DeviceLayer, "Notification for CHIPoBLE TX done (ConnId 0x%02x)", bt_conn_index(completeEvent->BtConn)); + ChipLogDetail(DeviceLayer, "Indication for CHIPoBLE TX characteristic done (ConnId 0x%02x, result 0x%02x)", + bt_conn_index(c2IndDoneEvent->BtConn), c2IndDoneEvent->Result); - // Signal the BLE Layer that the outstanding notification is complete. - HandleIndicationConfirmation(completeEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_TX); - bt_conn_unref(completeEvent->BtConn); + // Signal the BLE Layer that the outstanding indication is complete. + HandleIndicationConfirmation(c2IndDoneEvent->BtConn, &CHIP_BLE_SVC_ID, &chipUUID_CHIPoBLEChar_TX); + bt_conn_unref(c2IndDoneEvent->BtConn); return CHIP_NO_ERROR; } +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +CHIP_ERROR BLEManagerImpl::PrepareC3CharData() +{ + CHIP_ERROR err = CHIP_NO_ERROR; + BitFlags additionalDataFields; + AdditionalDataPayloadGeneratorParams additionalDataPayloadParams; + +#if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID) + uint8_t rotatingDeviceIdUniqueId[ConfigurationManager::kRotatingDeviceIDUniqueIDLength] = {}; + MutableByteSpan rotatingDeviceIdUniqueIdSpan(rotatingDeviceIdUniqueId); + + err = DeviceLayer::GetDeviceInstanceInfoProvider()->GetRotatingDeviceIdUniqueId(rotatingDeviceIdUniqueIdSpan); + SuccessOrExit(err); + err = ConfigurationMgr().GetLifetimeCounter(additionalDataPayloadParams.rotatingDeviceIdLifetimeCounter); + SuccessOrExit(err); + additionalDataPayloadParams.rotatingDeviceIdUniqueId = rotatingDeviceIdUniqueIdSpan; + additionalDataFields.Set(AdditionalDataFields::RotatingDeviceId); +#endif /* CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID) */ + + err = AdditionalDataPayloadGenerator().generateAdditionalDataPayload(additionalDataPayloadParams, c3CharDataBufferHandle, + additionalDataFields); + +exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to generate TLV encoded Additional Data (%s)", __func__); + } + + return err; +} +#endif + void BLEManagerImpl::HandleBLEAdvertisementIntervalChange(System::Layer * layer, void * param) { BLEMgr().SetAdvertisingMode(BLEAdvertisingMode::kSlowAdvertising); @@ -535,29 +578,21 @@ void BLEManagerImpl::_OnPlatformEvent(const ChipDeviceEvent * event) err = HandleTXCharCCCDWrite(event); break; - case DeviceEventType::kPlatformZephyrBleRXWrite: + case DeviceEventType::kPlatformZephyrBleC1WriteEvent: err = HandleRXCharWrite(event); break; - case DeviceEventType::kPlatformZephyrBleTXComplete: + case DeviceEventType::kPlatformZephyrBleC2IndDoneEvent: err = HandleTXCharComplete(event); break; - case DeviceEventType::kServiceProvisioningChange: - // Force the advertising state to be refreshed to reflect new provisioning state. - mFlags.Set(Flags::kAdvertisingRefreshNeeded); - - DriveBLEState(); - - break; - default: break; } if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "Disabling CHIPoBLE service due to error: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "Disabling CHIPoBLE service due to error: %" CHIP_ERROR_FORMAT, err.Format()); mServiceMode = ConnectivityManager::kCHIPoBLEServiceMode_Disabled; PlatformMgr().ScheduleWork(DriveBLEState, 0); } @@ -594,29 +629,30 @@ bool BLEManagerImpl::UnsubscribeCharacteristic(BLE_CONNECTION_OBJECT conId, cons bool BLEManagerImpl::SendIndication(BLE_CONNECTION_OBJECT conId, const ChipBleUUID * svcId, const ChipBleUUID * charId, PacketBufferHandle pBuf) { - CHIP_ERROR err = CHIP_NO_ERROR; - int status = 0; - uint8_t index = bt_conn_index((bt_conn *) conId); - bt_gatt_notify_params * params = &mNotifyParams[index]; + CHIP_ERROR err = CHIP_NO_ERROR; + int status = 0; + uint8_t index = bt_conn_index(conId); + bt_gatt_indicate_params * params = &mIndicateParams[index]; - VerifyOrExit(IsSubscribed((bt_conn *) conId) == true, err = CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrExit(IsSubscribed(conId) == true, err = CHIP_ERROR_INVALID_ARGUMENT); - ChipLogDetail(DeviceLayer, "Sending notification for CHIPoBLE TX (ConnId %02x, len %u)", index, pBuf->DataLength()); + ChipLogDetail(DeviceLayer, "Sending indication for CHIPoBLE TX characteristic (ConnId %02x, len %u)", index, + pBuf->DataLength()); - params->uuid = nullptr; - params->attr = &sChipoBleAttributes[kCHIPoBLE_CCC_AttributeIndex]; - params->data = pBuf->Start(); - params->len = pBuf->DataLength(); - params->func = HandleTXCompleted; - params->user_data = nullptr; + params->uuid = nullptr; + params->attr = &sChipoBleAttributes[kCHIPoBLE_CCC_AttributeIndex]; + params->func = HandleTXIndicated; + params->data = pBuf->Start(); + params->len = pBuf->DataLength(); - status = bt_gatt_notify_cb((bt_conn *) conId, params); + status = bt_gatt_indicate(conId, params); VerifyOrExit(status == 0, err = MapErrorZephyr(status)); exit: if (err != CHIP_NO_ERROR) { - ChipLogError(DeviceLayer, "Sending notification for CHIPoBLE TX failed: %s", ErrorStr(err)); + ChipLogError(DeviceLayer, "BLEManagerImpl::SendIndication() failed: %." CHIP_ERROR_FORMAT, err.Format()); + ChipLogError(DeviceLayer, "BLEManagerImpl::SendIndication() failed: %d", status); } return err == CHIP_NO_ERROR; @@ -692,9 +728,9 @@ ssize_t BLEManagerImpl::HandleRXWrite(struct bt_conn * conId, const struct bt_ga if (!packetBuf.IsNull()) { // Arrange to post a CHIPoBLERXWriteEvent event to the CHIP queue. - event.Type = DeviceEventType::kPlatformZephyrBleRXWrite; - event.Platform.BleRXWriteEvent.BtConn = bt_conn_ref(conId); - event.Platform.BleRXWriteEvent.Data = std::move(packetBuf).UnsafeRelease(); + event.Type = DeviceEventType::kPlatformZephyrBleC1WriteEvent; + event.Platform.BleC1WriteEvent.BtConn = bt_conn_ref(conId); + event.Platform.BleC1WriteEvent.Data = std::move(packetBuf).UnsafeRelease(); } // If we failed to allocate a buffer, post a kPlatformZephyrBleOutOfBuffersEvent event. @@ -712,9 +748,9 @@ bool BLEManagerImpl::HandleTXCCCWrite(struct bt_conn * conId, const struct bt_ga { ChipDeviceEvent event; - if (value != BT_GATT_CCC_NOTIFY && value != 0) + if (value != BT_GATT_CCC_INDICATE && value != 0) { - return false; + return BT_GATT_ERR(BT_ATT_ERR_VALUE_NOT_ALLOWED); } event.Type = DeviceEventType::kPlatformZephyrBleCCCWrite; @@ -723,15 +759,16 @@ bool BLEManagerImpl::HandleTXCCCWrite(struct bt_conn * conId, const struct bt_ga PlatformMgr().PostEventOrDie(&event); - return true; + return sizeof(value); } -void BLEManagerImpl::HandleTXCompleted(struct bt_conn * conId, void * /* param */) +void BLEManagerImpl::HandleTXIndicated(struct bt_conn * conId, IndicationAttrType, uint8_t err) { ChipDeviceEvent event; - event.Type = DeviceEventType::kPlatformZephyrBleTXComplete; - event.Platform.BleTXCompleteEvent.BtConn = bt_conn_ref(conId); + event.Type = DeviceEventType::kPlatformZephyrBleC2IndDoneEvent; + event.Platform.BleC2IndDoneEvent.BtConn = bt_conn_ref(conId); + event.Platform.BleC2IndDoneEvent.Result = err; PlatformMgr().PostEventOrDie(&event); } @@ -742,15 +779,6 @@ void BLEManagerImpl::HandleConnect(struct bt_conn * conId, uint8_t err) PlatformMgr().LockChipStack(); - // bt_le_conn_param connparam = { - // .interval_min = (u16_t)(100 / 1.25), - // .interval_max = (u16_t)(4000 / 1.25), - // .latency = 0, - // .timeout = 100 - // }; - - // bt_conn_le_param_update(conId, &connparam); - // Don't handle BLE connecting events when it is not related to CHIPoBLE VerifyOrExit(sInstance.mFlags.Has(Flags::kChipoBleGattServiceRegister), ); @@ -782,6 +810,23 @@ void BLEManagerImpl::HandleDisconnect(struct bt_conn * conId, uint8_t reason) exit: PlatformMgr().UnlockChipStack(); } + +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING +ssize_t BLEManagerImpl::HandleC3Read(struct bt_conn * conId, const struct bt_gatt_attr * attr, void * buf, uint16_t len, + uint16_t offset) +{ + ChipLogDetail(DeviceLayer, "Read request received for CHIPoBLE C3 (ConnId 0x%02x)", bt_conn_index(conId)); + + if (sInstance.c3CharDataBufferHandle.IsNull()) + { + return 0; + } + + return bt_gatt_attr_read(conId, attr, buf, len, offset, sInstance.c3CharDataBufferHandle->Start(), + sInstance.c3CharDataBufferHandle->DataLength()); +} +#endif + } // namespace Internal } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/bouffalolab/BL702/BLEManagerImpl.h b/src/platform/bouffalolab/BL702/BLEManagerImpl.h index b87b812662f00a..0f9ff7666a1c1e 100644 --- a/src/platform/bouffalolab/BL702/BLEManagerImpl.h +++ b/src/platform/bouffalolab/BL702/BLEManagerImpl.h @@ -1,6 +1,6 @@ /* - * - * Copyright (c) 2020-2021 Project CHIP Authors + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,12 +15,6 @@ * limitations under the License. */ -/** - * @file - * Provides an implementation of the BLEManager object for the Bouffalolab - * BL702 platform. - */ - #pragma once #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE @@ -48,7 +42,9 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla private: // ===== Members that implement the BLEManager internal interface. - + using IndicationAttrType = + std::conditional_t::value, + bt_gatt_indicate_params *, const bt_gatt_attr *>; CHIP_ERROR _Init(void); void _Shutdown() {} bool _IsAdvertisingEnabled(void); @@ -99,8 +95,11 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla uint16_t mGAPConns; CHIPoBLEServiceMode mServiceMode; bool mSubscribedConns[CONFIG_BT_MAX_CONN]; - bt_gatt_notify_params mNotifyParams[CONFIG_BT_MAX_CONN]; + bt_gatt_indicate_params mIndicateParams[CONFIG_BT_MAX_CONN]; bt_conn_cb mConnCallbacks; +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + PacketBufferHandle c3CharDataBufferHandle; +#endif void DriveBLEState(void); CHIP_ERROR ConfigureAdvertising(void); @@ -111,6 +110,9 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla CHIP_ERROR HandleRXCharWrite(const ChipDeviceEvent * event); CHIP_ERROR HandleTXCharCCCDWrite(const ChipDeviceEvent * event); CHIP_ERROR HandleTXCharComplete(const ChipDeviceEvent * event); +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + CHIP_ERROR PrepareC3CharData(); +#endif bool IsSubscribed(bt_conn * conn); bool SetSubscribed(bt_conn * conn); bool UnsetSubscribed(bt_conn * conn); @@ -119,7 +121,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla static void DriveBLEState(intptr_t arg); // Below callbacks run from the system workqueue context and have a limited stack capacity. - static void HandleTXCompleted(bt_conn * conn, void * param); + static void HandleTXIndicated(bt_conn * conn, IndicationAttrType attr, uint8_t err); static void HandleConnect(bt_conn * conn, uint8_t err); static void HandleDisconnect(bt_conn * conn, uint8_t reason); static void HandleBLEAdvertisementIntervalChange(System::Layer * layer, void * param); @@ -136,6 +138,10 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla static ssize_t HandleRXWrite(bt_conn * conn, const bt_gatt_attr * attr, const void * buf, uint16_t len, uint16_t offset, uint8_t flags); static bool HandleTXCCCWrite(bt_conn * conn, const bt_gatt_attr * attr, uint16_t value); + +#if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING + static ssize_t HandleC3Read(struct bt_conn * conn, const struct bt_gatt_attr * attr, void * buf, uint16_t len, uint16_t offset); +#endif }; /** diff --git a/src/platform/bouffalolab/BL702/BUILD.gn b/src/platform/bouffalolab/BL702/BUILD.gn index 86424f63d99e58..efd5564e963b43 100644 --- a/src/platform/bouffalolab/BL702/BUILD.gn +++ b/src/platform/bouffalolab/BL702/BUILD.gn @@ -1,4 +1,5 @@ -# Copyright (c) 2021 Project CHIP Authors +# Copyright (c) 2022 Project CHIP Authors +# All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/src/platform/bouffalolab/BL702/BlePlatformConfig.h b/src/platform/bouffalolab/BL702/BlePlatformConfig.h index 0116c5df59d7ca..8579667417a7c9 100644 --- a/src/platform/bouffalolab/BL702/BlePlatformConfig.h +++ b/src/platform/bouffalolab/BL702/BlePlatformConfig.h @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Texas Instruments Incorporated + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/platform/bouffalolab/BL702/CHIPDevicePlatformConfig.h b/src/platform/bouffalolab/BL702/CHIPDevicePlatformConfig.h index 9a686ff494b492..e54231f2198166 100644 --- a/src/platform/bouffalolab/BL702/CHIPDevicePlatformConfig.h +++ b/src/platform/bouffalolab/BL702/CHIPDevicePlatformConfig.h @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Texas Instruments Incorporated + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/platform/bouffalolab/BL702/CHIPDevicePlatformEvent.h b/src/platform/bouffalolab/BL702/CHIPDevicePlatformEvent.h index 8e1a89c5344a8e..d14d1f7b9bb2ac 100644 --- a/src/platform/bouffalolab/BL702/CHIPDevicePlatformEvent.h +++ b/src/platform/bouffalolab/BL702/CHIPDevicePlatformEvent.h @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Texas Instruments Incorporated + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,12 +39,12 @@ enum PublicPlatformSpecificEventTypes */ enum InternalPlatformSpecificEventTypes { - kPlatformZephyrEvent = chip::DeviceLayer::DeviceEventType::kRange_InternalPlatformSpecific, + kPlatformZephyrEvent = kRange_InternalPlatformSpecific, kPlatformZephyrBleConnected, kPlatformZephyrBleDisconnected, kPlatformZephyrBleCCCWrite, - kPlatformZephyrBleRXWrite, - kPlatformZephyrBleTXComplete, + kPlatformZephyrBleC1WriteEvent, + kPlatformZephyrBleC2IndDoneEvent, kPlatformZephyrBleOutOfBuffersEvent, }; @@ -63,15 +62,16 @@ struct BleCCCWriteEventType uint16_t Value; }; -struct BleRXWriteEventType +struct BleC1WriteEventType { bt_conn * BtConn; ::chip::System::PacketBuffer * Data; }; -struct BleTXCompleteEventType +struct BleC2IndDoneEventType { bt_conn * BtConn; + uint8_t Result; }; /** @@ -83,8 +83,8 @@ struct ChipDevicePlatformEvent final { BleConnEventType BleConnEvent; BleCCCWriteEventType BleCCCWriteEvent; - BleRXWriteEventType BleRXWriteEvent; - BleTXCompleteEventType BleTXCompleteEvent; + BleC1WriteEventType BleC1WriteEvent; + BleC2IndDoneEventType BleC2IndDoneEvent; }; }; diff --git a/src/platform/bouffalolab/BL702/CHIPPlatformConfig.h b/src/platform/bouffalolab/BL702/CHIPPlatformConfig.h index c31bb5521a1349..8187b71999d43d 100644 --- a/src/platform/bouffalolab/BL702/CHIPPlatformConfig.h +++ b/src/platform/bouffalolab/BL702/CHIPPlatformConfig.h @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Texas Instruments Incorporated + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +15,6 @@ * limitations under the License. */ -/** - * @file - * Platform-specific configuration overrides for CHIP on - * the Texas Instruments CC1352 platform. - * - * NOTE: currently a bare-bones implementation to allow for building. - */ - #pragma once #include diff --git a/src/platform/bouffalolab/BL702/CHIPmemory.cpp b/src/platform/bouffalolab/BL702/CHIPmemory.cpp index 069fe29ea0bdc9..5438016ad53d0f 100644 --- a/src/platform/bouffalolab/BL702/CHIPmemory.cpp +++ b/src/platform/bouffalolab/BL702/CHIPmemory.cpp @@ -1,6 +1,5 @@ /* - * - * Copyright (c) 2020-2021 Project CHIP Authors + * Copyright (c) 2022 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,13 +15,6 @@ * limitations under the License. */ -/** - * @file - * This file implements heap memory allocation APIs for CHIP. These functions are platform - * specific and might be C Standard Library heap functions re-direction in most of cases. - * - */ - #include #include diff --git a/src/platform/bouffalolab/BL702/ConfigurationManagerImpl.cpp b/src/platform/bouffalolab/BL702/ConfigurationManagerImpl.cpp index 11a5dbe4ca25e7..a6be2c40158d58 100644 --- a/src/platform/bouffalolab/BL702/ConfigurationManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702/ConfigurationManagerImpl.cpp @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Texas Instruments Incorporated + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +15,6 @@ * limitations under the License. */ -/** - * @file - * Provides the implementation of the Device Layer ConfigurationManager object - * for the Bouffalolab BL702 platform. - * - */ - -/* this file behaves like a config.h, comes first */ #include #include diff --git a/src/platform/bouffalolab/BL702/ConfigurationManagerImpl.h b/src/platform/bouffalolab/BL702/ConfigurationManagerImpl.h index 1d9693b891e5b8..db7668bf0f5eab 100644 --- a/src/platform/bouffalolab/BL702/ConfigurationManagerImpl.h +++ b/src/platform/bouffalolab/BL702/ConfigurationManagerImpl.h @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Texas Instruments Incorporated + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,12 +15,6 @@ * limitations under the License. */ -/** - * @file - * Provides an implementation of the ConfigurationManager object - * for the Bouffalolab bl702 platform. - */ - #pragma once #include diff --git a/src/platform/bouffalolab/BL702/ConnectivityManagerImpl.cpp b/src/platform/bouffalolab/BL702/ConnectivityManagerImpl.cpp index f3690a6c713545..cf1585a44a0e53 100644 --- a/src/platform/bouffalolab/BL702/ConnectivityManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702/ConnectivityManagerImpl.cpp @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Texas Instruments Incorporated + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,13 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @file - * Provides an implementation of the ConfigurationManager object - * for the Bouffalolab bl702 platform. - */ -/* this file behaves like a config.h, comes first */ #include #include diff --git a/src/platform/bouffalolab/BL702/ConnectivityManagerImpl.h b/src/platform/bouffalolab/BL702/ConnectivityManagerImpl.h index b5f8f5e5cbcca5..06774161b8c3f2 100644 --- a/src/platform/bouffalolab/BL702/ConnectivityManagerImpl.h +++ b/src/platform/bouffalolab/BL702/ConnectivityManagerImpl.h @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Texas Instruments Incorporated + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,11 +14,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/** - * @file - * Platform-specific connectivity manager class for the Texas - * Instruments BL702 platform. - */ #pragma once diff --git a/src/platform/bouffalolab/BL702/DeviceNetworkProvisioningDelegateImpl.cpp b/src/platform/bouffalolab/BL702/DeviceNetworkProvisioningDelegateImpl.cpp index 6e873b4ed43c92..c96218933aff2c 100644 --- a/src/platform/bouffalolab/BL702/DeviceNetworkProvisioningDelegateImpl.cpp +++ b/src/platform/bouffalolab/BL702/DeviceNetworkProvisioningDelegateImpl.cpp @@ -1,6 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/platform/bouffalolab/BL702/DeviceNetworkProvisioningDelegateImpl.h b/src/platform/bouffalolab/BL702/DeviceNetworkProvisioningDelegateImpl.h index 44d8d1a5397b6b..d81c3c9821db8a 100644 --- a/src/platform/bouffalolab/BL702/DeviceNetworkProvisioningDelegateImpl.h +++ b/src/platform/bouffalolab/BL702/DeviceNetworkProvisioningDelegateImpl.h @@ -1,6 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/src/platform/bouffalolab/BL702/DiagnosticDataProviderImpl.cpp b/src/platform/bouffalolab/BL702/DiagnosticDataProviderImpl.cpp index 3a591ef88117b7..90da3db7fab7da 100644 --- a/src/platform/bouffalolab/BL702/DiagnosticDataProviderImpl.cpp +++ b/src/platform/bouffalolab/BL702/DiagnosticDataProviderImpl.cpp @@ -1,6 +1,6 @@ /* - * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,12 +15,6 @@ * limitations under the License. */ -/** - * @file - * Provides an implementation of the DiagnosticDataProvider object - * for BL702 platform. - */ - #include #include diff --git a/src/platform/bouffalolab/BL702/DiagnosticDataProviderImpl.h b/src/platform/bouffalolab/BL702/DiagnosticDataProviderImpl.h index ba2d4b16389be9..6411b8e4cbd501 100644 --- a/src/platform/bouffalolab/BL702/DiagnosticDataProviderImpl.h +++ b/src/platform/bouffalolab/BL702/DiagnosticDataProviderImpl.h @@ -1,6 +1,6 @@ /* - * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,11 +15,6 @@ * limitations under the License. */ -/** - * @file - * Provides an implementation of the DiagnosticDataProvider object. - */ - #pragma once #include diff --git a/src/platform/bouffalolab/BL702/InetPlatformConfig.h b/src/platform/bouffalolab/BL702/InetPlatformConfig.h index 1edbefcd784d4d..088999420a6aae 100644 --- a/src/platform/bouffalolab/BL702/InetPlatformConfig.h +++ b/src/platform/bouffalolab/BL702/InetPlatformConfig.h @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +15,6 @@ * limitations under the License. */ -/** - * @file - * Platform-specific configuration overrides for the Openchip Inet - * Layer on BL702 platforms using the Bouffalolab IOT SDK. - * - */ - #pragma once // ==================== Platform Adaptations ==================== diff --git a/src/platform/bouffalolab/BL702/KeyValueStoreManagerImpl.cpp b/src/platform/bouffalolab/BL702/KeyValueStoreManagerImpl.cpp index 0231d6f823874c..929cfbace3668a 100644 --- a/src/platform/bouffalolab/BL702/KeyValueStoreManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702/KeyValueStoreManagerImpl.cpp @@ -1,6 +1,5 @@ /* - * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2022 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,11 +15,6 @@ * limitations under the License. */ -/** - * @file - * Platform-specific key value storage implementation for Bouffalolab BL702 - */ - /* this file behaves like a config.h, comes first */ #include diff --git a/src/platform/bouffalolab/BL702/KeyValueStoreManagerImpl.h b/src/platform/bouffalolab/BL702/KeyValueStoreManagerImpl.h index 0ddcf4aad0974d..65a9bfde758766 100644 --- a/src/platform/bouffalolab/BL702/KeyValueStoreManagerImpl.h +++ b/src/platform/bouffalolab/BL702/KeyValueStoreManagerImpl.h @@ -1,6 +1,5 @@ /* - * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2022 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,11 +15,6 @@ * limitations under the License. */ -/** - * @file - * Platform-specific key value storage implementation for Bouffalolab BL702 - */ - #pragma once namespace chip { diff --git a/src/platform/bouffalolab/BL702/Logging.cpp b/src/platform/bouffalolab/BL702/Logging.cpp index 58cd191453cc88..24193ea434ae28 100644 --- a/src/platform/bouffalolab/BL702/Logging.cpp +++ b/src/platform/bouffalolab/BL702/Logging.cpp @@ -1,4 +1,19 @@ -/* See Project CHIP LICENSE file for licensing information. */ +/* + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * 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 diff --git a/src/platform/bouffalolab/BL702/OTAImageProcessorImpl.cpp b/src/platform/bouffalolab/BL702/OTAImageProcessorImpl.cpp index 5d014eea06216d..c59e34d366cfc2 100644 --- a/src/platform/bouffalolab/BL702/OTAImageProcessorImpl.cpp +++ b/src/platform/bouffalolab/BL702/OTAImageProcessorImpl.cpp @@ -1,6 +1,5 @@ /* - * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2022 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/platform/bouffalolab/BL702/OTAImageProcessorImpl.h b/src/platform/bouffalolab/BL702/OTAImageProcessorImpl.h index 6ecf3e43c778c4..4bae9152f8f48c 100644 --- a/src/platform/bouffalolab/BL702/OTAImageProcessorImpl.h +++ b/src/platform/bouffalolab/BL702/OTAImageProcessorImpl.h @@ -1,6 +1,5 @@ /* - * - * Copyright (c) 2021 Project CHIP Authors + * Copyright (c) 2022 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp b/src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp index 65d61307109a36..c76b6b688f8a0f 100644 --- a/src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702/PlatformManagerImpl.cpp @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Texas Instruments Incorporated + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,12 +15,6 @@ * limitations under the License. */ -/** - * @file - * Provides an implementation of the PlatformManager object - * for the Bouffalolab BL702 platform. - */ - /* this file behaves like a config.h, comes first */ #include diff --git a/src/platform/bouffalolab/BL702/PlatformManagerImpl.h b/src/platform/bouffalolab/BL702/PlatformManagerImpl.h index 3cd7c4e2962861..31cc14ebc97168 100644 --- a/src/platform/bouffalolab/BL702/PlatformManagerImpl.h +++ b/src/platform/bouffalolab/BL702/PlatformManagerImpl.h @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Texas Instruments Incorporated + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,11 +15,6 @@ * limitations under the License. */ -/** - * @file - * Provides an implementation of the PlatformManager object. - */ - #pragma once #include diff --git a/src/platform/bouffalolab/BL702/SystemPlatformConfig.h b/src/platform/bouffalolab/BL702/SystemPlatformConfig.h index 7de2e8f6379fb0..f3f843c0d55c99 100644 --- a/src/platform/bouffalolab/BL702/SystemPlatformConfig.h +++ b/src/platform/bouffalolab/BL702/SystemPlatformConfig.h @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,13 +15,6 @@ * limitations under the License. */ -/** - * @file - * Platform-specific configuration overrides for the CHIP System - * Layer - * - */ - #pragma once #include diff --git a/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp b/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp index f165112facc91f..73a96a90a6e853 100644 --- a/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp +++ b/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.cpp @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Nest Labs, Inc. + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +15,6 @@ * limitations under the License. */ -/** - * @file - * Provides an implementation of the ThreadStackManager object for - * BL702 platforms using the Bouffalolab SDK and the OpenThread - * stack. - * - */ -/* this file behaves like a config.h, comes first */ #include #include diff --git a/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.h b/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.h index cc88caeeefbff2..61a9b72e3b6334 100644 --- a/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.h +++ b/src/platform/bouffalolab/BL702/ThreadStackManagerImpl.h @@ -1,7 +1,6 @@ /* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2020 Texas Instruments Incorporated + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,14 +15,6 @@ * limitations under the License. */ -/** - * @file - * Provides an implementation of the ThreadStackManager object - * for the Bouffalolab BL702 platform. - * - * NOTE: currently a bare-bones implementation to allow for building. - */ - #pragma once #include diff --git a/src/platform/bouffalolab/BL702/bl702Config.cpp b/src/platform/bouffalolab/BL702/bl702Config.cpp index 6cae8a52b3fea9..0c51dd6d9afbbc 100644 --- a/src/platform/bouffalolab/BL702/bl702Config.cpp +++ b/src/platform/bouffalolab/BL702/bl702Config.cpp @@ -1,8 +1,5 @@ /* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019-2020 Google LLC. - * Copyright (c) 2019 Nest Labs, Inc. + * Copyright (c) 2022 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,11 +15,6 @@ * limitations under the License. */ -/** - * @file - * Utilities for interacting with the the BL702 Easyflash module. - */ -/* this file behaves like a config.h, comes first */ #include #include diff --git a/src/platform/bouffalolab/BL702/bl702Config.h b/src/platform/bouffalolab/BL702/bl702Config.h index 46ad99de297f89..967dfcdfcf8aa7 100644 --- a/src/platform/bouffalolab/BL702/bl702Config.h +++ b/src/platform/bouffalolab/BL702/bl702Config.h @@ -1,8 +1,5 @@ /* - * - * Copyright (c) 2021 Project CHIP Authors - * Copyright (c) 2019-2020 Google LLC. - * Copyright (c) 2019 Nest Labs, Inc. + * Copyright (c) 2022 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,11 +15,6 @@ * limitations under the License. */ -/** - * @file - * Utilities for interacting with the the BL702 Easyflash module. - */ - #pragma once #include diff --git a/third_party/bouffalolab/bl602/bl602_sdk.gni b/third_party/bouffalolab/bl602/bl602_sdk.gni index ce3ca73a90a7c7..5c9c2b370eb39d 100644 --- a/third_party/bouffalolab/bl602/bl602_sdk.gni +++ b/third_party/bouffalolab/bl602/bl602_sdk.gni @@ -60,6 +60,8 @@ template("bl602_sdk") { "${bl602_sdk_root}/components/network/lwip/src/include/lwip/apps", "${bl602_sdk_root}/components/network/lwip/lwip-port", "${bl602_sdk_root}/components/network/lwip/lwip-port/FreeRTOS", + "${bl602_sdk_root}/components/network/lwip/lwip-port/hook", + "${bl602_sdk_root}/components/network/lwip_mdns", #"${bl602_sdk_root}/components/network/lwip_mdns", @@ -250,6 +252,9 @@ template("bl602_sdk") { "OS_USING_FREERTOS", "BL602_MATTER_SUPPORT", "TD_DIAGNOSIS_STA", + "CONFIG_ENABLE_IPV6_ADDR_CALLBACK", + "CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT", + "CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT", ] if (bl602_board == "BL-HWC-G1") { diff --git a/third_party/bouffalolab/repo b/third_party/bouffalolab/repo index 880fc351904db2..9563086f233769 160000 --- a/third_party/bouffalolab/repo +++ b/third_party/bouffalolab/repo @@ -1 +1 @@ -Subproject commit 880fc351904db2825d3a2c767d60fe1ae8cc5722 +Subproject commit 9563086f233769db0163163307272f739d969cca From c2e0f70e0d4697f7f0b6932cede19b7f90277806 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 26 Sep 2022 16:32:20 -0400 Subject: [PATCH 5/6] Fix nltest runner builds (#22878) * Force a board name for silabs_board so that linux-x64-nl-test-runner can be built * Fix unit tests --- scripts/build/builders/host.py | 3 +++ scripts/build/testdata/build_linux_on_x64.txt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/build/builders/host.py b/scripts/build/builders/host.py index faa664b558c15d..63de9aeddff126 100644 --- a/scripts/build/builders/host.py +++ b/scripts/build/builders/host.py @@ -297,6 +297,9 @@ def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, if app == HostApp.NL_TEST_RUNNER: self.build_command = 'runner' + # board will NOT be used, but is required to be able to properly + # include things added by the test_runner efr32 build + self.extra_gn_options.append('silabs_board="BRD4161A"') # Crypto library has per-platform defaults (like openssl for linux/mac # and mbedtls for android/freertos/zephyr/mbed/...) diff --git a/scripts/build/testdata/build_linux_on_x64.txt b/scripts/build/testdata/build_linux_on_x64.txt index 0f4069fbdab319..dbf58430c638a3 100644 --- a/scripts/build/testdata/build_linux_on_x64.txt +++ b/scripts/build/testdata/build_linux_on_x64.txt @@ -262,7 +262,7 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/minimal-mdns --args=chip_inet_config_enable_ipv4=false {out}/linux-x64-minmdns-ipv6only # Generating linux-x64-nl-test-runner -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 {out}/linux-x64-nl-test-runner +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/src/test_driver/efr32 '--args=silabs_board="BRD4161A"' {out}/linux-x64-nl-test-runner # Generating linux-x64-ota-provider gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/ota-provider-app/linux --args=chip_config_network_layer_ble=false {out}/linux-x64-ota-provider From f2cd15fd76ccda8aa42abbedbcf971fe0b2da349 Mon Sep 17 00:00:00 2001 From: yunhanw-google Date: Mon, 26 Sep 2022 16:25:02 -0700 Subject: [PATCH 6/6] [Android] Integrate cluster state cache with android Java IM API (#22851) * Integrate cluster state cache with java im API * address comments --- src/app/ClusterStateCache.cpp | 5 ++ src/app/ClusterStateCache.h | 2 + src/controller/java/AndroidCallbacks.cpp | 46 +++++++++++++++++-- src/controller/java/AndroidCallbacks.h | 6 ++- .../java/CHIPDeviceController-JNI.cpp | 12 ++--- .../ChipDeviceController.java | 4 +- .../devicecontroller/model/ClusterState.java | 11 +++++ .../devicecontroller/model/NodeState.java | 10 ++++ 8 files changed, 82 insertions(+), 14 deletions(-) diff --git a/src/app/ClusterStateCache.cpp b/src/app/ClusterStateCache.cpp index acb6a0623db140..1ccff3e5567f67 100644 --- a/src/app/ClusterStateCache.cpp +++ b/src/app/ClusterStateCache.cpp @@ -532,5 +532,10 @@ CHIP_ERROR ClusterStateCache::OnUpdateDataVersionFilterList(DataVersionFilterIBs return err; } +CHIP_ERROR ClusterStateCache::GetLastReportDataPath(ConcreteClusterPath & aPath) +{ + aPath = mLastReportDataPath; + return CHIP_NO_ERROR; +} } // namespace app } // namespace chip diff --git a/src/app/ClusterStateCache.h b/src/app/ClusterStateCache.h index 8ba58f1d923798..c6c545e501a9da 100644 --- a/src/app/ClusterStateCache.h +++ b/src/app/ClusterStateCache.h @@ -483,6 +483,8 @@ class ClusterStateCache : protected ReadClient::Callback mEventStatusCache.clear(); } + CHIP_ERROR GetLastReportDataPath(ConcreteClusterPath & aPath); + private: using AttributeState = Variant, StatusIB>; // mPendingDataVersion represents a tentative data version for a cluster that we have gotten some reports for. diff --git a/src/controller/java/AndroidCallbacks.cpp b/src/controller/java/AndroidCallbacks.cpp index 3fd3a42c0eb77f..b5d0cc58734c17 100644 --- a/src/controller/java/AndroidCallbacks.cpp +++ b/src/controller/java/AndroidCallbacks.cpp @@ -121,7 +121,7 @@ void GetConnectedDeviceCallback::OnDeviceConnectionFailureFn(void * context, con ReportCallback::ReportCallback(jobject wrapperCallback, jobject subscriptionEstablishedCallback, jobject reportCallback, jobject resubscriptionAttemptCallback) : - mBufferedReadAdapter(*this) + mClusterCacheAdapter(*this) { JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); VerifyOrReturn(env != nullptr, ChipLogError(Controller, "Could not get JNIEnv for current thread")); @@ -186,6 +186,8 @@ void ReportCallback::OnReportBegin() void ReportCallback::OnReportEnd() { + UpdateClusterDataVersion(); + // Transform C++ jobject pair list to a Java HashMap, and call onReport() on the Java callback. CHIP_ERROR err = CHIP_NO_ERROR; JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); @@ -280,7 +282,43 @@ void ReportCallback::OnAttributeData(const app::ConcreteDataAttributePath & aPat VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Controller, "Could not find addAttribute method")); env->CallVoidMethod(mNodeStateObj, addAttributeMethod, static_cast(aPath.mEndpointId), static_cast(aPath.mClusterId), static_cast(aPath.mAttributeId), attributeStateObj); - VerifyOrReturnError(!env->ExceptionCheck(), env->ExceptionDescribe()); + VerifyOrReturn(!env->ExceptionCheck(), env->ExceptionDescribe()); + + UpdateClusterDataVersion(); +} + +void ReportCallback::UpdateClusterDataVersion() +{ + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + chip::app::ConcreteClusterPath lastConcreteClusterPath; + + if (mClusterCacheAdapter.GetLastReportDataPath(lastConcreteClusterPath) != CHIP_NO_ERROR) + { + return; + } + + if (!lastConcreteClusterPath.IsValidConcreteClusterPath()) + { + return; + } + + chip::Optional committedDataVersion; + if (mClusterCacheAdapter.GetVersion(lastConcreteClusterPath, committedDataVersion) != CHIP_NO_ERROR) + { + return; + } + if (!committedDataVersion.HasValue()) + { + return; + } + + // SetDataVersion to NodeState + jmethodID setDataVersionMethod; + CHIP_ERROR err = JniReferences::GetInstance().FindMethod(env, mNodeStateObj, "setDataVersion", "(IJI)V", &setDataVersionMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Controller, "Could not find setDataVersion method")); + env->CallVoidMethod(mNodeStateObj, setDataVersionMethod, static_cast(lastConcreteClusterPath.mEndpointId), + static_cast(lastConcreteClusterPath.mClusterId), static_cast(committedDataVersion.Value())); + VerifyOrReturn(!env->ExceptionCheck(), env->ExceptionDescribe()); } void ReportCallback::OnEventData(const app::EventHeader & aEventHeader, TLV::TLVReader * apData, const app::StatusIB * apStatus) @@ -356,7 +394,7 @@ void ReportCallback::OnEventData(const app::EventHeader & aEventHeader, TLV::TLV env->CallVoidMethod(mNodeStateObj, addEventMethod, static_cast(aEventHeader.mPath.mEndpointId), static_cast(aEventHeader.mPath.mClusterId), static_cast(aEventHeader.mPath.mEventId), eventStateObj); - VerifyOrReturnError(!env->ExceptionCheck(), env->ExceptionDescribe()); + VerifyOrReturn(!env->ExceptionCheck(), env->ExceptionDescribe()); } CHIP_ERROR ReportCallback::CreateChipAttributePath(const app::ConcreteDataAttributePath & aPath, jobject & outObj) @@ -628,7 +666,7 @@ void ReportEventCallback::OnEventData(const app::EventHeader & aEventHeader, TLV env->CallVoidMethod(mNodeStateObj, addEventMethod, static_cast(aEventHeader.mPath.mEndpointId), static_cast(aEventHeader.mPath.mClusterId), static_cast(aEventHeader.mPath.mEventId), eventStateObj); - VerifyOrReturnError(!env->ExceptionCheck(), env->ExceptionDescribe()); + VerifyOrReturn(!env->ExceptionCheck(), env->ExceptionDescribe()); } CHIP_ERROR ReportEventCallback::CreateChipEventPath(const app::ConcreteEventPath & aPath, jobject & outObj) diff --git a/src/controller/java/AndroidCallbacks.h b/src/controller/java/AndroidCallbacks.h index 684fd4c5487d44..915825aa8c4d83 100644 --- a/src/controller/java/AndroidCallbacks.h +++ b/src/controller/java/AndroidCallbacks.h @@ -42,7 +42,7 @@ struct GetConnectedDeviceCallback jobject mJavaCallbackRef = nullptr; }; -struct ReportCallback : public app::ReadClient::Callback +struct ReportCallback : public app::ClusterStateCache::Callback { /** Subscription established callback can be nullptr. */ ReportCallback(jobject wrapperCallback, jobject subscriptionEstablishedCallback, jobject reportCallback, @@ -74,9 +74,11 @@ struct ReportCallback : public app::ReadClient::Callback CHIP_ERROR CreateChipEventPath(const app::ConcreteEventPath & aPath, jobject & outObj); + void UpdateClusterDataVersion(); + app::ReadClient * mReadClient = nullptr; - app::BufferedReadCallback mBufferedReadAdapter; + app::ClusterStateCache mClusterCacheAdapter; jobject mWrapperCallbackRef = nullptr; jobject mSubscriptionEstablishedCallbackRef = nullptr; jobject mResubscriptionAttemptCallbackRef = nullptr; diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index 21313a6c789e5f..2a4d7e9cc97755 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -1077,9 +1077,9 @@ JNI_METHOD(void, subscribe) auto callback = reinterpret_cast(callbackHandle); - app::ReadClient * readClient = - Platform::New(app::InteractionModelEngine::GetInstance(), device->GetExchangeManager(), - callback->mBufferedReadAdapter, app::ReadClient::InteractionType::Subscribe); + app::ReadClient * readClient = Platform::New( + app::InteractionModelEngine::GetInstance(), device->GetExchangeManager(), + callback->mClusterCacheAdapter.GetBufferedCallback(), app::ReadClient::InteractionType::Subscribe); err = readClient->SendRequest(params); if (err != CHIP_NO_ERROR) @@ -1126,9 +1126,9 @@ JNI_METHOD(void, read) auto callback = reinterpret_cast(callbackHandle); - app::ReadClient * readClient = - Platform::New(app::InteractionModelEngine::GetInstance(), device->GetExchangeManager(), - callback->mBufferedReadAdapter, app::ReadClient::InteractionType::Read); + app::ReadClient * readClient = Platform::New( + app::InteractionModelEngine::GetInstance(), device->GetExchangeManager(), + callback->mClusterCacheAdapter.GetBufferedCallback(), app::ReadClient::InteractionType::Read); err = readClient->SendRequest(params); if (err != CHIP_NO_ERROR) diff --git a/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java b/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java index 759dee577c502a..c24d0dd298dd4f 100644 --- a/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java +++ b/src/controller/java/src/chip/devicecontroller/ChipDeviceController.java @@ -452,7 +452,7 @@ public byte[] getAttestationChallenge(long devicePtr) { } /** Subscribe to the given attribute path. */ - public void subscribeToPath( + public void subscribeToAttributePath( SubscriptionEstablishedCallback subscriptionEstablishedCallback, ReportCallback reportCallback, long devicePtr, @@ -524,7 +524,7 @@ public void subscribeToPath( } /** Read the given attribute path. */ - public void readPath( + public void readAttributePath( ReportCallback callback, long devicePtr, List attributePaths) { ReportCallbackJni jniCallback = new ReportCallbackJni(null, callback, null); read( diff --git a/src/controller/java/src/chip/devicecontroller/model/ClusterState.java b/src/controller/java/src/chip/devicecontroller/model/ClusterState.java index 149d3b1ca97662..e90d0e76acec54 100644 --- a/src/controller/java/src/chip/devicecontroller/model/ClusterState.java +++ b/src/controller/java/src/chip/devicecontroller/model/ClusterState.java @@ -19,15 +19,18 @@ import androidx.annotation.Nullable; import java.util.Map; +import java.util.Optional; /** Class for tracking CHIP cluster state in a hierarchical manner. */ public final class ClusterState { private Map attributes; private Map events; + private Optional dataVersion; public ClusterState(Map attributes, Map events) { this.attributes = attributes; this.events = events; + this.dataVersion = Optional.empty(); } public Map getAttributeStates() { @@ -38,6 +41,14 @@ public Map getEventStates() { return events; } + public void setDataVersion(int version) { + dataVersion = Optional.of(version); + } + + public Optional getDataVersion() { + return dataVersion; + } + /** * Convenience utility for getting an {@code AttributeState}. * diff --git a/src/controller/java/src/chip/devicecontroller/model/NodeState.java b/src/controller/java/src/chip/devicecontroller/model/NodeState.java index d2155aa1ff9b23..652dc3265ffab1 100644 --- a/src/controller/java/src/chip/devicecontroller/model/NodeState.java +++ b/src/controller/java/src/chip/devicecontroller/model/NodeState.java @@ -33,6 +33,16 @@ public Map getEndpointStates() { return endpoints; } + // Called from native code only, which ignores access modifiers. + private void setDataVersion(int endpointId, long clusterId, int dataVersion) { + EndpointState endpointState = getEndpointState(endpointId); + ClusterState clusterState = endpointState.getClusterState(clusterId); + + if (clusterState != null) { + clusterState.setDataVersion(dataVersion); + } + } + // Called from native code only, which ignores access modifiers. private void addAttribute( int endpointId, long clusterId, long attributeId, AttributeState attributeStateToAdd) {