From ea419ac5e400e2037f7298719fffabaff896c7ed Mon Sep 17 00:00:00 2001 From: andrei-menzopol <96489227+andrei-menzopol@users.noreply.github.com> Date: Fri, 30 Sep 2022 22:06:46 +0300 Subject: [PATCH] [K32W0] Add platform changes and features (#22896) * [K32W0] Add platform changes and features * Add SVE2 fixes and other changes and features * Add support for custom certificate policy. * Certificate declaration: set certificate_type to 1 * Add new demo certificates * Add demo certificates allowing testing with two different DUTs * Add custom lighting app ZAP file - e.g.: removed generic and not needed clusters like the ones required for Ethernet/WiFi; removed the optional clusters for an On/Off Device Type; * Add ksdk_mbedlts.c such that we redirect all the AES calls through SecLib.c * Add TestEventTrigger Support * Add functionality for ResetWatermarks() * Add callback for PDM logs * Fix NotifyUpdateApplied - message that is sent when booting for the first time with an OTA image was not being send due to a bug in the PDM read function: ReadConfigValue(...); * Add delay when rebooting after OTA finishes * Improve OTA mechanism * Remove third parameter of ReadConfigValue() and use a TValue& parameter which can be used for extracting the value length * Consume faster the RX buffer * RX buffer should be processed with high priority because: * 15.4 packets are consumed on Thread task; * Thread task has a higher priority than the Matter one (3 > 2) * Fix Low Power * fix 15.4 warm-up time: before this commit calibration time also included the time required for attaching to the Thread network This led to a large warm-up value that blocked some 15.4 operations Fix this by including in the warm-up time only the 15.4 radio initialization time * fix the warm-up initial value to avoid any conflicts * fix possible overflow in reading timestamp values * Make sure that all the logs are disabled when an application is compiled with low-power support; logging can interference with LP timings and break functionality; * Fix time support for Matter * using FreeRTOS timers (based on FreeRTOS tickets) is inaccurate and leads to time drifting * use OT Timers API (Wtimer-based) for getting us/ms timestamps * Fix ExtractPubkeyFromX509Cert in CHIPCryptoPALTinyCrypt.cpp * Fix BLE advertising interval + issue warning if the peer doesn't support 2Mbps * Fix Diagnostic Data Provider * Fix OnOff attribute persistence over hw reset * Fix compilation issue for lock-app * Disable by default on lighting-app BLE Set Phy Req to 2M to be extra cautious during interops * Update readme files Signed-off-by: Doru Gucea Signed-off-by: Marius Tache Signed-off-by: Andrei Menzopol * Fix gn includes, spelling, wordlist Signed-off-by: Andrei Menzopol * Update ot-nxp submodule Signed-off-by: Andrei Menzopol * Fix gn includes, exclude certs from restyle, fix messaging readme Signed-off-by: Andrei Menzopol * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Restyled by prettier-markdown * Restyled by shellharden * Restyled by shfmt * Restyled by autopep8 * Fix low-power build Signed-off-by: Marius Tache Signed-off-by: Andrei Menzopol * Restyled by clang-format * Fix SecLib compile issue Signed-off-by: Andrei Menzopol * Restyled by clang-format * Update worflows K32W0 examples yaml Signed-off-by: Andrei Menzopol * Update docker version, expected gn gen Signed-off-by: Andrei Menzopol * Hotfix nxp shell build Signed-off-by: Andrei Menzopol Signed-off-by: Doru Gucea Signed-off-by: Marius Tache Signed-off-by: Andrei Menzopol Co-authored-by: Restyled.io --- .github/.wordlist.txt | 13 +- .github/workflows/examples-k32w.yaml | 2 +- .restyled.yaml | 1 + examples/lighting-app/nxp/k32w/k32w0/BUILD.gn | 16 +- .../lighting-app/nxp/k32w/k32w0/README.md | 57 +- .../k32w/k32w0/include/CHIPProjectConfig.h | 99 +- .../nxp/k32w/k32w0/include/FreeRTOSConfig.h | 5 +- .../nxp/k32w/k32w0/main/AppTask.cpp | 92 +- .../nxp/k32w/k32w0/main/LightingManager.cpp | 5 + .../nxp/k32w/k32w0/main/ZclCallbacks.cpp | 20 - .../nxp/k32w/k32w0/main/include/AppEvent.h | 3 +- .../nxp/k32w/k32w0/main/include/AppTask.h | 5 +- .../k32w/k32w0/main/include/LightingManager.h | 1 + .../lighting-app/nxp/k32w/k32w0/main/main.cpp | 56 +- examples/lighting-app/nxp/zap/BUILD.gn | 25 + .../nxp/zap/lighting-on-off.matter | 1431 +++ .../lighting-app/nxp/zap/lighting-on-off.zap | 9118 +++++++++++++++++ examples/lock-app/lock-common/BUILD.gn | 0 examples/lock-app/lock-common/lock-app.zap | 0 examples/lock-app/nxp/k32w/k32w0/BUILD.gn | 1 + examples/lock-app/nxp/k32w/k32w0/README.md | 127 +- .../k32w/k32w0/include/CHIPProjectConfig.h | 54 +- .../nxp/k32w/k32w0/include/FreeRTOSConfig.h | 5 +- .../lock-app/nxp/k32w/k32w0/main/AppTask.cpp | 37 +- .../nxp/k32w/k32w0/main/include/AppTask.h | 4 +- .../lock-app/nxp/k32w/k32w0/main/main.cpp | 241 +- .../platform/nxp/doc/manufacturing_flow.md | 116 + .../k32w0/app/ldscripts/chip-k32w0x-linker.ld | 26 +- .../app/project_include/OpenThreadConfig.h | 10 +- .../k32w/k32w0/app/support/FreeRtosHooks.c | 9 +- .../dut1/Chip-DAC-NXP-1037-A220-Cert.der | Bin 0 -> 490 bytes .../dut1/Chip-DAC-NXP-1037-A220-Cert.pem | 13 + .../dut1/Chip-DAC-NXP-1037-A220-Key.der | Bin 0 -> 121 bytes .../dut1/Chip-DAC-NXP-1037-A220-Key.pem | 5 + .../demo_generated_certs/dut1/out_dut1.bin | Bin 0 -> 1161 bytes .../dut2/Chip-DAC-NXP-1037-A220-Cert.der | Bin 0 -> 490 bytes .../dut2/Chip-DAC-NXP-1037-A220-Cert.pem | 13 + .../dut2/Chip-DAC-NXP-1037-A220-Key.der | Bin 0 -> 121 bytes .../dut2/Chip-DAC-NXP-1037-A220-Key.pem | 5 + .../demo_generated_certs/dut2/out_dut2.bin | Bin 0 -> 1161 bytes .../paa/Chip-PAA-NXP-Cert.der | Bin 0 -> 435 bytes .../paa/Chip-PAA-NXP-Cert.pem | 12 + .../paa/Chip-PAA-NXP-Key.pem | 5 + .../pai/Chip-PAI-NXP-1037-A220-Cert.der | Bin 0 -> 454 bytes .../pai/Chip-PAI-NXP-1037-A220-Cert.pem | 12 + .../pai/Chip-PAI-NXP-1037-A220-Key.pem | 5 + .../nxp/k32w/k32w0/scripts/generate_cert.sh | 86 + examples/shell/nxp/k32w/k32w0/BUILD.gn | 9 +- .../shell/nxp/k32w/k32w0/include/AppTask.h | 1 + .../nxp/k32w/k32w0/include/FreeRTOSConfig.h | 5 +- .../shell/nxp/k32w/k32w0/main/AppTask.cpp | 110 +- examples/shell/nxp/k32w/k32w0/main/main.cpp | 9 +- scripts/build/build/targets.py | 4 +- scripts/build/builders/k32w.py | 5 + .../build/testdata/build_all_except_host.txt | 4 +- .../nxp/generate_nxp_chip_factory_bin.py | 170 + src/crypto/CHIPCryptoPALTinyCrypt.cpp | 14 +- src/messaging/README.md | 2 +- src/platform/nxp/k32w/common/RamStorage.cpp | 102 + src/platform/nxp/k32w/common/RamStorage.h | 54 + .../nxp/k32w/k32w0/BLEManagerImpl.cpp | 32 +- src/platform/nxp/k32w/k32w0/BLEManagerImpl.h | 3 +- src/platform/nxp/k32w/k32w0/BUILD.gn | 21 +- .../nxp/k32w/k32w0/CHIPDevicePlatformConfig.h | 82 +- .../k32w/k32w0/ConfigurationManagerImpl.cpp | 19 +- .../nxp/k32w/k32w0/ConfigurationManagerImpl.h | 2 - .../k32w0/DefaultTestEventTriggerDelegate.cpp | 42 + .../k32w0/DefaultTestEventTriggerDelegate.h | 39 + .../k32w/k32w0/DiagnosticDataProviderImpl.cpp | 88 + .../k32w/k32w0/DiagnosticDataProviderImpl.h | 7 +- src/platform/nxp/k32w/k32w0/K32W0Config.cpp | 301 +- src/platform/nxp/k32w/k32w0/K32W0Config.h | 88 +- .../k32w/k32w0/K32W0FactoryDataProvider.cpp | 326 + .../nxp/k32w/k32w0/K32W0FactoryDataProvider.h | 79 + .../k32w/k32w0/KeyValueStoreManagerImpl.cpp | 3 +- src/platform/nxp/k32w/k32w0/Logging.cpp | 6 + src/platform/nxp/k32w/k32w0/LowPowerHooks.cpp | 321 + .../nxp/k32w/k32w0/OTAImageProcessorImpl.cpp | 11 +- .../nxp/k32w/k32w0/PlatformManagerImpl.cpp | 14 + src/platform/nxp/k32w/k32w0/RamStorage.cpp | 283 - src/platform/nxp/k32w/k32w0/RamStorage.h | 62 - .../nxp/k32w/k32w0/SystemPlatformConfig.h | 2 +- .../nxp/k32w/k32w0/SystemTimeSupport.cpp | 123 + .../nxp/k32w/k32w0/ThreadStackManagerImpl.cpp | 16 + .../nxp/k32w/k32w0/ThreadStackManagerImpl.h | 3 + src/platform/nxp/k32w/k32w0/args.gni | 12 +- .../nxp/k32w/k32w0/crypto/ksdk_mbedtls.c | 4324 ++++++++ third_party/nxp/k32w0_sdk/BUILD.gn | 10 +- third_party/nxp/k32w0_sdk/k32w0_sdk.gni | 24 +- .../sdk_fixes/Eeprom_MX25R8035F_c.patch | 112 - .../k32w0_sdk/sdk_fixes/MemManager_h.patch | 22 - .../k32w0_sdk/sdk_fixes/OtaSupport_c.patch | 144 - .../nxp/k32w0_sdk/sdk_fixes/OtaUtils_c.patch | 19 - .../nxp/k32w0_sdk/sdk_fixes/OtaUtils_h.patch | 24 + .../nxp/k32w0_sdk/sdk_fixes/SecLib_h.patch | 24 - .../sdk_fixes/app_dual_mode_low_power_h.patch | 24 - .../sdk_fixes/app_dual_mode_switch_h.patch | 21 - .../nxp/k32w0_sdk/sdk_fixes/ble_utils_h.patch | 14 - .../fsl_os_abstraction_free_rtos_c.patch | 54 + .../nxp/k32w0_sdk/sdk_fixes/gpio_pins_h.patch | 14 - .../nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh | 8 +- .../k32w0_sdk/sdk_fixes/settings_k32w_c.patch | 11 - .../k32w0_sdk/sdk_fixes/sign_images_sh.patch | 18 - third_party/openthread/ot-nxp | 2 +- .../platforms/nxp/k32w/k32w0/BUILD.gn | 2 + .../nxp/zap-generated/CHIPClientCallbacks.h | 32 + .../nxp/zap-generated/CHIPClusters.h | 44 + .../zap-generated/IMClusterCommandHandler.cpp | 905 ++ .../PluginApplicationCallbacks.h | 41 + .../lighting-app/nxp/zap-generated/access.h | 254 + .../nxp/zap-generated/af-gen-event.h | 39 + .../nxp/zap-generated/callback-stub.cpp | 263 + .../nxp/zap-generated/endpoint_config.h | 779 ++ .../nxp/zap-generated/gen_config.h | 138 + .../nxp/zap-generated/gen_tokens.h | 45 + 115 files changed, 20067 insertions(+), 1553 deletions(-) create mode 100644 examples/lighting-app/nxp/zap/BUILD.gn create mode 100644 examples/lighting-app/nxp/zap/lighting-on-off.matter create mode 100644 examples/lighting-app/nxp/zap/lighting-on-off.zap mode change 100755 => 100644 examples/lock-app/lock-common/BUILD.gn mode change 100755 => 100644 examples/lock-app/lock-common/lock-app.zap create mode 100644 examples/platform/nxp/doc/manufacturing_flow.md create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Cert.der create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Cert.pem create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Key.der create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Key.pem create mode 100644 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/out_dut1.bin create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Cert.der create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Cert.pem create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Key.der create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Key.pem create mode 100644 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/out_dut2.bin create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/paa/Chip-PAA-NXP-Cert.der create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/paa/Chip-PAA-NXP-Cert.pem create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/paa/Chip-PAA-NXP-Key.pem create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Cert.der create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Cert.pem create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Key.pem create mode 100755 examples/platform/nxp/k32w/k32w0/scripts/generate_cert.sh create mode 100755 scripts/tools/nxp/generate_nxp_chip_factory_bin.py create mode 100644 src/platform/nxp/k32w/common/RamStorage.cpp create mode 100644 src/platform/nxp/k32w/common/RamStorage.h create mode 100644 src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp create mode 100644 src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h create mode 100644 src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.cpp create mode 100644 src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.h create mode 100644 src/platform/nxp/k32w/k32w0/LowPowerHooks.cpp delete mode 100644 src/platform/nxp/k32w/k32w0/RamStorage.cpp delete mode 100644 src/platform/nxp/k32w/k32w0/RamStorage.h create mode 100644 src/platform/nxp/k32w/k32w0/SystemTimeSupport.cpp create mode 100644 src/platform/nxp/k32w/k32w0/crypto/ksdk_mbedtls.c delete mode 100644 third_party/nxp/k32w0_sdk/sdk_fixes/Eeprom_MX25R8035F_c.patch delete mode 100644 third_party/nxp/k32w0_sdk/sdk_fixes/MemManager_h.patch delete mode 100644 third_party/nxp/k32w0_sdk/sdk_fixes/OtaSupport_c.patch delete mode 100644 third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_c.patch create mode 100644 third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_h.patch delete mode 100644 third_party/nxp/k32w0_sdk/sdk_fixes/SecLib_h.patch delete mode 100644 third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_low_power_h.patch delete mode 100644 third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_switch_h.patch delete mode 100644 third_party/nxp/k32w0_sdk/sdk_fixes/ble_utils_h.patch create mode 100644 third_party/nxp/k32w0_sdk/sdk_fixes/fsl_os_abstraction_free_rtos_c.patch delete mode 100644 third_party/nxp/k32w0_sdk/sdk_fixes/gpio_pins_h.patch delete mode 100644 third_party/nxp/k32w0_sdk/sdk_fixes/settings_k32w_c.patch delete mode 100644 third_party/nxp/k32w0_sdk/sdk_fixes/sign_images_sh.patch create mode 100644 zzz_generated/lighting-app/nxp/zap-generated/CHIPClientCallbacks.h create mode 100644 zzz_generated/lighting-app/nxp/zap-generated/CHIPClusters.h create mode 100644 zzz_generated/lighting-app/nxp/zap-generated/IMClusterCommandHandler.cpp create mode 100644 zzz_generated/lighting-app/nxp/zap-generated/PluginApplicationCallbacks.h create mode 100644 zzz_generated/lighting-app/nxp/zap-generated/access.h create mode 100644 zzz_generated/lighting-app/nxp/zap-generated/af-gen-event.h create mode 100644 zzz_generated/lighting-app/nxp/zap-generated/callback-stub.cpp create mode 100644 zzz_generated/lighting-app/nxp/zap-generated/endpoint_config.h create mode 100644 zzz_generated/lighting-app/nxp/zap-generated/gen_config.h create mode 100644 zzz_generated/lighting-app/nxp/zap-generated/gen_tokens.h diff --git a/.github/.wordlist.txt b/.github/.wordlist.txt index e693e22c2850be..ca364bc513ae9c 100644 --- a/.github/.wordlist.txt +++ b/.github/.wordlist.txt @@ -20,7 +20,6 @@ accessor AccountLogin acdbc ack -ACK ACKed ACL ACLs @@ -156,7 +155,6 @@ bootable Bootloader BorderRouterAP bouffalolab -Bouffalolab BRD breakpoint bredr @@ -332,6 +330,7 @@ cxx CY CYW DAC +DACs dadbdcdddedf DAP DAPLINK @@ -449,6 +448,7 @@ dryrun DS duplicative DUT +DUTS DV DVK dynload @@ -596,9 +596,9 @@ GPL GPLv Gradle gradlew +Groupcast GroupId GroupKeyManagement -Groupcast groupKeySecurityPolicy groupKeySetID groupsettings @@ -652,7 +652,6 @@ ignoreQueryImage ihex IlluminanceMeasurement IM -IsInitiator imager imagetool imageUri @@ -990,6 +989,7 @@ PAAs PacketBuffer PAI PairDevice +PAIs PAKE palletsprojects pankore @@ -1376,13 +1376,14 @@ uint ULA UNBLUR uncommissioned +Unencrypted unfocus Unicast UniFlash UnitLocalization -Unencrypted unpair unprovisioned +Unsecure untrusted updateAvailable updateNotAvailable @@ -1400,7 +1401,6 @@ userConsentState userguide USERINTERFACE UserLabel -Unsecure usermod usr UTF @@ -1419,6 +1419,7 @@ ver Verifier Verifiers VID +vids virtualenv visualstudio vlatest diff --git a/.github/workflows/examples-k32w.yaml b/.github/workflows/examples-k32w.yaml index 81dfa05f5f014a..ffdfe159633598 100644 --- a/.github/workflows/examples-k32w.yaml +++ b/.github/workflows/examples-k32w.yaml @@ -34,7 +34,7 @@ jobs: if: github.actor != 'restyled-io[bot]' container: - image: connectedhomeip/chip-build-k32w:0.5.99 + image: connectedhomeip/chip-build-k32w:0.6.02 volumes: - "/tmp/bloat_reports:/tmp/bloat_reports" steps: diff --git a/.restyled.yaml b/.restyled.yaml index 8de3586a65401b..9b6e7bcde82817 100644 --- a/.restyled.yaml +++ b/.restyled.yaml @@ -74,6 +74,7 @@ exclude: - "examples/chef/zzz_generated/**/*" - "src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm" # https://github.com/project-chip/connectedhomeip/issues/20236 - "src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h" # https://github.com/project-chip/connectedhomeip/issues/20236 + - "examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/**/*" changed_paths: diff --git a/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn b/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn index c19ccbac46f23a..ff271fc042ffa4 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn +++ b/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn @@ -79,10 +79,13 @@ k32w0_executable("light_app") { "main/main.cpp", ] + public = [ "${chip_root}/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h" ] + deps = [ ":sdk", "${chip_root}/examples/common/QRCode", - "${chip_root}/examples/lighting-app/lighting-common/", + "${chip_root}/examples/lighting-app/nxp/zap/", + "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/lib", "${chip_root}/third_party/mbedtls:mbedtls", "${k32w0_platform_dir}/app/support:freertos_mbedtls_utils", @@ -113,16 +116,7 @@ k32w0_executable("light_app") { "-Wl,--defsym", "-Wl,__app_load_address__=0x4000", "-Wl,--defsym", - "-Wl,__app_stated_size__=0x99A00", - ] - } - - if (chip_enable_ota_requestor) { - ldflags += [ - "-Wl,--defsym", - "-Wl,__app_load_address__=0x4000", - "-Wl,--defsym", - "-Wl,__app_stated_size__=0x99A00", + "-Wl,__app_stated_size__=0x99200", ] } diff --git a/examples/lighting-app/nxp/k32w/k32w0/README.md b/examples/lighting-app/nxp/k32w/k32w0/README.md index 8ea1d9848debcd..6b7f6d83a44d6c 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/README.md +++ b/examples/lighting-app/nxp/k32w/k32w0/README.md @@ -22,6 +22,8 @@ network. - [Bluetooth LE Rendezvous](#bluetooth-le-rendezvous) - [Device UI](#device-ui) - [Building](#building) + - [Known issues](#building-issues) +- [Manufacturing data](#manufacturing) - [Flashing and debugging](#flashdebug) - [Pigweed Tokenizer](#tokenizer) - [Detokenizer script](#detokenizer) @@ -193,18 +195,15 @@ effects: In order to build the Project CHIP example, we recommend using a Linux distribution (the demo-application was compiled on Ubuntu 20.04). -- Download [K32W0 SDK 2.6.6 for Project CHIP](https://mcuxpresso.nxp.com/). - Creating an nxp.com account is required before being able to download the - SDK. Once the account is created, login and follow the steps for downloading - SDK_2_6_6_K32W061DK6 (required for K32W061 flavor). The SDK Builder UI - selection should be similar with the one from the image below. - ![MCUXpresso SDK Download](../../../../platform/nxp/k32w/k32w0/doc/images/mcux-sdk-download.JPG) +- Download + [K32W0 SDK 2.6.7](https://cache.nxp.com/lgfiles/bsps/SDK_2_6_7_K32W061DK6.zip). - Start building the application either with Secure Element or without - without Secure Element ``` -user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=/home/user/Desktop/SDK_2_6_6_K32W061DK6/ +user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=/home/user/Desktop/SDK_2_6_7_K32W061DK6/ +user@ubuntu:~/Desktop/git/connectedhomeip$ ./third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh user@ubuntu:~/Desktop/git/connectedhomeip$ source ./scripts/activate.sh user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/lighting-app/nxp/k32w/k32w0 user@ubuntu:~/Desktop/git/connectedhomeip/examples/lighting-app/nxp/k32w/k32w0$ gn gen out/debug --args="k32w0_sdk_root=\"${NXP_K32W0_SDK_ROOT}\" chip_with_OM15082=1 chip_with_ot_cli=0 is_debug=false chip_crypto=\"tinycrypt\" chip_with_se05x=0 chip_pw_tokenizer_logging=true mbedtls_repo=\"//third_party/connectedhomeip/third_party/nxp/libs/mbedtls\"" @@ -246,6 +245,20 @@ pycryptodome 3.9.8 The resulting output file can be found in out/debug/chip-k32w0x-light-example. + + +## Known issues + +- When using Secure element and cross-compiling on Linux, log messages from + the Plug&Trust middleware stack may not echo to the console. + + + +## Manufacturing data + +See +[Guide for writing manufacturing data on NXP devices](../../../../platform/nxp/doc/manufacturing_flow.md). + ## Flashing and debugging @@ -414,14 +427,14 @@ Here is the interpretation of the fields: Second, image directory 1 must be written: ``` -DK6Programmer.exe -V5 -s -P 1000000 -w image_dir_1=00400000CD040101 +DK6Programmer.exe -V5 -s -P 1000000 -w image_dir_1=00400000C9040101 ``` Here is the interpretation of the fields: ``` 00400000 -> start address 0x00004000 -CD04 -> 0x4CD pages of 512-bytes (= 614,5kB) +CD04 -> 0x4C9 pages of 512-bytes (= 612,5kB) 01 -> bootable flag 01 -> image type for the application ``` @@ -482,42 +495,42 @@ used for connecting the RPis to WiFi. Build the Linux OTA provider application: ``` -doru@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota-provider-app chip_config_network_layer_ble=false +user@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/ota-provider-app chip_config_network_layer_ble=false ``` Build OTA image and start the OTA Provider Application: ``` -doru@computer1:~/connectedhomeip$ : ./src/app/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 1 -vs "1.0" -da sha256 chip-k32w0x-light-example.bin chip-k32w0x-light-example.ota -doru@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_* -doru@computer1:~/connectedhomeip$ : ./out/ota-provider-app/chip-ota-provider-app -f chip-k32w0x-light-example.ota +user@computer1:~/connectedhomeip$ : ./src/app/ota_image_tool.py create -v 0xDEAD -p 0xBEEF -vn 1 -vs "1.0" -da sha256 chip-k32w0x-light-example.bin chip-k32w0x-light-example.ota +user@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_* +user@computer1:~/connectedhomeip$ : ./out/ota-provider-app/chip-ota-provider-app -f chip-k32w0x-light-example.ota ``` Build Linux chip-tool: ``` -doru@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/chip-tool out/chip-tool-app +user@computer1:~/connectedhomeip$ : ./scripts/examples/gn_build_example.sh examples/chip-tool out/chip-tool-app ``` Provision the OTA provider application and assign node id _1_. Also, grant ACL entries to allow OTA requestors: ``` -doru@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_* -doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing onnetwork 1 20202021 -doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": null}]' 1 0 +user@computer1:~/connectedhomeip$ : rm -rf /tmp/chip_* +user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing onnetwork 1 20202021 +user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null}, {"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": null, "targets": null}]' 1 0 ``` Provision the device and assign node id _2_: ``` -doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing ble-thread 2 hex: 20202021 3840 +user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool pairing ble-thread 2 hex: 20202021 3840 ``` Start the OTA process: ``` -doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 2 0 +user@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool otasoftwareupdaterequestor announce-ota-provider 1 0 0 0 2 0 ``` @@ -537,7 +550,7 @@ doru@computer1:~/connectedhomeip$ : ./out/chip-tool-app/chip-tool otasoftwareupd command: ``` -doru@computer1:~/connectedhomeip$ : sudo docker kill $container_id +user@computer1:~/connectedhomeip$ : sudo docker kill $container_id ``` - In order to avoid MDNS issues, only one interface should be active at one @@ -545,8 +558,8 @@ doru@computer1:~/connectedhomeip$ : sudo docker kill $container_id disable multicast on that interface: ``` -doru@computer1:~/connectedhomeip$ sudo ip link set dev eth0 down -doru@computer1:~/connectedhomeip$ sudo ifconfig eth0 -multicast +user@computer1:~/connectedhomeip$ sudo ip link set dev eth0 down +user@computer1:~/connectedhomeip$ sudo ifconfig eth0 -multicast ``` - If OTBR Docker image is used, then the "-B" parameter should point to the diff --git a/examples/lighting-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h b/examples/lighting-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h index e0b01be6a7a421..e10bf8522eaf0b 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h +++ b/examples/lighting-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h @@ -34,20 +34,55 @@ // including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS. #define CHIP_CONFIG_SECURITY_TEST_MODE 0 -// Use a default setup PIN code if one hasn't been provisioned in flash. -#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 -#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 +// Use hard-coded test certificates already embedded in generic chip code => set it to 0 +// Use real/development certificates => set it to 1 + file the provisioning section from +// the internal flash +#ifndef CONFIG_CHIP_K32W0_REAL_FACTORY_DATA +#define CONFIG_CHIP_K32W0_REAL_FACTORY_DATA 0 +#endif -// Use a default pairing code if one hasn't been provisioned in flash. -#define CHIP_DEVICE_CONFIG_USE_TEST_PAIRING_CODE "CHIPUS" +#if CONFIG_CHIP_K32W0_REAL_FACTORY_DATA + +// VID/PID for product => will be used by Basic Information Cluster +#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0x1037 +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0xA220 + +// set it to 0 for the moment +#define CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER 0 + +#ifndef CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION +//-> format_version = 1 +//-> vendor_id = 0x1037 +//-> product_id_array = [ 0xA220 ] +//-> device_type_id = 0x0100 +//-> certificate_id = "ZIG20142ZB330003-24" +//-> security_level = 0 +//-> security_information = 0 +//-> version_number = 0x2694 +//-> certification_type = 1 +//-> dac_origin_vendor_id is not present +//-> dac_origin_product_id is not present +#define CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION \ + { \ + 0x30, 0x81, 0xe7, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x81, 0xd9, 0x30, 0x81, 0xd6, \ + 0x02, 0x01, 0x03, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, \ + 0x44, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x37, 0x04, 0x35, 0x15, 0x24, 0x00, \ + 0x01, 0x25, 0x01, 0x37, 0x10, 0x36, 0x02, 0x05, 0x20, 0xa2, 0x18, 0x25, 0x03, 0x00, 0x01, 0x2c, 0x04, 0x13, 0x5a, \ + 0x49, 0x47, 0x32, 0x30, 0x31, 0x34, 0x31, 0x5a, 0x42, 0x33, 0x33, 0x30, 0x30, 0x30, 0x31, 0x2d, 0x32, 0x34, 0x24, \ + 0x05, 0x00, 0x24, 0x06, 0x00, 0x24, 0x07, 0x01, 0x24, 0x08, 0x01, 0x18, 0x31, 0x7c, 0x30, 0x7a, 0x02, 0x01, 0x03, \ + 0x80, 0x14, 0x62, 0xfa, 0x82, 0x33, 0x59, 0xac, 0xfa, 0xa9, 0x96, 0x3e, 0x1c, 0xfa, 0x14, 0x0a, 0xdd, 0xf5, 0x04, \ + 0xf3, 0x71, 0x60, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, 0x0a, 0x06, \ + 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x04, 0x46, 0x30, 0x44, 0x02, 0x20, 0x5f, 0x32, 0xbc, 0x8b, \ + 0xa7, 0xd6, 0x1c, 0xfc, 0x6b, 0xc2, 0x1f, 0xbb, 0x42, 0xc2, 0xa7, 0x93, 0x45, 0x8a, 0xd9, 0xa6, 0x62, 0x15, 0xb6, \ + 0x93, 0xc4, 0x90, 0x24, 0xdf, 0xca, 0x03, 0x3a, 0x96, 0x02, 0x20, 0x5f, 0xc6, 0x62, 0x7a, 0x84, 0x49, 0x13, 0xf9, \ + 0x99, 0xd5, 0xbb, 0xab, 0xa0, 0x26, 0x22, 0xad, 0xdc, 0x32, 0xe6, 0x02, 0x2f, 0xf2, 0xaa, 0x52, 0x09, 0x86, 0x1d, \ + 0xe4, 0x76, 0x1b, 0xfd, 0x05, \ + } + +// All remaining data will be pulled from provisioning region of flash. +#endif -/** - * CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER - * - * Enables the use of a hard-coded default serial number if none - * is found in CHIP NV storage. - */ -#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" +#else /** * CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID @@ -63,6 +98,23 @@ */ #define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005 +// Use a default setup PIN code if one hasn't been provisioned in flash. +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 +#define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 + +// Use a default pairing code if one hasn't been provisioned in flash. +#define CHIP_DEVICE_CONFIG_USE_TEST_PAIRING_CODE "CHIPUS" + +/** + * CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER + * + * Enables the use of a hard-coded default serial number if none + * is found in CHIP NV storage. + */ +#define CHIP_DEVICE_CONFIG_TEST_SERIAL_NUMBER "TEST_SN" + +#endif + /** * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION * @@ -126,7 +178,7 @@ * provision the device with its unique operational credentials and manage * its own access control lists. */ -#define CHIP_CONFIG_MAX_FABRICS 4 // 3 fabrics + 1 for rotation slack +#define CHIP_CONFIG_MAX_FABRICS 5 // 5 is the minimum number of supported fabrics /** * @def CHIP_IM_MAX_NUM_COMMAND_HANDLER @@ -156,3 +208,24 @@ #endif // BUILD_RELEASE #define CHIP_DEVICE_CONFIG_ENABLE_EXTENDED_DISCOVERY 1 + +/** + * CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ + * + * This define enables/disables the Gap_LeSetPhy request to switch to 2M. + * It is disabled here for interoperability reasons just to be extra cautious. + * Both devices may send a Link Layer control procedure in parallel resulting in a + * LPM Error Transaction Collision. + * If the peer device doesn't accept our reject command, this can result in a BLE + * connection timeout. + */ +#define CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ 0 + +/** + * CHIP_DEVICE_CONFIG_INIT_OTA_DELAY + * + * The amount of time in miliseconds after which OTA initialization should be + * scheduled after a new image is applied. + * + */ +#define CHIP_DEVICE_CONFIG_INIT_OTA_DELAY 3000 diff --git a/examples/lighting-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h b/examples/lighting-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h index 8c533831108e98..7990935565ce51 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h +++ b/examples/lighting-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h @@ -56,7 +56,10 @@ #define configUSE_ALTERNATIVE_API 0 /* Deprecated! */ #define configQUEUE_REGISTRY_SIZE 8 #define configUSE_QUEUE_SETS 0 -#define configUSE_TIME_SLICING 0 +/* make sure that Thread task can interrupt lengthy Matter + * processing in case priority inversion occurs + */ +#define configUSE_TIME_SLICING 1 #define configUSE_NEWLIB_REENTRANT 0 #define configENABLE_BACKWARD_COMPATIBILITY 1 #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp index 8d3f2f0bd0afac..ab05f79d417c4e 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/AppTask.cpp @@ -24,17 +24,19 @@ #include #include #include +#include #include #include #include - -#include +#include #include #include #include #include +#include + /* OTA related includes */ #if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR #include "OTAImageProcessorImpl.h" @@ -56,6 +58,7 @@ #ifdef ENABLE_HSM_DEVICE_ATTESTATION #include "DeviceAttestationSe05xCredsExample.h" #endif +#include "CHIPProjectConfig.h" #define FACTORY_RESET_TRIGGER_TIMEOUT 6000 #define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 @@ -70,8 +73,9 @@ static QueueHandle_t sAppEventQueue; static LEDWidget sStatusLED; static LEDWidget sLightLED; -static bool sIsThreadProvisioned = false; -static bool sHaveBLEConnections = false; +static bool sIsThreadProvisioned = false; +static bool sHaveBLEConnections = false; +static bool sIsDnssdPlatformInitialized = false; static uint32_t eventMask = 0; @@ -85,6 +89,11 @@ using namespace chip; AppTask AppTask::sAppTask; +// This key is for testing/certification only and should not be used in production devices. +// For production devices this key must be provided from factory data. +uint8_t sTestEventTriggerEnableKey[TestEventTriggerDelegate::kEnableKeyLength] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, + 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }; + static Identify gIdentify = { chip::EndpointId{ 1 }, AppTask::OnIdentifyStart, AppTask::OnIdentifyStop, EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, AppTask::OnTriggerEffect, // Use invalid value for identifiers to enable TriggerEffect command @@ -122,22 +131,30 @@ CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; + PlatformMgr().AddEventHandler(MatterEventHandler, 0); + // Init ZCL Data Model and start server PlatformMgr().ScheduleWork(InitServer, 0); - // Initialize device attestation config +// Initialize device attestation config +#if CONFIG_CHIP_K32W0_REAL_FACTORY_DATA + // Initialize factory data provider + ReturnErrorOnFailure(K32W0FactoryDataProvider::GetDefaultInstance().Init()); +#if CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER + SetDeviceInstanceInfoProvider(&mK32W0FactoryDataProvider); +#endif + SetDeviceAttestationCredentialsProvider(&K32W0FactoryDataProvider::GetDefaultInstance()); + SetCommissionableDataProvider(&K32W0FactoryDataProvider::GetDefaultInstance()); +#else #ifdef ENABLE_HSM_DEVICE_ATTESTATION SetDeviceAttestationCredentialsProvider(Examples::GetExampleSe05xDACProvider()); #else SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif -#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR - PlatformMgr().ScheduleWork(InitOTA, 0); -#endif - // QR code will be used with CHIP Tool PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); +#endif /* HW init leds */ LED_Init(); @@ -185,8 +202,20 @@ CHIP_ERROR AppTask::Init() K32W_LOG("Current Software Version: %s", currentSoftwareVer); - PlatformMgr().AddEventHandler(ThreadProvisioningHandler, 0); - +#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR + if (gImageProcessor.IsFirstImageRun()) + { + // If DNS-SD initialization was captured by MatterEventHandler, then + // OTA initialization will be started as soon as possible. Otherwise, + // a periodic timer is started until the DNS-SD initialization event + // is received. Configurable delay: CHIP_DEVICE_CONFIG_INIT_OTA_DELAY + AppTask::OnScheduleInitOTA(nullptr, nullptr); + } + else + { + PlatformMgr().ScheduleWork(AppTask::InitOTA, 0); + } +#endif return err; } @@ -205,7 +234,13 @@ void AppTask::InitServer(intptr_t arg) static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); + auto & infoProvider = chip::DeviceLayer::DeviceInfoProviderImpl::GetDefaultInstance(); + infoProvider.SetStorageDelegate(initParams.persistentStorageDelegate); + chip::DeviceLayer::SetDeviceInfoProvider(&infoProvider); + // Init ZCL Data Model and start server + static DefaultTestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(sTestEventTriggerEnableKey) }; + initParams.testEventTriggerDelegate = &testEventTriggerDelegate; chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; nativeParams.lockCb = LockOpenThreadTask; nativeParams.unlockCb = UnlockOpenThreadTask; @@ -266,7 +301,7 @@ void AppTask::AppTaskMain(void * pvParameter) PlatformMgr().UnlockChipStack(); } - // Update the status LED if factory reset has not been initiated. + // Update the status LED if factory reset or identify process have not been initiated. // // If system has "full connectivity", keep the LED On constantly. // @@ -469,6 +504,8 @@ void AppTask::LightActionEventHandler(AppEvent * aEvent) } else if (aEvent->Type == AppEvent::kEventType_Button) { + actor = AppEvent::kEventType_Button; + if (LightingMgr().IsTurnedOff()) { action = LightingManager::TURNON_ACTION; @@ -524,6 +561,24 @@ void AppTask::PostOTAResume() event.Handler = OTAResumeEventHandler; sAppTask.PostEvent(&event); } + +void AppTask::OnScheduleInitOTA(chip::System::Layer * systemLayer, void * appState) +{ + if (sIsDnssdPlatformInitialized) + { + PlatformMgr().ScheduleWork(AppTask::InitOTA, 0); + } + else + { + CHIP_ERROR error = chip::DeviceLayer::SystemLayer().StartTimer( + chip::System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_INIT_OTA_DELAY), AppTask::OnScheduleInitOTA, nullptr); + + if (error != CHIP_NO_ERROR) + { + K32W_LOG("Failed to schedule OTA initialization timer."); + } + } +} #endif void AppTask::BleHandler(AppEvent * aEvent) @@ -536,7 +591,11 @@ void AppTask::BleHandler(AppEvent * aEvent) K32W_LOG("Another function is scheduled. Could not toggle BLE state!"); return; } + PlatformMgr().ScheduleWork(AppTask::BleStartAdvertising, 0); +} +void AppTask::BleStartAdvertising(intptr_t arg) +{ if (ConnectivityMgr().IsBLEAdvertisingEnabled()) { ConnectivityMgr().SetBLEAdvertisingEnabled(false); @@ -557,7 +616,7 @@ void AppTask::BleHandler(AppEvent * aEvent) } } -void AppTask::ThreadProvisioningHandler(const ChipDeviceEvent * event, intptr_t) +void AppTask::MatterEventHandler(const ChipDeviceEvent * event, intptr_t) { if (event->Type == DeviceEventType::kServiceProvisioningChange && event->ServiceProvisioningChange.IsServiceProvisioned) { @@ -576,6 +635,12 @@ void AppTask::ThreadProvisioningHandler(const ChipDeviceEvent * event, intptr_t) { sAppTask.PostOTAResume(); } + + if (event->Type == DeviceEventType::kDnssdPlatformInitialized) + { + K32W_LOG("Dnssd platform initialized."); + sIsDnssdPlatformInitialized = true; + } #endif #if CONFIG_CHIP_NFC_COMMISSIONING @@ -879,6 +944,7 @@ void AppTask::UpdateDeviceStateInternal(intptr_t arg) /* set the device state */ sLightLED.Set(onoffAttrValue); + LightingMgr().SetState(onoffAttrValue); } extern "C" void OTAIdleActivities(void) diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/LightingManager.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/LightingManager.cpp index af2dae0f3ff062..7a5cefc9b668fc 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/LightingManager.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/LightingManager.cpp @@ -39,6 +39,11 @@ void LightingManager::SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Ca mActionCompleted_CB = aActionCompleted_CB; } +void LightingManager::SetState(bool state) +{ + mState = state ? kState_On : kState_Off; +} + bool LightingManager::IsTurnedOff() { return (mState == kState_Off) ? true : false; diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/ZclCallbacks.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/ZclCallbacks.cpp index 0503bd2c71b488..5a4eee6e2c09e4 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/ZclCallbacks.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/ZclCallbacks.cpp @@ -68,23 +68,3 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & ChipLogProgress(Zcl, "Unknown attribute ID: " ChipLogFormatMEI, ChipLogValueMEI(path.mAttributeId)); } } - -/** @brief OnOff Cluster Init - * - * This function is called when a specific cluster is initialized. It gives the - * application an opportunity to take care of cluster initialization procedures. - * It is called exactly once for each endpoint where cluster is present. - * - * @param endpoint Ver.: always - * - * TODO Issue #3841 - * emberAfOnOffClusterInitCallback happens before the stack initialize the cluster - * attributes to the default value. - * The logic here expects something similar to the deprecated Plugins callback - * emberAfPluginOnOffClusterServerPostInitCallback. - * - */ -void emberAfOnOffClusterInitCallback(EndpointId endpoint) -{ - GetAppTask().UpdateClusterState(); -} diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/include/AppEvent.h b/examples/lighting-app/nxp/k32w/k32w0/main/include/AppEvent.h index f067c2ed86368c..902c70b3cb656f 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/include/AppEvent.h +++ b/examples/lighting-app/nxp/k32w/k32w0/main/include/AppEvent.h @@ -25,7 +25,8 @@ struct AppEvent { enum AppEventTypes { - kEventType_Button = 0, + kEventType_None = 0, + kEventType_Button, kEventType_Timer, kEventType_TurnOn, kEventType_Install, diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/include/AppTask.h b/examples/lighting-app/nxp/k32w/k32w0/main/include/AppTask.h index fc8c164871d15e..e47c217bae169e 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/include/AppTask.h +++ b/examples/lighting-app/nxp/k32w/k32w0/main/include/AppTask.h @@ -22,6 +22,7 @@ #include #include "AppEvent.h" +#include "K32W0FactoryDataProvider.h" #include "LightingManager.h" #include @@ -73,6 +74,7 @@ class AppTask static void HandleKeyboard(void); static void OTAHandler(AppEvent * aEvent); static void BleHandler(AppEvent * aEvent); + static void BleStartAdvertising(intptr_t arg); static void LightActionEventHandler(AppEvent * aEvent); static void OTAResumeEventHandler(AppEvent * aEvent); static void ResetActionEventHandler(AppEvent * aEvent); @@ -81,7 +83,7 @@ class AppTask static void ButtonEventHandler(uint8_t pin_no, uint8_t button_action); static void TimerEventHandler(TimerHandle_t xTimer); - static void ThreadProvisioningHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + static void MatterEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); void StartTimer(uint32_t aTimeoutInMs); static void RestoreLightingState(void); @@ -90,6 +92,7 @@ class AppTask static void InitOTA(intptr_t arg); static void StartOTAQuery(intptr_t arg); static void PostOTAResume(); + static void OnScheduleInitOTA(chip::System::Layer * systemLayer, void * appState); #endif static void UpdateClusterStateInternal(intptr_t arg); diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/include/LightingManager.h b/examples/lighting-app/nxp/k32w/k32w0/main/include/LightingManager.h index 6fa7aef75c0c27..327bf3bdf02763 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/include/LightingManager.h +++ b/examples/lighting-app/nxp/k32w/k32w0/main/include/LightingManager.h @@ -50,6 +50,7 @@ class LightingManager typedef void (*Callback_fn_initiated)(Action_t, int32_t aActor); typedef void (*Callback_fn_completed)(Action_t); void SetCallbacks(Callback_fn_initiated aActionInitiated_CB, Callback_fn_completed aActionCompleted_CB); + void SetState(bool state); private: friend LightingManager & LightingMgr(void); diff --git a/examples/lighting-app/nxp/k32w/k32w0/main/main.cpp b/examples/lighting-app/nxp/k32w/k32w0/main/main.cpp index 58091c8fba4dae..4c2ce040d2b786 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/main/main.cpp +++ b/examples/lighting-app/nxp/k32w/k32w0/main/main.cpp @@ -31,6 +31,14 @@ #include "FreeRtosHooks.h" #include "app_config.h" +#ifdef K32WMCM_APP_BUILD +#define string string_shadow +#include "AppApi.h" +#include "MMAC.h" +#include "mac_sap.h" +#undef string +#endif + using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; @@ -45,6 +53,31 @@ uint8_t __attribute__((section(".heap"))) ucHeap[HEAP_SIZE]; extern "C" void sched_enable(); +#define NORMAL_PWR_LIMIT 10 /* dBm */ + +#ifdef K32WMCM_APP_BUILD +/* Must be called before zps_eAplAfInit() */ +void APP_SetHighTxPowerMode(); + +/* Must be called after zps_eAplAfInit() */ +void APP_SetMaxTxPower(); + +#undef HIGH_TX_PWR_LIMIT +#define HIGH_TX_PWR_LIMIT 15 /* dBm */ +/* High Tx power */ +void APP_SetHighTxPowerMode() +{ + if (CHIP_IS_HITXPOWER_CAPABLE()) + vMMAC_SetTxPowerMode(TRUE); +} + +void APP_SetMaxTxPower() +{ + if (CHIP_IS_HITXPOWER_CAPABLE()) + eAppApiPlmeSet(PHY_PIB_ATTR_TX_POWER, HIGH_TX_PWR_LIMIT); +} +#endif + extern "C" void main_task(void const * argument) { CHIP_ERROR err = CHIP_NO_ERROR; @@ -73,6 +106,10 @@ extern "C" void main_task(void const * argument) // Init Chip memory management before the stack chip::Platform::MemoryInit(); +#ifdef K32WMCM_APP_BUILD + APP_SetHighTxPowerMode(); +#endif + err = PlatformMgr().InitChipStack(); if (err != CHIP_NO_ERROR) { @@ -98,12 +135,12 @@ extern "C" void main_task(void const * argument) goto exit; } - err = PlatformMgr().StartEventLoopTask(); - if (err != CHIP_NO_ERROR) - { - K32W_LOG("Error during PlatformMgr().StartEventLoopTask();"); - goto exit; - } +#ifdef K32WMCM_APP_BUILD + APP_SetMaxTxPower(); + otPlatRadioSetTransmitPower(ThreadStackMgrImpl().OTInstance(), HIGH_TX_PWR_LIMIT); +#else + otPlatRadioSetTransmitPower(ThreadStackMgrImpl().OTInstance(), NORMAL_PWR_LIMIT); +#endif // Start OpenThread task err = ThreadStackMgrImpl().StartThreadTask(); @@ -120,6 +157,13 @@ extern "C" void main_task(void const * argument) goto exit; } + err = PlatformMgr().StartEventLoopTask(); + if (err != CHIP_NO_ERROR) + { + K32W_LOG("Error during PlatformMgr().StartEventLoopTask();"); + goto exit; + } + GetAppTask().AppTaskMain(NULL); exit: diff --git a/examples/lighting-app/nxp/zap/BUILD.gn b/examples/lighting-app/nxp/zap/BUILD.gn new file mode 100644 index 00000000000000..fd4026e2b9dbf7 --- /dev/null +++ b/examples/lighting-app/nxp/zap/BUILD.gn @@ -0,0 +1,25 @@ +# 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. + +import("//build_overrides/chip.gni") +import("${chip_root}/examples/common/pigweed/pigweed_rpcs.gni") +import("${chip_root}/src/app/chip_data_model.gni") + +chip_data_model("zap") { + zap_file = "lighting-on-off.zap" + + zap_pregenerated_dir = + "${chip_root}/zzz_generated/lighting-app/nxp/zap-generated" + is_server = true +} diff --git a/examples/lighting-app/nxp/zap/lighting-on-off.matter b/examples/lighting-app/nxp/zap/lighting-on-off.matter new file mode 100644 index 00000000000000..f3c1b5aba6a0b0 --- /dev/null +++ b/examples/lighting-app/nxp/zap/lighting-on-off.matter @@ -0,0 +1,1431 @@ +// This IDL was generated automatically by ZAP. +// It is for view/code review purposes only. + +server cluster Identify = 3 { + enum IdentifyEffectIdentifier : ENUM8 { + kBlink = 0; + kBreathe = 1; + kOkay = 2; + kChannelChange = 11; + kFinishEffect = 254; + kStopEffect = 255; + } + + enum IdentifyEffectVariant : ENUM8 { + kDefault = 0; + } + + enum IdentifyIdentifyType : ENUM8 { + kNone = 0; + kVisibleLight = 1; + kVisibleLED = 2; + kAudibleBeep = 3; + kDisplay = 4; + kActuator = 5; + } + + attribute int16u identifyTime = 0; + readonly attribute enum8 identifyType = 1; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct IdentifyRequest { + INT16U identifyTime = 0; + } + + request struct TriggerEffectRequest { + IdentifyEffectIdentifier effectIdentifier = 0; + IdentifyEffectVariant effectVariant = 1; + } + + command access(invoke: manage) Identify(IdentifyRequest): DefaultSuccess = 0; + command access(invoke: manage) TriggerEffect(TriggerEffectRequest): DefaultSuccess = 64; +} + +server cluster Groups = 4 { + bitmap GroupClusterFeature : BITMAP32 { + kGroupNames = 0x1; + } + + readonly attribute bitmap8 nameSupport = 0; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AddGroupRequest { + group_id groupId = 0; + CHAR_STRING groupName = 1; + } + + request struct ViewGroupRequest { + group_id groupId = 0; + } + + request struct GetGroupMembershipRequest { + group_id groupList[] = 0; + } + + request struct RemoveGroupRequest { + group_id groupId = 0; + } + + request struct AddGroupIfIdentifyingRequest { + group_id groupId = 0; + CHAR_STRING groupName = 1; + } + + response struct AddGroupResponse = 0 { + ENUM8 status = 0; + group_id groupId = 1; + } + + response struct ViewGroupResponse = 1 { + ENUM8 status = 0; + group_id groupId = 1; + CHAR_STRING groupName = 2; + } + + response struct GetGroupMembershipResponse = 2 { + nullable INT8U capacity = 0; + group_id groupList[] = 1; + } + + response struct RemoveGroupResponse = 3 { + ENUM8 status = 0; + group_id groupId = 1; + } + + fabric command access(invoke: manage) AddGroup(AddGroupRequest): AddGroupResponse = 0; + fabric command ViewGroup(ViewGroupRequest): ViewGroupResponse = 1; + fabric command GetGroupMembership(GetGroupMembershipRequest): GetGroupMembershipResponse = 2; + fabric command access(invoke: manage) RemoveGroup(RemoveGroupRequest): RemoveGroupResponse = 3; + fabric command access(invoke: manage) RemoveAllGroups(): DefaultSuccess = 4; + fabric command access(invoke: manage) AddGroupIfIdentifying(AddGroupIfIdentifyingRequest): DefaultSuccess = 5; +} + +server cluster OnOff = 6 { + enum OnOffDelayedAllOffEffectVariant : ENUM8 { + kFadeToOffIn0p8Seconds = 0; + kNoFade = 1; + k50PercentDimDownIn0p8SecondsThenFadeToOffIn12Seconds = 2; + } + + enum OnOffDyingLightEffectVariant : ENUM8 { + k20PercenterDimUpIn0p5SecondsThenFadeToOffIn1Second = 0; + } + + enum OnOffEffectIdentifier : ENUM8 { + kDelayedAllOff = 0; + kDyingLight = 1; + } + + enum OnOffStartUpOnOff : ENUM8 { + kOff = 0; + kOn = 1; + kTogglePreviousOnOff = 2; + } + + bitmap OnOffControl : BITMAP8 { + kAcceptOnlyWhenOn = 0x1; + } + + bitmap OnOffFeature : BITMAP32 { + kLighting = 0x1; + } + + bitmap SceneFeatures : BITMAP32 { + kSceneNames = 0x1; + } + + readonly nosubscribe attribute boolean onOff = 0; + readonly attribute boolean globalSceneControl = 16384; + attribute int16u onTime = 16385; + attribute int16u offWaitTime = 16386; + attribute access(write: manage) nullable OnOffStartUpOnOff startUpOnOff = 16387; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct OffWithEffectRequest { + OnOffEffectIdentifier effectId = 0; + OnOffDelayedAllOffEffectVariant effectVariant = 1; + } + + request struct OnWithTimedOffRequest { + OnOffControl onOffControl = 0; + int16u onTime = 1; + int16u offWaitTime = 2; + } + + command Off(): DefaultSuccess = 0; + command On(): DefaultSuccess = 1; + command Toggle(): DefaultSuccess = 2; + command OffWithEffect(OffWithEffectRequest): DefaultSuccess = 64; + command OnWithRecallGlobalScene(): DefaultSuccess = 65; + command OnWithTimedOff(OnWithTimedOffRequest): DefaultSuccess = 66; +} + +server cluster LevelControl = 8 { + enum MoveMode : ENUM8 { + kUp = 0; + kDown = 1; + } + + enum StepMode : ENUM8 { + kUp = 0; + kDown = 1; + } + + bitmap LevelControlFeature : BITMAP32 { + kOnOff = 0x1; + kLighting = 0x2; + kFrequency = 0x4; + } + + readonly attribute nullable int8u currentLevel = 0; + readonly attribute int16u remainingTime = 1; + readonly attribute int8u minLevel = 2; + readonly attribute int8u maxLevel = 3; + attribute bitmap8 options = 15; + attribute nullable int8u onLevel = 17; + attribute access(write: manage) nullable int8u startUpCurrentLevel = 16384; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct MoveToLevelRequest { + INT8U level = 0; + nullable INT16U transitionTime = 1; + BITMAP8 optionsMask = 2; + BITMAP8 optionsOverride = 3; + } + + request struct MoveRequest { + MoveMode moveMode = 0; + nullable INT8U rate = 1; + BITMAP8 optionsMask = 2; + BITMAP8 optionsOverride = 3; + } + + request struct StepRequest { + StepMode stepMode = 0; + INT8U stepSize = 1; + nullable INT16U transitionTime = 2; + BITMAP8 optionsMask = 3; + BITMAP8 optionsOverride = 4; + } + + request struct StopRequest { + BITMAP8 optionsMask = 0; + BITMAP8 optionsOverride = 1; + } + + request struct MoveToLevelWithOnOffRequest { + INT8U level = 0; + nullable INT16U transitionTime = 1; + BITMAP8 optionsMask = 2; + BITMAP8 optionsOverride = 3; + } + + request struct MoveWithOnOffRequest { + MoveMode moveMode = 0; + nullable INT8U rate = 1; + BITMAP8 optionsMask = 2; + BITMAP8 optionsOverride = 3; + } + + request struct StepWithOnOffRequest { + StepMode stepMode = 0; + INT8U stepSize = 1; + nullable INT16U transitionTime = 2; + BITMAP8 optionsMask = 3; + BITMAP8 optionsOverride = 4; + } + + request struct StopWithOnOffRequest { + BITMAP8 optionsMask = 0; + BITMAP8 optionsOverride = 1; + } + + command MoveToLevel(MoveToLevelRequest): DefaultSuccess = 0; + command Move(MoveRequest): DefaultSuccess = 1; + command Step(StepRequest): DefaultSuccess = 2; + command Stop(StopRequest): DefaultSuccess = 3; + command MoveToLevelWithOnOff(MoveToLevelWithOnOffRequest): DefaultSuccess = 4; + command MoveWithOnOff(MoveWithOnOffRequest): DefaultSuccess = 5; + command StepWithOnOff(StepWithOnOffRequest): DefaultSuccess = 6; + command StopWithOnOff(StopWithOnOffRequest): DefaultSuccess = 7; +} + +server cluster Descriptor = 29 { + struct DeviceTypeStruct { + devtype_id type = 0; + int16u revision = 1; + } + + readonly attribute DeviceTypeStruct deviceTypeList[] = 0; + readonly attribute CLUSTER_ID serverList[] = 1; + readonly attribute CLUSTER_ID clientList[] = 2; + readonly attribute ENDPOINT_NO partsList[] = 3; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +server cluster AccessControl = 31 { + enum AuthMode : ENUM8 { + kPase = 1; + kCase = 2; + kGroup = 3; + } + + enum ChangeTypeEnum : ENUM8 { + kChanged = 0; + kAdded = 1; + kRemoved = 2; + } + + enum Privilege : ENUM8 { + kView = 1; + kProxyView = 2; + kOperate = 3; + kManage = 4; + kAdminister = 5; + } + + struct AccessControlEntry { + Privilege privilege = 1; + AuthMode authMode = 2; + nullable int64u subjects[] = 3; + nullable Target targets[] = 4; + fabric_idx fabricIndex = 254; + } + + struct Target { + nullable cluster_id cluster = 0; + nullable endpoint_no endpoint = 1; + nullable devtype_id deviceType = 2; + } + + info event access(read: administer) AccessControlEntryChanged = 0 { + nullable node_id adminNodeID = 1; + nullable INT16U adminPasscodeID = 2; + ChangeTypeEnum changeType = 3; + nullable AccessControlEntry latestValue = 4; + fabric_idx fabricIndex = 254; + } + + info event access(read: administer) AccessControlExtensionChanged = 1 { + nullable node_id adminNodeID = 1; + nullable INT16U adminPasscodeID = 2; + ChangeTypeEnum changeType = 3; + nullable ExtensionEntry latestValue = 4; + fabric_idx fabricIndex = 254; + } + + attribute access(read: administer, write: administer) AccessControlEntry acl[] = 0; + readonly attribute int16u subjectsPerAccessControlEntry = 2; + readonly attribute int16u targetsPerAccessControlEntry = 3; + readonly attribute int16u accessControlEntriesPerFabric = 4; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +server cluster Basic = 40 { + struct CapabilityMinimaStruct { + int16u caseSessionsPerFabric = 0; + int16u subscriptionsPerFabric = 1; + } + + critical event StartUp = 0 { + INT32U softwareVersion = 0; + } + + critical event ShutDown = 1 { + } + + info event Leave = 2 { + fabric_idx fabricIndex = 0; + } + + info event ReachableChanged = 3 { + boolean reachableNewValue = 0; + } + + readonly attribute int16u dataModelRevision = 0; + readonly attribute char_string<32> vendorName = 1; + readonly attribute vendor_id vendorID = 2; + readonly attribute char_string<32> productName = 3; + readonly attribute int16u productID = 4; + attribute access(write: manage) char_string<32> nodeLabel = 5; + attribute access(write: administer) char_string<2> location = 6; + readonly attribute int16u hardwareVersion = 7; + readonly attribute char_string<64> hardwareVersionString = 8; + readonly attribute int32u softwareVersion = 9; + readonly attribute char_string<64> softwareVersionString = 10; + readonly attribute CapabilityMinimaStruct capabilityMinima = 19; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; +} + +client cluster OtaSoftwareUpdateProvider = 41 { + enum OTAApplyUpdateAction : ENUM8 { + kProceed = 0; + kAwaitNextAction = 1; + kDiscontinue = 2; + } + + enum OTADownloadProtocol : ENUM8 { + kBDXSynchronous = 0; + kBDXAsynchronous = 1; + kHttps = 2; + kVendorSpecific = 3; + } + + enum OTAQueryStatus : ENUM8 { + kUpdateAvailable = 0; + kBusy = 1; + kNotAvailable = 2; + kDownloadProtocolNotSupported = 3; + } + + readonly attribute int16u clusterRevision = 65533; + + request struct QueryImageRequest { + vendor_id vendorId = 0; + INT16U productId = 1; + INT32U softwareVersion = 2; + OTADownloadProtocol protocolsSupported[] = 3; + optional INT16U hardwareVersion = 4; + optional CHAR_STRING<2> location = 5; + optional BOOLEAN requestorCanConsent = 6; + optional OCTET_STRING<512> metadataForProvider = 7; + } + + request struct ApplyUpdateRequestRequest { + OCTET_STRING<32> updateToken = 0; + INT32U newVersion = 1; + } + + request struct NotifyUpdateAppliedRequest { + OCTET_STRING<32> updateToken = 0; + INT32U softwareVersion = 1; + } + + response struct QueryImageResponse = 1 { + OTAQueryStatus status = 0; + optional INT32U delayedActionTime = 1; + optional CHAR_STRING<256> imageURI = 2; + optional INT32U softwareVersion = 3; + optional CHAR_STRING<64> softwareVersionString = 4; + optional OCTET_STRING<32> updateToken = 5; + optional BOOLEAN userConsentNeeded = 6; + optional OCTET_STRING<512> metadataForRequestor = 7; + } + + response struct ApplyUpdateResponse = 3 { + OTAApplyUpdateAction action = 0; + INT32U delayedActionTime = 1; + } + + command QueryImage(QueryImageRequest): QueryImageResponse = 0; + command ApplyUpdateRequest(ApplyUpdateRequestRequest): ApplyUpdateResponse = 2; + command NotifyUpdateApplied(NotifyUpdateAppliedRequest): DefaultSuccess = 4; +} + +server cluster OtaSoftwareUpdateRequestor = 42 { + enum OTAAnnouncementReason : ENUM8 { + kSimpleAnnouncement = 0; + kUpdateAvailable = 1; + kUrgentUpdateAvailable = 2; + } + + enum OTAChangeReasonEnum : ENUM8 { + kUnknown = 0; + kSuccess = 1; + kFailure = 2; + kTimeOut = 3; + kDelayByProvider = 4; + } + + enum OTAUpdateStateEnum : ENUM8 { + kUnknown = 0; + kIdle = 1; + kQuerying = 2; + kDelayedOnQuery = 3; + kDownloading = 4; + kApplying = 5; + kDelayedOnApply = 6; + kRollingBack = 7; + kDelayedOnUserConsent = 8; + } + + struct ProviderLocation { + node_id providerNodeID = 1; + endpoint_no endpoint = 2; + fabric_idx fabricIndex = 254; + } + + info event StateTransition = 0 { + OTAUpdateStateEnum previousState = 0; + OTAUpdateStateEnum newState = 1; + OTAChangeReasonEnum reason = 2; + nullable INT32U targetSoftwareVersion = 3; + } + + critical event VersionApplied = 1 { + INT32U softwareVersion = 0; + INT16U productID = 1; + } + + info event DownloadError = 2 { + INT32U softwareVersion = 0; + INT64U bytesDownloaded = 1; + nullable INT8U progressPercent = 2; + nullable INT64S platformCode = 3; + } + + attribute ProviderLocation defaultOtaProviders[] = 0; + readonly attribute boolean updatePossible = 1; + readonly attribute OTAUpdateStateEnum updateState = 2; + readonly attribute nullable int8u updateStateProgress = 3; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AnnounceOtaProviderRequest { + node_id providerNodeId = 0; + vendor_id vendorId = 1; + OTAAnnouncementReason announcementReason = 2; + optional OCTET_STRING<512> metadataForNode = 3; + endpoint_no endpoint = 4; + } + + command AnnounceOtaProvider(AnnounceOtaProviderRequest): DefaultSuccess = 0; +} + +server cluster GeneralCommissioning = 48 { + enum CommissioningError : ENUM8 { + kOk = 0; + kValueOutsideRange = 1; + kInvalidAuthentication = 2; + kNoFailSafe = 3; + kBusyWithOtherAdmin = 4; + } + + enum RegulatoryLocationType : ENUM8 { + kIndoor = 0; + kOutdoor = 1; + kIndoorOutdoor = 2; + } + + struct BasicCommissioningInfo { + int16u failSafeExpiryLengthSeconds = 0; + int16u maxCumulativeFailsafeSeconds = 1; + } + + attribute access(write: administer) int64u breadcrumb = 0; + readonly attribute BasicCommissioningInfo basicCommissioningInfo = 1; + readonly attribute RegulatoryLocationType regulatoryConfig = 2; + readonly attribute RegulatoryLocationType locationCapability = 3; + readonly attribute boolean supportsConcurrentConnection = 4; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct ArmFailSafeRequest { + INT16U expiryLengthSeconds = 0; + INT64U breadcrumb = 1; + } + + request struct SetRegulatoryConfigRequest { + RegulatoryLocationType newRegulatoryConfig = 0; + CHAR_STRING countryCode = 1; + INT64U breadcrumb = 2; + } + + response struct ArmFailSafeResponse = 1 { + CommissioningError errorCode = 0; + CHAR_STRING debugText = 1; + } + + response struct SetRegulatoryConfigResponse = 3 { + CommissioningError errorCode = 0; + CHAR_STRING debugText = 1; + } + + response struct CommissioningCompleteResponse = 5 { + CommissioningError errorCode = 0; + CHAR_STRING debugText = 1; + } + + command access(invoke: administer) ArmFailSafe(ArmFailSafeRequest): ArmFailSafeResponse = 0; + command access(invoke: administer) SetRegulatoryConfig(SetRegulatoryConfigRequest): SetRegulatoryConfigResponse = 2; + fabric command access(invoke: administer) CommissioningComplete(): CommissioningCompleteResponse = 4; +} + +server cluster NetworkCommissioning = 49 { + enum NetworkCommissioningStatus : ENUM8 { + kSuccess = 0; + kOutOfRange = 1; + kBoundsExceeded = 2; + kNetworkIDNotFound = 3; + kDuplicateNetworkID = 4; + kNetworkNotFound = 5; + kRegulatoryError = 6; + kAuthFailure = 7; + kUnsupportedSecurity = 8; + kOtherConnectionFailure = 9; + kIPV6Failed = 10; + kIPBindFailed = 11; + kUnknownError = 12; + } + + enum WiFiBand : ENUM8 { + k2g4 = 0; + k3g65 = 1; + k5g = 2; + k6g = 3; + k60g = 4; + } + + bitmap NetworkCommissioningFeature : BITMAP32 { + kWiFiNetworkInterface = 0x1; + kThreadNetworkInterface = 0x2; + kEthernetNetworkInterface = 0x4; + } + + bitmap WiFiSecurity : BITMAP8 { + kUnencrypted = 0x1; + kWepPersonal = 0x2; + kWpaPersonal = 0x4; + kWpa2Personal = 0x8; + kWpa3Personal = 0x10; + } + + struct NetworkInfo { + octet_string<32> networkID = 0; + boolean connected = 1; + } + + struct WiFiInterfaceScanResult { + WiFiSecurity security = 0; + octet_string<32> ssid = 1; + octet_string<6> bssid = 2; + int16u channel = 3; + WiFiBand wiFiBand = 4; + int8s rssi = 5; + } + + struct ThreadInterfaceScanResult { + int16u panId = 0; + int64u extendedPanId = 1; + char_string<16> networkName = 2; + int16u channel = 3; + int8u version = 4; + octet_string<8> extendedAddress = 5; + int8s rssi = 6; + int8u lqi = 7; + } + + readonly attribute access(read: administer) int8u maxNetworks = 0; + readonly attribute access(read: administer) NetworkInfo networks[] = 1; + readonly attribute int8u scanMaxTimeSeconds = 2; + readonly attribute int8u connectMaxTimeSeconds = 3; + attribute access(write: administer) boolean interfaceEnabled = 4; + readonly attribute access(read: administer) nullable NetworkCommissioningStatus lastNetworkingStatus = 5; + readonly attribute access(read: administer) nullable octet_string<32> lastNetworkID = 6; + readonly attribute access(read: administer) nullable int32s lastConnectErrorValue = 7; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct ScanNetworksRequest { + optional nullable OCTET_STRING<32> ssid = 0; + optional INT64U breadcrumb = 1; + } + + request struct AddOrUpdateThreadNetworkRequest { + OCTET_STRING<254> operationalDataset = 0; + optional INT64U breadcrumb = 1; + } + + request struct RemoveNetworkRequest { + OCTET_STRING<32> networkID = 0; + optional INT64U breadcrumb = 1; + } + + request struct ConnectNetworkRequest { + OCTET_STRING<32> networkID = 0; + optional INT64U breadcrumb = 1; + } + + request struct ReorderNetworkRequest { + OCTET_STRING<32> networkID = 0; + INT8U networkIndex = 1; + optional INT64U breadcrumb = 2; + } + + response struct ScanNetworksResponse = 1 { + NetworkCommissioningStatus networkingStatus = 0; + optional CHAR_STRING debugText = 1; + optional WiFiInterfaceScanResult wiFiScanResults[] = 2; + optional ThreadInterfaceScanResult threadScanResults[] = 3; + } + + response struct NetworkConfigResponse = 5 { + NetworkCommissioningStatus networkingStatus = 0; + optional CHAR_STRING<512> debugText = 1; + optional INT8U networkIndex = 2; + } + + response struct ConnectNetworkResponse = 7 { + NetworkCommissioningStatus networkingStatus = 0; + optional CHAR_STRING debugText = 1; + nullable INT32S errorValue = 2; + } + + command access(invoke: administer) ScanNetworks(ScanNetworksRequest): ScanNetworksResponse = 0; + command access(invoke: administer) AddOrUpdateThreadNetwork(AddOrUpdateThreadNetworkRequest): NetworkConfigResponse = 3; + command access(invoke: administer) RemoveNetwork(RemoveNetworkRequest): NetworkConfigResponse = 4; + command access(invoke: administer) ConnectNetwork(ConnectNetworkRequest): ConnectNetworkResponse = 6; + command access(invoke: administer) ReorderNetwork(ReorderNetworkRequest): NetworkConfigResponse = 8; +} + +server cluster GeneralDiagnostics = 51 { + enum BootReasonType : ENUM8 { + kUnspecified = 0; + kPowerOnReboot = 1; + kBrownOutReset = 2; + kSoftwareWatchdogReset = 3; + kHardwareWatchdogReset = 4; + kSoftwareUpdateCompleted = 5; + kSoftwareReset = 6; + } + + enum HardwareFaultType : ENUM8 { + kUnspecified = 0; + kRadio = 1; + kSensor = 2; + kResettableOverTemp = 3; + kNonResettableOverTemp = 4; + kPowerSource = 5; + kVisualDisplayFault = 6; + kAudioOutputFault = 7; + kUserInterfaceFault = 8; + kNonVolatileMemoryError = 9; + kTamperDetected = 10; + } + + enum InterfaceType : ENUM8 { + kUnspecified = 0; + kWiFi = 1; + kEthernet = 2; + kCellular = 3; + kThread = 4; + } + + enum NetworkFaultType : ENUM8 { + kUnspecified = 0; + kHardwareFailure = 1; + kNetworkJammed = 2; + kConnectionFailed = 3; + } + + enum RadioFaultType : ENUM8 { + kUnspecified = 0; + kWiFiFault = 1; + kCellularFault = 2; + kThreadFault = 3; + kNFCFault = 4; + kBLEFault = 5; + kEthernetFault = 6; + } + + struct NetworkInterfaceType { + char_string<32> name = 0; + boolean isOperational = 1; + nullable boolean offPremiseServicesReachableIPv4 = 2; + nullable boolean offPremiseServicesReachableIPv6 = 3; + octet_string<8> hardwareAddress = 4; + octet_string IPv4Addresses[] = 5; + octet_string IPv6Addresses[] = 6; + InterfaceType type = 7; + } + + critical event HardwareFaultChange = 0 { + HardwareFaultType current[] = 0; + HardwareFaultType previous[] = 1; + } + + critical event RadioFaultChange = 1 { + RadioFaultType current[] = 0; + RadioFaultType previous[] = 1; + } + + critical event NetworkFaultChange = 2 { + NetworkFaultType current[] = 0; + NetworkFaultType previous[] = 1; + } + + critical event BootReason = 3 { + BootReasonType bootReason = 0; + } + + readonly attribute NetworkInterfaceType networkInterfaces[] = 0; + readonly attribute int16u rebootCount = 1; + readonly attribute boolean testEventTriggersEnabled = 8; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct TestEventTriggerRequest { + OCTET_STRING<16> enableKey = 0; + INT64U eventTrigger = 1; + } + + command access(invoke: manage) TestEventTrigger(TestEventTriggerRequest): DefaultSuccess = 0; +} + +server cluster SoftwareDiagnostics = 52 { + bitmap SoftwareDiagnosticsFeature : BITMAP32 { + kWaterMarks = 0x1; + } + + struct ThreadMetrics { + int64u id = 0; + optional char_string<8> name = 1; + optional int32u stackFreeCurrent = 2; + optional int32u stackFreeMinimum = 3; + optional int32u stackSize = 4; + } + + info event SoftwareFault = 0 { + INT64U id = 0; + optional CHAR_STRING name = 1; + optional OCTET_STRING faultRecording = 2; + } + + readonly attribute ThreadMetrics threadMetrics[] = 0; + readonly attribute int64u currentHeapFree = 1; + readonly attribute int64u currentHeapUsed = 2; + readonly attribute int64u currentHeapHighWatermark = 3; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + command ResetWatermarks(): DefaultSuccess = 0; +} + +server cluster ThreadNetworkDiagnostics = 53 { + enum NetworkFault : ENUM8 { + kUnspecified = 0; + kLinkDown = 1; + kHardwareFailure = 2; + kNetworkJammed = 3; + } + + enum RoutingRole : ENUM8 { + kUnspecified = 0; + kUnassigned = 1; + kSleepyEndDevice = 2; + kEndDevice = 3; + kReed = 4; + kRouter = 5; + kLeader = 6; + } + + enum ThreadConnectionStatus : ENUM8 { + kConnected = 0; + kNotConnected = 1; + } + + bitmap ThreadNetworkDiagnosticsFeature : BITMAP32 { + kPacketCounts = 0x1; + kErrorCounts = 0x2; + kMLECounts = 0x4; + kMACCounts = 0x8; + } + + struct NeighborTable { + int64u extAddress = 0; + int32u age = 1; + int16u rloc16 = 2; + int32u linkFrameCounter = 3; + int32u mleFrameCounter = 4; + int8u lqi = 5; + nullable int8s averageRssi = 6; + nullable int8s lastRssi = 7; + int8u frameErrorRate = 8; + int8u messageErrorRate = 9; + boolean rxOnWhenIdle = 10; + boolean fullThreadDevice = 11; + boolean fullNetworkData = 12; + boolean isChild = 13; + } + + struct RouteTable { + int64u extAddress = 0; + int16u rloc16 = 1; + int8u routerId = 2; + int8u nextHop = 3; + int8u pathCost = 4; + int8u LQIIn = 5; + int8u LQIOut = 6; + int8u age = 7; + boolean allocated = 8; + boolean linkEstablished = 9; + } + + struct SecurityPolicy { + int16u rotationTime = 0; + bitmap16 flags = 1; + } + + struct OperationalDatasetComponents { + boolean activeTimestampPresent = 0; + boolean pendingTimestampPresent = 1; + boolean masterKeyPresent = 2; + boolean networkNamePresent = 3; + boolean extendedPanIdPresent = 4; + boolean meshLocalPrefixPresent = 5; + boolean delayPresent = 6; + boolean panIdPresent = 7; + boolean channelPresent = 8; + boolean pskcPresent = 9; + boolean securityPolicyPresent = 10; + boolean channelMaskPresent = 11; + } + + info event ConnectionStatus = 0 { + ThreadConnectionStatus connectionStatus = 0; + } + + info event NetworkFaultChange = 1 { + NetworkFault current[] = 0; + NetworkFault previous[] = 1; + } + + readonly attribute nullable int16u channel = 0; + readonly attribute nullable RoutingRole routingRole = 1; + readonly attribute nullable char_string<16> networkName = 2; + readonly attribute nullable int16u panId = 3; + readonly attribute nullable int64u extendedPanId = 4; + readonly attribute nullable octet_string<17> meshLocalPrefix = 5; + readonly attribute int64u overrunCount = 6; + readonly attribute NeighborTable neighborTableList[] = 7; + readonly attribute RouteTable routeTableList[] = 8; + readonly attribute nullable int32u partitionId = 9; + readonly attribute nullable int8u weighting = 10; + readonly attribute nullable int8u dataVersion = 11; + readonly attribute nullable int8u stableDataVersion = 12; + readonly attribute nullable int8u leaderRouterId = 13; + readonly attribute int16u detachedRoleCount = 14; + readonly attribute int16u childRoleCount = 15; + readonly attribute int16u routerRoleCount = 16; + readonly attribute int16u leaderRoleCount = 17; + readonly attribute int16u attachAttemptCount = 18; + readonly attribute int16u partitionIdChangeCount = 19; + readonly attribute int16u betterPartitionAttachAttemptCount = 20; + readonly attribute int16u parentChangeCount = 21; + readonly attribute int32u txTotalCount = 22; + readonly attribute int32u txUnicastCount = 23; + readonly attribute int32u txBroadcastCount = 24; + readonly attribute int32u txAckRequestedCount = 25; + readonly attribute int32u txAckedCount = 26; + readonly attribute int32u txNoAckRequestedCount = 27; + readonly attribute int32u txDataCount = 28; + readonly attribute int32u txDataPollCount = 29; + readonly attribute int32u txBeaconCount = 30; + readonly attribute int32u txBeaconRequestCount = 31; + readonly attribute int32u txOtherCount = 32; + readonly attribute int32u txRetryCount = 33; + readonly attribute int32u txDirectMaxRetryExpiryCount = 34; + readonly attribute int32u txIndirectMaxRetryExpiryCount = 35; + readonly attribute int32u txErrCcaCount = 36; + readonly attribute int32u txErrAbortCount = 37; + readonly attribute int32u txErrBusyChannelCount = 38; + readonly attribute int32u rxTotalCount = 39; + readonly attribute int32u rxUnicastCount = 40; + readonly attribute int32u rxBroadcastCount = 41; + readonly attribute int32u rxDataCount = 42; + readonly attribute int32u rxDataPollCount = 43; + readonly attribute int32u rxBeaconCount = 44; + readonly attribute int32u rxBeaconRequestCount = 45; + readonly attribute int32u rxOtherCount = 46; + readonly attribute int32u rxAddressFilteredCount = 47; + readonly attribute int32u rxDestAddrFilteredCount = 48; + readonly attribute int32u rxDuplicatedCount = 49; + readonly attribute int32u rxErrNoFrameCount = 50; + readonly attribute int32u rxErrUnknownNeighborCount = 51; + readonly attribute int32u rxErrInvalidSrcAddrCount = 52; + readonly attribute int32u rxErrSecCount = 53; + readonly attribute int32u rxErrFcsCount = 54; + readonly attribute int32u rxErrOtherCount = 55; + readonly attribute nullable SecurityPolicy securityPolicy = 59; + readonly attribute nullable octet_string<4> channelPage0Mask = 60; + readonly attribute nullable OperationalDatasetComponents operationalDatasetComponents = 61; + readonly attribute NetworkFault activeNetworkFaultsList[] = 62; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + command ResetCounts(): DefaultSuccess = 0; +} + +server cluster AdministratorCommissioning = 60 { + enum CommissioningWindowStatus : ENUM8 { + kWindowNotOpen = 0; + kEnhancedWindowOpen = 1; + kBasicWindowOpen = 2; + } + + enum StatusCode : ENUM8 { + kBusy = 2; + kPAKEParameterError = 3; + kWindowNotOpen = 4; + } + + readonly attribute CommissioningWindowStatus windowStatus = 0; + readonly attribute nullable fabric_idx adminFabricIndex = 1; + readonly attribute nullable int16u adminVendorId = 2; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct OpenCommissioningWindowRequest { + INT16U commissioningTimeout = 0; + OCTET_STRING PAKEVerifier = 1; + INT16U discriminator = 2; + INT32U iterations = 3; + OCTET_STRING salt = 4; + } + + timed command access(invoke: administer) OpenCommissioningWindow(OpenCommissioningWindowRequest): DefaultSuccess = 0; + timed command access(invoke: administer) RevokeCommissioning(): DefaultSuccess = 2; +} + +server cluster OperationalCredentials = 62 { + enum OperationalCertStatus : ENUM8 { + kSuccess = 0; + kInvalidPublicKey = 1; + kInvalidNodeOpId = 2; + kInvalidNOC = 3; + kMissingCsr = 4; + kTableFull = 5; + kInvalidAdminSubject = 6; + kFabricConflict = 9; + kLabelConflict = 10; + kInvalidFabricIndex = 11; + } + + struct NOCStruct { + octet_string noc = 1; + nullable octet_string icac = 2; + fabric_idx fabricIndex = 254; + } + + struct FabricDescriptor { + octet_string<65> rootPublicKey = 1; + vendor_id vendorId = 2; + fabric_id fabricId = 3; + node_id nodeId = 4; + char_string<32> label = 5; + fabric_idx fabricIndex = 254; + } + + readonly attribute access(read: administer) NOCStruct NOCs[] = 0; + readonly attribute FabricDescriptor fabrics[] = 1; + readonly attribute int8u supportedFabrics = 2; + readonly attribute int8u commissionedFabrics = 3; + readonly attribute OCTET_STRING trustedRootCertificates[] = 4; + readonly attribute int8u currentFabricIndex = 5; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct AttestationRequestRequest { + OCTET_STRING attestationNonce = 0; + } + + request struct CertificateChainRequestRequest { + INT8U certificateType = 0; + } + + request struct CSRRequestRequest { + OCTET_STRING CSRNonce = 0; + optional boolean isForUpdateNOC = 1; + } + + request struct AddNOCRequest { + OCTET_STRING NOCValue = 0; + optional OCTET_STRING ICACValue = 1; + OCTET_STRING IPKValue = 2; + Int64u caseAdminSubject = 3; + VENDOR_ID adminVendorId = 4; + } + + request struct UpdateNOCRequest { + OCTET_STRING NOCValue = 0; + optional OCTET_STRING ICACValue = 1; + } + + request struct UpdateFabricLabelRequest { + CHAR_STRING<32> label = 0; + } + + request struct RemoveFabricRequest { + fabric_idx fabricIndex = 0; + } + + request struct AddTrustedRootCertificateRequest { + OCTET_STRING rootCertificate = 0; + } + + response struct AttestationResponse = 1 { + OCTET_STRING attestationElements = 0; + OCTET_STRING signature = 1; + } + + response struct CertificateChainResponse = 3 { + OCTET_STRING certificate = 0; + } + + response struct CSRResponse = 5 { + OCTET_STRING NOCSRElements = 0; + OCTET_STRING attestationSignature = 1; + } + + response struct NOCResponse = 8 { + OperationalCertStatus statusCode = 0; + optional fabric_idx fabricIndex = 1; + optional CHAR_STRING debugText = 2; + } + + command access(invoke: administer) AttestationRequest(AttestationRequestRequest): AttestationResponse = 0; + command access(invoke: administer) CertificateChainRequest(CertificateChainRequestRequest): CertificateChainResponse = 2; + command access(invoke: administer) CSRRequest(CSRRequestRequest): CSRResponse = 4; + command access(invoke: administer) AddNOC(AddNOCRequest): NOCResponse = 6; + fabric command access(invoke: administer) UpdateNOC(UpdateNOCRequest): NOCResponse = 7; + fabric command access(invoke: administer) UpdateFabricLabel(UpdateFabricLabelRequest): NOCResponse = 9; + command access(invoke: administer) RemoveFabric(RemoveFabricRequest): NOCResponse = 10; + command access(invoke: administer) AddTrustedRootCertificate(AddTrustedRootCertificateRequest): DefaultSuccess = 11; +} + +server cluster GroupKeyManagement = 63 { + enum GroupKeySecurityPolicy : ENUM8 { + kTrustFirst = 0; + kCacheAndSync = 1; + } + + struct GroupKeyMapStruct { + group_id groupId = 1; + int16u groupKeySetID = 2; + fabric_idx fabricIndex = 254; + } + + struct GroupInfoMapStruct { + group_id groupId = 1; + endpoint_no endpoints[] = 2; + optional char_string<16> groupName = 3; + fabric_idx fabricIndex = 254; + } + + struct GroupKeySetStruct { + int16u groupKeySetID = 0; + GroupKeySecurityPolicy groupKeySecurityPolicy = 1; + nullable octet_string<16> epochKey0 = 2; + nullable epoch_us epochStartTime0 = 3; + nullable octet_string<16> epochKey1 = 4; + nullable epoch_us epochStartTime1 = 5; + nullable octet_string<16> epochKey2 = 6; + nullable epoch_us epochStartTime2 = 7; + } + + attribute access(write: manage) GroupKeyMapStruct groupKeyMap[] = 0; + readonly attribute GroupInfoMapStruct groupTable[] = 1; + readonly attribute int16u maxGroupsPerFabric = 2; + readonly attribute int16u maxGroupKeysPerFabric = 3; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + request struct KeySetWriteRequest { + GroupKeySetStruct groupKeySet = 0; + } + + request struct KeySetReadRequest { + INT16U groupKeySetID = 0; + } + + request struct KeySetRemoveRequest { + INT16U groupKeySetID = 0; + } + + request struct KeySetReadAllIndicesRequest { + INT16U groupKeySetIDs[] = 0; + } + + response struct KeySetReadResponse = 2 { + GroupKeySetStruct groupKeySet = 0; + } + + response struct KeySetReadAllIndicesResponse = 5 { + INT16U groupKeySetIDs[] = 0; + } + + fabric command access(invoke: administer) KeySetWrite(KeySetWriteRequest): DefaultSuccess = 0; + fabric command access(invoke: administer) KeySetRead(KeySetReadRequest): KeySetReadResponse = 1; + fabric command access(invoke: administer) KeySetRemove(KeySetRemoveRequest): DefaultSuccess = 3; + fabric command access(invoke: administer) KeySetReadAllIndices(KeySetReadAllIndicesRequest): KeySetReadAllIndicesResponse = 4; +} + +endpoint 0 { + device type rootdevice = 22; + binding cluster OtaSoftwareUpdateProvider; + + server cluster Descriptor { + callback attribute deviceTypeList; + callback attribute serverList; + callback attribute clientList; + callback attribute partsList; + ram attribute featureMap; + callback attribute clusterRevision default = 1; + } + + server cluster AccessControl { + callback attribute acl; + callback attribute subjectsPerAccessControlEntry default = 4; + callback attribute targetsPerAccessControlEntry default = 3; + callback attribute accessControlEntriesPerFabric default = 3; + callback attribute attributeList; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster Basic { + callback attribute dataModelRevision default = 10; + callback attribute vendorName; + callback attribute vendorID; + callback attribute productName; + callback attribute productID; + persist attribute nodeLabel; + callback attribute location default = "XX"; + callback attribute hardwareVersion; + callback attribute hardwareVersionString; + callback attribute softwareVersion; + callback attribute softwareVersionString; + callback attribute capabilityMinima; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster OtaSoftwareUpdateRequestor { + callback attribute defaultOtaProviders; + ram attribute updatePossible default = 1; + ram attribute updateState; + ram attribute updateStateProgress; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster GeneralCommissioning { + ram attribute breadcrumb; + callback attribute basicCommissioningInfo; + callback attribute regulatoryConfig; + callback attribute locationCapability; + callback attribute supportsConcurrentConnection default = 1; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster NetworkCommissioning { + ram attribute maxNetworks; + callback attribute networks; + ram attribute scanMaxTimeSeconds; + ram attribute connectMaxTimeSeconds; + ram attribute interfaceEnabled; + ram attribute lastNetworkingStatus; + ram attribute lastNetworkID; + ram attribute lastConnectErrorValue; + ram attribute featureMap default = 2; + ram attribute clusterRevision default = 1; + } + + server cluster GeneralDiagnostics { + callback attribute networkInterfaces; + callback attribute rebootCount; + callback attribute testEventTriggersEnabled; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster SoftwareDiagnostics { + callback attribute threadMetrics; + callback attribute currentHeapFree; + callback attribute currentHeapUsed; + callback attribute currentHeapHighWatermark; + ram attribute featureMap default = 1; + ram attribute clusterRevision default = 1; + } + + server cluster ThreadNetworkDiagnostics { + callback attribute channel; + callback attribute routingRole; + callback attribute networkName; + callback attribute panId; + callback attribute extendedPanId; + callback attribute meshLocalPrefix; + callback attribute overrunCount; + callback attribute neighborTableList; + callback attribute routeTableList; + callback attribute partitionId; + callback attribute weighting; + callback attribute dataVersion; + callback attribute stableDataVersion; + callback attribute leaderRouterId; + callback attribute detachedRoleCount; + callback attribute childRoleCount; + callback attribute routerRoleCount; + callback attribute leaderRoleCount; + callback attribute attachAttemptCount; + callback attribute partitionIdChangeCount; + callback attribute betterPartitionAttachAttemptCount; + callback attribute parentChangeCount; + callback attribute txTotalCount; + callback attribute txUnicastCount; + callback attribute txBroadcastCount; + callback attribute txAckRequestedCount; + callback attribute txAckedCount; + callback attribute txNoAckRequestedCount; + callback attribute txDataCount; + callback attribute txDataPollCount; + callback attribute txBeaconCount; + callback attribute txBeaconRequestCount; + callback attribute txOtherCount; + callback attribute txRetryCount; + callback attribute txDirectMaxRetryExpiryCount; + callback attribute txIndirectMaxRetryExpiryCount; + callback attribute txErrCcaCount; + callback attribute txErrAbortCount; + callback attribute txErrBusyChannelCount; + callback attribute rxTotalCount; + callback attribute rxUnicastCount; + callback attribute rxBroadcastCount; + callback attribute rxDataCount; + callback attribute rxDataPollCount; + callback attribute rxBeaconCount; + callback attribute rxBeaconRequestCount; + callback attribute rxOtherCount; + callback attribute rxAddressFilteredCount; + callback attribute rxDestAddrFilteredCount; + callback attribute rxDuplicatedCount; + callback attribute rxErrNoFrameCount; + callback attribute rxErrUnknownNeighborCount; + callback attribute rxErrInvalidSrcAddrCount; + callback attribute rxErrSecCount; + callback attribute rxErrFcsCount; + callback attribute rxErrOtherCount; + callback attribute securityPolicy; + callback attribute channelPage0Mask; + callback attribute operationalDatasetComponents; + callback attribute activeNetworkFaultsList; + ram attribute featureMap default = 0x000F; + ram attribute clusterRevision default = 1; + } + + server cluster AdministratorCommissioning { + callback attribute windowStatus; + callback attribute adminFabricIndex default = 1; + callback attribute adminVendorId; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster OperationalCredentials { + callback attribute NOCs; + callback attribute fabrics; + callback attribute supportedFabrics; + callback attribute commissionedFabrics; + callback attribute trustedRootCertificates; + callback attribute currentFabricIndex; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } + + server cluster GroupKeyManagement { + callback attribute groupKeyMap; + callback attribute groupTable; + callback attribute maxGroupsPerFabric; + callback attribute maxGroupKeysPerFabric; + ram attribute featureMap; + ram attribute clusterRevision default = 1; + } +} +endpoint 1 { + device type dimmablelight = 256; + + server cluster Identify { + ram attribute identifyTime; + ram attribute identifyType; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap; + ram attribute clusterRevision default = 4; + } + + server cluster Groups { + ram attribute nameSupport; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap; + ram attribute clusterRevision default = 4; + } + + server cluster OnOff { + persist attribute onOff; + ram attribute globalSceneControl default = 0x01; + ram attribute onTime; + ram attribute offWaitTime; + persist attribute startUpOnOff default = 0xFF; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap default = 1; + ram attribute clusterRevision default = 4; + } + + server cluster LevelControl { + persist attribute currentLevel default = 0x01; + ram attribute remainingTime; + ram attribute minLevel default = 0x01; + ram attribute maxLevel default = 0xFE; + ram attribute options; + ram attribute onLevel; + persist attribute startUpCurrentLevel default = 254; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap default = 3; + ram attribute clusterRevision default = 5; + } + + server cluster Descriptor { + callback attribute deviceTypeList; + callback attribute serverList; + callback attribute clientList; + callback attribute partsList; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute attributeList; + ram attribute featureMap; + callback attribute clusterRevision default = 1; + } +} + + diff --git a/examples/lighting-app/nxp/zap/lighting-on-off.zap b/examples/lighting-app/nxp/zap/lighting-on-off.zap new file mode 100644 index 00000000000000..c9421d4b35f342 --- /dev/null +++ b/examples/lighting-app/nxp/zap/lighting-on-off.zap @@ -0,0 +1,9118 @@ +{ + "featureLevel": 81, + "creator": "zap", + "keyValuePairs": [ + { + "key": "commandDiscovery", + "value": "1" + }, + { + "key": "defaultResponsePolicy", + "value": "always" + }, + { + "key": "manufacturerCodes", + "value": "0x1002" + } + ], + "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../../src/app/zap-templates/zcl/zcl.json", + "type": "zcl-properties", + "category": "matter", + "version": 1, + "description": "Matter SDK ZCL data" + }, + { + "pathRelativity": "relativeToZap", + "path": "../../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + } + ], + "endpointTypes": [ + { + "name": "MA-rootdevice", + "deviceTypeName": "MA-rootdevice", + "deviceTypeCode": 22, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "Identify", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "identify time", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AddGroup", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ViewGroup", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "GetGroupMembership", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveGroup", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveAllGroups", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "AddGroupIfIdentifying", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "AddGroupResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ViewGroupResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "GetGroupMembershipResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveGroupResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "name support", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Scenes", + "code": 5, + "mfgCode": null, + "define": "SCENES_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AddScene", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ViewScene", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveScene", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveAllScenes", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StoreScene", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RecallScene", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "GetSceneMembership", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Scenes", + "code": 5, + "mfgCode": null, + "define": "SCENES_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "AddSceneResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ViewSceneResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveSceneResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveAllScenesResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "StoreSceneResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "GetSceneMembershipResponse", + "code": 6, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "SceneCount", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentScene", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentGroup", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "group_id", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SceneValid", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NameSupport", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/Off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "Off", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "On", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Toggle", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/Off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "OnOff", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/off Switch Configuration", + "code": 7, + "mfgCode": null, + "define": "ON_OFF_SWITCH_CONFIG_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/off Switch Configuration", + "code": 7, + "mfgCode": null, + "define": "ON_OFF_SWITCH_CONFIG_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "switch type", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "switch actions", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "MoveToLevel", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Move", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Step", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Stop", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveToLevelWithOnOff", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveWithOnOff", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StepWithOnOff", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StopWithOnOff", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "CurrentLevel", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DeviceTypeList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ServerList", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClientList", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PartsList", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Access Control", + "code": 31, + "mfgCode": null, + "define": "ACCESS_CONTROL_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Access Control", + "code": 31, + "mfgCode": null, + "define": "ACCESS_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ACL", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Extension", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SubjectsPerAccessControlEntry", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TargetsPerAccessControlEntry", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AccessControlEntriesPerFabric", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "AccessControlEntryChanged", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "AccessControlExtensionChanged", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DataModelRevision", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "10", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "vendor_id", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NodeLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "XX", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ManufacturingDate", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "20210614123456ZZ", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PartNumber", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductURL", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "long_char_string", + "included": 0, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductLabel", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SerialNumber", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LocalConfigDisabled", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 0, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Reachable", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 0, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UniqueID", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CapabilityMinima", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "CapabilityMinimaStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "StartUp", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "ShutDown", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "Leave", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "OTA Software Update Provider", + "code": 41, + "mfgCode": null, + "define": "OTA_PROVIDER_CLUSTER", + "side": "client", + "enabled": 1, + "commands": [ + { + "name": "QueryImage", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ApplyUpdateRequest", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "NotifyUpdateApplied", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "OTA Software Update Provider", + "code": 41, + "mfgCode": null, + "define": "OTA_PROVIDER_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "QueryImageResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ApplyUpdateResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "OTA Software Update Requestor", + "code": 42, + "mfgCode": null, + "define": "OTA_REQUESTOR_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AnnounceOtaProvider", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "OTA Software Update Requestor", + "code": 42, + "mfgCode": null, + "define": "OTA_REQUESTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DefaultOtaProviders", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "UpdatePossible", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpdateState", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "OTAUpdateStateEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpdateStateProgress", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "StateTransition", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "VersionApplied", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "DownloadError", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Localization Configuration", + "code": 43, + "mfgCode": null, + "define": "LOCALIZATION_CONFIGURATION_CLUSTER", + "side": "client", + "enabled": 0 + }, + { + "name": "Localization Configuration", + "code": 43, + "mfgCode": null, + "define": "LOCALIZATION_CONFIGURATION_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "ActiveLocale", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "en-US", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedLocales", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "client", + "enabled": 0 + }, + { + "name": "Time Format Localization", + "code": 44, + "mfgCode": null, + "define": "TIME_FORMAT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "HourFormat", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "HourFormat", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveCalendarType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "CalendarType", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportedCalendarTypes", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Unit Localization", + "code": 45, + "mfgCode": null, + "define": "UNIT_LOCALIZATION_CLUSTER", + "side": "client", + "enabled": 0 + }, + { + "name": "Unit Localization", + "code": 45, + "mfgCode": null, + "define": "UNIT_LOCALIZATION_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "TemperatureUnit", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "TempUnit", + "included": 0, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "General Commissioning", + "code": 48, + "mfgCode": null, + "define": "GENERAL_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ArmFailSafe", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetRegulatoryConfig", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "CommissioningComplete", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "General Commissioning", + "code": 48, + "mfgCode": null, + "define": "GENERAL_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ArmFailSafeResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "SetRegulatoryConfigResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "CommissioningCompleteResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "Breadcrumb", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "BasicCommissioningInfo", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "BasicCommissioningInfo", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RegulatoryConfig", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "RegulatoryLocationType", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LocationCapability", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "RegulatoryLocationType", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SupportsConcurrentConnection", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ScanNetworks", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddOrUpdateWiFiNetwork", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 0 + }, + { + "name": "AddOrUpdateThreadNetwork", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveNetwork", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ConnectNetwork", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ReorderNetwork", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Network Commissioning", + "code": 49, + "mfgCode": null, + "define": "NETWORK_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "ScanNetworksResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "NetworkConfigResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ConnectNetworkResponse", + "code": 7, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "MaxNetworks", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Networks", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ScanMaxTimeSeconds", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ConnectMaxTimeSeconds", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "InterfaceEnabled", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastNetworkingStatus", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "NetworkCommissioningStatus", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastNetworkID", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "LastConnectErrorValue", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int32s", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "2", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Diagnostic Logs", + "code": 50, + "mfgCode": null, + "define": "DIAGNOSTIC_LOGS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "RetrieveLogsRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Diagnostic Logs", + "code": 50, + "mfgCode": null, + "define": "DIAGNOSTIC_LOGS_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "RetrieveLogsRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RetrieveLogsResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "General Diagnostics", + "code": 51, + "mfgCode": null, + "define": "GENERAL_DIAGNOSTICS_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "General Diagnostics", + "code": 51, + "mfgCode": null, + "define": "GENERAL_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "TestEventTrigger", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "NetworkInterfaces", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RebootCount", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UpTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TotalOperationalHours", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BootReasons", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveHardwareFaults", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveRadioFaults", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ActiveNetworkFaults", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TestEventTriggersEnabled", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "false", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "BootReason", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, + { + "name": "Software Diagnostics", + "code": 52, + "mfgCode": null, + "define": "SOFTWARE_DIAGNOSTICS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ResetWatermarks", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Software Diagnostics", + "code": 52, + "mfgCode": null, + "define": "SOFTWARE_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "ThreadMetrics", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentHeapFree", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentHeapUsed", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentHeapHighWatermark", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Thread Network Diagnostics", + "code": 53, + "mfgCode": null, + "define": "THREAD_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ResetCounts", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Thread Network Diagnostics", + "code": 53, + "mfgCode": null, + "define": "THREAD_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "channel", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RoutingRole", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "RoutingRole", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NetworkName", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PanId", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ExtendedPanId", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "MeshLocalPrefix", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OverrunCount", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NeighborTableList", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RouteTableList", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PartitionId", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "weighting", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "DataVersion", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "StableDataVersion", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LeaderRouterId", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "DetachedRoleCount", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ChildRoleCount", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RouterRoleCount", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LeaderRoleCount", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "AttachAttemptCount", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PartitionIdChangeCount", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "BetterPartitionAttachAttemptCount", + "code": 20, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ParentChangeCount", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxTotalCount", + "code": 22, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxUnicastCount", + "code": 23, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxBroadcastCount", + "code": 24, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxAckRequestedCount", + "code": 25, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxAckedCount", + "code": 26, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxNoAckRequestedCount", + "code": 27, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxDataCount", + "code": 28, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxDataPollCount", + "code": 29, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxBeaconCount", + "code": 30, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxBeaconRequestCount", + "code": 31, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxOtherCount", + "code": 32, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxRetryCount", + "code": 33, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxDirectMaxRetryExpiryCount", + "code": 34, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxIndirectMaxRetryExpiryCount", + "code": 35, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxErrCcaCount", + "code": 36, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxErrAbortCount", + "code": 37, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxErrBusyChannelCount", + "code": 38, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxTotalCount", + "code": 39, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxUnicastCount", + "code": 40, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxBroadcastCount", + "code": 41, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxDataCount", + "code": 42, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxDataPollCount", + "code": 43, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxBeaconCount", + "code": 44, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxBeaconRequestCount", + "code": 45, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxOtherCount", + "code": 46, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxAddressFilteredCount", + "code": 47, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxDestAddrFilteredCount", + "code": 48, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxDuplicatedCount", + "code": 49, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrNoFrameCount", + "code": 50, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrUnknownNeighborCount", + "code": 51, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrInvalidSrcAddrCount", + "code": 52, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrSecCount", + "code": 53, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrFcsCount", + "code": 54, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RxErrOtherCount", + "code": 55, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ActiveTimestamp", + "code": 56, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PendingTimestamp", + "code": 57, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Delay", + "code": 58, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "SecurityPolicy", + "code": 59, + "mfgCode": null, + "side": "server", + "type": "SecurityPolicy", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ChannelPage0Mask", + "code": 60, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OperationalDatasetComponents", + "code": 61, + "mfgCode": null, + "side": "server", + "type": "OperationalDatasetComponents", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ActiveNetworkFaultsList", + "code": 62, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x000F", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "WiFi Network Diagnostics", + "code": 54, + "mfgCode": null, + "define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ResetCounts", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "WiFi Network Diagnostics", + "code": 54, + "mfgCode": null, + "define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "bssid", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "octet_string", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SecurityType", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "SecurityType", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "WiFiVersion", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "WiFiVersionType", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ChannelNumber", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Rssi", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int8s", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "BeaconLostCount", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "BeaconRxCount", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketMulticastRxCount", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketMulticastTxCount", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketUnicastRxCount", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketUnicastTxCount", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentMaxRate", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OverrunCount", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Ethernet Network Diagnostics", + "code": 55, + "mfgCode": null, + "define": "ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "ResetCounts", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Ethernet Network Diagnostics", + "code": 55, + "mfgCode": null, + "define": "ETHERNET_NETWORK_DIAGNOSTICS_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "PHYRate", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "PHYRateType", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FullDuplex", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PacketRxCount", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PacketTxCount", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TxErrCount", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CollisionCount", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OverrunCount", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CarrierDetect", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "TimeSinceReset", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "int64u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000000000000000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Switch", + "code": 59, + "mfgCode": null, + "define": "SWITCH_CLUSTER", + "side": "client", + "enabled": 0 + }, + { + "name": "Switch", + "code": 59, + "mfgCode": null, + "define": "SWITCH_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "AdministratorCommissioning", + "code": 60, + "mfgCode": null, + "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "OpenCommissioningWindow", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "OpenBasicCommissioningWindow", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RevokeCommissioning", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "AdministratorCommissioning", + "code": 60, + "mfgCode": null, + "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "WindowStatus", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "CommissioningWindowStatus", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AdminFabricIndex", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "fabric_idx", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AdminVendorId", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Operational Credentials", + "code": 62, + "mfgCode": null, + "define": "OPERATIONAL_CREDENTIALS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AttestationRequest", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "CertificateChainRequest", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "CSRRequest", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddNOC", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "UpdateNOC", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "UpdateFabricLabel", + "code": 9, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RemoveFabric", + "code": 10, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "AddTrustedRootCertificate", + "code": 11, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Operational Credentials", + "code": 62, + "mfgCode": null, + "define": "OPERATIONAL_CREDENTIALS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AttestationResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "CertificateChainResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "CSRResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "NOCResponse", + "code": 8, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "NOCs", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Fabrics", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SupportedFabrics", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CommissionedFabrics", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "TrustedRootCertificates", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentFabricIndex", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Group Key Management", + "code": 63, + "mfgCode": null, + "define": "GROUP_KEY_MANAGEMENT_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "KeySetWrite", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "KeySetRead", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "KeySetRemove", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "KeySetReadAllIndices", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ] + }, + { + "name": "Group Key Management", + "code": 63, + "mfgCode": null, + "define": "GROUP_KEY_MANAGEMENT_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "KeySetReadResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "KeySetReadAllIndicesResponse", + "code": 5, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "GroupKeyMap", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GroupTable", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxGroupsPerFabric", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxGroupKeysPerFabric", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Fixed Label", + "code": 64, + "mfgCode": null, + "define": "FIXED_LABEL_CLUSTER", + "side": "client", + "enabled": 0 + }, + { + "name": "Fixed Label", + "code": 64, + "mfgCode": null, + "define": "FIXED_LABEL_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "client", + "enabled": 0 + }, + { + "name": "User Label", + "code": 65, + "mfgCode": null, + "define": "USER_LABEL_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "label list", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + } + ] + }, + { + "name": "MA-dimmablelight", + "deviceTypeName": "MA-onofflight", + "deviceTypeCode": 256, + "deviceTypeProfileId": 259, + "clusters": [ + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "Identify", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "TriggerEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Identify", + "code": 3, + "mfgCode": null, + "define": "IDENTIFY_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "identify time", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "identify type", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AddGroup", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ViewGroup", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "GetGroupMembership", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveGroup", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveAllGroups", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "AddGroupIfIdentifying", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Groups", + "code": 4, + "mfgCode": null, + "define": "GROUPS_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "AddGroupResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ViewGroupResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "GetGroupMembershipResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveGroupResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "name support", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Scenes", + "code": 5, + "mfgCode": null, + "define": "SCENES_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "AddScene", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ViewScene", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveScene", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RemoveAllScenes", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StoreScene", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "RecallScene", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "GetSceneMembership", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedAddScene", + "code": 64, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedViewScene", + "code": 65, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "CopyScene", + "code": 66, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Scenes", + "code": 5, + "mfgCode": null, + "define": "SCENES_CLUSTER", + "side": "server", + "enabled": 0, + "commands": [ + { + "name": "AddSceneResponse", + "code": 0, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "ViewSceneResponse", + "code": 1, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveSceneResponse", + "code": 2, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "RemoveAllScenesResponse", + "code": 3, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "StoreSceneResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + }, + { + "name": "GetSceneMembershipResponse", + "code": 6, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "SceneCount", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentScene", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentGroup", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "group_id", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SceneValid", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NameSupport", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LastConfiguredBy", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "node_id", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/Off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "Off", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "On", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Toggle", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "OffWithEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "OnWithRecallGlobalScene", + "code": 65, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "OnWithTimedOff", + "code": 66, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "On/Off", + "code": 6, + "mfgCode": null, + "define": "ON_OFF_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "OnOff", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "GlobalSceneControl", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OnTime", + "code": 16385, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OffWaitTime", + "code": 16386, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "StartUpOnOff", + "code": 16387, + "mfgCode": null, + "side": "server", + "type": "OnOffStartUpOnOff", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFF", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "4", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "MoveToLevel", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Move", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Step", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Stop", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveToLevelWithOnOff", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveWithOnOff", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StepWithOnOff", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StopWithOnOff", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Level Control", + "code": 8, + "mfgCode": null, + "define": "LEVEL_CONTROL_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "CurrentLevel", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RemainingTime", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "MinLevel", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxLevel", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFE", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentFrequency", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MinFrequency", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "MaxFrequency", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Options", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "OnOffTransitionTime", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OnLevel", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OnTransitionTime", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OffTransitionTime", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "DefaultMoveRate", + "code": 20, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "50", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "StartUpCurrentLevel", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "NVM", + "singleton": 0, + "bounded": 0, + "defaultValue": "254", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Descriptor", + "code": 29, + "mfgCode": null, + "define": "DESCRIPTOR_CLUSTER", + "side": "server", + "enabled": 1, + "attributes": [ + { + "name": "DeviceTypeList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ServerList", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClientList", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PartsList", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Binding", + "code": 30, + "mfgCode": null, + "define": "BINDING_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Binding", + "code": 30, + "mfgCode": null, + "define": "BINDING_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "Binding", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Basic", + "code": 40, + "mfgCode": null, + "define": "BASIC_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "DataModelRevision", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "10", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorName", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "VendorID", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "vendor_id", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductName", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductID", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NodeLabel", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Location", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "XX", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersion", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "HardwareVersionString", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersion", + "code": 9, + "mfgCode": null, + "side": "server", + "type": "int32u", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SoftwareVersionString", + "code": 10, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ManufacturingDate", + "code": 11, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "20210614123456ZZ", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PartNumber", + "code": 12, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductURL", + "code": 13, + "mfgCode": null, + "side": "server", + "type": "long_char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ProductLabel", + "code": 14, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "SerialNumber", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "LocalConfigDisabled", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "NVM", + "singleton": 1, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Reachable", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "boolean", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "UniqueID", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 1, + "storageOption": "External", + "singleton": 1, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CapabilityMinima", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "CapabilityMinimaStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 1, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Color Control", + "code": 768, + "mfgCode": null, + "define": "COLOR_CONTROL_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "MoveToHue", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveHue", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StepHue", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveToSaturation", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveSaturation", + "code": 4, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StepSaturation", + "code": 5, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveToHueAndSaturation", + "code": 6, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveToColor", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "MoveColor", + "code": 8, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "StepColor", + "code": 9, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "MoveToColorTemperature", + "code": 10, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedMoveToHue", + "code": 64, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedMoveHue", + "code": 65, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedStepHue", + "code": 66, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "EnhancedMoveToHueAndSaturation", + "code": 67, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "ColorLoopSet", + "code": 68, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StopMoveStep", + "code": 71, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "MoveColorTemperature", + "code": 75, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "StepColorTemperature", + "code": 76, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Color Control", + "code": 768, + "mfgCode": null, + "define": "COLOR_CONTROL_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "CurrentHue", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentSaturation", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "RemainingTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentX", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x616B", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CurrentY", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x607D", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "DriftCompensation", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CompensationText", + "code": 6, + "mfgCode": null, + "side": "server", + "type": "char_string", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTemperatureMireds", + "code": 7, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00FA", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorMode", + "code": 8, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Options", + "code": 15, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "NumberOfPrimaries", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "Primary1X", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary1Y", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary1Intensity", + "code": 19, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2X", + "code": 21, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2Y", + "code": 22, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary2Intensity", + "code": 23, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3X", + "code": 25, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3Y", + "code": 26, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary3Intensity", + "code": 27, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4X", + "code": 32, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4Y", + "code": 33, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary4Intensity", + "code": 34, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5X", + "code": 36, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5Y", + "code": 37, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary5Intensity", + "code": 38, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6X", + "code": 40, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6Y", + "code": 41, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "Primary6Intensity", + "code": 42, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "WhitePointX", + "code": 48, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "WhitePointY", + "code": 49, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointRX", + "code": 50, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointRY", + "code": 51, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointRIntensity", + "code": 52, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointGX", + "code": 54, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointGY", + "code": 55, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointGIntensity", + "code": 56, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointBX", + "code": 58, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointBY", + "code": 59, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ColorPointBIntensity", + "code": 60, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EnhancedCurrentHue", + "code": 16384, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "EnhancedColorMode", + "code": 16385, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopActive", + "code": 16386, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopDirection", + "code": 16387, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x00", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopTime", + "code": 16388, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0019", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopStartEnhancedHue", + "code": 16389, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x2300", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorLoopStoredEnhancedHue", + "code": 16390, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorCapabilities", + "code": 16394, + "mfgCode": null, + "side": "server", + "type": "bitmap16", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x1F", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTempPhysicalMinMireds", + "code": 16395, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ColorTempPhysicalMaxMireds", + "code": 16396, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0xFEFF", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CoupleColorTempToLevelMinMireds", + "code": 16397, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "StartUpColorTemperatureMireds", + "code": 16400, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 0, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x1F", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "5", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Occupancy Sensing", + "code": 1030, + "mfgCode": null, + "define": "OCCUPANCY_SENSING_CLUSTER", + "side": "client", + "enabled": 0, + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "Occupancy Sensing", + "code": 1030, + "mfgCode": null, + "define": "OCCUPANCY_SENSING_CLUSTER", + "side": "server", + "enabled": 0, + "attributes": [ + { + "name": "occupancy", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "occupancy sensor type", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "occupancy sensor type bitmap", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "bitmap8", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "PIR occupied to unoccupied delay", + "code": 16, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PIR unoccupied to occupied delay", + "code": 17, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "PIR unoccupied to occupied threshold", + "code": 18, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ultrasonic occupied to unoccupied delay", + "code": 32, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ultrasonic unoccupied to occupied delay", + "code": 33, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ultrasonic unoccupied to occupied threshold", + "code": 34, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "physical contact occupied to unoccupied delay", + "code": 48, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "physical contact unoccupied to occupied delay", + "code": 49, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0000", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "physical contact unoccupied to occupied threshold", + "code": 50, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x01", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "3", + "reportable": 1, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + } + ] + } + ], + "endpoints": [ + { + "endpointTypeName": "MA-rootdevice", + "endpointTypeIndex": 0, + "profileId": 259, + "endpointId": 0, + "networkId": 0, + "endpointVersion": 1, + "deviceIdentifier": 22 + }, + { + "endpointTypeName": "MA-dimmablelight", + "endpointTypeIndex": 1, + "profileId": 259, + "endpointId": 1, + "networkId": 0, + "endpointVersion": 1, + "deviceIdentifier": 256 + } + ], + "log": [] +} \ No newline at end of file diff --git a/examples/lock-app/lock-common/BUILD.gn b/examples/lock-app/lock-common/BUILD.gn old mode 100755 new mode 100644 diff --git a/examples/lock-app/lock-common/lock-app.zap b/examples/lock-app/lock-common/lock-app.zap old mode 100755 new mode 100644 diff --git a/examples/lock-app/nxp/k32w/k32w0/BUILD.gn b/examples/lock-app/nxp/k32w/k32w0/BUILD.gn index 57d4498ce98ad0..95f1a8c02a7848 100644 --- a/examples/lock-app/nxp/k32w/k32w0/BUILD.gn +++ b/examples/lock-app/nxp/k32w/k32w0/BUILD.gn @@ -83,6 +83,7 @@ k32w0_executable("lock_app") { ":sdk", "${chip_root}/examples/common/QRCode", "${chip_root}/examples/lock-app/lock-common", + "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/crypto", "${chip_root}/src/lib", "${chip_root}/third_party/mbedtls:mbedtls", diff --git a/examples/lock-app/nxp/k32w/k32w0/README.md b/examples/lock-app/nxp/k32w/k32w0/README.md index 9c1ef8ef3170f2..352d03055e862d 100644 --- a/examples/lock-app/nxp/k32w/k32w0/README.md +++ b/examples/lock-app/nxp/k32w/k32w0/README.md @@ -22,16 +22,18 @@ network. - [Bluetooth LE Rendezvous](#bluetooth-le-rendezvous) - [Device UI](#device-ui) - [Building](#building) + - [Known issues](#building-issues) +- [Manufacturing data](#manufacturing) - [Flashing and debugging](#flashdebug) -- [Known Issues](#knownissues) -- [Testing the example](#testing-the-example) - [Pigweed Tokenizer](#tokenizer) - [Detokenizer script](#detokenizer) - [Notes](#detokenizer-notes) - [Known issues](#detokenizer-known-issues) - [Tinycrypt ECC operations](#tinycrypt) - - [Building steps](#tinycrypt-building-steps) +- [Low power](#low-power) + + - [Known issues](#low-power-issues) @@ -172,21 +174,18 @@ will be initiated. In order to build the Project CHIP example, we recommend using a Linux distribution (the demo-application was compiled on Ubuntu 20.04). -- Download [K32W061 SDK 2.6.6 for Project CHIP](https://mcuxpresso.nxp.com/). - Creating an nxp.com account is required before being able to download the - SDK. Once the account is created, login and follow the steps for downloading - SDK_2_6_6_K32W061DK6. The SDK Builder UI selection should be similar with - the one from the image below. - ![MCUXpresso SDK Download](../../../../platform/nxp/k32w/k32w0/doc/images/mcux-sdk-download.JPG) +- Download + [K32W0 SDK 2.6.7](https://cache.nxp.com/lgfiles/bsps/SDK_2_6_7_K32W061DK6.zip). - Start building the application either with Secure Element or without - without Secure Element ``` -user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=/home/user/Desktop/SDK_2_6_6_K32W061DK6/ +user@ubuntu:~/Desktop/git/connectedhomeip$ export NXP_K32W0_SDK_ROOT=/home/user/Desktop/SDK_2_6_7_K32W061DK6/ +user@ubuntu:~/Desktop/git/connectedhomeip$ ./third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh user@ubuntu:~/Desktop/git/connectedhomeip$ source ./scripts/activate.sh -user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/lock-app/nxp/k32w/k32w0/ +user@ubuntu:~/Desktop/git/connectedhomeip$ cd examples/lock-app/nxp/k32w/k32w0 user@ubuntu:~/Desktop/git/connectedhomeip/examples/lock-app/nxp/k32w/k32w0$ gn gen out/debug --args="k32w0_sdk_root=\"${NXP_K32W0_SDK_ROOT}\" chip_with_OM15082=1 chip_with_ot_cli=0 is_debug=false chip_crypto=\"tinycrypt\" chip_with_se05x=0 chip_pw_tokenizer_logging=true mbedtls_repo=\"//third_party/connectedhomeip/third_party/nxp/libs/mbedtls\"" user@ubuntu:~/Desktop/git/connectedhomeip/examples/lock-app/nxp/k32w/k32w0$ ninja -C out/debug user@ubuntu:~/Desktop/git/connectedhomeip/examples/lock-app/nxp/k32w/k32w0$ $NXP_K32W0_SDK_ROOT/tools/imagetool/sign_images.sh out/debug/ @@ -218,6 +217,20 @@ pycryptodome 3.9.8 The resulting output file can be found in out/debug/chip-k32w0x-lock-example. + + +## Known issues + +- When using Secure element and cross-compiling on Linux, log messages from + the Plug&Trust middleware stack may not echo to the console. + + + +## Manufacturing data + +See +[Guide for writing manufacturing data on NXP devices](../../../../platform/nxp/doc/manufacturing_flow.md). + ## Flashing and debugging @@ -229,58 +242,6 @@ All you have to do is to replace the Openthread binaries from the above documentation with _out/debug/chip-k32w0x-lock-example.bin_ if DK6Programmer is used or with _out/debug/chip-k32w0x-lock-example_ if MCUXpresso is used. - - -## Low power - -The example also offers the possibility to run in low power mode. This means -that the board will go in a deep power down mode most of the time and the power -consumption will be very low. - -In order build with low power support, the _chip_with_low_power=1_ must be -provided to the build system. In this case, please note that the GN build -arguments chip*with_OM15082 and \_chip_with_ot_cli* must be set to 0. - -In order to maintain a low power consumption, the LEDs showing the state of the -elock and the internal state are disabled. Console logs can be used instead. -Also, please note that once the board is flashed with MCUXpresso the debugger -disconnects because the board enters low power. - -Power Measurement Tool can be used inside MCUXpresso for checking the power -consumption pattern: Window -> Show View -> Other -> Power Measurement Tool. The -configuration for this tool is the next one: - -![POWER_CONF](../../../../platform/nxp/k32w/k32w0/doc/images/power_conf.JPG) - -Also, please make sure that the J14 jumper is set to the _ENABLED_ position and -no expansion board is attached to the DK6. A view from this tool is illustrated -below: - -![POWER_VIEW](../../../../platform/nxp/k32w/k32w0/doc/images/power_view.JPG) - -Please note that that the Power Measurement Tool is not very accurate and -professional tools must be used if exact power consumption needs to be known. - -## Known issues - -- When cross-compiling on Linux - Log messages from the Plug&Trust middleware - stack may not echo to the console; -- Power Measurement Tool may not work correctly in MCUXpresso versions greater - that 11.0.1. - -## Testing the example - -The app can be deployed against any generic OpenThread Border Router. See the -guide -[Commissioning NXP K32W using Android CHIPTool](../../../docs/guides/nxp_k32w_android_commissioning.md) -for step-by-step instructions. - -## Video demo - -See -[Unlocking the Future of Project CHIP Webinar](https://www.nxp.com/design/training/unlocking-the-future-of-project-chip:TIP-EEE-UNLOCKING-THE-FUTURE-OF-PROJECT-CHIP) -for an in-depth analysis of NXP capabilities for Project CHIP. - ## Pigweed tokenizer @@ -374,3 +335,43 @@ In order to use the tinycrypt ecc operations, use the following build arguments: To disable tinycrypt ecc operations, simply build with _chip_crypto=\"mbedtls\"_ and with or without _mbedtls_repo_. If used with _mbedtls_repo_ the mbedtls implementation from `NXPmicro/mbedtls` library will be used. + + + +## Low power + +The example also offers the possibility to run in low power mode. This means +that the board will go in a deep power down mode most of the time and the power +consumption will be very low. + +In order to build with low power support, the _chip_with_low_power=1_ must be +provided to the build system. In this case, please note that the GN build +arguments _chip_with_OM15082_ and _chip_with_ot_cli_ must be set to 0 and +_chip_logging_ must be set to false to disable logging. + +In order to maintain a low power consumption, the LEDs showing the state of the +elock and the internal state are disabled. Console logs can be used instead. +Also, please note that once the board is flashed with MCUXpresso the debugger +disconnects because the board enters low power. + +Power Measurement Tool can be used inside MCUXpresso for checking the power +consumption pattern: Window -> Show View -> Other -> Power Measurement Tool. The +configuration for this tool is the next one: + +![POWER_CONF](../../../../platform/nxp/k32w/k32w0/doc/images/power_conf.JPG) + +Also, please make sure that the J14 jumper is set to the _ENABLED_ position and +no expansion board is attached to the DK6. A view from this tool is illustrated +below: + +![POWER_VIEW](../../../../platform/nxp/k32w/k32w0/doc/images/power_view.JPG) + +Please note that that the Power Measurement Tool is not very accurate and +professional tools must be used if exact power consumption needs to be known. + + + +## Known issues + +- Power Measurement Tool may not work correctly in MCUXpresso versions greater + that 11.0.1. diff --git a/examples/lock-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h b/examples/lock-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h index 26b42ea1acd871..cca7403d37767f 100644 --- a/examples/lock-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h +++ b/examples/lock-app/nxp/k32w/k32w0/include/CHIPProjectConfig.h @@ -34,6 +34,56 @@ // including message encryption. Because of this they MUST NEVER BE ENABLED IN PRODUCTION BUILDS. #define CHIP_CONFIG_SECURITY_TEST_MODE 0 +// Use hard-coded test certificates already embedded in generic chip code => set it to 0 +// Use real/development certificates => set it to 1 + file the provisioning section from +// the internal flash +#ifndef CONFIG_CHIP_K32W0_REAL_FACTORY_DATA +#define CONFIG_CHIP_K32W0_REAL_FACTORY_DATA 0 +#endif + +#if CONFIG_CHIP_K32W0_REAL_FACTORY_DATA + +// VID/PID for product => will be used by Basic Information Cluster +#define CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID 0x1037 +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0xA220 + +// set it to 0 for the moment +#define CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER 0 + +#ifndef CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION +//-> format_version = 1 +//-> vendor_id = 0x1037 +//-> product_id_array = [ 0xA220 ] +//-> device_type_id = 0x0015 +//-> certificate_id = "ZIG20142ZB330003-24" +//-> security_level = 0 +//-> security_information = 0 +//-> version_number = 0x2694 +//-> certification_type = 0 +//-> dac_origin_vendor_id is not present +//-> dac_origin_product_id is not present +#define CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION \ + { \ + 0x30, 0x81, 0xe8, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x81, 0xda, 0x30, 0x81, 0xd7, \ + 0x02, 0x01, 0x03, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, \ + 0x44, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x37, 0x04, 0x35, 0x15, 0x24, 0x00, \ + 0x01, 0x25, 0x01, 0x37, 0x10, 0x36, 0x02, 0x05, 0x20, 0xa2, 0x18, 0x24, 0x03, 0x15, 0x2c, 0x04, 0x13, 0x5a, 0x49, \ + 0x47, 0x32, 0x30, 0x31, 0x34, 0x31, 0x5a, 0x42, 0x33, 0x33, 0x30, 0x30, 0x30, 0x31, 0x2d, 0x32, 0x34, 0x24, 0x05, \ + 0x00, 0x24, 0x06, 0x00, 0x25, 0x07, 0x76, 0x98, 0x24, 0x08, 0x00, 0x18, 0x31, 0x7d, 0x30, 0x7b, 0x02, 0x01, 0x03, \ + 0x80, 0x14, 0x62, 0xfa, 0x82, 0x33, 0x59, 0xac, 0xfa, 0xa9, 0x96, 0x3e, 0x1c, 0xfa, 0x14, 0x0a, 0xdd, 0xf5, 0x04, \ + 0xf3, 0x71, 0x60, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, 0x0a, 0x06, \ + 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x04, 0x47, 0x30, 0x45, 0x02, 0x20, 0x29, 0x7f, 0xf6, 0x0e, \ + 0x4c, 0x72, 0x38, 0x77, 0x19, 0xfc, 0xb9, 0x7c, 0x08, 0x71, 0x8a, 0x88, 0x61, 0xf7, 0x0a, 0xf7, 0xf0, 0x63, 0x43, \ + 0x09, 0x69, 0xb0, 0x40, 0xf2, 0xce, 0xfd, 0x69, 0x15, 0x02, 0x21, 0x00, 0xa8, 0xd1, 0x6e, 0xae, 0xd5, 0x7f, 0x28, \ + 0x34, 0x0d, 0x21, 0x65, 0xa3, 0x3f, 0xc4, 0x4c, 0x8b, 0x26, 0x26, 0x3f, 0xb2, 0xac, 0x8f, 0x22, 0xe4, 0xff, 0xbd, \ + 0x9b, 0x48, 0x2d, 0x7e, 0xc9, 0x17, \ + } + +// All remaining data will be pulled from the provisioning region of flash. +#endif + +#else + // Use a default setup PIN code if one hasn't been provisioned in flash. #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_PIN_CODE 20202021 #define CHIP_DEVICE_CONFIG_USE_TEST_SETUP_DISCRIMINATOR 0xF00 @@ -63,6 +113,8 @@ */ #define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8006 +#endif + /** * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION * @@ -126,7 +178,7 @@ * provision the device with its unique operational credentials and manage * its own access control lists. */ -#define CHIP_CONFIG_MAX_FABRICS 4 // 3 fabrics + 1 for rotation slack +#define CHIP_CONFIG_MAX_FABRICS 5 // 5 is the minimum number of supported fabrics #define CHIP_DEVICE_CONFIG_ENABLE_SED 1 #define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL 1000_ms32 diff --git a/examples/lock-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h b/examples/lock-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h index 25c298f039198b..22d311ad15326c 100644 --- a/examples/lock-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h +++ b/examples/lock-app/nxp/k32w/k32w0/include/FreeRTOSConfig.h @@ -67,7 +67,10 @@ #define configUSE_ALTERNATIVE_API 0 /* Deprecated! */ #define configQUEUE_REGISTRY_SIZE 8 #define configUSE_QUEUE_SETS 0 -#define configUSE_TIME_SLICING 0 +/* make sure that Thread task can interrupt lengthy Matter + * processing in case priority inversion occurs + */ +#define configUSE_TIME_SLICING 1 #define configUSE_NEWLIB_REENTRANT 0 #define configENABLE_BACKWARD_COMPATIBILITY 1 #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 diff --git a/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp b/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp index 3a78c9c7f632c4..cb78aef83ee0cd 100644 --- a/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/lock-app/nxp/k32w/k32w0/main/AppTask.cpp @@ -21,15 +21,15 @@ #include #include +#include #include #include #include +#include #include #include #include -#include - #include #include #include @@ -38,6 +38,7 @@ #include "Keyboard.h" #include "LED.h" #include "LEDWidget.h" +#include "PWR_Interface.h" #include "app_config.h" #if CHIP_CRYPTO_HSM @@ -52,7 +53,6 @@ constexpr uint8_t kAppEventQueueSize = 10; TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. -static SemaphoreHandle_t sCHIPEventLock; static QueueHandle_t sAppEventQueue; #if !cPWR_UsePowerDownMode @@ -95,7 +95,16 @@ CHIP_ERROR AppTask::Init() // Init ZCL Data Model and start server PlatformMgr().ScheduleWork(InitServer, 0); - // Initialize device attestation config +// Initialize device attestation config +#if CONFIG_CHIP_K32W0_REAL_FACTORY_DATA + // Initialize factory data provider + ReturnErrorOnFailure(K32W0FactoryDataProvider::GetDefaultInstance().Init()); +#if CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER + SetDeviceInstanceInfoProvider(&K32W0FactoryDataProvider::GetDefaultInstance()); +#endif + SetDeviceAttestationCredentialsProvider(&K32W0FactoryDataProvider::GetDefaultInstance()); + SetCommissionableDataProvider(&K32W0FactoryDataProvider::GetDefaultInstance()); +#else #ifdef ENABLE_HSM_DEVICE_ATTESTATION SetDeviceAttestationCredentialsProvider(Examples::GetExampleSe05xDACProvider()); #else @@ -104,6 +113,7 @@ CHIP_ERROR AppTask::Init() // QR code will be used with CHIP Tool PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE)); +#endif /* HW init leds */ #if !cPWR_UsePowerDownMode @@ -142,13 +152,6 @@ CHIP_ERROR AppTask::Init() BoltLockMgr().SetCallbacks(ActionInitiated, ActionCompleted); - sCHIPEventLock = xSemaphoreCreateMutex(); - if (sCHIPEventLock == NULL) - { - K32W_LOG("xSemaphoreCreateMutex() failed"); - assert(err == CHIP_NO_ERROR); - } - // Print the current software version char currentSoftwareVer[ConfigurationManager::kMaxSoftwareVersionStringLength + 1] = { 0 }; err = ConfigurationMgr().GetSoftwareVersionString(currentSoftwareVer, sizeof(currentSoftwareVer)); @@ -158,7 +161,7 @@ CHIP_ERROR AppTask::Init() assert(err == CHIP_NO_ERROR); } - PlatformMgr().AddEventHandler(ThreadProvisioningHandler, 0); + PlatformMgr().AddEventHandler(MatterEventHandler, 0); K32W_LOG("Current Software Version: %s", currentSoftwareVer); return err; @@ -181,6 +184,10 @@ void AppTask::InitServer(intptr_t arg) static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); + auto & infoProvider = chip::DeviceLayer::DeviceInfoProviderImpl::GetDefaultInstance(); + infoProvider.SetStorageDelegate(initParams.persistentStorageDelegate); + chip::DeviceLayer::SetDeviceInfoProvider(&infoProvider); + // Init ZCL Data Model and start server chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; nativeParams.lockCb = LockOpenThreadTask; @@ -542,7 +549,11 @@ void AppTask::BleHandler(void * aGenericEvent) K32W_LOG("Another function is scheduled. Could not toggle BLE state!"); return; } + PlatformMgr().ScheduleWork(AppTask::BleStartAdvertising, 0); +} +void AppTask::BleStartAdvertising(intptr_t arg) +{ if (ConnectivityMgr().IsBLEAdvertisingEnabled()) { ConnectivityMgr().SetBLEAdvertisingEnabled(false); @@ -563,7 +574,7 @@ void AppTask::BleHandler(void * aGenericEvent) } } -void AppTask::ThreadProvisioningHandler(const ChipDeviceEvent * event, intptr_t) +void AppTask::MatterEventHandler(const ChipDeviceEvent * event, intptr_t) { if (event->Type == DeviceEventType::kServiceProvisioningChange && event->ServiceProvisioningChange.IsServiceProvisioned) { diff --git a/examples/lock-app/nxp/k32w/k32w0/main/include/AppTask.h b/examples/lock-app/nxp/k32w/k32w0/main/include/AppTask.h index 9e0116cacf7e8d..db06766b56c193 100644 --- a/examples/lock-app/nxp/k32w/k32w0/main/include/AppTask.h +++ b/examples/lock-app/nxp/k32w/k32w0/main/include/AppTask.h @@ -23,6 +23,7 @@ #include "AppEvent.h" #include "BoltLockManager.h" +#include "K32W0FactoryDataProvider.h" #include @@ -57,6 +58,7 @@ class AppTask static void HandleKeyboard(void); static void JoinHandler(void * aGenericEvent); static void BleHandler(void * aGenericEvent); + static void BleStartAdvertising(intptr_t arg); static void LockActionEventHandler(void * aGenericEvent); static void ResetActionEventHandler(void * aGenericEvent); static void InstallEventHandler(void * aGenericEvent); @@ -64,7 +66,7 @@ class AppTask static void ButtonEventHandler(uint8_t pin_no, uint8_t button_action); static void TimerEventHandler(TimerHandle_t xTimer); - static void ThreadProvisioningHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); + static void MatterEventHandler(const chip::DeviceLayer::ChipDeviceEvent * event, intptr_t arg); static void UpdateClusterStateInternal(intptr_t arg); static void ThreadStart(); static void InitServer(intptr_t arg); diff --git a/examples/lock-app/nxp/k32w/k32w0/main/main.cpp b/examples/lock-app/nxp/k32w/k32w0/main/main.cpp index a792030a7c78b0..4692a4068c6d52 100644 --- a/examples/lock-app/nxp/k32w/k32w0/main/main.cpp +++ b/examples/lock-app/nxp/k32w/k32w0/main/main.cpp @@ -36,8 +36,6 @@ using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; using namespace ::chip::Logging; -#define ENABLE_LOW_POWER_LOGS 0 - #if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) #include "Keyboard.h" #include "OtaSupport.h" @@ -52,39 +50,18 @@ using namespace ::chip::Logging; #include "MacSched.h" typedef void (*InitFunc)(void); + extern InitFunc __init_array_start; extern InitFunc __init_array_end; +extern "C" void sched_enable(); + /* low power requirements */ #if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) -extern "C" void vMMAC_IntHandlerBbc(); -extern "C" void vMMAC_IntHandlerPhy(); -extern "C" void BOARD_SetClockForPowerMode(void); -extern "C" void stopM2(); - -static void dm_switch_wakeupCallBack(void); -static void dm_switch_preSleepCallBack(void); -static void ThreadExitSleep(); -static void BOARD_SetClockForWakeup(void); - -typedef struct -{ - bool_t bleAppRunning; - bool_t bleAppStopInprogress; - bool_t threadInitialized; - uint32_t threadWarmBootInitTime; -} sDualModeAppStates; - -typedef void * appCallbackParam_t; -typedef void (*appCallbackHandler_t)(appCallbackParam_t param); - -static sDualModeAppStates dualModeStates; - -#define THREAD_WARM_BOOT_INIT_DURATION_DEFAULT_VALUE 4000 +extern "C" void setThreadInitialized(bool isInitialized); +extern "C" bool isThreadInitialized(); #endif -extern "C" void sched_enable(); - /* needed for FreeRtos Heap 4 */ uint8_t __attribute__((section(".heap"))) ucHeap[HEAP_SIZE]; @@ -99,26 +76,13 @@ extern "C" void main_task(void const * argument) (*pFunc)(); } + mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree); err = PlatformMgrImpl().InitBoardFwk(); if (err != CHIP_NO_ERROR) { return; } -#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) - PWR_Init(); - - /* Internal - MATTER-303: keep in retention the entire RAM1 for the moment */ - PWR_vAddRamRetention((uint32_t) 0x4020000, 0x10000); - - PWR_RegisterLowPowerExitCallback(dm_switch_wakeupCallBack); - PWR_RegisterLowPowerEnterCallback(dm_switch_preSleepCallBack); - - dm_lp_init(); -#endif - - mbedtls_platform_set_calloc_free(CHIPPlatformMemoryCalloc, CHIPPlatformMemoryFree); - K32W_LOG("Welcome to NXP ELock Demo App"); /* Mbedtls Threading support is needed because both @@ -147,23 +111,15 @@ extern "C" void main_task(void const * argument) */ sched_enable(); -#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) - dualModeStates.threadWarmBootInitTime = THREAD_WARM_BOOT_INIT_DURATION_DEFAULT_VALUE; - dualModeStates.threadInitialized = TRUE; -#endif - ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_SleepyEndDevice); if (ret != CHIP_NO_ERROR) { goto exit; } - ret = PlatformMgr().StartEventLoopTask(); - if (ret != CHIP_NO_ERROR) - { - K32W_LOG("Error during PlatformMgr().StartEventLoopTask();"); - goto exit; - } +#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) + setThreadInitialized(TRUE); +#endif // Start OpenThread task ret = ThreadStackMgrImpl().StartThreadTask(); @@ -180,6 +136,13 @@ extern "C" void main_task(void const * argument) goto exit; } + ret = PlatformMgr().StartEventLoopTask(); + if (ret != CHIP_NO_ERROR) + { + K32W_LOG("Error during PlatformMgr().StartEventLoopTask();"); + goto exit; + } + GetAppTask().AppTaskMain(NULL); exit: @@ -195,180 +158,10 @@ extern "C" void otSysEventSignalPending(void) #if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) /* make sure that 15.4 radio is initialized before waking up the Thread task */ - if (dualModeStates.threadInitialized == TRUE) + if (isThreadInitialized()) #endif { BaseType_t yieldRequired = ThreadStackMgrImpl().SignalThreadActivityPendingFromISR(); portYIELD_FROM_ISR(yieldRequired); } } - -#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) -uint32_t dm_switch_get15_4InitWakeUpTime(void) -{ - return dualModeStates.threadWarmBootInitTime; -} - -extern "C" bleResult_t App_PostCallbackMessage(appCallbackHandler_t handler, appCallbackParam_t param) -{ - AppEvent event; - event.Type = AppEvent::kEventType_Lp; - - event.Handler = handler; - event.param = param; - -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("App_PostCallbackMessage %d", (uint32_t) param); -#endif - - GetAppTask().PostEvent(&event); - - return gBleSuccess_c; -} - -static void dm_switch_wakeupCallBack(void) -{ - BOARD_SetClockForWakeup(); - -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("dm_switch_wakeupCallBack"); - K32W_LOG("Warm up time actual value: %d", dualModeStates.threadWarmBootInitTime); -#endif - - RNG_Init(); - SecLib_Init(); - - KBD_PrepareExitLowPower(); - - PWR_WakeupReason_t wakeReason = PWR_GetWakeupReason(); - if (wakeReason.Bits.FromBLE_LLTimer == 1) - { -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("woken up from LL"); -#endif - } - else if (wakeReason.Bits.FromKeyBoard == 1) - { -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("woken up from FromKeyBoard"); -#endif - } - else if (wakeReason.Bits.FromTMR == 1) - { -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("woken up from TMR"); -#endif - } - dm_lp_wakeup(); -} - -static void dm_switch_preSleepCallBack(void) -{ -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("dm_switch_preSleepCallBack"); -#endif - - if (dualModeStates.threadInitialized) - { - /* stop the internal MAC Scheduler timer */ - stopM2(); - /* disable the MAC scheduler */ - sched_disable(); - otPlatRadioDisable(NULL); - dualModeStates.threadInitialized = FALSE; - } - /* Inform the low power dual mode module that we will sleep */ - dm_lp_preSleep(); - - /* configure pins for power down mode */ - BOARD_SetPinsForPowerMode(); - /* DeInitialize application support for drivers */ - BOARD_DeInitAdc(); - /* DeInit the necessary clocks */ - BOARD_SetClockForPowerMode(); -} - -extern "C" void vDynStopAll(void) -{ - vDynRequestState(E_DYN_SLAVE, E_DYN_STATE_OFF); - vDynRequestState(E_DYN_MASTER, E_DYN_STATE_OFF); -} - -void dm_switch_init15_4AfterWakeUp(void) -{ - uint32_t tick1 = 0; - uint32_t tick2 = 0; - - if (dualModeStates.threadWarmBootInitTime == THREAD_WARM_BOOT_INIT_DURATION_DEFAULT_VALUE) - { - /* Get a 32K tick */ - PWR_Start32kCounter(); - tick1 = PWR_Get32kTimestamp(); - } - - /* Radio must be re-enabled after waking up from sleep. - * The module is completely disabled in power down mode */ - ThreadExitSleep(); - - if (dualModeStates.threadWarmBootInitTime == THREAD_WARM_BOOT_INIT_DURATION_DEFAULT_VALUE) - { - tick2 = PWR_Get32kTimestamp(); - dualModeStates.threadWarmBootInitTime = ((tick2 - tick1) * 15625u) >> 9; - - /* Add a margin of 1 ms */ - dualModeStates.threadWarmBootInitTime += 1000; - -#if ENABLE_LOW_POWER_LOGS - K32W_LOG("Calibration: %d", dualModeStates.threadWarmBootInitTime); -#endif - } -} - -static void ThreadExitSleep() -{ - if (!dualModeStates.threadInitialized && ConnectivityMgr().IsThreadEnabled()) - { - /* Install uMac interrupt handlers */ - OSA_InstallIntHandler(ZIGBEE_MAC_IRQn, vMMAC_IntHandlerBbc); - OSA_InstallIntHandler(ZIGBEE_MODEM_IRQn, vMMAC_IntHandlerPhy); - - /* Radio must be re-enabled after waking up from sleep. - * The module is completely disabled in power down mode */ - otPlatRadioEnable(NULL); - sched_enable(); - - dualModeStates.threadInitialized = TRUE; - - /* wake up the Thread stack and check if any processing needs to be done */ - otTaskletsSignalPending(NULL); - } -} - -extern "C" void App_NotifyWakeup(void) -{ - if ((!dualModeStates.threadInitialized)) - { - /* Notify the dual mode low power mode */ - (void) App_PostCallbackMessage(dm_lp_processEvent, (void *) e15_4WakeUpEnded); - } -} - -extern "C" void App_AllowDeviceToSleep() -{ - PWR_PreventEnterLowPower(false); -} - -extern "C" void App_DisallowDeviceToSleep() -{ - PWR_PreventEnterLowPower(true); -} - -static void BOARD_SetClockForWakeup(void) -{ - /* Enables the clock for the I/O controller block. 0: Disable. 1: Enable.: 0x01u */ - CLOCK_EnableClock(kCLOCK_Iocon); - /* Enables the clock for the GPIO0 module */ - CLOCK_EnableClock(kCLOCK_Gpio0); -} - -#endif diff --git a/examples/platform/nxp/doc/manufacturing_flow.md b/examples/platform/nxp/doc/manufacturing_flow.md new file mode 100644 index 00000000000000..83afb4ab85335b --- /dev/null +++ b/examples/platform/nxp/doc/manufacturing_flow.md @@ -0,0 +1,116 @@ + + +## Manufacturing data + +By default, the example application is configured to use generic test +certificates and provisioning data embedded with the application code. It is +possible for a final stage application to generate its own manufacturing data: + +- Generate new certificates + + _PAI_VID_ and _PAI_PID_ variables must be changed accordingly inside + generate_cert.sh script + + _generate_cert.sh_ script needs as input parameter the path to chip-cert + tool (compile it from ./src/tools/chip-cert). The output of the script is: + the DAC, PAI and PAA certificates. The DAC and PAI certificates will be + written in a special section of the internal flash, while the PAA will be + used on the chip-tool side as trust anchor. Please note that for _real + production manufacturing_ the "production PAA" is trusted via the DCL rather + than thorough PAA certificate generated along with DAC and PAI. The PAI cert + may also have a different lifecycle. + + ``` + user@ubuntu:~/Desktop/git/connectedhomeip$ ./examples/platform/nxp/k32w/k32w0/scripts/generate_cert.sh ./src/tools/chip-cert/out/chip-cert + ``` + +* Generate new provisioning data and convert all the data to a binary: + + ``` + user@ubuntu:~/Desktop/git/connectedhomeip$ python3 ./scripts/tools/nxp/generate_nxp_chip_factory_bin.py -i 10000 -s ABCDEFGHIJKLMNOPQRSXYZ -p 14014 -d 1000 --dac_cert /home/ubuntu/manufacturing/Chip-DAC-NXP-Cert.der --dac_key /home/ubuntu/manufacturing/Chip-DAC-NXP-Key.der --pai_cert /home/ubuntu/manufacturing/Chip-PAI-NXP-Cert.der --spake2p_path ./src/tools/spake2p/out/spake2p --out out.bin + ``` + + Here is the interpretation of the parameters: + + ``` + -i -> SPAKE2+ iteration + -s -> SPAKE2+ salt + -p -> SPAKE2+ passcode + - d -> discriminator + --dac_cert -> path to the DAC (der format) location + --dac_key -> path to the DAC key (der format) location + --pai_cert -> path to the PAI (der format) location + --spake2p_path -> path to the spake2p tool (compile it from ./src/tools/spake2p) + --out -> name of the binary that will be used for storing all the generated data + + ``` + +* Write out.bin to the internal flash at location 0x9D200: + + ``` + DK6Programmer.exe -Y -V2 -s -P 1000000 -Y -p FLASH@0x9D200="out.bin" + ``` + +* Generate a new CD (certification declaration): + + Inside _gen-test-cds.sh_, the parameters _vids_, _pid0_, _device_type_id_ + must be changed accordingly. Use _Chip-Test-CD-Signing-\*_ key and + certificate already available in + _./credentials/test/certification-declaration/_ which acts as CSA + Certificate. This CSA certificate is also hard-coded as Trust Anchor in the + current chip-tool version. To use this certificate and avoid generating a + new one, lines 69-70 must be commented in the _gen-test-cds.sh_ script (the + ones that are generating a new CD signing authority). + + ``` + user@ubuntu:~/Desktop/git/connectedhomeip$ ./credentials/test/gen-test-cds.sh ./src/tools/chip-cert/out/chip-cert + ``` + +* Set the correct VID/PID and CD in the + examples/\$APP_NAME/nxp/k32w/k32w0/ChipProjectConfig.h file VID and PID + values should correspond to the ones used for DAC. CD bytes should be the + ones obtained at the step above: + + ``` + user@ubuntu:~/manufacturing hexdump -ve '1/1 "0x%.2x, "' Chip-Test-CD-1037-A220.der + ``` + +* Use _chip_with_factory_data=1_ gn compilation argument + + This is needed in order to load the data from the special flash section. + Build and flash the application. + +* Run chip-tool with a new PAA: + + ``` + ./chip-tool pairing ble-thread 2 hex: $hex_value 14014 1000 --paa-trust-store-path /home/ubuntu/certs/paa + ``` + + Here is the interpretation of the parameters: + + ``` + --paa-trust-store-path -> path to the generated PAA (der format) + ``` + + _paa-trust-store-path_ must contain only the PAA certificate. Avoid placing + other certificates in the same location as this may confuse chip-tool. + + PAA certificate can be copied to the chip-tool machine using SCP for + example. + + This is needed for testing self-generated DACs, but likely not required for + "true production" with production PAI issued DACs. + +* Useful information/Known issues + + Implementation of manufacturing data provisioning has been validated using test certificates generated by OpenSSL 1.1.1l. + + Also, demo DAC, PAI and PAA certificates needed in case _chip_with_factory_data=1_ is used can be found in examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs. + + dut1/dut2 folders contains different DACs/Private Keys and can be used for testing topologies with 2 DUTS. + + out_dut1.bin/out2_dut2.bin contains the corresponding DACs/PAIs generated using generate_nxp_chip_factory_bin.py script. The discriminator is 14014 and the passcode is 1000. + + These demo certificates are working with the CDs installed in CHIPProjectConfig.h. + + diff --git a/examples/platform/nxp/k32w/k32w0/app/ldscripts/chip-k32w0x-linker.ld b/examples/platform/nxp/k32w/k32w0/app/ldscripts/chip-k32w0x-linker.ld index 359a9ef790336d..996d7d16e73766 100644 --- a/examples/platform/nxp/k32w/k32w0/app/ldscripts/chip-k32w0x-linker.ld +++ b/examples/platform/nxp/k32w/k32w0/app/ldscripts/chip-k32w0x-linker.ld @@ -54,11 +54,22 @@ m_int_sector_size = 512; /* first 8K: SSBL, next 8K: SSBL update region */ m_app_start = DEFINED(__app_load_address__) ? __app_load_address__ : 0x0; +/* PSECT: 8.5K */ +m_psect_size = 0x2200; + /* sizeof(BOOT_BLOCK_T) + sizeof(IMAGE_CERT_T) + SIGNATURE_LEN + alignment = 1024 bytes */ m_app_meta_data = 0x400; -/* 640K (Total Flash size) - 16K (SSBL + SSBL update region) - 8.5K (PSECT) - m_app_meta_data */ -m_app_size = DEFINED(__app_stated_size__) ? __app_stated_size__ : 0x9DE00; +/* manufacturing data: 2K */ +m_factory_data_size = 0x800; + +/* 16K: SSBL + SSBL update region */ +m_ssbl_size = 0x4000; + +/* default app size, without OTA */ +m_app_default_size = m_int_flash_size - m_psect_size - m_app_meta_data - m_factory_data_size; + +m_app_size = DEFINED(__app_stated_size__) ? __app_stated_size__ : m_app_default_size; MEMORY { @@ -88,9 +99,8 @@ NV_STORAGE_SECTOR_SIZE = m_ext_flash_sector_size; NV_STORAGE_START_ADDRESS = m_ext_flash_size - 1; NV_STORAGE_END_ADDRESS = NV_STORAGE_START_ADDRESS - NV_STORAGE_SIZE + 1; -INT_STORAGE_START = m_int_flash_size - 17 * m_int_sector_size - 1; -INT_STORAGE_END = INT_STORAGE_START; -INT_STORAGE_SIZE = INT_STORAGE_START - INT_STORAGE_END; +FACTORY_DATA_START_ADDRESS = m_int_flash_size - m_psect_size - m_app_meta_data - m_factory_data_size; +FACTORY_DATA_END_ADDRESS = FACTORY_DATA_START_ADDRESS + m_factory_data_size - 1; __ram_vector_table__ = 1; vector_table_size = 0x120; @@ -213,9 +223,8 @@ SECTIONS _etext = .; - .heap_packet_buffer (COPY): + .heap (COPY): { - *(.bss._ZN4chip6System12PacketBuffer11sBufferPoolE) __HeapBase = .; _heap = .; KEEP(*(.heap*)) @@ -353,4 +362,7 @@ SECTIONS PROVIDE(_scratch_buf_end = __scratch_area_top__); __StackLimit = _vStackTop - STACK_SIZE; + + __FACTORY_DATA_START = FACTORY_DATA_START_ADDRESS; + __FACTORY_DATA_SIZE = m_factory_data_size; } diff --git a/examples/platform/nxp/k32w/k32w0/app/project_include/OpenThreadConfig.h b/examples/platform/nxp/k32w/k32w0/app/project_include/OpenThreadConfig.h index ef95988da9ab24..93f6d442baefe9 100644 --- a/examples/platform/nxp/k32w/k32w0/app/project_include/OpenThreadConfig.h +++ b/examples/platform/nxp/k32w/k32w0/app/project_include/OpenThreadConfig.h @@ -94,9 +94,17 @@ #undef OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS #define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS 44 -#undef OPENTHREAD_CONFIG_PLATFORM_CSL_UNCERT +#undef OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE +#define OPENTHREAD_CONFIG_DNSSD_SERVER_ENABLE 0 + +#undef OPENTHREAD_CONFIG_SRP_SERVER_ENABLE +#define OPENTHREAD_CONFIG_SRP_SERVER_ENABLE 0 + +#undef OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE +#define OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE 0 #define UART_USE_SERIAL_MGR 1 +#define UART_USE_SERIAL_MGR_LOG 1 //#define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG diff --git a/examples/platform/nxp/k32w/k32w0/app/support/FreeRtosHooks.c b/examples/platform/nxp/k32w/k32w0/app/support/FreeRtosHooks.c index e6a445c1c086ff..508db54ca5dec2 100644 --- a/examples/platform/nxp/k32w/k32w0/app/support/FreeRtosHooks.c +++ b/examples/platform/nxp/k32w/k32w0/app/support/FreeRtosHooks.c @@ -236,14 +236,11 @@ extern void OTAIdleActivities(void); void vApplicationIdleHook(void) { - // Data queued by PDM will be written to external flash - // when PDM_vIdleTask is called. Interrupts are disabled - // to ensure there is no context switch during the actual - // writing, thus avoiding race conditions. - OSA_InterruptDisable(); + vTaskSuspendAll(); PDM_vIdleTask(PDM_MAX_WRITES_INFINITE); - OSA_InterruptEnable(); + xTaskResumeAll(); OTAIdleActivities(); + BOARD_ActionOnIdle(); } diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Cert.der b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Cert.der new file mode 100755 index 0000000000000000000000000000000000000000..80eb11aa573fee53fa756bd6b85b799ea8eb4a15 GIT binary patch literal 490 zcmXqLVti)M#MrZdnTe5!i6f2qjNGMtQFR7fY#dr`9_MUXn3)W$4V4WP*_cCFn0cgp z6H7``ixgZ^%Tjal3vyHQN)!SdJr(>S0t`hAgxI*W*%(ISM1!{x9T?&9bSGF-tW)DXJ`XrfF!ERI0? z3?dDL+1SB8U}A)Ng_)6^*@=P0?5Id;6vNatU&SP24C2hISrX<~^#neyVy$=i`+S<> z$$i^$e;hk4rPUac$gq9=(Yfv%&s@bA7}mtE^k;ecUGU7}1cNvO9-xb5g&7(DvoIMj z81R93{2(4MxY!#EWI=pB7BLnPmWi<|Q{@a>b}1BHH~h)`QS;u`iw5!_X=N4(1F;5? zS^;C`kh&8IZ@B(!iCtedePbvKJ96MNdoUQdGAa0(^Uug|()}qWm1HEjH7zYn+4ab$ z8{bn7e44l@@w=8JlOjXQiXZvs{=IiT#BTmEX1z@Pn@>4QzD{4X;?AnKOLX^`HUR)i CTatYM literal 0 HcmV?d00001 diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Cert.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Cert.pem new file mode 100755 index 00000000000000..e467b093f6a28a --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Cert.pem @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIIB5jCCAYygAwIBAgIIZgPMHtK+Wn4wCgYIKoZIzj0EAwIwOzEjMCEGA1UEAwwa +TWF0dGVyIERldmVsb3BtZW50IFBBSSBOWFAxFDASBgorBgEEAYKifAIBDAQxMDM3 +MB4XDTIyMDYyMTEyMzUwMFoXDTQyMDYyMTEyMzQ1OVowVTEnMCUGA1UEAwweTWF0 +dGVyIERldmVsb3BtZW50IERBQyBOWFAgRFUxMRQwEgYKKwYBBAGConwCAQwEMTAz +NzEUMBIGCisGAQQBgqJ8AgIMBEEyMjAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC +AAQ2xRRlWgCVrPUWGVwwXjd7BGCfeoxR43oFf0T955Yhyb62bfjGyxoqgVRhALev +xZ1HCOZFFgAArF+pTwTl9xHMo2AwXjAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQE +AwIHgDAdBgNVHQ4EFgQUBJFdqWUeMYS6IHLXMfkD8SnetdEwHwYDVR0jBBgwFoAU +fRAzA1R+yGDsCvy0Xa92l7FVBAcwCgYIKoZIzj0EAwIDSAAwRQIgTjcPmGhCLfkW +GmIyGbVmZlYjRcTy2PdkwPKRomH3KhkCIQCEqPhvzv7vQ8IHN/Fcrxx/7PJspPWX +oqjcqu2kLbw1gg== +-----END CERTIFICATE----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Key.der b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Key.der new file mode 100755 index 0000000000000000000000000000000000000000..f0943691f6e01675874378bf212683c4159ce9bf GIT binary patch literal 121 zcmV-<0EYiCcLD(c1R$xdFvS`3S=Gq4kv{zT=uBdPIXr3w3~y|R3IKGj|3aV&1_&yK zNX|V20SBQ(13~}*Ni bfmC4tx39&WM+oLc761UOU#U+7<@XWHEnqPc literal 0 HcmV?d00001 diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Key.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Key.pem new file mode 100755 index 00000000000000..7e45934095653a --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/Chip-DAC-NXP-1037-A220-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIKmuMMUZ81nVyLaRPvz66ExigTk8agUMb2yICgB0rv9CoAoGCCqGSM49 +AwEHoUQDQgAENsUUZVoAlaz1FhlcMF43ewRgn3qMUeN6BX9E/eeWIcm+tm34xssa +KoFUYQC3r8WdRwjmRRYAAKxfqU8E5fcRzA== +-----END EC PRIVATE KEY----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/out_dut1.bin b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut1/out_dut1.bin new file mode 100644 index 0000000000000000000000000000000000000000..44370e1deb3a2f782834b5bbe39e1d63f33ca418 GIT binary patch literal 1161 zcmZQst_OJ{Jh|KUcF^kB~G<6HfPR$A`G%?5z4bOJ9aMjNB zFEWnM&&({yDE4;^HuNk?^2!hJ$w>_l4k$7RN;3|r$jqxU2siQ%tSC1O%B-xYhzK?| zh;S?QFG$V}_xH-miU=z3D9i9ObPvqWPq$32NOE+vwPliEaCCBZadmU|@bvQb@%8f$ z2n-62hzzu~WoBUzP-kFZQD9iP&fuuz=g6xkwoSDA^Xr9AQlq6!7AsGFP6ro5$-4he ztgjdini!t}anAx~CPpSEjx^>oa+mf+)fsTHacH%9oU>(NW-_ogR5nm#V-96u=8^JE zEGbDXQgBHvOU=nI$W6^FQ3!DKRPc)kFcdKmV&l?gV`O1$T2#Zt$irf2U~Fz6C(dhR zWMF1wXlP_?YG4p0&T9hWnwVNf8H5_D8>m7Im&0PXi=#8ha0Qo8L+loyi8Ar9I0Ef6 zh%^vpV+Z?yi4p1*W=3{qCk7U?qavwM3{%&96_boHh%>KdNtj>N6Zp7_wch3L^J$7F z_ifAlaqP5|R%1va!}j$@=elz|a}{G?SQEd}pXKRy!83~!4B`xUfG(C5W@P-&!eqc; zzz5>-gLuH;Vs9{z1@ZY<#8^aFCdRHzl{0MFrBHO;@F(*}&3juf8pwmBm02VV#2Q3u z1&o

P{rQ;rg>Bc756OjiD^;$brx7!C>IZq~K@HKO@6Q_otXtl9A-rw6ri~*CU^9 zd`~&>Y2u>9?^=>fiVQ6)e&nC~_ulysyZOhM^)mHuKIJU=I(^ZKJFDI<(cNR(#C8l6 z*@u8Q9U9qTD_u=Ff2yBCw$DJzP{TkC=s;j(%VUX;07pk?e1sShj9ZEl4(=Fy8xayy ztIO7KE1mg?FZ^%$Q9a=0>kG8ni4W9jUYlcu+pgo{t~dg@{%qWsck?X2kS0t`hAgxI*W*%(ISM1!{x9T?&9bSGF-tW)Cju;XrfF!ERI0? z3?dDL+1SB8U}A)Ng_)6^*@=PW?KS?~_3V>apU+lXb5&p=Ti&w2<#{<bd`{3p`)kTw^_4WBpUDNz`ae_gd0T0l{vcimv|5=y} z7!3G8Jbn-l7+mZP2C^VNABz}^$lrgZ*5%pr9r65eqA*%G_HZ2HDf7Ix&oXZBz)aAi`Ek60t}M2qWB^{17u8dLwR4%~Td z-_O7HY+XNJ$L!UPNo7)G*qrb0?+_KOoPY3?)SY?@b?00URsW2IZyZmqx_9-_T}=Rw C{g@p9 literal 0 HcmV?d00001 diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Cert.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Cert.pem new file mode 100755 index 00000000000000..b1ca72c3fd85e5 --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Cert.pem @@ -0,0 +1,13 @@ +-----BEGIN CERTIFICATE----- +MIIB5jCCAYygAwIBAgIIKgA7aa0WwLIwCgYIKoZIzj0EAwIwOzEjMCEGA1UEAwwa +TWF0dGVyIERldmVsb3BtZW50IFBBSSBOWFAxFDASBgorBgEEAYKifAIBDAQxMDM3 +MB4XDTIyMDYyMTEyMzUwMFoXDTQyMDYyMTEyMzQ1OVowVTEnMCUGA1UEAwweTWF0 +dGVyIERldmVsb3BtZW50IERBQyBOWFAgRFUyMRQwEgYKKwYBBAGConwCAQwEMTAz +NzEUMBIGCisGAQQBgqJ8AgIMBEEyMjAwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNC +AATt1g9trweSBeebJqzVEKEGbqb9d25stXL7rYpDDJW3ReN6fsZPE63wUNfCAR4r +1C5XLeDZ9iWik+aOjk6VrIP9o2AwXjAMBgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQE +AwIHgDAdBgNVHQ4EFgQU/f51OzcNZuWpWCe/fJTPx+WHtO0wHwYDVR0jBBgwFoAU +fRAzA1R+yGDsCvy0Xa92l7FVBAcwCgYIKoZIzj0EAwIDSAAwRQIgH1isFOQqCvx7 +8qnqgWX+q1G51r75/T8GivnrXL0rXGUCIQCzb09PQFpbI2/ByhrcfzgnQ21IJU9o +oexByare1eLdKQ== +-----END CERTIFICATE----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Key.der b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Key.der new file mode 100755 index 0000000000000000000000000000000000000000..a8e3adccff66d4e79fcfba8353aab391a39ce80e GIT binary patch literal 121 zcmV-<0EYiCcLD(c1RycVJPXD*l#Y43)P<<9dF^PZO>1 bP}jl%9xK!?S1sV#_9dc|=8ld|m8^sP{SP+7 literal 0 HcmV?d00001 diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Key.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Key.pem new file mode 100755 index 00000000000000..df1f3ce731ebbf --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/Chip-DAC-NXP-1037-A220-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIDHJPAvGN+VO8BjTlewIRqc6zNpduVXS4g+t22jGRqcSoAoGCCqGSM49 +AwEHoUQDQgAE7dYPba8HkgXnmyas1RChBm6m/XdubLVy+62KQwyVt0Xjen7GTxOt +8FDXwgEeK9QuVy3g2fYlopPmjo5OlayD/Q== +-----END EC PRIVATE KEY----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/out_dut2.bin b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/dut2/out_dut2.bin new file mode 100644 index 0000000000000000000000000000000000000000..f47a8b4c53a9089c626d5f4d28a30ebc04c6757c GIT binary patch literal 1161 zcmZQst_OJ{Jh|KUcF^kB~G<6HfPR$A`G%?5z4bOJ9aMjNB zFEWnM&&({yDE4;^HuNk?^2!hJ$w>_l4k$7RN;3|r$jqxU2siQ%tSC1O%B-xYhzK?| zh;S?QFG$V}_xH-miU=z3D9i9ObPvqWPq$32NOE+vwPliEaCCBZadmU|@bvQb@%8f$ z2n-62hzzu~WoBUzP-kFZQD87UX~TWY{HfmuiOW;paJVhEI&&*_XXvFz{A+J#9CKSP z#QKWSpo#Gr5ce!#W@2Pw;?QES&Ri>YV3PqC8;4e#$2nUTW+nq`LuCU+Hs(+kW*#Zu z#FCQKA_bS!vecaXg51=+5`_RqPX)h-07DT2AvP{;Hbxf4rbRVOj65uc2FB(Fa^k#3 zMh0d^hK5GQrUnL4;=Cp>u8FB-ltHMWx`8Uha5*f7yEr<73|DXoHNtKInkW+wizCoJ zgGd8mHg>QNm>8j6VP<4!c4A<8dyPMLJ^Liq=d;z;ToqWzmbdJ0d0x)eqTg$~oOz~h zcYRz{cg$aS?T3KthZyCwujqyAKDhZ!bs6$0Eie^7mh0XJmZ64$8qk5j$d<3BpA08B^*347!eXv ztIO7KE1mg?FZ^%$Q9a=0>kG8ni4W9jUYlcu+pgo{t~dg@{%qWsck?X2kJkHs&Ff$ow8EP1)u`!3TF!RX! zCYF?>7Ad%-mZj$87v!eql_&%_Ix6@@1Sq(Kh8P;iiSrs68JHOv8X6g!8W=>0^P0f8 zCZ?8AB$*XyAk4-Nb_Ek7)H%$I?95IKEb>t&wuPj1#g&Sjp5iuLaF^E9SywnJCe%q> zZrf1h)M4K%+-kn?M8tt7Ub2%bx@3+{UbM1m72DsOB=fSctinb0i_;8J41|DQk`-oT z{LjK+zy_q47#R)tKw|tLF`&m8*$iYsd_ER277+=>%}N><*P3itoI2s(=S+FlV|*G0 z@*rtt76}8f2J8xuf|1#s!N7${L2oHUMOZFNSHi_x4(P tuNVV`4}+8}bGdi;V8e=o9}Kx|DvOv3WOvOLjM>RupTFQ@FvBT5F#seyhoJxf literal 0 HcmV?d00001 diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Cert.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Cert.pem new file mode 100755 index 00000000000000..851c024c11355a --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Cert.pem @@ -0,0 +1,12 @@ +-----BEGIN CERTIFICATE----- +MIIBwjCCAWegAwIBAgIIVqlFNQn5J8owCgYIKoZIzj0EAwIwKjEoMCYGA1UEAwwf +TWF0dGVyIERldmVsb3BtZW50IFBBQSBOWFAgRFVUMTAeFw0yMjA2MjExMjM1MDBa +Fw00MjA2MjExMjM0NTlaMDsxIzAhBgNVBAMMGk1hdHRlciBEZXZlbG9wbWVudCBQ +QUkgTlhQMRQwEgYKKwYBBAGConwCAQwEMTAzNzBZMBMGByqGSM49AgEGCCqGSM49 +AwEHA0IABO1YVFx9LQaA2mcD5DnpA0QTHmotGERCvb8ujV7k9h9VNQ9/4/moeLAa +aXmeEhbKQSfmffTtIkg4sbou5Lb/TW2jZjBkMBIGA1UdEwEB/wQIMAYBAf8CAQAw +DgYDVR0PAQH/BAQDAgEGMB0GA1UdDgQWBBR9EDMDVH7IYOwK/LRdr3aXsVUEBzAf +BgNVHSMEGDAWgBQYIbMiKNGtNLCjZZD+82kfBcYOKDAKBggqhkjOPQQDAgNJADBG +AiEAzaTJNdqkVxeRSuVEMhQj6TytmpcozfWQ4j3qAVETw0YCIQCmRN7DwYCowfAx +Czx5cgJwHbqbEVy5C39voNFTAMouFg== +-----END CERTIFICATE----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Key.pem b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Key.pem new file mode 100755 index 00000000000000..8fdf7698dbc1e2 --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/pai/Chip-PAI-NXP-1037-A220-Key.pem @@ -0,0 +1,5 @@ +-----BEGIN EC PRIVATE KEY----- +MHcCAQEEICQz6OJVkUzCuN9bJOvSBzcO/YZke3JfahE5kMVTCv2moAoGCCqGSM49 +AwEHoUQDQgAE7VhUXH0tBoDaZwPkOekDRBMeai0YREK9vy6NXuT2H1U1D3/j+ah4 +sBppeZ4SFspBJ+Z99O0iSDixui7ktv9NbQ== +-----END EC PRIVATE KEY----- diff --git a/examples/platform/nxp/k32w/k32w0/scripts/generate_cert.sh b/examples/platform/nxp/k32w/k32w0/scripts/generate_cert.sh new file mode 100755 index 00000000000000..172662ed192496 --- /dev/null +++ b/examples/platform/nxp/k32w/k32w0/scripts/generate_cert.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +# +# +# Copyright (c) 2022 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. +# + +# +# Description: +# This is a utility script that creates PAA, PAI and DAC certificates for NXP factory data. +# + +if [ -z "$1" ]; then + echo "Usage: ./generate_cert.sh chip-cert-path" + exit 1 +fi + +CHIP_CERT_TOOL="$1" + +function exit_err() { + echo "${1}" + exit 1 +} + +DATE="2022-06-21 12:35:00" +LIFETIME="7305" + +PAA_DATE="$DATE" +PAA_LIFETIME="$LIFETIME" +PAA_CERT="Chip-PAA-NXP-Cert.pem" +PAA_KEY="Chip-PAA-NXP-Key.pem" + +PAI_DATE="$DATE" +PAI_LIFETIME="$LIFETIME" +PAI_VID="1037" +PAI_PID="A220" +PAI_CERT="Chip-PAI-NXP-"$PAI_VID"-"$PAI_PID"-Cert.pem" +PAI_CERT_DER="Chip-PAI-NXP-"$PAI_VID"-"$PAI_PID"-Cert.der" +PAI_KEY="Chip-PAI-NXP-"$PAI_VID"-"$PAI_PID"-Key.pem" + +DAC_DATE="$DATE" +DAC_LIFETIME="$LIFETIME" +DAC_VID="$PAI_VID" +DAC_PID="$PAI_PID" +DAC_CERT="Chip-DAC-NXP-"$DAC_VID"-"$DAC_PID"-Cert.pem" +DAC_CERT_DER="Chip-DAC-NXP-"$DAC_VID"-"$DAC_PID"-Cert.der" +DAC_KEY="Chip-DAC-NXP-"$DAC_VID"-"$DAC_PID"-Key.pem" +DAC_KEY_DER="Chip-DAC-NXP-"$DAC_VID"-"$DAC_PID"-Key.der" + +# Remove certificates if present +rm -rf "$PAA_CERT" "$PAA_KEY" "$PAI_CERT" "$PAI_KEY" "$DAC_CERT" "$DAC_KEY" "$PAI_CERT_DER" "$DAC_CERT_DER" "$DAC_KEY_DER" >/dev/null 2>&1 + +# Generate certificates +echo "Generate certificates" + +# PAA (root authoritity) +"$CHIP_CERT_TOOL" gen-att-cert --type a --subject-cn "Matter Development PAA NXP" --valid-from "$PAA_DATE" --lifetime "$PAA_LIFETIME" --out-key "$PAA_KEY" --out "$PAA_CERT" && echo "Generated PAA" || exit_err "Failed to generate PAA" + +# PAI (vendor) +"$CHIP_CERT_TOOL" gen-att-cert --type i --subject-cn "Matter Development PAI NXP" --subject-vid "$PAI_VID" --valid-from "$PAI_DATE" --lifetime "$PAI_LIFETIME" --ca-key "$PAA_KEY" --ca-cert "$PAA_CERT" --out-key "$PAI_KEY" --out "$PAI_CERT" && echo "Generated PAI" || exit_err "Failed to generate PAI" + +# DAC (product) +"$CHIP_CERT_TOOL" gen-att-cert --type d --subject-cn "Matter Development DAC NXP" --subject-vid "$DAC_VID" --subject-pid "$DAC_PID" --valid-from "$DAC_DATE" --lifetime "$DAC_LIFETIME" --ca-key "$PAI_KEY" --ca-cert "$PAI_CERT" --out-key "$DAC_KEY" --out "$DAC_CERT" && echo "Generated DAC" || exit_err "Failed to generate DAC" + +# Convert certificates and keys to der format (binary x509) +echo "Convert certificates and keys to DER format" + +# PAI +"$CHIP_CERT_TOOL" convert-cert -d "$PAI_CERT" "$PAI_CERT_DER" && echo "Converted PAI" || exit_err "Failed to convert PAI" + +# DAC Cer +"$CHIP_CERT_TOOL" convert-cert -d "$DAC_CERT" "$DAC_CERT_DER" && echo "Converted DAC Cert" || exit_err "Failed to convert DAC Cert" + +# DAC Key +"$CHIP_CERT_TOOL" convert-key -d "$DAC_KEY" "$DAC_KEY_DER" && echo "Converted DAC Key" || exit_err "Failed to convert DAC Key" diff --git a/examples/shell/nxp/k32w/k32w0/BUILD.gn b/examples/shell/nxp/k32w/k32w0/BUILD.gn index f6c4039783a5dd..19e52dcd502c7b 100644 --- a/examples/shell/nxp/k32w/k32w0/BUILD.gn +++ b/examples/shell/nxp/k32w/k32w0/BUILD.gn @@ -15,6 +15,7 @@ import("//build_overrides/chip.gni") import("//build_overrides/k32w0_sdk.gni") import("//build_overrides/openthread.gni") +import("${chip_root}/src/platform/device.gni") import("${chip_root}/third_party/simw-top-mini/simw_config.gni") import("${k32w0_sdk_build_root}/k32w0_executable.gni") @@ -39,16 +40,11 @@ k32w0_sdk("sdk") { "main/include", "main", "include", - "${k32w0_platform_dir}/app/project_include", "${k32w0_platform_dir}/app/support", "${k32w0_platform_dir}/util/include", ] - defines = [ - # shell app uses openthread but does not have the NETWORK_COMMISSIONING cluster or zap config. - "_NO_NETWORK_COMMISSIONING_DRIVER_", - ] - + defines = [] if (is_debug) { defines += [ "BUILD_RELEASE=0" ] } else { @@ -68,6 +64,7 @@ k32w0_executable("shell_app") { deps = [ ":sdk", + "${chip_root}/examples/common/QRCode", "${chip_root}/examples/lock-app/lock-common", "${chip_root}/examples/shell/shell_common:shell_common", "${chip_root}/third_party/mbedtls:mbedtls", diff --git a/examples/shell/nxp/k32w/k32w0/include/AppTask.h b/examples/shell/nxp/k32w/k32w0/include/AppTask.h index cdfbf664746404..28480735fef81d 100644 --- a/examples/shell/nxp/k32w/k32w0/include/AppTask.h +++ b/examples/shell/nxp/k32w/k32w0/include/AppTask.h @@ -66,6 +66,7 @@ class AppTask static void ThreadStart(); void StartTimer(uint32_t aTimeoutInMs); + static void InitServer(intptr_t arg); enum Function_t { diff --git a/examples/shell/nxp/k32w/k32w0/include/FreeRTOSConfig.h b/examples/shell/nxp/k32w/k32w0/include/FreeRTOSConfig.h index 9419372bbed91a..f25e96df522d13 100644 --- a/examples/shell/nxp/k32w/k32w0/include/FreeRTOSConfig.h +++ b/examples/shell/nxp/k32w/k32w0/include/FreeRTOSConfig.h @@ -55,7 +55,10 @@ #define configUSE_ALTERNATIVE_API 0 /* Deprecated! */ #define configQUEUE_REGISTRY_SIZE 8 #define configUSE_QUEUE_SETS 0 -#define configUSE_TIME_SLICING 0 +/* make sure that Thread task can interrupt lengthy Matter + * processing in case priority inversion occurs + */ +#define configUSE_TIME_SLICING 1 #define configUSE_NEWLIB_REENTRANT 0 #define configENABLE_BACKWARD_COMPATIBILITY 1 #define configNUM_THREAD_LOCAL_STORAGE_POINTERS 5 diff --git a/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp b/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp index efb0ccdadeaaf5..0ceec53420993b 100644 --- a/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp +++ b/examples/shell/nxp/k32w/k32w0/main/AppTask.cpp @@ -30,14 +30,18 @@ #include +#include +#include +#include +#include + #include "Keyboard.h" #include "LED.h" #include "LEDWidget.h" #include "app_config.h" -#define FACTORY_RESET_TRIGGER_TIMEOUT 6000 -#define FACTORY_RESET_CANCEL_WINDOW_TIMEOUT 3000 -#define APP_EVENT_QUEUE_SIZE 10 +constexpr uint32_t kFactoryResetTriggerTimeout = 6000; +constexpr uint8_t kAppEventQueueSize = 10; TimerHandle_t sFunctionTimer; // FreeRTOS app sw timer. @@ -46,7 +50,6 @@ static QueueHandle_t sAppEventQueue; static LEDWidget sStatusLED; static bool sIsThreadProvisioned = false; -static bool sIsThreadEnabled = false; static bool sHaveBLEConnections = false; static uint32_t eventMask = 0; @@ -60,40 +63,23 @@ CHIP_ERROR AppTask::StartAppTask() { CHIP_ERROR err = CHIP_NO_ERROR; - sAppEventQueue = xQueueCreate(APP_EVENT_QUEUE_SIZE, sizeof(AppEvent)); + sAppEventQueue = xQueueCreate(kAppEventQueueSize, sizeof(AppEvent)); if (sAppEventQueue == NULL) { err = APP_ERROR_EVENT_QUEUE_FAILED; K32W_LOG("Failed to allocate app event queue"); - assert(err == CHIP_NO_ERROR); + assert(false); } return err; } -void LockOpenThreadTask(void) -{ - chip::DeviceLayer::ThreadStackMgr().LockThreadStack(); -} - -void UnlockOpenThreadTask(void) -{ - chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack(); -} - CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; // Init ZCL Data Model and start server - static chip::CommonCaseDeviceServerInitParams initParams; - (void) initParams.InitializeStaticResourcesBeforeServerInit(); - chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; - nativeParams.lockCb = LockOpenThreadTask; - nativeParams.unlockCb = UnlockOpenThreadTask; - nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); - initParams.endpointNativeParams = static_cast(&nativeParams); - chip::Server::GetInstance().Init(initParams); + PlatformMgr().ScheduleWork(InitServer, 0); // Initialize device attestation config SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); @@ -126,15 +112,15 @@ CHIP_ERROR AppTask::Init() } // Print the current software version - char softwareVersionString[ConfigurationManager::kMaxSoftwareVersionStringLength + 1] = { 0 }; - err = ConfigurationMgr().GetSoftwareVersionString(softwareVersionString, sizeof(softwareVersionString)); + char currentSoftwareVer[ConfigurationManager::kMaxSoftwareVersionStringLength + 1] = { 0 }; + err = ConfigurationMgr().GetSoftwareVersionString(currentSoftwareVer, sizeof(currentSoftwareVer)); if (err != CHIP_NO_ERROR) { K32W_LOG("Get version error"); assert(err == CHIP_NO_ERROR); } - K32W_LOG("Current Software Version: %s", softwareVersionString); + K32W_LOG("Current Software Version: %s", currentSoftwareVer); #if CONFIG_CHIP_NFC_COMMISSIONING PlatformMgr().AddEventHandler(ThreadProvisioningHandler, 0); @@ -143,6 +129,30 @@ CHIP_ERROR AppTask::Init() return err; } +void LockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().LockThreadStack(); +} + +void UnlockOpenThreadTask(void) +{ + chip::DeviceLayer::ThreadStackMgr().UnlockThreadStack(); +} + +void AppTask::InitServer(intptr_t arg) +{ + static chip::CommonCaseDeviceServerInitParams initParams; + (void) initParams.InitializeStaticResourcesBeforeServerInit(); + + // Init ZCL Data Model and start server + chip::Inet::EndPointStateOpenThread::OpenThreadEndpointInitParam nativeParams; + nativeParams.lockCb = LockOpenThreadTask; + nativeParams.unlockCb = UnlockOpenThreadTask; + nativeParams.openThreadInstancePtr = chip::DeviceLayer::ThreadStackMgrImpl().OTInstance(); + initParams.endpointNativeParams = static_cast(&nativeParams); + VerifyOrDie((chip::Server::GetInstance().Init(initParams)) == CHIP_NO_ERROR); +} + void AppTask::AppTaskMain(void * pvParameter) { AppEvent event; @@ -156,7 +166,8 @@ void AppTask::AppTaskMain(void * pvParameter) while (true) { - BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, pdMS_TO_TICKS(10)); + TickType_t xTicksToWait = pdMS_TO_TICKS(10); + BaseType_t eventReceived = xQueueReceive(sAppEventQueue, &event, xTicksToWait); while (eventReceived == pdTRUE) { sAppTask.DispatchEvent(&event); @@ -170,9 +181,7 @@ void AppTask::AppTaskMain(void * pvParameter) // task is busy (e.g. with a long crypto operation). if (PlatformMgr().TryLockChipStack()) { - sIsThreadProvisioned = ConnectivityMgr().IsThreadProvisioned(); - sIsThreadEnabled = ConnectivityMgr().IsThreadEnabled(); - sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0); + sHaveBLEConnections = (ConnectivityMgr().NumBLEConnections() != 0); PlatformMgr().UnlockChipStack(); } @@ -190,7 +199,7 @@ void AppTask::AppTaskMain(void * pvParameter) // Otherwise, blink the LED ON for a very short time. if (sAppTask.mFunction != kFunction_FactoryReset) { - if (sIsThreadProvisioned && sIsThreadEnabled) + if (sIsThreadProvisioned) { sStatusLED.Blink(950, 50); } @@ -205,7 +214,6 @@ void AppTask::AppTaskMain(void * pvParameter) } sStatusLED.Animate(); - HandleKeyboard(); } } @@ -242,6 +250,8 @@ void AppTask::ButtonEventHandler(uint8_t pin_no, uint8_t button_action) void AppTask::KBD_Callback(uint8_t events) { eventMask = eventMask | (uint32_t)(1 << events); + + HandleKeyboard(); } void AppTask::HandleKeyboard(void) @@ -319,7 +329,7 @@ void AppTask::ResetActionEventHandler(AppEvent * aEvent) } else { - uint32_t resetTimeout = FACTORY_RESET_TRIGGER_TIMEOUT; + uint32_t resetTimeout = kFactoryResetTriggerTimeout; if (sAppTask.mFunction != kFunction_NoneSelected) { @@ -334,7 +344,7 @@ void AppTask::ResetActionEventHandler(AppEvent * aEvent) sStatusLED.Set(false); sStatusLED.Blink(500); - sAppTask.StartTimer(FACTORY_RESET_TRIGGER_TIMEOUT); + sAppTask.StartTimer(kFactoryResetTriggerTimeout); } } @@ -369,9 +379,21 @@ void AppTask::BleHandler(AppEvent * aEvent) } } -#if CONFIG_CHIP_NFC_COMMISSIONING void AppTask::ThreadProvisioningHandler(const ChipDeviceEvent * event, intptr_t) { + if (event->Type == DeviceEventType::kServiceProvisioningChange && event->ServiceProvisioningChange.IsServiceProvisioned) + { + if (event->ServiceProvisioningChange.IsServiceProvisioned) + { + sIsThreadProvisioned = TRUE; + } + else + { + sIsThreadProvisioned = FALSE; + } + } + +#if CONFIG_CHIP_NFC_COMMISSIONING if (event->Type == DeviceEventType::kCHIPoBLEAdvertisingChange && event->CHIPoBLEAdvertisingChange.Result == kActivity_Stopped) { if (!NFCMgr().IsTagEmulationStarted()) @@ -397,8 +419,8 @@ void AppTask::ThreadProvisioningHandler(const ChipDeviceEvent * event, intptr_t) K32W_LOG("Started NFC Tag Emulation!"); } } -} #endif +} void AppTask::CancelTimer() { @@ -431,9 +453,21 @@ void AppTask::StartTimer(uint32_t aTimeoutInMs) void AppTask::PostEvent(const AppEvent * aEvent) { + portBASE_TYPE taskToWake = pdFALSE; if (sAppEventQueue != NULL) { - if (!xQueueSend(sAppEventQueue, aEvent, 1)) + if (__get_IPSR()) + { + if (!xQueueSendToFrontFromISR(sAppEventQueue, aEvent, &taskToWake)) + { + K32W_LOG("Failed to post event to app task event queue"); + } + if (taskToWake) + { + portYIELD_FROM_ISR(taskToWake); + } + } + else if (!xQueueSend(sAppEventQueue, aEvent, 0)) { K32W_LOG("Failed to post event to app task event queue"); } diff --git a/examples/shell/nxp/k32w/k32w0/main/main.cpp b/examples/shell/nxp/k32w/k32w0/main/main.cpp index 0693ba7213316d..152900341c4067 100644 --- a/examples/shell/nxp/k32w/k32w0/main/main.cpp +++ b/examples/shell/nxp/k32w/k32w0/main/main.cpp @@ -44,6 +44,7 @@ using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; using namespace ::chip::Logging; using chip::Shell::Engine; +#include "MacSched.h" typedef void (*InitFunc)(void); extern InitFunc __init_array_start; @@ -61,6 +62,7 @@ extern "C" unsigned int sleep(unsigned int seconds) static void shell_task(void * args) { + Engine::Root().Init(); Engine::Root().RunMainLoop(); } @@ -109,6 +111,11 @@ extern "C" void main_task(void const * argument) goto exit; } + /* Enable the MAC scheduler after BLEManagerImpl::_Init() and V2MMAC_Enable(). + * This is needed to register properly the active protocols. + */ + sched_enable(); + ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_MinimalEndDevice); if (ret != CHIP_NO_ERROR) { @@ -130,8 +137,6 @@ extern "C" void main_task(void const * argument) goto exit; } - // cmd_otcli_init(); - shellTaskHandle = xTaskCreate(shell_task, "shell_task", shell_task_size / sizeof(StackType_t), NULL, shell_task_priority, NULL); if (!shellTaskHandle) { diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 648b053c6bff54..6c4fcc8649cf8a 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -553,10 +553,10 @@ def K32WTargets(): yield target.Extend('light-ota-se', app=K32WApp.LIGHT, release=True, disable_ble=True, se05x=True).GlobBlacklist("Only on demand build") yield target.Extend('light-release-no-ota', app=K32WApp.LIGHT, tokenizer=True, disable_ota=True, release=True, tinycrypt=True) - yield target.Extend('shell-release', app=K32WApp.SHELL, release=True) + yield target.Extend('shell-release', app=K32WApp.SHELL, disable_logs=True, release=True) yield target.Extend('lock-release', app=K32WApp.LOCK, release=True) yield target.Extend('lock-low-power-release', app=K32WApp.LOCK, - low_power=True, release=True).GlobBlacklist("Only on demand build") + low_power=True, disable_logs=True, release=True).GlobBlacklist("Only on demand build") def cc13x2x7_26x2x7Targets(): diff --git a/scripts/build/builders/k32w.py b/scripts/build/builders/k32w.py index 39828157e934eb..f00c21a5ac3344 100644 --- a/scripts/build/builders/k32w.py +++ b/scripts/build/builders/k32w.py @@ -60,6 +60,7 @@ def __init__(self, tokenizer: bool = False, disable_ble: bool = False, disable_ota: bool = False, + disable_logs: bool = False, se05x: bool = False, tinycrypt: bool = False): super(K32WBuilder, self).__init__( @@ -72,6 +73,7 @@ def __init__(self, self.release = release self.disable_ble = disable_ble self.disable_ota = disable_ota + self.disable_logs = disable_logs self.se05x = se05x self.tinycrypt = tinycrypt @@ -97,6 +99,9 @@ def GnBuildArgs(self): if self.disable_ota: args.append('chip_enable_ota_requestor=false') + if self.disable_logs: + args.append('chip_logging=false') + if self.se05x: args.append('chip_with_se05x=true') diff --git a/scripts/build/testdata/build_all_except_host.txt b/scripts/build/testdata/build_all_except_host.txt index 127b9a9f329724..48b2f68c78ba30 100644 --- a/scripts/build/testdata/build_all_except_host.txt +++ b/scripts/build/testdata/build_all_except_host.txt @@ -927,7 +927,7 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa {root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh # Generating k32w-lock-low-power-release -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/nxp/k32w/k32w0 '--args=k32w0_sdk_root="TEST_NXP_K32W0_SDK_ROOT" chip_with_low_power=1 is_debug=false' {out}/k32w-lock-low-power-release +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/lock-app/nxp/k32w/k32w0 '--args=k32w0_sdk_root="TEST_NXP_K32W0_SDK_ROOT" chip_with_low_power=1 is_debug=false chip_logging=false' {out}/k32w-lock-low-power-release {root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh @@ -937,7 +937,7 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa {root}/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh # Generating k32w-shell-release -gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/shell/nxp/k32w/k32w0 '--args=k32w0_sdk_root="TEST_NXP_K32W0_SDK_ROOT" chip_with_low_power=0 is_debug=false' {out}/k32w-shell-release +gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/shell/nxp/k32w/k32w0 '--args=k32w0_sdk_root="TEST_NXP_K32W0_SDK_ROOT" chip_with_low_power=0 is_debug=false chip_logging=false' {out}/k32w-shell-release # Generating config mbed-CY8CPROTO_062_4343W-all-clusters-debug mbed-tools configure -t GCC_ARM -m CY8CPROTO_062_4343W -p {root}/examples/all-clusters-app/mbed -o {out}/mbed-CY8CPROTO_062_4343W-all-clusters-debug --mbed-os-path {root}/third_party/mbed-os/repo diff --git a/scripts/tools/nxp/generate_nxp_chip_factory_bin.py b/scripts/tools/nxp/generate_nxp_chip_factory_bin.py new file mode 100755 index 00000000000000..17b8b388d21855 --- /dev/null +++ b/scripts/tools/nxp/generate_nxp_chip_factory_bin.py @@ -0,0 +1,170 @@ +#!/usr/bin/env python3 +# +# 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. +# + +import argparse +import subprocess +import base64 +import logging +import os +from cryptography.hazmat.backends import default_backend +from cryptography.hazmat.primitives.serialization import load_der_private_key + +# Keys used to store KLV +KLV_KEYS = { + "Verifier": 1, + "Salt": 2, + "IC": 3, + "DacPKey": 4, + "DacCert": 5, + "PaiCert": 6, + "Disc": 7 +} + + +def type_int(n): + return int(n, 0) + + +def read_der(der_file): + with open(der_file, "rb") as file: + return file.read() + + +def generate_spake2_params(spake2_path, passcode, it, salt): + cmd = [ + spake2_path, "gen-verifier", "--iteration-count", + str(it), "--salt", + str(salt), "--pin-code", + str(passcode), "--out", "-" + ] + + out = subprocess.run(cmd, check=True, stdout=subprocess.PIPE).stdout + out = out.decode("utf-8").splitlines() + return dict(zip(out[0].split(','), out[1].split(','))) + + +def get_private_key_der(der_file, password): + data = read_der(der_file) + keys = load_der_private_key(data, password, backend=default_backend()) + private_key = keys.private_numbers().private_value.to_bytes( + 32, byteorder='big') + return private_key + + +def generate_klv(spake2_params, args): + klv = [] + + spake2p_verifier = str.encode(spake2_params["Verifier"]) + spake2p_salt = str.encode(spake2_params["Salt"]) + spake2p_it = int(spake2_params["Iteration Count"]).to_bytes(4, "little") + dac_private_key = get_private_key_der(args.dac_key, args.dac_key_password) + dac_cert = read_der(args.dac_cert) + pai_cert = read_der(args.pai_cert) + discriminator = int(args.discrimnator).to_bytes(4, "little") + + klv.append((KLV_KEYS["Verifier"], len(spake2p_verifier), spake2p_verifier)) + print("Verifier length: ", len(spake2p_verifier)) + klv.append((KLV_KEYS["Salt"], len(spake2p_salt), spake2p_salt)) + print("SALT length: ", len(spake2p_salt)) + klv.append((KLV_KEYS["IC"], 4, spake2p_it)) + klv.append((KLV_KEYS["DacPKey"], len(dac_private_key), dac_private_key)) + print("DAC Private Key length: ", len(dac_private_key)) + klv.append((KLV_KEYS["DacCert"], len(dac_cert), dac_cert)) + print("DAC Certificate length: ", len(dac_cert)) + klv.append((KLV_KEYS["PaiCert"], len(pai_cert), pai_cert)) + print("PAI Certificate length: ", len(pai_cert)) + klv.append((KLV_KEYS["Disc"], 4, discriminator)) + return klv + + +def klv_to_bin(klv, out): + with open(out, "wb") as file: + for entry in klv: + file.write(entry[0].to_bytes(1, "little")) + file.write(entry[1].to_bytes(2, "little")) + file.write(entry[2]) + size = file.seek(0, os.SEEK_END) + print("Size of generated binary is:", size, "bytes") + + +def main(): + parser = argparse.ArgumentParser(description="NXP Factory Data Generator") + + parser.add_argument("-i", + "--it", + required=True, + type=type_int, + help="[int | hex] Spake2 Iteration Counter") + parser.add_argument("-s", + "--salt", + type=str, + required=True, + help="[ascii] Spake2 Salt") + parser.add_argument("-p", + "--passcode", + type=type_int, + required=True, + help="[int | hex] PASE session passcode") + parser.add_argument("-d", + "--discrimnator", + type=type_int, + required=True, + help="[int | hex] BLE Pairing discrimantor") + parser.add_argument("--dac_cert", + type=str, + required=True, + help="[path] Path to DAC certificate in DER format") + parser.add_argument("--dac_key", + type=str, + required=True, + help="[path] Path to DAC key in DER format") + parser.add_argument("--dac_key_password", + type=str, + required=False, + help="[path] Password to decode DAC Key if available") + parser.add_argument("--pai_cert", + type=str, + required=True, + help="[path] Path to PAI certificate in DER format") + parser.add_argument("--spake2p_path", + type=str, + required=True, + help="[path] Path to Spake2P") + parser.add_argument("--out", + type=str, + required=True, + help="[path] Path to output binary") + + args = parser.parse_args() + + if args.dac_key_password is None: + logging.warning( + "DAC Key password not provided. It means DAC Key is not protected." + ) + + spake2_params = generate_spake2_params(args.spake2p_path, args.passcode, + args.it, args.salt) + klv = generate_klv(spake2_params, args) + klv_to_bin(klv, args.out) + + +if __name__ == "__main__": + main() + +# Example usage: +# python3 generate_nxp_chip_factory_bin.py -i 10000 -s ABCDEFGHIJKLMNOPQRS -p 14014 -d 1000 --dac_cert /home/john/nxp/connectedhomeip_nxp/Chip-DAC-NXP-Cert.der --dac_key /home/john/nxp/connectedhomeip_nxp/Chip-DAC-NXP-Key.der --pai_cert /home/john/nxp/connectedhomeip_nxp/Chip-PAI-NXP-Cert.der --spake2p_path /home/john/nxp/connectedhomeip_nxp/out/host/spake2p --out out.bin diff --git a/src/crypto/CHIPCryptoPALTinyCrypt.cpp b/src/crypto/CHIPCryptoPALTinyCrypt.cpp index d0afe4d6b23663..2083728bdd5135 100644 --- a/src/crypto/CHIPCryptoPALTinyCrypt.cpp +++ b/src/crypto/CHIPCryptoPALTinyCrypt.cpp @@ -1327,8 +1327,8 @@ CHIP_ERROR ExtractPubkeyFromX509Cert(const ByteSpan & certificate, Crypto::P256P #if defined(MBEDTLS_X509_CRT_PARSE_C) CHIP_ERROR error = CHIP_NO_ERROR; mbedtls_x509_crt mbed_cert; - mbedtls_ecp_keypair * keypair = nullptr; - size_t pubkey_size = 0; + mbedtls_uecc_keypair * keypair = nullptr; + size_t pubkey_size = 0; mbedtls_x509_crt_init(&mbed_cert); @@ -1338,15 +1338,11 @@ CHIP_ERROR ExtractPubkeyFromX509Cert(const ByteSpan & certificate, Crypto::P256P VerifyOrExit(mbedtls_pk_get_type(&(mbed_cert.CHIP_CRYPTO_PAL_PRIVATE_X509(pk))) == MBEDTLS_PK_ECKEY, error = CHIP_ERROR_INVALID_ARGUMENT); - keypair = mbedtls_pk_ec(mbed_cert.CHIP_CRYPTO_PAL_PRIVATE_X509(pk)); - VerifyOrExit(keypair->CHIP_CRYPTO_PAL_PRIVATE(grp).id == MapECPGroupId(pubkey.Type()), error = CHIP_ERROR_INVALID_ARGUMENT); - // Copy the public key from the cert in raw point format - result = - mbedtls_ecp_point_write_binary(&keypair->CHIP_CRYPTO_PAL_PRIVATE(grp), &keypair->CHIP_CRYPTO_PAL_PRIVATE(Q), - MBEDTLS_ECP_PF_UNCOMPRESSED, &pubkey_size, Uint8::to_uchar(pubkey.Bytes()), pubkey.Length()); + keypair = mbedtls_pk_uecc(mbed_cert.CHIP_CRYPTO_PAL_PRIVATE_X509(pk)); + Uint8::to_uchar(pubkey)[0] = 0x04; // uncompressed type + memcpy(Uint8::to_uchar(pubkey) + 1, keypair->public_key, 2 * NUM_ECC_BYTES); VerifyOrExit(result == 0, error = CHIP_ERROR_INTERNAL); - VerifyOrExit(pubkey_size == pubkey.Length(), error = CHIP_ERROR_INTERNAL); exit: _log_mbedTLS_error(result); diff --git a/src/messaging/README.md b/src/messaging/README.md index f85a2767b1c8c6..bab614e85360ae 100644 --- a/src/messaging/README.md +++ b/src/messaging/README.md @@ -21,7 +21,7 @@ Unless specified, numerical values are represented in decimal notation. | Field | Description | | -------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -| exchange_id | Exchange ID + IsInitiator flag from message header ('i' if initiator, 'r' if responder') | +| exchange_id | Exchange ID + `IsInitiator` flag from message header ('i' if initiator, 'r' if responder') | | msg_id | Message counter | | ack_msg_id | If present, the ACK message counter. Otherwise, this entire field is omitted from display | | msg_category | U: Un-secure Unicast, S: Secure Unicast, G: Secure Groupcast | diff --git a/src/platform/nxp/k32w/common/RamStorage.cpp b/src/platform/nxp/k32w/common/RamStorage.cpp new file mode 100644 index 00000000000000..716fc8dbec20b0 --- /dev/null +++ b/src/platform/nxp/k32w/common/RamStorage.cpp @@ -0,0 +1,102 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +namespace chip::DeviceLayer::Internal { + +RamStorage::Buffer RamStorage::sBuffer = nullptr; + +CHIP_ERROR RamStorage::Init(uint16_t aNvmId, uint16_t aInitialSize) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + sBuffer = getRamBuffer(aNvmId, aInitialSize); + if (!sBuffer) + { + err = CHIP_ERROR_NO_MEMORY; + } + + return err; +} + +void RamStorage::FreeBuffer() +{ + if (sBuffer) + { + free(sBuffer); + sBuffer = nullptr; + } +} + +CHIP_ERROR RamStorage::Read(uint16_t aKey, int aIndex, uint8_t * aValue, uint16_t * aValueLength) +{ + CHIP_ERROR err; + rsError status; + + status = ramStorageGet(sBuffer, aKey, aIndex, aValue, aValueLength); + SuccessOrExit(err = MapStatusToChipError(status)); + +exit: + return err; +} + +CHIP_ERROR RamStorage::Write(uint16_t aKey, const uint8_t * aValue, uint16_t aValueLength) +{ + CHIP_ERROR err; + rsError status = RS_ERROR_NONE; + + // Delete all occurrences of "key" and resize buffer if needed + // before scheduling writing of new value. + ramStorageDelete(sBuffer, aKey, -1); + status = ramStorageResize(&sBuffer, aKey, aValue, aValueLength); + SuccessOrExit(err = MapStatusToChipError(status)); + status = ramStorageSet(sBuffer, aKey, aValue, aValueLength); + SuccessOrExit(err = MapStatusToChipError(status)); + +exit: + return err; +} + +CHIP_ERROR RamStorage::Delete(uint16_t aKey, int aIndex) +{ + rsError status = ramStorageDelete(sBuffer, aKey, aIndex); + return MapStatusToChipError(status); +} + +CHIP_ERROR RamStorage::MapStatusToChipError(rsError rsStatus) +{ + CHIP_ERROR err; + + switch (rsStatus) + { + case RS_ERROR_NONE: + err = CHIP_NO_ERROR; + break; + case RS_ERROR_NOT_FOUND: + err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; + break; + default: + err = CHIP_ERROR_BUFFER_TOO_SMALL; + break; + } + + return err; +} + +} // namespace chip::DeviceLayer::Internal diff --git a/src/platform/nxp/k32w/common/RamStorage.h b/src/platform/nxp/k32w/common/RamStorage.h new file mode 100644 index 00000000000000..414db35d61d878 --- /dev/null +++ b/src/platform/nxp/k32w/common/RamStorage.h @@ -0,0 +1,54 @@ +/* + * + * Copyright (c) 2022 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. + */ + +#pragma once + +#include + +#include "pdm_ram_storage_glue.h" +#include "ram_storage.h" + +namespace chip { +namespace DeviceLayer { +namespace Internal { + +/** + * + * All ram storage operations should be managed by this class. + */ +class RamStorage +{ +public: + using Buffer = ramBufferDescriptor *; + + static CHIP_ERROR Init(uint16_t aNvmId, uint16_t aInitialSize); + static void FreeBuffer(); + static Buffer GetBuffer() { return sBuffer; } + + static CHIP_ERROR Read(uint16_t aKey, int aIndex, uint8_t * aValue, uint16_t * aValueLength); + static CHIP_ERROR Write(uint16_t aKey, const uint8_t * aValue, uint16_t aValueLength); + static CHIP_ERROR Delete(uint16_t aKey, int aIndex); + +private: + static CHIP_ERROR MapStatusToChipError(rsError rsStatus); + + static Buffer sBuffer; +}; + +} // namespace Internal +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/BLEManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/BLEManagerImpl.cpp index 7ef69ae8b36947..e0728be466351b 100644 --- a/src/platform/nxp/k32w/k32w0/BLEManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/BLEManagerImpl.cpp @@ -835,7 +835,7 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) advInterval = CHIP_DEVICE_CONFIG_BLE_SLOW_ADVERTISING_INTERVAL_MAX; } - adv_params.minInterval = adv_params.maxInterval = advInterval; + adv_params.minInterval = adv_params.maxInterval = (uint16_t)(advInterval / 0.625F); adv_params.advertisingType = gAdvConnectableUndirected_c; adv_params.ownAddressType = gBleAddrTypePublic_c; adv_params.peerAddressType = gBleAddrTypePublic_c; @@ -846,11 +846,11 @@ CHIP_ERROR BLEManagerImpl::ConfigureAdvertisingData(void) err = blekw_start_advertising(&adv_params, &adv, &scanRsp); if (err == BLE_OK) { - ChipLogProgress(DeviceLayer, "Started Advertising."); + ChipLogProgress(DeviceLayer, "Started Advertising at %d ms", advInterval); } else { - ChipLogProgress(DeviceLayer, "Advertising error!"); + ChipLogProgress(DeviceLayer, "Advertising error 0x%x!", err); return CHIP_ERROR_INCORRECT_STATE; } @@ -964,8 +964,6 @@ void BLEManagerImpl::bleAppTask(void * p_arg) { xEventGroupWaitBits(bleAppTaskLoopEvent, LOOP_EV_BLE, true, false, portMAX_DELAY); - PlatformMgr().LockChipStack(); - if (MSG_Pending(&blekw_msg_list)) { /* There is message from the BLE tasks to solve */ @@ -975,7 +973,16 @@ void BLEManagerImpl::bleAppTask(void * p_arg) if (msg->type == BLE_KW_MSG_ERROR) { - ChipLogProgress(DeviceLayer, "BLE Error: %d.\n", msg->data.u8); + if (msg->data.u8 == BLE_KW_MSG_2M_UPGRADE_ERROR) + { + ChipLogProgress(DeviceLayer, + "Warning. BLE is using 1Mbps. Couldn't upgrade to 2Mbps, " + "maybe the peer is missing 2Mbps support."); + } + else + { + ChipLogProgress(DeviceLayer, "BLE Error: %d.\n", msg->data.u8); + } } else if (msg->type == BLE_KW_MSG_CONNECTED) { @@ -1009,7 +1016,6 @@ void BLEManagerImpl::bleAppTask(void * p_arg) /* Freed the message from the queue */ MSG_Free(msg); } - PlatformMgr().UnlockChipStack(); } } @@ -1181,7 +1187,15 @@ void BLEManagerImpl::blekw_generic_cb(gapGenericEvent_t * pGenericEvent) ChipLogProgress(DeviceLayer, "BLE Internal Error: Code 0x%04X, Source 0x%08X, HCI OpCode %d.\n", pGenericEvent->eventData.internalError.errorCode, pGenericEvent->eventData.internalError.errorSource, pGenericEvent->eventData.internalError.hciCommandOpcode); - (void) blekw_msg_add_u8(BLE_KW_MSG_ERROR, BLE_INTERNAL_ERROR); + if ((gHciUnsupportedRemoteFeature_c == pGenericEvent->eventData.internalError.errorCode) && + (gLeSetPhy_c == pGenericEvent->eventData.internalError.errorSource)) + { + (void) blekw_msg_add_u8(BLE_KW_MSG_ERROR, BLE_KW_MSG_2M_UPGRADE_ERROR); + } + else + { + (void) blekw_msg_add_u8(BLE_KW_MSG_ERROR, BLE_INTERNAL_ERROR); + } break; case gAdvertisingSetupFailed_c: @@ -1241,10 +1255,12 @@ void BLEManagerImpl::blekw_gap_connection_cb(deviceId_t deviceId, gapConnectionE if (pConnectionEvent->eventType == gConnEvtConnected_c) { +#if CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ ChipLogProgress(DeviceLayer, "BLE K32W: Trying to set the PHY to 2M"); (void) Gap_LeSetPhy(FALSE, deviceId, 0, gConnPhyUpdateReqTxPhySettings_c, gConnPhyUpdateReqRxPhySettings_c, (uint16_t) gConnPhyUpdateReqPhyOptions_c); +#endif /* Notify App Task that the BLE is connected now */ (void) blekw_msg_add_u8(BLE_KW_MSG_CONNECTED, (uint8_t) deviceId); diff --git a/src/platform/nxp/k32w/k32w0/BLEManagerImpl.h b/src/platform/nxp/k32w/k32w0/BLEManagerImpl.h index b3b473337bf253..f6b5a0df6e07d9 100644 --- a/src/platform/nxp/k32w/k32w0/BLEManagerImpl.h +++ b/src/platform/nxp/k32w/k32w0/BLEManagerImpl.h @@ -119,7 +119,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla enum { kMaxConnections = BLE_LAYER_NUM_BLE_ENDPOINTS, - kMaxDeviceNameLength = 16, + kMaxDeviceNameLength = 32, kUnusedIndex = 0xFF, }; @@ -165,6 +165,7 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla BLE_E_FAIL, BLE_E_START_ADV_FAILED, BLE_INTERNAL_ERROR, + BLE_KW_MSG_2M_UPGRADE_ERROR, } ble_err_t; typedef struct ble_att_written_data_s diff --git a/src/platform/nxp/k32w/k32w0/BUILD.gn b/src/platform/nxp/k32w/k32w0/BUILD.gn index e813d8253c48bd..35228093e77f0a 100644 --- a/src/platform/nxp/k32w/k32w0/BUILD.gn +++ b/src/platform/nxp/k32w/k32w0/BUILD.gn @@ -13,8 +13,10 @@ # limitations under the License. import("//build_overrides/chip.gni") +import("//build_overrides/k32w0_sdk.gni") import("${chip_root}/src/platform/device.gni") +import("${k32w0_sdk_build_root}/k32w0_sdk.gni") assert(chip_device_platform == "k32w0") @@ -24,8 +26,9 @@ if (chip_enable_openthread) { static_library("k32w0") { sources = [ - "../../../FreeRTOS/SystemTimeSupport.cpp", "../../../SingletonConfigurationManager.cpp", + "../common/RamStorage.cpp", + "../common/RamStorage.h", "BLEManagerImpl.cpp", "BLEManagerImpl.h", "CHIPDevicePlatformConfig.h", @@ -34,12 +37,16 @@ static_library("k32w0") { "ConfigurationManagerImpl.h", "ConnectivityManagerImpl.cpp", "ConnectivityManagerImpl.h", + "DefaultTestEventTriggerDelegate.cpp", + "DefaultTestEventTriggerDelegate.h", "DeviceNetworkProvisioningDelegateImpl.cpp", "DeviceNetworkProvisioningDelegateImpl.h", "DiagnosticDataProviderImpl.cpp", "DiagnosticDataProviderImpl.h", "K32W0Config.cpp", "K32W0Config.h", + "K32W0FactoryDataProvider.cpp", + "K32W0FactoryDataProvider.h", "KeyValueStoreManagerImpl.cpp", "KeyValueStoreManagerImpl.h", "Logging.cpp", @@ -47,9 +54,21 @@ static_library("k32w0") { "NFCManagerImpl.h", "PlatformManagerImpl.cpp", "PlatformManagerImpl.h", + "SystemTimeSupport.cpp", "ble_function_mux.c", ] + public = [ + "${chip_root}/src/credentials/DeviceAttestationCredsProvider.h", + "${chip_root}/src/credentials/examples/DeviceAttestationCredsExample.h", + "${chip_root}/src/credentials/examples/ExampleDACs.h", + "${chip_root}/src/credentials/examples/ExamplePAI.h", + ] + + if (chip_with_low_power != 0) { + sources += [ "LowPowerHooks.cpp" ] + } + if (chip_enable_ota_requestor) { sources += [ "OTAImageProcessorImpl.cpp", diff --git a/src/platform/nxp/k32w/k32w0/CHIPDevicePlatformConfig.h b/src/platform/nxp/k32w/k32w0/CHIPDevicePlatformConfig.h index 3529d47b4435e6..c5cc9287e5c97e 100644 --- a/src/platform/nxp/k32w/k32w0/CHIPDevicePlatformConfig.h +++ b/src/platform/nxp/k32w/k32w0/CHIPDevicePlatformConfig.h @@ -64,9 +64,79 @@ #define CHIP_DEVICE_LAYER_BLE_CONN_CFG_TAG 1 #endif // CHIP_DEVICE_LAYER_BLE_CONN_CFG_TAG +#ifndef CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION +//-> format_version = 1 +//-> vendor_id = 0xFFF1 +//-> product_id_array = [ 0x8000, 0x8001, 0x8002, 0x8003, 0x8004, 0x8005, 0x8006, 0x8007, 0x8008, 0x8009, 0x800A, 0x800B, +// 0x800C, 0x800D, 0x800E, 0x800F, 0x8010, 0x8011, 0x8012, 0x8013, 0x8014, 0x8015, 0x8016, 0x8017, 0x8018, 0x8019, 0x801A, +// 0x801B, 0x801C, 0x801D, 0x801E, 0x801F, 0x8020, 0x8021, 0x8022, 0x8023, 0x8024, 0x8025, 0x8026, 0x8027, 0x8028, 0x8029, +// 0x802A, 0x802B, 0x802C, 0x802D, 0x802E, 0x802F, 0x8030, 0x8031, 0x8032, 0x8033, 0x8034, 0x8035, 0x8036, 0x8037, 0x8038, +// 0x8039, 0x803A, 0x803B, 0x803C, 0x803D, 0x803E, 0x803F, 0x8040, 0x8041, 0x8042, 0x8043, 0x8044, 0x8045, 0x8046, 0x8047, +// 0x8048, 0x8049, 0x804A, 0x804B, 0x804C, 0x804D, 0x804E, 0x804F, 0x8050, 0x8051, 0x8052, 0x8053, 0x8054, 0x8055, 0x8056, +// 0x8057, 0x8058, 0x8059, 0x805A, 0x805B, 0x805C, 0x805D, 0x805E, 0x805F, 0x8060, 0x8061, 0x8062, 0x8063 ] +//-> device_type_id = 0x0016 +//-> certificate_id = "ZIG20142ZB330003-24" +//-> security_level = 0 +//-> security_information = 0 +//-> version_number = 0x2694 +//-> certification_type = 0 +//-> dac_origin_vendor_id is not present +//-> dac_origin_product_id is not present +#define CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION \ + { \ + 0x30, 0x82, 0x02, 0x19, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x82, 0x02, 0x0a, 0x30, \ + 0x82, 0x02, 0x06, 0x02, 0x01, 0x03, 0x31, 0x0d, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, \ + 0x02, 0x01, 0x30, 0x82, 0x01, 0x71, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01, 0xa0, 0x82, \ + 0x01, 0x62, 0x04, 0x82, 0x01, 0x5e, 0x15, 0x24, 0x00, 0x01, 0x25, 0x01, 0xe1, 0xee, 0x36, 0x02, 0x05, 0x00, 0x80, \ + 0x05, 0x01, 0x80, 0x05, 0x02, 0x80, 0x05, 0x03, 0x80, 0x05, 0x04, 0x80, 0x05, 0x05, 0x80, 0x05, 0x06, 0x80, 0x05, \ + 0x07, 0x80, 0x05, 0x08, 0x80, 0x05, 0x09, 0x80, 0x05, 0x0a, 0x80, 0x05, 0x0b, 0x80, 0x05, 0x0c, 0x80, 0x05, 0x0d, \ + 0x80, 0x05, 0x0e, 0x80, 0x05, 0x0f, 0x80, 0x05, 0x10, 0x80, 0x05, 0x11, 0x80, 0x05, 0x12, 0x80, 0x05, 0x13, 0x80, \ + 0x05, 0x14, 0x80, 0x05, 0x15, 0x80, 0x05, 0x16, 0x80, 0x05, 0x17, 0x80, 0x05, 0x18, 0x80, 0x05, 0x19, 0x80, 0x20, \ + 0x05, 0x1a, 0x80, 0x05, 0x1b, 0x80, 0x05, 0x1c, 0x80, 0x05, 0x1d, 0x80, 0x05, 0x1e, 0x80, 0x05, 0x1f, 0x80, 0x05, \ + 0x80, 0x05, 0x21, 0x80, 0x05, 0x22, 0x80, 0x05, 0x23, 0x80, 0x05, 0x24, 0x80, 0x05, 0x25, 0x80, 0x05, 0x26, 0x80, \ + 0x05, 0x27, 0x80, 0x05, 0x28, 0x80, 0x05, 0x29, 0x80, 0x05, 0x2a, 0x80, 0x05, 0x2b, 0x80, 0x05, 0x2c, 0x80, 0x05, \ + 0x2d, 0x80, 0x05, 0x2e, 0x80, 0x05, 0x2f, 0x80, 0x05, 0x30, 0x80, 0x05, 0x31, 0x80, 0x05, 0x32, 0x80, 0x05, 0x33, \ + 0x80, 0x05, 0x34, 0x80, 0x05, 0x35, 0x80, 0x05, 0x36, 0x80, 0x05, 0x37, 0x80, 0x05, 0x38, 0x80, 0x05, 0x39, 0x80, \ + 0x05, 0x3a, 0x80, 0x05, 0x3b, 0x80, 0x05, 0x3c, 0x80, 0x05, 0x3d, 0x80, 0x05, 0x3e, 0x80, 0x05, 0x3f, 0x80, 0x05, \ + 0x40, 0x80, 0x05, 0x41, 0x80, 0x05, 0x42, 0x80, 0x05, 0x43, 0x80, 0x05, 0x44, 0x80, 0x05, 0x45, 0x80, 0x05, 0x46, \ + 0x80, 0x05, 0x47, 0x80, 0x05, 0x48, 0x80, 0x05, 0x49, 0x80, 0x05, 0x4a, 0x80, 0x05, 0x4b, 0x80, 0x05, 0x4c, 0x80, \ + 0x05, 0x4d, 0x80, 0x05, 0x4e, 0x80, 0x05, 0x4f, 0x80, 0x05, 0x50, 0x80, 0x05, 0x51, 0x80, 0x05, 0x52, 0x80, 0x05, \ + 0x53, 0x80, 0x05, 0x54, 0x80, 0x05, 0x55, 0x80, 0x05, 0x56, 0x80, 0x05, 0x57, 0x80, 0x05, 0x58, 0x80, 0x05, 0x59, \ + 0x80, 0x05, 0x5a, 0x80, 0x05, 0x5b, 0x80, 0x05, 0x5c, 0x80, 0x05, 0x5d, 0x80, 0x05, 0x5e, 0x80, 0x05, 0x5f, 0x80, \ + 0x05, 0x60, 0x80, 0x05, 0x61, 0x80, 0x05, 0x62, 0x80, 0x05, 0x63, 0x80, 0x18, 0x24, 0x03, 0x16, 0x2c, 0x04, 0x13, \ + 0x5a, 0x49, 0x47, 0x32, 0x30, 0x31, 0x34, 0x32, 0x5a, 0x42, 0x33, 0x33, 0x30, 0x30, 0x30, 0x33, 0x2d, 0x32, 0x34, \ + 0x24, 0x05, 0x00, 0x24, 0x06, 0x00, 0x25, 0x07, 0x94, 0x26, 0x24, 0x08, 0x00, 0x18, 0x31, 0x7d, 0x30, 0x7b, 0x02, \ + 0x01, 0x03, 0x80, 0x14, 0x62, 0xfa, 0x82, 0x33, 0x59, 0xac, 0xfa, 0xa9, 0x96, 0x3e, 0x1c, 0xfa, 0x14, 0x0a, 0xdd, \ + 0xf5, 0x04, 0xf3, 0x71, 0x60, 0x30, 0x0b, 0x06, 0x09, 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x30, \ + 0x0a, 0x06, 0x08, 0x2a, 0x86, 0x48, 0xce, 0x3d, 0x04, 0x03, 0x02, 0x04, 0x47, 0x30, 0x45, 0x02, 0x20, 0x24, 0xe5, \ + 0xd1, 0xf4, 0x7a, 0x7d, 0x7b, 0x0d, 0x20, 0x6a, 0x26, 0xef, 0x69, 0x9b, 0x7c, 0x97, 0x57, 0xb7, 0x2d, 0x46, 0x90, \ + 0x89, 0xde, 0x31, 0x92, 0xe6, 0x78, 0xc7, 0x45, 0xe7, 0xf6, 0x0c, 0x02, 0x21, 0x00, 0xf8, 0xaa, 0x2f, 0xa7, 0x11, \ + 0xfc, 0xb7, 0x9b, 0x97, 0xe3, 0x97, 0xce, 0xda, 0x66, 0x7b, 0xae, 0x46, 0x4e, 0x2b, 0xd3, 0xff, 0xdf, 0xc3, 0xcc, \ + 0xed, 0x7a, 0xa8, 0xca, 0x5f, 0x4c, 0x1a, 0x7c \ + } +#endif + +/** + * @def CHIP_DEVICE_LAYER_OTA_REBOOT_DELAY + * + * The delay before rebooting after an OTA process was finished. + */ +#ifndef CHIP_DEVICE_LAYER_OTA_REBOOT_DELAY +#define CHIP_DEVICE_LAYER_OTA_REBOOT_DELAY 3000 +#endif // CHIP_DEVICE_LAYER_OTA_REBOOT_DELAY + +/** + * @def CHIP_DEVICE_LAYER_ENABLE_PDM_LOGS + * + * Flag to enable PDM events logging. Disabled by default. + */ +#ifndef CHIP_DEVICE_LAYER_ENABLE_PDM_LOGS +#define CHIP_DEVICE_LAYER_ENABLE_PDM_LOGS 0 +#endif // CHIP_DEVICE_LAYER_ENABLE_PDM_LOGS + // ========== Platform-specific Configuration Overrides ========= #ifndef CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE -#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE (5 * 1024) +#define CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE (6 * 1024) #endif // CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE #ifndef CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE @@ -80,6 +150,16 @@ #define CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME "BLE App Task" #endif // CHIP_DEVICE_CONFIG_BLE_APP_TASK_NAME +/** + * @def CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ + * + * Enables/disables the Gap_LeSetPhy request to switch to 2M; enabled by default. + * May be disabled on applications for interoperability reasons. + */ +#ifndef CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ +#define CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ 1 +#endif // CHIP_DEVICE_CONFIG_BLE_SET_PHY_2M_REQ + #define CHIP_DEVICE_CONFIG_ENABLE_WIFI_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY 0 #define CHIP_DEVICE_CONFIG_ENABLE_THREAD_TELEMETRY_FULL 0 diff --git a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp index 451536e8deedbd..c236c05d1fa618 100644 --- a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp @@ -52,13 +52,6 @@ CHIP_ERROR ConfigurationManagerImpl::Init() CHIP_ERROR err; uint32_t rebootCount = 0; - // Save out software version on first boot - if (!K32WConfig::ConfigValueExists(K32WConfig::kConfigKey_SoftwareVersion)) - { - err = StoreSoftwareVersion(CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); - SuccessOrExit(err); - } - if (K32WConfig::ConfigValueExists(K32WConfig::kCounterKey_RebootCount)) { err = GetRebootCount(rebootCount); @@ -70,7 +63,7 @@ CHIP_ERROR ConfigurationManagerImpl::Init() else { // The first boot after factory reset of the Node. - err = StoreRebootCount(1); + err = StoreRebootCount(0); SuccessOrExit(err); } @@ -118,16 +111,6 @@ CHIP_ERROR ConfigurationManagerImpl::StoreTotalOperationalHours(uint32_t totalOp return WriteConfigValue(K32WConfig::kCounterKey_TotalOperationalHours, totalOperationalHours); } -CHIP_ERROR ConfigurationManagerImpl::GetSoftwareVersion(uint32_t & softwareVer) -{ - return ReadConfigValue(K32WConfig::kConfigKey_SoftwareVersion, softwareVer); -} - -CHIP_ERROR ConfigurationManagerImpl::StoreSoftwareVersion(uint32_t softwareVer) -{ - return WriteConfigValue(K32WConfig::kConfigKey_SoftwareVersion, softwareVer); -} - CHIP_ERROR ConfigurationManagerImpl::GetBootReason(uint32_t & bootReason) { bootReason = to_underlying(BootReasonType::kUnspecified); diff --git a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h index 689dc8d9732d0c..32a8f315f8f85d 100644 --- a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h +++ b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h @@ -51,8 +51,6 @@ class ConfigurationManagerImpl final : public Internal::GenericConfigurationMana CHIP_ERROR WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value) override; CHIP_ERROR GetRebootCount(uint32_t & rebootCount) override; CHIP_ERROR StoreRebootCount(uint32_t rebootCount) override; - CHIP_ERROR GetSoftwareVersion(uint32_t & softwareVer) override; - CHIP_ERROR StoreSoftwareVersion(uint32_t softwareVer) override; CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours) override; CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours) override; CHIP_ERROR GetBootReason(uint32_t & bootReasons) override; diff --git a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp new file mode 100644 index 00000000000000..1a01acfdb69385 --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.cpp @@ -0,0 +1,42 @@ +/* + * + * 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 "DefaultTestEventTriggerDelegate.h" + +#include +#include + +namespace chip { + +bool DefaultTestEventTriggerDelegate::DoesEnableKeyMatch(const ByteSpan & enableKey) const +{ + return !mEnableKey.empty() && mEnableKey.data_equal(enableKey); +} + +CHIP_ERROR DefaultTestEventTriggerDelegate::HandleEventTrigger(uint64_t eventTrigger) +{ + if (eventTrigger == kQueryTrigger) + { + ChipLogProgress(DeviceLayer, "DefaultTestEventTriggerDelegate: event triggered"); + return CHIP_NO_ERROR; + } + + return CHIP_ERROR_INVALID_ARGUMENT; +} + +} // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h new file mode 100644 index 00000000000000..cf71fb37d96470 --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/DefaultTestEventTriggerDelegate.h @@ -0,0 +1,39 @@ +/* + * + * 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. + */ + +#pragma once + +#include + +namespace chip { + +class DefaultTestEventTriggerDelegate : public TestEventTriggerDelegate +{ +public: + static constexpr uint64_t kQueryTrigger = 1234; + + explicit DefaultTestEventTriggerDelegate(const ByteSpan & enableKey) : mEnableKey(enableKey) {} + + bool DoesEnableKeyMatch(const ByteSpan & enableKey) const override; + CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; + +private: + ByteSpan mEnableKey; +}; + +} // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp b/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp index 0eefc9063c2209..bb16488e6e4c7d 100644 --- a/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.cpp @@ -31,8 +31,14 @@ #include #endif +extern "C" void xPortResetHeapMinimumEverFreeHeapSize(void); + #include +#include + +using namespace ::chip::app::Clusters::GeneralDiagnostics; + namespace chip { namespace DeviceLayer { @@ -72,6 +78,71 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapHighWatermark(uint64_t & cu return CHIP_NO_ERROR; } +CHIP_ERROR DiagnosticDataProviderImpl::ResetWatermarks() +{ + // If implemented, the server SHALL set the value of the CurrentHeapHighWatermark attribute to the + // value of the CurrentHeapUsed. + + xPortResetHeapMinimumEverFreeHeapSize(); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetThreadMetrics(ThreadMetrics ** threadMetricsOut) +{ + /* Obtain all available task information */ + TaskStatus_t * taskStatusArray; + ThreadMetrics * head = nullptr; + unsigned long arraySize, x, dummy; + + arraySize = uxTaskGetNumberOfTasks(); + + taskStatusArray = (TaskStatus_t *) pvPortMalloc(arraySize * sizeof(TaskStatus_t)); + + if (taskStatusArray != NULL) + { + /* Generate raw status information about each task. */ + arraySize = uxTaskGetSystemState(taskStatusArray, arraySize, &dummy); + /* For each populated position in the taskStatusArray array, + format the raw data as human readable ASCII data. */ + + for (x = 0; x < arraySize; x++) + { + ThreadMetrics * thread = (ThreadMetrics *) pvPortMalloc(sizeof(ThreadMetrics)); + + strncpy(thread->NameBuf, taskStatusArray[x].pcTaskName, kMaxThreadNameLength - 1); + thread->NameBuf[kMaxThreadNameLength] = '\0'; + thread->name.Emplace(CharSpan::fromCharString(thread->NameBuf)); + thread->id = taskStatusArray[x].xTaskNumber; + + thread->stackFreeMinimum.Emplace(taskStatusArray[x].usStackHighWaterMark); + + /* Unsupported metrics */ + // thread->stackSize; + // thread->stackFreeCurrent; + + thread->Next = head; + head = thread; + } + + *threadMetricsOut = head; + /* The array is no longer needed, free the memory it consumes. */ + vPortFree(taskStatusArray); + } + + return CHIP_NO_ERROR; +} + +void DiagnosticDataProviderImpl::ReleaseThreadMetrics(ThreadMetrics * threadMetrics) +{ + while (threadMetrics) + { + ThreadMetrics * del = threadMetrics; + threadMetrics = threadMetrics->Next; + vPortFree(del); + } +} + CHIP_ERROR DiagnosticDataProviderImpl::GetRebootCount(uint16_t & rebootCount) { uint32_t count = 0; @@ -139,5 +210,22 @@ DiagnosticDataProvider & GetDiagnosticDataProviderImpl() return DiagnosticDataProviderImpl::GetDefaultInstance(); } +CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** netifpp) +{ + NetworkInterface * ifp = new NetworkInterface(); + + const char * threadNetworkName = otThreadGetNetworkName(ThreadStackMgrImpl().OTInstance()); + ifp->name = Span(threadNetworkName, strlen(threadNetworkName)); + ifp->isOperational = true; + ifp->offPremiseServicesReachableIPv4.SetNull(); + ifp->offPremiseServicesReachableIPv6.SetNull(); + ifp->type = InterfaceType::EMBER_ZCL_INTERFACE_TYPE_THREAD; + uint8_t macBuffer[ConfigurationManager::kPrimaryMACAddressLength]; + ConfigurationMgr().GetPrimary802154MACAddress(macBuffer); + ifp->hardwareAddress = ByteSpan(macBuffer, ConfigurationManager::kPrimaryMACAddressLength); + *netifpp = ifp; + return CHIP_NO_ERROR; +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.h b/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.h index 390ce75bb31f4a..05be335999482b 100644 --- a/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.h +++ b/src/platform/nxp/k32w/k32w0/DiagnosticDataProviderImpl.h @@ -30,7 +30,7 @@ namespace chip { namespace DeviceLayer { /** - * Concrete implementation of the PlatformManager singleton object for Linux platforms. + * Concrete implementation of the PlatformManager singleton object for K32W0 platforms. */ class DiagnosticDataProviderImpl : public DiagnosticDataProvider { @@ -39,14 +39,19 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider // ===== Methods that implement the PlatformManager abstract interface. + bool SupportsWatermarks() override { return true; } CHIP_ERROR GetCurrentHeapFree(uint64_t & currentHeapFree) override; CHIP_ERROR GetCurrentHeapUsed(uint64_t & currentHeapUsed) override; CHIP_ERROR GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) override; + CHIP_ERROR ResetWatermarks() override; + CHIP_ERROR GetThreadMetrics(ThreadMetrics ** threadMetricsOut) override; + void ReleaseThreadMetrics(ThreadMetrics * threadMetrics) override; CHIP_ERROR GetRebootCount(uint16_t & rebootCount) override; CHIP_ERROR GetUpTime(uint64_t & upTime) override; CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours) override; CHIP_ERROR GetBootReason(BootReasonType & bootReason) override; + CHIP_ERROR GetNetworkInterfaces(NetworkInterface ** netifpp) override; }; /** diff --git a/src/platform/nxp/k32w/k32w0/K32W0Config.cpp b/src/platform/nxp/k32w/k32w0/K32W0Config.cpp index c22f4c5a862312..e98045b619c027 100644 --- a/src/platform/nxp/k32w/k32w0/K32W0Config.cpp +++ b/src/platform/nxp/k32w/k32w0/K32W0Config.cpp @@ -37,27 +37,33 @@ namespace DeviceLayer { namespace Internal { osaMutexId_t K32WConfig::pdmMutexHandle = NULL; -static ramBufferDescriptor * ramDescr = NULL; -constexpr uint16_t kNvmIdChipConfigData = 0x5000; -constexpr uint16_t kRamBufferInitialSize = 3072; +#if CHIP_DEVICE_LAYER_ENABLE_PDM_LOGS +static void PDM_SystemCallback(uint32_t number, PDM_eSystemEventCode code) +{ + uint8_t capacity = PDM_u8GetSegmentCapacity(); + uint8_t occupancy = PDM_u8GetSegmentOccupancy(); + ChipLogProgress(DeviceLayer, "[PDM]Event (number, code): (%lu, %d)", number, code); + ChipLogProgress(DeviceLayer, "[PDM]Capacity: %hhu", capacity); + ChipLogProgress(DeviceLayer, "[PDM]Occupancy: %hhu", occupancy); +} +#endif CHIP_ERROR K32WConfig::Init() { CHIP_ERROR err = CHIP_NO_ERROR; - int pdmStatus; + int status; /* Initialise the Persistent Data Manager */ pdmMutexHandle = OSA_MutexCreate(); VerifyOrExit((NULL != pdmMutexHandle), err = CHIP_ERROR_NO_MEMORY); - pdmStatus = PDM_Init(); - SuccessOrExit(err = MapPdmInitStatus(pdmStatus)); + status = PDM_Init(); + SuccessOrExit(err = MapPdmInitStatusToChipError(status)); +#if CHIP_DEVICE_LAYER_ENABLE_PDM_LOGS + PDM_vRegisterSystemCallback(PDM_SystemCallback); +#endif - ramDescr = getRamBuffer(kNvmIdChipConfigData, kRamBufferInitialSize); - if (!ramDescr) - { - err = CHIP_ERROR_NO_MEMORY; - } + err = RamStorage::Init(kNvmIdChipConfigData, kRamBufferInitialSize); exit: if (err != CHIP_NO_ERROR) @@ -66,10 +72,8 @@ CHIP_ERROR K32WConfig::Init() { OSA_MutexDestroy(pdmMutexHandle); } - if (ramDescr) - { - free(ramDescr); - } + + RamStorage::FreeBuffer(); } return err; } @@ -92,65 +96,15 @@ void K32WConfig::MutexUnlock(osaMutexId_t mutexId) } } -CHIP_ERROR K32WConfig::ReadConfigValue(Key key, bool & val) -{ - CHIP_ERROR err; - bool tempVal; - rsError status; - uint16_t sizeToRead = sizeof(tempVal); - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageGet(ramDescr, key, 0, (uint8_t *) &tempVal, &sizeToRead); - SuccessOrExit(err = MapRamStorageStatus(status)); - val = tempVal; - -exit: - return err; -} - -CHIP_ERROR K32WConfig::ReadConfigValue(Key key, uint32_t & val) -{ - CHIP_ERROR err; - uint32_t tempVal; - rsError status; - uint16_t sizeToRead = sizeof(tempVal); - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageGet(ramDescr, key, 0, (uint8_t *) &tempVal, &sizeToRead); - SuccessOrExit(err = MapRamStorageStatus(status)); - val = tempVal; - -exit: - return err; -} - -CHIP_ERROR K32WConfig::ReadConfigValue(Key key, uint64_t & val) -{ - CHIP_ERROR err; - uint32_t tempVal; - rsError status; - uint16_t sizeToRead = sizeof(tempVal); - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - status = ramStorageGet(ramDescr, key, 0, (uint8_t *) &tempVal, &sizeToRead); - SuccessOrExit(err = MapRamStorageStatus(status)); - val = tempVal; - -exit: - return err; -} - CHIP_ERROR K32WConfig::ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen) { CHIP_ERROR err; - rsError status; uint16_t sizeToRead = bufSize; - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); + err = RamStorage::Read(key, 0, (uint8_t *) buf, &sizeToRead); + SuccessOrExit(err); - // We can call ramStorageGet with null pointer to only retrieve the size - status = ramStorageGet(ramDescr, key, 0, (uint8_t *) buf, &sizeToRead); - SuccessOrExit(err = MapRamStorageStatus(status)); outLen = sizeToRead; exit: @@ -168,125 +122,6 @@ CHIP_ERROR K32WConfig::ReadConfigValueCounter(uint8_t counterIdx, uint32_t & val return ReadConfigValue(key, val); } -CHIP_ERROR K32WConfig::WriteConfigValue(Key key, bool val) -{ - CHIP_ERROR err; - PDM_teStatus pdmStatus; - rsError ramStatus = RS_ERROR_NONE; - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - MutexLock(pdmMutexHandle, osaWaitForever_c); - - /* first delete all occurrences of "key" */ - ramStorageDelete(ramDescr, key, -1); - - /* resize RAM Buffer if needed */ - ramStatus = ramStorageResize(&ramDescr, key, (uint8_t *) &val, sizeof(bool)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* add to RAM buffer */ - ramStatus = ramStorageSet(ramDescr, key, (uint8_t *) &val, sizeof(bool)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* schedule flash writing */ - pdmStatus = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); - SuccessOrExit(err = MapPdmStatus(pdmStatus)); - -exit: - MutexUnlock(pdmMutexHandle); - return err; -} - -CHIP_ERROR K32WConfig::WriteConfigValueSync(Key key, bool val) -{ - CHIP_ERROR err; - PDM_teStatus pdmStatus; - rsError ramStatus = RS_ERROR_NONE; - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - MutexLock(pdmMutexHandle, osaWaitForever_c); - - /* first delete all occurrences of "key" */ - ramStorageDelete(ramDescr, key, -1); - - /* resize RAM Buffer if needed */ - ramStatus = ramStorageResize(&ramDescr, key, (uint8_t *) &val, sizeof(bool)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* add to RAM buffer */ - ramStatus = ramStorageSet(ramDescr, key, (uint8_t *) &val, sizeof(bool)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - // Interrupts are disabled to ensure there is no context switch during the actual - // writing, thus avoiding race conditions. - OSA_InterruptDisable(); - pdmStatus = PDM_eSaveRecordData(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); - OSA_InterruptEnable(); - SuccessOrExit(err = MapPdmStatus(pdmStatus)); - -exit: - MutexUnlock(pdmMutexHandle); - return err; -} - -CHIP_ERROR K32WConfig::WriteConfigValue(Key key, uint32_t val) -{ - CHIP_ERROR err; - PDM_teStatus pdmStatus; - rsError ramStatus = RS_ERROR_NONE; - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - MutexLock(pdmMutexHandle, osaWaitForever_c); - - /* first delete all occurrences of "key" */ - ramStorageDelete(ramDescr, key, -1); - - /* resize RAM Buffer if needed */ - ramStatus = ramStorageResize(&ramDescr, key, (uint8_t *) &val, sizeof(uint32_t)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* add to RAM buffer */ - ramStatus = ramStorageSet(ramDescr, key, (uint8_t *) &val, sizeof(uint32_t)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* schedule flash writing */ - pdmStatus = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); - SuccessOrExit(err = MapPdmStatus(pdmStatus)); - -exit: - MutexUnlock(pdmMutexHandle); - return err; -} - -CHIP_ERROR K32WConfig::WriteConfigValue(Key key, uint64_t val) -{ - CHIP_ERROR err; - PDM_teStatus pdmStatus; - rsError ramStatus = RS_ERROR_NONE; - - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. - MutexLock(pdmMutexHandle, osaWaitForever_c); - - /* first delete all occurrences of "key" */ - ramStorageDelete(ramDescr, key, -1); - - /* resize RAM Buffer if needed */ - ramStatus = ramStorageResize(&ramDescr, key, (uint8_t *) &val, sizeof(uint64_t)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* add to RAM buffer */ - ramStatus = ramStorageSet(ramDescr, key, (uint8_t *) &val, sizeof(uint64_t)); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* schedule flash writing */ - pdmStatus = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); - SuccessOrExit(err = MapPdmStatus(pdmStatus)); - -exit: - MutexUnlock(pdmMutexHandle); - return err; -} - CHIP_ERROR K32WConfig::WriteConfigValueStr(Key key, const char * str) { return WriteConfigValueStr(key, str, (str != NULL) ? strlen(str) : 0); @@ -295,32 +130,22 @@ CHIP_ERROR K32WConfig::WriteConfigValueStr(Key key, const char * str) CHIP_ERROR K32WConfig::WriteConfigValueStr(Key key, const char * str, size_t strLen) { CHIP_ERROR err; - PDM_teStatus pdmStatus; - rsError ramStatus = RS_ERROR_NONE; + PDM_teStatus status; + RamStorage::Buffer buffer; - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. MutexLock(pdmMutexHandle, osaWaitForever_c); + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); if (!str) { - ramStatus = ramStorageDelete(ramDescr, key, -1); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); + err = RamStorage::Delete(key, -1); } else { - /* first delete all occurrences of "key" */ - ramStorageDelete(ramDescr, key, -1); - - /* resize RAM Buffer if needed */ - ramStatus = ramStorageResize(&ramDescr, key, (uint8_t *) str, strLen); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* add to RAM buffer */ - ramStatus = ramStorageSet(ramDescr, key, (uint8_t *) str, strLen); - SuccessOrExit(err = MapRamStorageStatus(ramStatus)); - - /* schedule flash writing */ - pdmStatus = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); + err = RamStorage::Write(key, (uint8_t *) str, strLen); + SuccessOrExit(err); + buffer = RamStorage::GetBuffer(); + status = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, buffer, buffer->ramBufferLen + kRamDescHeaderSize); } exit: @@ -342,16 +167,17 @@ CHIP_ERROR K32WConfig::WriteConfigValueCounter(uint8_t counterIdx, uint32_t val) CHIP_ERROR K32WConfig::ClearConfigValue(Key key) { CHIP_ERROR err = CHIP_NO_ERROR; - rsError status; - PDM_teStatus pdmStatus; + PDM_teStatus status; + RamStorage::Buffer buffer; - VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. MutexLock(pdmMutexHandle, osaWaitForever_c); - status = ramStorageDelete(ramDescr, key, -1); - SuccessOrExit(err = MapRamStorageStatus(status)); + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); // Verify key id. + err = RamStorage::Delete(key, -1); + SuccessOrExit(err); - pdmStatus = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); - SuccessOrExit(err = MapPdmStatus(pdmStatus)); + buffer = RamStorage::GetBuffer(); + status = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, buffer, buffer->ramBufferLen + kRamDescHeaderSize); + SuccessOrExit(err = MapPdmStatusToChipError(status)); exit: MutexUnlock(pdmMutexHandle); @@ -360,34 +186,37 @@ CHIP_ERROR K32WConfig::ClearConfigValue(Key key) bool K32WConfig::ConfigValueExists(Key key) { - rsError status; + CHIP_ERROR err; uint16_t sizeToRead; bool found = false; if (ValidConfigKey(key)) { - status = ramStorageGet(ramDescr, key, 0, NULL, &sizeToRead); - found = (status == RS_ERROR_NONE && sizeToRead != 0); + err = RamStorage::Read(key, 0, NULL, &sizeToRead); + found = (err == CHIP_NO_ERROR && sizeToRead != 0); } + return found; } CHIP_ERROR K32WConfig::FactoryResetConfig(void) { CHIP_ERROR err = CHIP_NO_ERROR; - PDM_teStatus pdmStatus; + PDM_teStatus status; + RamStorage::Buffer buffer; MutexLock(pdmMutexHandle, osaWaitForever_c); + FactoryResetConfigInternal(kMinConfigKey_ChipCounter, kMaxConfigKey_ChipCounter); FactoryResetConfigInternal(kMinConfigKey_ChipConfig, kMaxConfigKey_ChipConfig); FactoryResetConfigInternal(kMinConfigKey_KVSKey, kMaxConfigKey_KVSKey); FactoryResetConfigInternal(kMinConfigKey_KVSValue, kMaxConfigKey_KVSValue); - pdmStatus = PDM_eSaveRecordData(kNvmIdChipConfigData, ramDescr, ramDescr->ramBufferLen + kRamDescHeaderSize); - SuccessOrExit(err = MapPdmStatus(pdmStatus)); + buffer = RamStorage::GetBuffer(); + status = PDM_eSaveRecordData(kNvmIdChipConfigData, buffer, buffer->ramBufferLen + kRamDescHeaderSize); + SuccessOrExit(err = MapPdmStatusToChipError(status)); exit: - free((void *) ramDescr); - ramDescr = NULL; + RamStorage::FreeBuffer(); MutexUnlock(pdmMutexHandle); return err; } @@ -396,50 +225,30 @@ void K32WConfig::FactoryResetConfigInternal(Key firstKey, Key lastKey) { for (Key key = firstKey; key <= lastKey; key++) { - ramStorageDelete(ramDescr, key, -1); + RamStorage::Delete(key, -1); } } -CHIP_ERROR K32WConfig::MapPdmStatus(PDM_teStatus pdmStatus) +CHIP_ERROR K32WConfig::MapPdmStatusToChipError(PDM_teStatus status) { CHIP_ERROR err; - switch (pdmStatus) + switch (status) { case PDM_E_STATUS_OK: err = CHIP_NO_ERROR; break; default: - err = CHIP_ERROR(ChipError::Range::kPlatform, pdmStatus); - break; - } - - return err; -} - -CHIP_ERROR K32WConfig::MapRamStorageStatus(rsError rsStatus) -{ - CHIP_ERROR err; - - switch (rsStatus) - { - case RS_ERROR_NONE: - err = CHIP_NO_ERROR; - break; - case RS_ERROR_NOT_FOUND: - err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND; - break; - default: - err = CHIP_ERROR_BUFFER_TOO_SMALL; + err = CHIP_ERROR(ChipError::Range::kPlatform, status); break; } return err; } -CHIP_ERROR K32WConfig::MapPdmInitStatus(int pdmStatus) +CHIP_ERROR K32WConfig::MapPdmInitStatusToChipError(int status) { - return (pdmStatus == 0) ? CHIP_NO_ERROR : CHIP_ERROR(ChipError::Range::kPlatform, pdmStatus); + return (status == 0) ? CHIP_NO_ERROR : CHIP_ERROR(ChipError::Range::kPlatform, status); } bool K32WConfig::ValidConfigKey(Key key) diff --git a/src/platform/nxp/k32w/k32w0/K32W0Config.h b/src/platform/nxp/k32w/k32w0/K32W0Config.h index cc8919cf21ebb9..26ff2a41b3adc9 100644 --- a/src/platform/nxp/k32w/k32w0/K32W0Config.h +++ b/src/platform/nxp/k32w/k32w0/K32W0Config.h @@ -16,12 +16,6 @@ * limitations under the License. */ -/** - * @file - * Utilities for accessing persisted device configuration on - * platforms based on the NXP K32W SDK. - */ - #pragma once #include @@ -32,11 +26,15 @@ #include "fsl_os_abstraction.h" #include "pdm_ram_storage_glue.h" #include "ram_storage.h" +#include namespace chip { namespace DeviceLayer { namespace Internal { +constexpr uint16_t kNvmIdChipConfigData = 0x5000; +constexpr uint16_t kRamBufferInitialSize = 3072; + constexpr inline uint16_t K32WConfigKey(uint8_t chipId, uint8_t pdmId) { return static_cast(chipId) << 8 | pdmId; @@ -117,16 +115,16 @@ class K32WConfig static CHIP_ERROR Init(void); // Configuration methods used by the GenericConfigurationManagerImpl<> template. - static CHIP_ERROR ReadConfigValue(Key key, bool & val); - static CHIP_ERROR ReadConfigValue(Key key, uint32_t & val); - static CHIP_ERROR ReadConfigValue(Key key, uint64_t & val); + template + static CHIP_ERROR ReadConfigValue(Key key, TValue & val); + template + static CHIP_ERROR WriteConfigValue(Key key, TValue val); + template + static CHIP_ERROR WriteConfigValueSync(Key key, TValue val); + static CHIP_ERROR ReadConfigValueStr(Key key, char * buf, size_t bufSize, size_t & outLen); static CHIP_ERROR ReadConfigValueBin(Key key, uint8_t * buf, size_t bufSize, size_t & outLen); static CHIP_ERROR ReadConfigValueCounter(uint8_t counterIdx, uint32_t & val); - static CHIP_ERROR WriteConfigValue(Key key, bool val); - static CHIP_ERROR WriteConfigValueSync(Key key, bool val); - static CHIP_ERROR WriteConfigValue(Key key, uint32_t val); - static CHIP_ERROR WriteConfigValue(Key key, uint64_t val); static CHIP_ERROR WriteConfigValueStr(Key key, const char * str); static CHIP_ERROR WriteConfigValueStr(Key key, const char * str, size_t strLen); static CHIP_ERROR WriteConfigValueBin(Key key, const uint8_t * data, size_t dataLen); @@ -149,9 +147,8 @@ class K32WConfig static constexpr uint8_t GetRecordKey(uint32_t key); private: - static CHIP_ERROR MapPdmStatus(PDM_teStatus pdmStatus); - static CHIP_ERROR MapRamStorageStatus(rsError rsStatus); - static CHIP_ERROR MapPdmInitStatus(int pdmStatus); + static CHIP_ERROR MapPdmStatusToChipError(PDM_teStatus status); + static CHIP_ERROR MapPdmInitStatusToChipError(int status); static void FactoryResetConfigInternal(Key firstKey, Key lastKey); }; @@ -171,6 +168,65 @@ inline constexpr uint8_t K32WConfig::GetRecordKey(Key key) return static_cast(key); } +template +CHIP_ERROR K32WConfig::ReadConfigValue(Key key, TValue & val) +{ + CHIP_ERROR err; + uint16_t valLen = sizeof(val); + + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); + err = RamStorage::Read(key, 0, (uint8_t *) &val, &valLen); + SuccessOrExit(err); + +exit: + return err; +} + +template +CHIP_ERROR K32WConfig::WriteConfigValue(Key key, TValue val) +{ + CHIP_ERROR err; + PDM_teStatus status; + RamStorage::Buffer buffer; + + MutexLock(pdmMutexHandle, osaWaitForever_c); + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); + err = RamStorage::Write(key, (uint8_t *) &val, sizeof(TValue)); + SuccessOrExit(err); + + buffer = RamStorage::GetBuffer(); + status = PDM_eSaveRecordDataInIdleTask(kNvmIdChipConfigData, buffer, buffer->ramBufferLen + kRamDescHeaderSize); + SuccessOrExit(err = MapPdmStatusToChipError(status)); + +exit: + MutexUnlock(pdmMutexHandle); + return err; +} + +template +CHIP_ERROR K32WConfig::WriteConfigValueSync(Key key, TValue val) +{ + CHIP_ERROR err; + PDM_teStatus status; + RamStorage::Buffer buffer; + + MutexLock(pdmMutexHandle, osaWaitForever_c); + VerifyOrExit(ValidConfigKey(key), err = CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND); + err = RamStorage::Write(key, (uint8_t *) &val, sizeof(TValue)); + SuccessOrExit(err); + // Interrupts are disabled to ensure there is no context switch during the actual + // writing, thus avoiding race conditions. + OSA_InterruptDisable(); + buffer = RamStorage::GetBuffer(); + status = PDM_eSaveRecordData(kNvmIdChipConfigData, buffer, buffer->ramBufferLen + kRamDescHeaderSize); + OSA_InterruptEnable(); + SuccessOrExit(err = MapPdmStatusToChipError(status)); + +exit: + MutexUnlock(pdmMutexHandle); + return err; +} + } // namespace Internal } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.cpp b/src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.cpp new file mode 100644 index 00000000000000..33491c1873dd17 --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.cpp @@ -0,0 +1,326 @@ +/* + * + * Copyright (c) 2022 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. + */ + +#if (!CONFIG_CHIP_K32W0_REAL_FACTORY_DATA || !(defined CONFIG_CHIP_K32W0_REAL_FACTORY_DATA)) +#include +#include +#include +#endif + +#include "OtaUtils.h" +#include "fsl_flash.h" +#include +#include +#include +#include +#include + +#include "K32W0FactoryDataProvider.h" + +/* Grab symbol for the base address from the linker file. */ +extern uint32_t __FACTORY_DATA_START[]; +extern uint32_t __FACTORY_DATA_SIZE[]; + +namespace chip { +namespace { + +CHIP_ERROR LoadKeypairFromRaw(ByteSpan privateKey, ByteSpan publicKey, Crypto::P256Keypair & keypair) +{ + Crypto::P256SerializedKeypair serialized_keypair; + ReturnErrorOnFailure(serialized_keypair.SetLength(privateKey.size() + publicKey.size())); + memcpy(serialized_keypair.Bytes(), publicKey.data(), publicKey.size()); + memcpy(serialized_keypair.Bytes() + publicKey.size(), privateKey.data(), privateKey.size()); + return keypair.Deserialize(serialized_keypair); +} +} // namespace + +namespace DeviceLayer { + +K32W0FactoryDataProvider & K32W0FactoryDataProvider::GetDefaultInstance() +{ + static K32W0FactoryDataProvider sInstance; + return sInstance; +} + +static constexpr size_t kSpake2pSerializedVerifier_MaxBase64Len = + BASE64_ENCODED_LEN(chip::Crypto::kSpake2p_VerifierSerialized_Length) + 1; +static constexpr size_t kSpake2pSalt_MaxBase64Len = BASE64_ENCODED_LEN(chip::Crypto::kSpake2p_Max_PBKDF_Salt_Length) + 1; +static constexpr size_t kMaxCertLen = 600; +static constexpr size_t kMaxKeyLen = 32; + +static constexpr size_t kVerifierId = 1; +static constexpr size_t kSaltId = 2; +static constexpr size_t kIcId = 3; +static constexpr size_t kDacPrivateKeyId = 4; +static constexpr size_t kDacCertificateId = 5; +static constexpr size_t kPaiCertificateId = 6; +static constexpr size_t kDiscriminatorId = 7; + +static constexpr size_t kMaxId = kDiscriminatorId; + +static uint16_t maxLengths[kMaxId + 1]; +static uint32_t factoryDataActualSize = 0; + +typedef otaUtilsResult_t (*OtaUtils_EEPROM_ReadData)(uint16_t nbBytes, uint32_t address, uint8_t * pInbuf); + +static uint8_t ReadDataMemCpy(uint16_t num, uint32_t src, uint8_t * dst) +{ + memcpy(dst, (void *) (src), num); + return 0; +} + +CHIP_ERROR SearchForId(uint8_t searchedType, uint8_t * pBuf, size_t bufLength, uint16_t & length) +{ + CHIP_ERROR err = CHIP_ERROR_NOT_FOUND; + uint32_t factoryDataStartAddress = (uint32_t) __FACTORY_DATA_START; + uint32_t addr = factoryDataStartAddress; + OtaUtils_EEPROM_ReadData pFunctionEepromRead = (OtaUtils_EEPROM_ReadData) ReadDataMemCpy; + uint8_t type = 0; + + while (addr < (factoryDataStartAddress + (uint32_t) __FACTORY_DATA_SIZE)) + { + if (gOtaUtilsSuccess_c != OtaUtils_ReadFromInternalFlash((uint16_t) sizeof(type), addr, &type, NULL, pFunctionEepromRead) || + gOtaUtilsSuccess_c != + OtaUtils_ReadFromInternalFlash((uint16_t) sizeof(length), addr + 1, (uint8_t *) &length, NULL, pFunctionEepromRead)) + break; + + if ((type > kMaxId) || (length > maxLengths[type])) + { + break; + } + + if (searchedType == type) + { + if (bufLength < length) + { + err = CHIP_ERROR_BUFFER_TOO_SMALL; + } + else + { + if (gOtaUtilsSuccess_c != OtaUtils_ReadFromInternalFlash(length, addr + 3, pBuf, NULL, pFunctionEepromRead)) + break; + + err = CHIP_NO_ERROR; + } + break; + } + else + { + /* Jump past 2 bytes of length and then use length to jump to next data */ + addr = addr + 3 + length; + } + } + + return err; +} + +CHIP_ERROR K32W0FactoryDataProvider::Init() +{ + + maxLengths[kVerifierId] = kSpake2pSerializedVerifier_MaxBase64Len; + maxLengths[kSaltId] = kSpake2pSalt_MaxBase64Len; + maxLengths[kIcId] = 4; + maxLengths[kDacPrivateKeyId] = kMaxKeyLen; + maxLengths[kDacCertificateId] = kMaxCertLen; + maxLengths[kPaiCertificateId] = kMaxCertLen; + maxLengths[kDiscriminatorId] = 4; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetCertificationDeclaration(MutableByteSpan & outBuffer) +{ + constexpr uint8_t kCdForAllExamples[] = CHIP_DEVICE_CONFIG_CERTIFICATION_DECLARATION; + + return CopySpanToMutableSpan(ByteSpan{ kCdForAllExamples }, outBuffer); +} + +CHIP_ERROR K32W0FactoryDataProvider::GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) +{ + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetDeviceAttestationCert(MutableByteSpan & outBuffer) +{ + uint16_t certificateSize = 0; + ReturnErrorOnFailure(SearchForId(kDacCertificateId, outBuffer.data(), outBuffer.size(), certificateSize)); + outBuffer.reduce_size(certificateSize); + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetProductAttestationIntermediateCert(MutableByteSpan & outBuffer) +{ + uint16_t certificateSize = 0; + ReturnErrorOnFailure(SearchForId(kPaiCertificateId, outBuffer.data(), outBuffer.size(), certificateSize)); + outBuffer.reduce_size(certificateSize); + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::SignWithDeviceAttestationKey(const ByteSpan & messageToSign, MutableByteSpan & outSignBuffer) +{ + Crypto::P256ECDSASignature signature; + Crypto::P256Keypair keypair; + VerifyOrReturnError(IsSpanUsable(outSignBuffer), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(IsSpanUsable(messageToSign), CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrReturnError(outSignBuffer.size() >= signature.Capacity(), CHIP_ERROR_BUFFER_TOO_SMALL); + + // In a non-exemplary implementation, the public key is not needed here. It is used here merely because + // Crypto::P256Keypair is only (currently) constructable from raw keys if both private/public keys are present. + Crypto::P256PublicKey dacPublicKey; + uint8_t certBuf[kMaxCertLen]; + MutableByteSpan dacCertSpan(certBuf); + uint16_t certificateSize = 0; + CHIP_ERROR err = CHIP_NO_ERROR; + + err = SearchForId(kDacCertificateId, dacCertSpan.data(), dacCertSpan.size(), certificateSize); + ReturnErrorOnFailure(err); + dacCertSpan.reduce_size(certificateSize); + /* Extract Public Key of DAC certificate from itself */ + err = Crypto::ExtractPubkeyFromX509Cert(dacCertSpan, dacPublicKey); + ReturnErrorOnFailure(err); + + /* Get private key of DAC certificate from reserved section */ + uint8_t keyBuf[kMaxKeyLen]; + MutableByteSpan dacPrivateKeySpan(keyBuf); + uint16_t keySize = 0; + ReturnErrorOnFailure(SearchForId(kDacPrivateKeyId, dacPrivateKeySpan.data(), dacPrivateKeySpan.size(), keySize)); + dacPrivateKeySpan.reduce_size(keySize); + + ReturnErrorOnFailure(LoadKeypairFromRaw(ByteSpan(dacPrivateKeySpan.data(), dacPrivateKeySpan.size()), + ByteSpan(dacPublicKey.Bytes(), dacPublicKey.Length()), keypair)); + ReturnErrorOnFailure(keypair.ECDSA_sign_msg(messageToSign.data(), messageToSign.size(), signature)); + + return CopySpanToMutableSpan(ByteSpan{ signature.ConstBytes(), signature.Length() }, outSignBuffer); +} + +CHIP_ERROR K32W0FactoryDataProvider::GetSetupDiscriminator(uint16_t & setupDiscriminator) +{ + uint32_t discriminator = 0; + uint16_t temp = 0; + + ReturnErrorOnFailure(SearchForId(kDiscriminatorId, (uint8_t *) &discriminator, sizeof(discriminator), temp)); + setupDiscriminator = (uint16_t)(discriminator & 0x0000FFFF); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::SetSetupDiscriminator(uint16_t setupDiscriminator) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetSpake2pIterationCount(uint32_t & iterationCount) +{ + uint16_t temp = 0; + + return SearchForId(kIcId, (uint8_t *) &iterationCount, sizeof(iterationCount), temp); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetSpake2pSalt(MutableByteSpan & saltBuf) +{ + char saltB64[kSpake2pSalt_MaxBase64Len] = { 0 }; + uint16_t saltB64Len = 0; + + ReturnErrorOnFailure(SearchForId(kSaltId, (uint8_t *) (&saltB64[0]), sizeof(saltB64), saltB64Len)); + size_t saltLen = chip::Base64Decode32(saltB64, saltB64Len, reinterpret_cast(saltB64)); + + ReturnErrorCodeIf(saltLen > saltBuf.size(), CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(saltBuf.data(), saltB64, saltLen); + saltBuf.reduce_size(saltLen); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & verifierLen) +{ + char verifierB64[kSpake2pSerializedVerifier_MaxBase64Len] = { 0 }; + uint16_t verifierB64Len = 0; + ReturnErrorOnFailure(SearchForId(kVerifierId, (uint8_t *) &verifierB64[0], sizeof(verifierB64), verifierB64Len)); + + verifierLen = chip::Base64Decode32(verifierB64, verifierB64Len, reinterpret_cast(verifierB64)); + ReturnErrorCodeIf(verifierLen > verifierBuf.size(), CHIP_ERROR_BUFFER_TOO_SMALL); + memcpy(verifierBuf.data(), verifierB64, verifierLen); + verifierBuf.reduce_size(verifierLen); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetSetupPasscode(uint32_t & setupPasscode) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::SetSetupPasscode(uint32_t setupPasscode) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +#if CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER +CHIP_ERROR K32W0FactoryDataProvider::GetVendorName(char * buf, size_t bufSize) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetVendorId(uint16_t & vendorId) +{ + vendorId = static_cast(CHIP_DEVICE_CONFIG_DEVICE_VENDOR_ID); + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetProductName(char * buf, size_t bufSize) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetProductId(uint16_t & productId) +{ + productId = static_cast(CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID); + return CHIP_NO_ERROR; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetSerialNumber(char * buf, size_t bufSize) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetHardwareVersion(uint16_t & hardwareVersion) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetHardwareVersionString(char * buf, size_t bufSize) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR K32W0FactoryDataProvider::GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) +{ +#if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CHIP_DEVICE_CONFIG_ROTATING_DEVICE_ID_UNIQUE_ID) +#endif + + return CHIP_ERROR_NOT_IMPLEMENTED; +} +#endif /* CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER */ +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.h b/src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.h new file mode 100644 index 00000000000000..2b50b1e08b3aa7 --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/K32W0FactoryDataProvider.h @@ -0,0 +1,79 @@ +/* + * + * Copyright (c) 2022 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. + */ +#pragma once + +#include +#include +#include + +#include "CHIPPlatformConfig.h" + +namespace chip { +namespace DeviceLayer { + +/** + * @brief This class provides Commissionable data, Device Attestation Credentials, + * and Device Instance Info. + */ + +class K32W0FactoryDataProvider : public CommissionableDataProvider, + public Credentials::DeviceAttestationCredentialsProvider +#if CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER + , + public DeviceInstanceInfoProvider +#endif // CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER +{ +public: + static K32W0FactoryDataProvider & GetDefaultInstance(); + + K32W0FactoryDataProvider() {} + + CHIP_ERROR Init(); + + // ===== Members functions that implement the CommissionableDataProvider + CHIP_ERROR GetSetupDiscriminator(uint16_t & setupDiscriminator) override; + CHIP_ERROR SetSetupDiscriminator(uint16_t setupDiscriminator) override; + CHIP_ERROR GetSpake2pIterationCount(uint32_t & iterationCount) override; + CHIP_ERROR GetSpake2pSalt(MutableByteSpan & saltBuf) override; + CHIP_ERROR GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & verifierLen) override; + CHIP_ERROR GetSetupPasscode(uint32_t & setupPasscode) override; + CHIP_ERROR SetSetupPasscode(uint32_t setupPasscode) override; + + // ===== Members functions that implement the DeviceAttestationCredentialsProvider + CHIP_ERROR GetCertificationDeclaration(MutableByteSpan & outBuffer) override; + CHIP_ERROR GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) override; + CHIP_ERROR GetDeviceAttestationCert(MutableByteSpan & outBuffer) override; + CHIP_ERROR GetProductAttestationIntermediateCert(MutableByteSpan & outBuffer) override; + CHIP_ERROR SignWithDeviceAttestationKey(const ByteSpan & messageToSign, MutableByteSpan & outSignBuffer) override; + +#if CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER + // ===== Members functions that implement the GenericDeviceInstanceInfoProvider + CHIP_ERROR GetVendorName(char * buf, size_t bufSize) override; + CHIP_ERROR GetVendorId(uint16_t & vendorId) override; + CHIP_ERROR GetProductName(char * buf, size_t bufSize) override; + CHIP_ERROR GetProductId(uint16_t & productId) override; + CHIP_ERROR GetHardwareVersionString(char * buf, size_t bufSize) override; + CHIP_ERROR GetSerialNumber(char * buf, size_t bufSize) override; + CHIP_ERROR GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) override; + CHIP_ERROR GetHardwareVersion(uint16_t & hardwareVersion) override; + + CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) override; +#endif // CHIP_DEVICE_CONFIG_ENABLE_DEVICE_INSTANCE_INFO_PROVIDER +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.cpp index f2fbd071bc3654..29a06f4ee917fd 100644 --- a/src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/KeyValueStoreManagerImpl.cpp @@ -99,8 +99,7 @@ CHIP_ERROR KeyValueStoreManagerImpl::_Get(const char * key, void * value, size_t } else { - ChipLogProgress(DeviceLayer, "KVS, error in getting the value of Matter key [%s]. Key not found in persistent storage.", - key); + ChipLogProgress(DeviceLayer, "KVS, Matter key [%s] not found in persistent storage.", key); } exit: diff --git a/src/platform/nxp/k32w/k32w0/Logging.cpp b/src/platform/nxp/k32w/k32w0/Logging.cpp index da545b6c7aff85..b00366999023ee 100644 --- a/src/platform/nxp/k32w/k32w0/Logging.cpp +++ b/src/platform/nxp/k32w/k32w0/Logging.cpp @@ -161,12 +161,15 @@ void ENFORCE_FORMAT(3, 0) LogV(const char * module, uint8_t category, const char */ extern "C" void ENFORCE_FORMAT(1, 2) LwIPLog(const char * msg, ...) { + +#if K32W_LOG_ENABLED va_list v; const char * module = "LWIP"; va_start(v, msg); GenericLog(msg, v, module, chip::Logging::kLogCategory_None); va_end(v); +#endif } #endif // CHIP_SYSTEM_CONFIG_USE_LWIP @@ -177,6 +180,8 @@ extern "C" void ENFORCE_FORMAT(1, 2) LwIPLog(const char * msg, ...) extern "C" void ENFORCE_FORMAT(3, 4) otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char * aFormat, ...) { + +#if K32W_LOG_ENABLED va_list v; const char * module = "OT"; @@ -186,6 +191,7 @@ extern "C" void ENFORCE_FORMAT(3, 4) otPlatLog(otLogLevel aLogLevel, otLogRegion va_start(v, aFormat); GenericLog(aFormat, v, module, chip::Logging::kLogCategory_None); va_end(v); +#endif } #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD diff --git a/src/platform/nxp/k32w/k32w0/LowPowerHooks.cpp b/src/platform/nxp/k32w/k32w0/LowPowerHooks.cpp new file mode 100644 index 00000000000000..1946feff8ad41f --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/LowPowerHooks.cpp @@ -0,0 +1,321 @@ +/* + * + * Copyright (c) 2022 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. + */ + +/** + * @file + * Provides a glue layer between Matter and NXP-SDK Low Power + */ + +#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) + +#include +#include + +#include "Keyboard.h" +#include "MacSched.h" +#include "OtaSupport.h" +#include "PWR_Configuration.h" +#include "PWR_Interface.h" +#include "RNG_Interface.h" +#include "app_dual_mode_low_power.h" +#include "app_dual_mode_switch.h" +#include "k32w0-chip-mbedtls-config.h" +#include // nogncheck + +#include "app_config.h" +#include "fsl_gpio.h" +#include "fsl_iocon.h" +#include "gpio_pins.h" + +using namespace ::chip; +using namespace ::chip::Inet; +using namespace ::chip::DeviceLayer; + +extern "C" void InitLowPower(); + +extern "C" void vMMAC_IntHandlerBbc(); +extern "C" void vMMAC_IntHandlerPhy(); +extern "C" void BOARD_SetClockForPowerMode(void); +extern "C" void stopM2(); +extern "C" void sched_enable(); +extern "C" uint64_t otPlatTimeGet(void); + +static void dm_switch_wakeupCallBack(void); +static void dm_switch_preSleepCallBack(void); +static void ThreadExitSleep(); +static void BOARD_SetClockForWakeup(void); + +typedef struct +{ + bool_t bleAppRunning; + bool_t bleAppStopInprogress; + bool_t threadInitialized; + uint32_t threadWarmBootInitTime; +} sDualModeAppStates; + +typedef void * appCallbackParam_t; +typedef void (*appCallbackHandler_t)(appCallbackParam_t param); + +static sDualModeAppStates dualModeStates; +/* 15.4 warm time must be > 0, so this value will be + * updated when 15.4 is initialized for the first time + */ +constexpr uint16_t kThreadWarmNotInitializedValue = 0; + +extern "C" void otTaskletsSignalPending(otInstance * p_instance); + +#define ENABLE_LOW_POWER_LOGS 0 + +void InitLowPower() +{ + PWR_Init(); + + /* Internal - MATTER-303: keep in retention the entire RAM1 for the moment */ + PWR_vAddRamRetention((uint32_t) 0x4020000, 0x10000); + + PWR_RegisterLowPowerExitCallback(dm_switch_wakeupCallBack); + PWR_RegisterLowPowerEnterCallback(dm_switch_preSleepCallBack); + + dualModeStates.threadWarmBootInitTime = kThreadWarmNotInitializedValue; + + dm_lp_init(); +} + +extern "C" void setThreadInitialized(bool isInitialized) +{ + dualModeStates.threadInitialized = isInitialized; +} + +extern "C" bool isThreadInitialized() +{ + return dualModeStates.threadInitialized; +} + +uint32_t dm_switch_get15_4InitWakeUpTime(void) +{ + return dualModeStates.threadWarmBootInitTime; +} + +extern "C" bleResult_t App_PostCallbackMessage(appCallbackHandler_t handler, appCallbackParam_t param) +{ + AppEvent event; + event.Type = AppEvent::kEventType_Lp; + event.Handler = handler; + event.param = param; + +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("App_PostCallbackMessage %d", (uint32_t) param); +#endif + + GetAppTask().PostEvent(&event); + + return gBleSuccess_c; +} + +static void dm_switch_wakeupCallBack(void) +{ + BOARD_SetClockForWakeup(); + SHA_ClkInit(SHA_INSTANCE); + CLOCK_EnableClock(kCLOCK_Aes); + +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("dm_switch_wakeupCallBack"); + K32W_LOG("Warm up time actual value: %d", dualModeStates.threadWarmBootInitTime); +#endif + + RNG_Init(); + SecLib_Init(); + OTA_InitExternalMemory(); + + KBD_PrepareExitLowPower(); + + PWR_WakeupReason_t wakeReason = PWR_GetWakeupReason(); + if (wakeReason.Bits.FromBLE_LLTimer == 1) + { +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("woken up from LL"); +#endif + } + else if (wakeReason.Bits.FromKeyBoard == 1) + { +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("woken up from FromKeyBoard"); +#endif + } + else if (wakeReason.Bits.FromTMR == 1) + { +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("woken up from TMR"); +#endif + } + dm_lp_wakeup(); +} + +void vOptimizeConsumption(uint32_t u32PIOvalue, uint32_t u32SkipIO) +{ + uint8_t u8KeepFro32k, u8KeepIOclk, u8KeepXtal32M; + + u8KeepFro32k = u32SkipIO >> 31; + u8KeepIOclk = (u32SkipIO >> 30) & 0x1; + u8KeepXtal32M = (u32SkipIO >> 29) & 0x1; + const gpio_pin_config_t pin_config = { .pinDirection = kGPIO_DigitalInput, .outputLogic = 1U }; + + if (u32PIOvalue != 0) + { + for (int i = 0; i < 22; i++) + { + + if (((u32SkipIO >> i) & 0x1) != 1) + { + /* configure GPIOs to Input mode */ + GPIO_PinInit(GPIO, 0, i, &pin_config); + IOCON_PinMuxSet(IOCON, 0, i, u32PIOvalue); + } + } + } + + if (u8KeepIOclk == 0) + { + CLOCK_DisableClock(kCLOCK_Iocon); + CLOCK_DisableClock(kCLOCK_InputMux); + CLOCK_DisableClock(kCLOCK_Gpio0); + } + + if (u8KeepXtal32M == 0) + { + CLOCK_DisableClock(kCLOCK_Xtal32M); // Crystal 32MHz + } + + // Keep the 32K clock + if (u8KeepFro32k == 0) + { + CLOCK_DisableClock(kCLOCK_Fro32k); + } +} + +static void dm_switch_preSleepCallBack(void) +{ +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("dm_switch_preSleepCallBack"); +#endif + + if (dualModeStates.threadInitialized) + { + /* stop the internal MAC Scheduler timer */ + stopM2(); + /* disable the MAC scheduler */ + sched_disable(); + otPlatRadioDisable(NULL); + setThreadInitialized(FALSE); + } + /* Inform the low power dual mode module that we will sleep */ + dm_lp_preSleep(); + + EEPROM_DeInit(); + /* BUTTON2 change contact, BUTTON4 start adv/factoryreset */ + vOptimizeConsumption((IOCON_FUNC0 | (0x2 << 3) | IOCON_ANALOG_EN), + (1 << IOCON_USER_BUTTON1_PIN) | (1 << IOCON_USER_BUTTON2_PIN)); + + /* disable SHA clock */ + SHA_ClkDeinit(SHA_INSTANCE); + + /* disable the AES clock */ + CLOCK_DisableClock(kCLOCK_Aes); + + /* configure pins for power down mode */ + BOARD_SetPinsForPowerMode(); + /* DeInitialize application support for drivers */ + BOARD_DeInitAdc(); + /* DeInit the necessary clocks */ + BOARD_SetClockForPowerMode(); +} + +extern "C" void vDynStopAll(void) +{ + vDynRequestState(E_DYN_SLAVE, E_DYN_STATE_OFF); + vDynRequestState(E_DYN_MASTER, E_DYN_STATE_OFF); +} + +void dm_switch_init15_4AfterWakeUp(void) +{ + uint64_t tick1 = 0; + + if (dualModeStates.threadWarmBootInitTime == kThreadWarmNotInitializedValue) + { + /* Get a 32K tick */ + PWR_Start32kCounter(); + tick1 = otPlatTimeGet(); + } + + if (!dualModeStates.threadInitialized && ConnectivityMgr().IsThreadEnabled()) + { + OSA_InstallIntHandler(ZIGBEE_MAC_IRQn, vMMAC_IntHandlerBbc); + OSA_InstallIntHandler(ZIGBEE_MODEM_IRQn, vMMAC_IntHandlerPhy); + + /* Radio must be re-enabled after waking up from sleep. + * The module is completely disabled in power down mode */ + otPlatRadioEnable(NULL); + sched_enable(); + + if (dualModeStates.threadWarmBootInitTime == kThreadWarmNotInitializedValue) + { + dualModeStates.threadWarmBootInitTime = (uint32_t)(otPlatTimeGet() - tick1); + + /* Add a margin of 1 ms */ + dualModeStates.threadWarmBootInitTime += 1000; + +#if ENABLE_LOW_POWER_LOGS + K32W_LOG("Calibration: %d", dualModeStates.threadWarmBootInitTime); +#endif + } + + setThreadInitialized(TRUE); + + /* wake up the Thread stack and check if any processing needs to be done */ + otTaskletsSignalPending(NULL); + } +} + +extern "C" void App_NotifyWakeup(void) +{ + if ((!dualModeStates.threadInitialized)) + { + + /* Notify the dual mode low power mode */ + (void) App_PostCallbackMessage(dm_lp_processEvent, (void *) e15_4WakeUpEnded); + } +} + +extern "C" void App_AllowDeviceToSleep() +{ + PWR_PreventEnterLowPower(false); +} + +extern "C" void App_DisallowDeviceToSleep() +{ + PWR_PreventEnterLowPower(true); +} + +static void BOARD_SetClockForWakeup(void) +{ + /* Enables the clock for the I/O controller block. 0: Disable. 1: Enable.: 0x01u */ + CLOCK_EnableClock(kCLOCK_Iocon); + /* Enables the clock for the GPIO0 module */ + CLOCK_EnableClock(kCLOCK_Gpio0); +} + +#endif diff --git a/src/platform/nxp/k32w/k32w0/OTAImageProcessorImpl.cpp b/src/platform/nxp/k32w/k32w0/OTAImageProcessorImpl.cpp index a44d0cb1dfec6e..79dc3ff663fdc7 100644 --- a/src/platform/nxp/k32w/k32w0/OTAImageProcessorImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/OTAImageProcessorImpl.cpp @@ -17,6 +17,7 @@ */ #include +#include #include #include @@ -282,11 +283,13 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) { if (CHIP_NO_ERROR == K32WConfig::WriteConfigValueSync(K32WConfig::kConfigKey_FirstRunOfOTAImage, firstRun)) { - /* Set the necessary information to inform the SSBL that a new image is available */ - DeviceLayer::ConfigurationMgr().StoreSoftwareVersion(imageProcessor->mSoftwareVersion); - OTA_SetNewImageFlag(); ChipLogProgress(SoftwareUpdate, "OTA image authentication success. Device will reboot with the new image!"); - ResetMCU(); + // Set the necessary information to inform the SSBL that a new image is available + // and trigger the actual device reboot after some time, to take into account + // queued actions, e.g. sending events to a subscription + SystemLayer().StartTimer( + chip::System::Clock::Milliseconds32(CHIP_DEVICE_LAYER_OTA_REBOOT_DELAY), + [](chip::System::Layer *, void *) { OTA_SetNewImageFlag(); }, nullptr); } else { diff --git a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp index 5f00b346bddcde..8ac58946b3c21d 100644 --- a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp @@ -43,6 +43,7 @@ #include "MemManager.h" #include "RNG_Interface.h" +#include "SecLib.h" #include "TimersManager.h" #include "fsl_sha.h" #include "k32w0-chip-mbedtls-config.h" @@ -52,6 +53,10 @@ namespace DeviceLayer { PlatformManagerImpl PlatformManagerImpl::sInstance; +#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) +extern "C" void InitLowPower(); +#endif + #if defined(MBEDTLS_USE_TINYCRYPT) osaMutexId_t PlatformManagerImpl::rngMutexHandle = NULL; #endif @@ -78,11 +83,18 @@ CHIP_ERROR PlatformManagerImpl::InitBoardFwk(void) } RNG_SetPseudoRandomNoSeed(NULL); + SecLib_Init(); + TMR_Init(); /* Used for OT initializations */ otSysInit(1, argv); +#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) + /* Low Power Init */ + InitLowPower(); +#endif + exit: return err; } @@ -130,6 +142,8 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) goto exit; } + SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); + mStartTime = System::SystemClock().GetMonotonicTimestamp(); #if CHIP_SYSTEM_CONFIG_USE_LWIP diff --git a/src/platform/nxp/k32w/k32w0/RamStorage.cpp b/src/platform/nxp/k32w/k32w0/RamStorage.cpp deleted file mode 100644 index 4d23aa7024ad64..00000000000000 --- a/src/platform/nxp/k32w/k32w0/RamStorage.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* - * - * 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. - */ - -/** - * @file - * NVM Writes are time-consuming so instead of blocking the main tasks (e.g.: Matter) - * buffer the writes in a RAM buffer that gets to be written in the Idle Task - */ -#include -#include -#include - -#include "FunctionLib.h" -#include "RamStorage.h" - -#ifndef RAM_STORAGE_LOG -#define RAM_STORAGE_LOG 0 -#endif - -#include - -#if RAM_STORAGE_LOG -#include "fsl_debug_console.h" -#define RAM_STORAGE_PRINTF(...) \ - PRINTF("[%s] ", __FUNCTION__); \ - PRINTF(__VA_ARGS__); \ - PRINTF("\n\r"); -#else -#define RAM_STORAGE_PRINTF(...) -#endif - -/* increment size for dynamic memory re-allocation in case the - * initial RAM buffer size gets insufficient - */ -constexpr size_t kRamBufferReallocSize = 512; -constexpr size_t kRamBufferMaxAllocSize = 10240; - -ramBufferDescriptor * getRamBuffer(uint16_t nvmId, uint16_t initialSize) -{ - ramBufferDescriptor * ramDescr = NULL; - bool bLoadDataFromNvm = false; - uint16_t bytesRead = 0; - uint16_t recordSize = 0; - uint16_t allocSize = initialSize; - - /* Check if dataset is present and get its size */ - if (PDM_bDoesDataExist(nvmId, &recordSize)) - { - bLoadDataFromNvm = true; - while (recordSize > allocSize) - { - // increase size until NVM data fits - allocSize += kRamBufferReallocSize; - } - } - - if (allocSize <= kRamBufferMaxAllocSize) - { - ramDescr = (ramBufferDescriptor *) malloc(allocSize); - if (ramDescr) - { - ramDescr->ramBufferLen = 0; - ramDescr->ramBufferMaxLen = allocSize - kRamDescHeaderSize; - - if (bLoadDataFromNvm) - { - /* Try to load the dataset in RAM */ - if (PDM_E_STATUS_OK != PDM_eReadDataFromRecord(nvmId, ramDescr, recordSize, &bytesRead)) - { - memset(ramDescr, 0, allocSize); - } - } - } - } - - return ramDescr; -} - -static rsError ramStorageAdd(ramBufferDescriptor * pBuffer, uint16_t aKey, const uint8_t * aValue, uint16_t aValueLength) -{ - rsError error = RS_ERROR_NONE; - struct settingsBlock currentBlock = { 0 }; - const uint16_t newBlockLength = sizeof(settingsBlock) + aValueLength; - - if (pBuffer->ramBufferLen + newBlockLength <= pBuffer->ramBufferMaxLen) - { - currentBlock.key = aKey; - currentBlock.length = aValueLength; - - memcpy(&pBuffer->pRamBuffer[pBuffer->ramBufferLen], ¤tBlock, sizeof(settingsBlock)); - memcpy(&pBuffer->pRamBuffer[pBuffer->ramBufferLen + sizeof(settingsBlock)], aValue, aValueLength); - pBuffer->ramBufferLen += newBlockLength; - - error = RS_ERROR_NONE; - } - else - { - error = RS_ERROR_NO_BUFS; - } - - RAM_STORAGE_PRINTF("key = %d lengthWriten = %d err = %d", aKey, aValueLength, error); - - return error; -} - -rsError ramStorageGet(const ramBufferDescriptor * pBuffer, uint16_t aKey, int aIndex, uint8_t * aValue, uint16_t * aValueLength) -{ - uint16_t i = 0; - uint16_t valueLength = 0; - uint16_t readLength = 0; - int currentIndex = 0; - struct settingsBlock currentBlock = { 0 }; - rsError error = RS_ERROR_NOT_FOUND; - - while (i < pBuffer->ramBufferLen) - { - memcpy(¤tBlock, &pBuffer->pRamBuffer[i], sizeof(settingsBlock)); - - if (aKey == currentBlock.key) - { - if (currentIndex == aIndex) - { - readLength = currentBlock.length; - - // Perform read only if an input buffer was passed in - if (aValue != NULL && aValueLength != NULL) - { - // Adjust read length if input buffer size is smaller - if (readLength > *aValueLength) - { - readLength = *aValueLength; - } - - memcpy(aValue, &pBuffer->pRamBuffer[i + sizeof(settingsBlock)], readLength); - } - - valueLength = currentBlock.length; - error = RS_ERROR_NONE; - break; - } - - currentIndex++; - } - - i += sizeof(settingsBlock) + currentBlock.length; - } - - if (aValueLength != NULL) - { - *aValueLength = valueLength; - } - - RAM_STORAGE_PRINTF("key = %d err = %d", aKey, error); - - return error; -} - -static rsError ramStorageSetInternal(ramBufferDescriptor * pBuffer, uint16_t aKey, const uint8_t * aValue, uint16_t aValueLength) -{ - uint16_t i = 0; - uint16_t currentBlockLength = 0; - uint16_t nextBlockStart = 0; - struct settingsBlock currentBlock = { 0 }; - - // Delete all entries of aKey - while (i < pBuffer->ramBufferLen) - { - memcpy(¤tBlock, &pBuffer->pRamBuffer[i], sizeof(settingsBlock)); - currentBlockLength = sizeof(settingsBlock) + currentBlock.length; - - if (aKey == currentBlock.key) - { - nextBlockStart = i + currentBlockLength; - - if (nextBlockStart < pBuffer->ramBufferLen) - { - memmove(&pBuffer->pRamBuffer[i], &pBuffer->pRamBuffer[nextBlockStart], pBuffer->ramBufferLen - nextBlockStart); - } - - VerifyOrDie(pBuffer->ramBufferLen >= currentBlockLength); - pBuffer->ramBufferLen -= currentBlockLength; - } - else - { - i += currentBlockLength; - } - } - - return ramStorageAdd(pBuffer, aKey, aValue, aValueLength); -} - -rsError ramStorageSet(ramBufferDescriptor ** pBuffer, uint16_t aKey, const uint8_t * aValue, uint16_t aValueLength) -{ - rsError err = RS_ERROR_NONE; - uint16_t allocSize = (*pBuffer)->ramBufferMaxLen; - ramBufferDescriptor * ptr = NULL; - - if (allocSize <= (*pBuffer)->ramBufferLen + aValueLength) - { - while ((allocSize < (*pBuffer)->ramBufferLen + aValueLength)) - { - /* Need to realocate the memory buffer, increase size by kRamBufferReallocSize until NVM data fits */ - allocSize += kRamBufferReallocSize; - } - - allocSize += kRamDescHeaderSize; - - if (kRamBufferMaxAllocSize <= kRamBufferMaxAllocSize) - { - ptr = (ramBufferDescriptor *) realloc((void *) (*pBuffer), allocSize); - VerifyOrExit((NULL != ptr), err = RS_ERROR_NO_BUFS); - *pBuffer = ptr; - (*pBuffer)->ramBufferMaxLen = allocSize; - } - else - { - err = RS_ERROR_NO_BUFS; - } - } - - err = ramStorageSetInternal(*pBuffer, aKey, aValue, aValueLength); - -exit: - return err; -} - -rsError ramStorageDelete(ramBufferDescriptor * pBuffer, uint16_t aKey, int aIndex) -{ - uint16_t i = 0; - int currentIndex = 0; - uint16_t nextBlockStart = 0; - uint16_t currentBlockLength = 0; - struct settingsBlock currentBlock = { 0 }; - rsError error = RS_ERROR_NOT_FOUND; - - while (i < pBuffer->ramBufferLen) - { - memcpy(¤tBlock, &pBuffer->pRamBuffer[i], sizeof(settingsBlock)); - currentBlockLength = sizeof(settingsBlock) + currentBlock.length; - - if (aKey == currentBlock.key) - { - if (currentIndex == aIndex) - { - nextBlockStart = i + currentBlockLength; - - if (nextBlockStart < pBuffer->ramBufferLen) - { - memmove(&pBuffer->pRamBuffer[i], &pBuffer->pRamBuffer[nextBlockStart], pBuffer->ramBufferLen - nextBlockStart); - } - - VerifyOrDie(pBuffer->ramBufferLen >= currentBlockLength); - pBuffer->ramBufferLen -= currentBlockLength; - - error = RS_ERROR_NONE; - break; - } - else - { - currentIndex++; - } - } - - i += currentBlockLength; - } - RAM_STORAGE_PRINTF("key = %d err = %d", aKey, error); - return error; -} diff --git a/src/platform/nxp/k32w/k32w0/RamStorage.h b/src/platform/nxp/k32w/k32w0/RamStorage.h deleted file mode 100644 index b1bc0ea3ad2ad6..00000000000000 --- a/src/platform/nxp/k32w/k32w0/RamStorage.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * - * 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. - */ - -#pragma once - -typedef enum -{ - RS_ERROR_NONE, - RS_ERROR_NOT_FOUND, - RS_ERROR_NO_BUFS -} rsError; - -/* the structure used for keeping the records has the same structure both in RAM and in NVM: - * ramBufferLen | ramBufferMaxLen | settingsBlock | .... | settingsBlock - * - * ramBufferLen shows how much of the RAM buffer is currently occupied with settingsBlock structures - * ramBufferMaxLen shows the total malloc'ed size. Dynamic re-allocation is possible - */ -typedef struct -{ - uint16_t ramBufferLen; - uint16_t ramBufferMaxLen; - uint8_t pRamBuffer[1]; -} ramBufferDescriptor; - -struct settingsBlock -{ - uint16_t key; - uint16_t length; -} __attribute__((packed)); - -#define member_size(type, member) sizeof(((type *) 0)->member) - -constexpr size_t kRamDescHeaderSize = - member_size(ramBufferDescriptor, ramBufferLen) + member_size(ramBufferDescriptor, ramBufferMaxLen); - -/* Return a RAM buffer with initialSize and populated with the contents of NVM ID - if found in flash */ -ramBufferDescriptor * getRamBuffer(uint16_t nvmId, uint16_t initialSize); - -/* search pBuffer for aKey and return its value in aValue. aValueLength will contain the length of aValueLength */ -rsError ramStorageGet(const ramBufferDescriptor * pBuffer, uint16_t aKey, int aIndex, uint8_t * aValue, uint16_t * aValueLength); - -/* search pBuffer for aKey and set its value to aValue (having aValueLength length) */ -rsError ramStorageSet(ramBufferDescriptor ** pBuffer, uint16_t aKey, const uint8_t * aValue, uint16_t aValueLength); - -/* search pBuffer for aKey and delete it */ -rsError ramStorageDelete(ramBufferDescriptor * pBuffer, uint16_t aKey, int aIndex); diff --git a/src/platform/nxp/k32w/k32w0/SystemPlatformConfig.h b/src/platform/nxp/k32w/k32w0/SystemPlatformConfig.h index 084b759158d5f0..bda39157039697 100644 --- a/src/platform/nxp/k32w/k32w0/SystemPlatformConfig.h +++ b/src/platform/nxp/k32w/k32w0/SystemPlatformConfig.h @@ -37,6 +37,6 @@ struct ChipDeviceEvent; // ==================== Platform Adaptations ==================== #define CHIP_SYSTEM_CONFIG_PLATFORM_PROVIDES_TIME 1 #define CHIP_SYSTEM_CONFIG_EVENT_OBJECT_TYPE const struct ::chip::DeviceLayer::ChipDeviceEvent * -#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 7 +#define CHIP_SYSTEM_CONFIG_PACKETBUFFER_POOL_SIZE 0 // ========== Platform-specific Configuration Overrides ========= diff --git a/src/platform/nxp/k32w/k32w0/SystemTimeSupport.cpp b/src/platform/nxp/k32w/k32w0/SystemTimeSupport.cpp new file mode 100644 index 00000000000000..48de1e30389b17 --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/SystemTimeSupport.cpp @@ -0,0 +1,123 @@ +/* + * + * Copyright (c) 2020 Project CHIP Authors + * Copyright (c) 2018 Nest Labs, Inc. + * 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 + * Provides implementations of the CHIP System Layer platform + * time/clock functions that are suitable for use on the K32W0 platform. + */ +/* this file behaves like a config.h, comes first */ +#include + +extern "C" uint64_t otPlatTimeGet(void); +extern "C" uint32_t otPlatAlarmMilliGetNow(void); + +namespace chip { +namespace System { +namespace Clock { + +namespace Internal { +ClockImpl gClockImpl; +} // namespace Internal + +namespace { + +uint64_t sBootTimeUS = 0; + +} // unnamed namespace + +Microseconds64 ClockImpl::GetMonotonicMicroseconds64(void) +{ + return Clock::Microseconds64(otPlatTimeGet()); +} + +Milliseconds64 ClockImpl::GetMonotonicMilliseconds64(void) +{ + return std::chrono::duration_cast(GetMonotonicMicroseconds64()); +} + +uint64_t GetClock_Monotonic(void) +{ + return otPlatTimeGet(); +} + +uint64_t GetClock_MonotonicMS(void) +{ + return (otPlatTimeGet() / 1000); +} + +uint64_t GetClock_MonotonicHiRes(void) +{ + return GetClock_Monotonic(); +} + +CHIP_ERROR ClockImpl::GetClock_RealTime(Clock::Microseconds64 & aCurTime) +{ + // TODO(19081): This platform does not properly error out if wall clock has + // not been set. For now, short circuit this. + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +#if 0 + if (sBootTimeUS == 0) + { + return CHIP_ERROR_REAL_TIME_NOT_SYNCED; + } + aCurTime = Clock::Microseconds64(sBootTimeUS + GetClock_Monotonic()); + return CHIP_NO_ERROR; +#endif +} + +CHIP_ERROR ClockImpl::GetClock_RealTimeMS(Clock::Milliseconds64 & aCurTime) +{ + if (sBootTimeUS == 0) + { + return CHIP_ERROR_REAL_TIME_NOT_SYNCED; + } + aCurTime = Clock::Milliseconds64((sBootTimeUS + GetClock_Monotonic()) / 1000); + return CHIP_NO_ERROR; +} + +CHIP_ERROR ClockImpl::SetClock_RealTime(Clock::Microseconds64 aNewCurTime) +{ + uint64_t timeSinceBootUS = GetClock_Monotonic(); + if (aNewCurTime.count() > timeSinceBootUS) + { + sBootTimeUS = aNewCurTime.count() - timeSinceBootUS; + } + else + { + sBootTimeUS = 0; + } + return CHIP_NO_ERROR; +} + +CHIP_ERROR InitClock_RealTime() +{ + Clock::Microseconds64 curTime = + Clock::Microseconds64((static_cast(CHIP_SYSTEM_CONFIG_VALID_REAL_TIME_THRESHOLD) * UINT64_C(1000000))); + // Use CHIP_SYSTEM_CONFIG_VALID_REAL_TIME_THRESHOLD as the initial value of RealTime. + // Then the RealTime obtained from GetClock_RealTime will be always valid. + // + // TODO(19081): This is broken because it causes the platform to report + // that it does have wall clock time when it actually doesn't. + return System::SystemClock().SetClock_RealTime(curTime); +} + +} // namespace Clock +} // namespace System +} // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.cpp index 78ccc1b9b0abf3..af2d7421646739 100644 --- a/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.cpp @@ -36,6 +36,10 @@ #include +#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) +extern "C" bool isThreadInitialized(); +#endif + namespace chip { namespace DeviceLayer { @@ -62,6 +66,18 @@ CHIP_ERROR ThreadStackManagerImpl::InitThreadStack(otInstance * otInst) return err; } +void ThreadStackManagerImpl::ProcessThreadActivity() +{ + +#if defined(cPWR_UsePowerDownMode) && (cPWR_UsePowerDownMode) + if (isThreadInitialized()) +#endif + { + otTaskletsProcess(OTInstance()); + otSysProcessDrivers(OTInstance()); + } +} + bool ThreadStackManagerImpl::IsInitialized() { return sInstance.mThreadStackLock != NULL; diff --git a/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.h b/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.h index 5e68b31524d81b..5f7adcefec6cb1 100644 --- a/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.h +++ b/src/platform/nxp/k32w/k32w0/ThreadStackManagerImpl.h @@ -72,6 +72,9 @@ class ThreadStackManagerImpl final : public ThreadStackManager, using ThreadStackManager::InitThreadStack; CHIP_ERROR InitThreadStack(otInstance * otInst); + using ThreadStackManager::ProcessThreadActivity; + void ProcessThreadActivity(); + private: // ===== Methods that implement the ThreadStackManager abstract interface. diff --git a/src/platform/nxp/k32w/k32w0/args.gni b/src/platform/nxp/k32w/k32w0/args.gni index 9aba65644b4394..0364287bd8196c 100644 --- a/src/platform/nxp/k32w/k32w0/args.gni +++ b/src/platform/nxp/k32w/k32w0/args.gni @@ -28,9 +28,15 @@ chip_build_tests = false chip_mdns = "platform" -# Trying to fit into the available flash by disabling optional logging for now -chip_detail_logging = false -chip_progress_logging = true +# Logs are enabled by default, but can be disabled by setting +# chip_logging=false in the build command. +# Alternatively, a user can overwrite the value for different logging levels +# by uncommenting the lines below and setting the corresponding value. +# A user can disable some logging levels to decrease flash usage. +#chip_detail_logging = true +#chip_progress_logging = true +#chip_automation_logging = true +#chip_error_logging = true chip_system_config_use_open_thread_inet_endpoints = true chip_with_lwip = false diff --git a/src/platform/nxp/k32w/k32w0/crypto/ksdk_mbedtls.c b/src/platform/nxp/k32w/k32w0/crypto/ksdk_mbedtls.c new file mode 100644 index 00000000000000..14f1070097393d --- /dev/null +++ b/src/platform/nxp/k32w/k32w0/crypto/ksdk_mbedtls.c @@ -0,0 +1,4324 @@ +/* + * Copyright 2015-2016, Freescale Semiconductor, Inc. + * Copyright 2017 NXP + * All rights reserved. + * + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include "SecLib.h" + +#if !defined(MBEDTLS_CONFIG_FILE) +#include "mbedtls/config.h" +#else +#include MBEDTLS_CONFIG_FILE +#endif + +#include "fsl_common.h" + +#if defined(FSL_FEATURE_SOC_LTC_COUNT) && (FSL_FEATURE_SOC_LTC_COUNT > 0) +#include "fsl_ltc.h" +#endif +#if defined(FSL_FEATURE_SOC_CAAM_COUNT) && (FSL_FEATURE_SOC_CAAM_COUNT > 0) +#include "fsl_caam.h" +#endif +#if defined(FSL_FEATURE_SOC_CAU3_COUNT) && (FSL_FEATURE_SOC_CAU3_COUNT > 0) +#include "fsl_cau3.h" +#endif +#if defined(FSL_FEATURE_SOC_DCP_COUNT) && (FSL_FEATURE_SOC_DCP_COUNT > 0) +#include "fsl_dcp.h" +#endif +#if defined(FSL_FEATURE_SOC_HASHCRYPT_COUNT) && (FSL_FEATURE_SOC_HASHCRYPT_COUNT > 0) +#include "fsl_hashcrypt.h" +#endif +#if defined(FSL_FEATURE_SOC_TRNG_COUNT) && (FSL_FEATURE_SOC_TRNG_COUNT > 0) +#if defined CPU_JN518X +#include "fsl_rng.h" +#else +#include "fsl_trng.h" +#endif +#elif defined(FSL_FEATURE_SOC_RNG_COUNT) && (FSL_FEATURE_SOC_RNG_COUNT > 0) +#include "fsl_rnga.h" +#elif defined(FSL_FEATURE_SOC_LPC_RNG1_COUNT) && (FSL_FEATURE_SOC_LPC_RNG1_COUNT > 0) +#include "fsl_rng.h" +#endif + +#define CLEAN_RETURN(value) \ + { \ + ret = value; \ + goto cleanup; \ + } + +/******************************************************************************/ +/*************************** CAAM *********************************************/ +/******************************************************************************/ +#if defined(FSL_FEATURE_SOC_CAAM_COUNT) && (FSL_FEATURE_SOC_CAAM_COUNT > 0) && defined(CRYPTO_USE_DRIVER_CAAM) +static caam_handle_t s_caamHandle = { .jobRing = kCAAM_JobRing0 }; +#endif + +/******************************************************************************/ +/*************************** CAU3 *********************************************/ +/******************************************************************************/ +#if defined(FSL_FEATURE_SOC_CAU3_COUNT) && (FSL_FEATURE_SOC_CAU3_COUNT > 0) +static cau3_handle_t s_cau3Handle = { .taskDone = MBEDTLS_CAU3_COMPLETION_SIGNAL, .keySlot = kCAU3_KeySlot0 }; +#endif + +/******************************************************************************/ +/**************************** DCP *********************************************/ +/******************************************************************************/ +#if defined(FSL_FEATURE_SOC_DCP_COUNT) && (FSL_FEATURE_SOC_DCP_COUNT > 0) +static dcp_handle_t s_dcpHandle = { .channel = kDCP_Channel0, .keySlot = kDCP_KeySlot0, .swapConfig = kDCP_NoSwap }; +#endif + +/******************************************************************************/ +/************************* Key slot management ********************************/ +/******************************************************************************/ +#if (defined(FSL_FEATURE_SOC_CAU3_COUNT) && (FSL_FEATURE_SOC_CAU3_COUNT > 0)) || (defined(MBEDTLS_FREESCALE_DCP_AES)) +static const void * s_mbedtlsCtx[4] = { 0 }; + +static void crypto_attach_ctx_to_key_slot(const void * ctx, uint8_t keySlot) +{ + s_mbedtlsCtx[keySlot] = ctx; +} + +static void crypto_detach_ctx_from_key_slot(const void * ctx) +{ + for (int i = 0; i < 4; i++) + { + if (ctx == s_mbedtlsCtx[i]) + { + s_mbedtlsCtx[i] = NULL; + break; + } + } +} + +static bool crypto_key_is_loaded(const void * ctx) +{ + bool ret = false; + for (int i = 0; i < 4; i++) + { + if (ctx == s_mbedtlsCtx[i]) + { + ret = true; + break; + } + } + return ret; +} +#endif + +#if defined(MBEDTLS_SHA1_ALT) || defined(MBEDTLS_SHA256_ALT) +/* Implementation that should never be optimized out by the compiler */ +static void mbedtls_zeroize(void * v, size_t n) +{ + volatile unsigned char * p = v; + while (n--) + *p++ = 0; +} +#endif /* MBEDTLS_SHA1_ALT || MBEDTLS_SHA256_ALT */ + +/******************************************************************************/ +/******************** CRYPTO_InitHardware **************************************/ +/******************************************************************************/ +/*! + * @brief Application init for various Crypto blocks. + * + * This function is provided to be called by MCUXpresso SDK applications. + * It calls basic init for Crypto Hw acceleration and Hw entropy modules. + */ +void CRYPTO_InitHardware(void) +{ +#if defined(FSL_FEATURE_SOC_LTC_COUNT) && (FSL_FEATURE_SOC_LTC_COUNT > 0) + /* Initialize LTC driver. + * This enables clocking and resets the module to a known state. */ + LTC_Init(LTC0); +#endif +#if defined(FSL_FEATURE_SOC_CAAM_COUNT) && (FSL_FEATURE_SOC_CAAM_COUNT > 0) && defined(CRYPTO_USE_DRIVER_CAAM) + /* Initialize CAAM driver. */ + caam_config_t caamConfig; + + CAAM_GetDefaultConfig(&caamConfig); + caamConfig.jobRingInterface[0] = &s_jrif0; + caamConfig.jobRingInterface[1] = &s_jrif1; + CAAM_Init(CAAM, &caamConfig); +#endif +#if defined(FSL_FEATURE_SOC_CAU3_COUNT) && (FSL_FEATURE_SOC_CAU3_COUNT > 0) + /* Initialize CAU3 */ + CAU3_Init(CAU3); +#endif +#if defined(FSL_FEATURE_SOC_DCP_COUNT) && (FSL_FEATURE_SOC_DCP_COUNT > 0) + /* Initialize DCP */ + dcp_config_t dcpConfig; + + DCP_GetDefaultConfig(&dcpConfig); + DCP_Init(DCP, &dcpConfig); +#endif +#if defined(FSL_FEATURE_SOC_CASPER_COUNT) && (FSL_FEATURE_SOC_CASPER_COUNT > 0) + /* Initialize CASPER */ + CASPER_Init(CASPER); +#endif +#if defined(FSL_FEATURE_SOC_HASHCRYPT_COUNT) && (FSL_FEATURE_SOC_HASHCRYPT_COUNT > 0) + /* Initialize HASHCRYPT */ + HASHCRYPT_Init(HASHCRYPT); +#endif + { /* Init RNG module.*/ +#if defined(FSL_FEATURE_SOC_TRNG_COUNT) && (FSL_FEATURE_SOC_TRNG_COUNT > 0) +#if defined CPU_JN518X +#if defined(RNG) +#define TRNG0 RNG +#endif +#else +#if defined(TRNG) +#define TRNG0 TRNG +#endif +#endif + trng_config_t trngConfig; + + TRNG_GetDefaultConfig(&trngConfig); + /* Set sample mode of the TRNG ring oscillator to Von Neumann, for better random data.*/ + /* Initialize TRNG */ + TRNG_Init(TRNG0, &trngConfig); +#elif defined(FSL_FEATURE_SOC_RNG_COUNT) && (FSL_FEATURE_SOC_RNG_COUNT > 0) + RNGA_Init(RNG); + RNGA_Seed(RNG, SIM->UIDL); +#endif + } +} + +/******************************************************************************/ +/*************************** DES **********************************************/ +/******************************************************************************/ + +#if defined(MBEDTLS_DES_C) + +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_MMCAU_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) || \ + defined(MBEDTLS_FREESCALE_CAU3_DES) + +#include "mbedtls/des.h" + +#if defined(MBEDTLS_FREESCALE_MMCAU_DES) +const unsigned char parityLookup[128] = { 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, + 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, + 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, + 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, + 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0 }; +#endif + +#if defined(MBEDTLS_FREESCALE_MMCAU_DES) || defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) +/* + * DES key schedule (56-bit, encryption) + */ +int mbedtls_des_setkey_enc(mbedtls_des_context * ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE]) +{ +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) + memcpy(ctx->sk, key, MBEDTLS_DES_KEY_SIZE); +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + int i; + unsigned char * sk_b = (unsigned char *) ctx->sk; + + /* fix key parity, if needed */ + for (i = 0; i < MBEDTLS_DES_KEY_SIZE; i++) + { + sk_b[i] = ((key[i] & 0xFE) | parityLookup[key[i] >> 1]); + } +#endif + ctx->mode = MBEDTLS_DES_ENCRYPT; + + return (0); +} + +/* + * DES key schedule (56-bit, decryption) + */ +int mbedtls_des_setkey_dec(mbedtls_des_context * ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE]) +{ +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) + memcpy(ctx->sk, key, MBEDTLS_DES_KEY_SIZE); +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + int i; + unsigned char * sk_b = (unsigned char *) ctx->sk; + + /* fix key parity, if needed */ + for (i = 0; i < MBEDTLS_DES_KEY_SIZE; i++) + { + sk_b[i] = ((key[i] & 0xFE) | parityLookup[key[i] >> 1]); + } +#endif + ctx->mode = MBEDTLS_DES_DECRYPT; + + return (0); +} +#endif /* MBEDTLS_FREESCALE_MMCAU_DES || MBEDTLS_FREESCALE_LTC_DES || MBEDTLS_FREESCALE_CAAM_DES */ + +/* + * Triple-DES key schedule (112-bit, encryption) + */ +int mbedtls_des3_set2key_enc(mbedtls_des3_context * ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2]) +{ +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) || defined(MBEDTLS_FREESCALE_CAU3_DES) + memcpy(ctx->sk, key, MBEDTLS_DES_KEY_SIZE * 2); + memcpy(&ctx->sk[4], key, MBEDTLS_DES_KEY_SIZE); /* K3 = K1 */ +#if defined(MBEDTLS_FREESCALE_CAU3_DES) + crypto_detach_ctx_from_key_slot(ctx); +#endif +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + int i; + unsigned char * sk_b = (unsigned char *) ctx->sk; + + /* fix key parity, if needed */ + for (i = 0; i < MBEDTLS_DES_KEY_SIZE * 2; i++) + { + sk_b[i] = ((key[i] & 0xFE) | parityLookup[key[i] >> 1]); + } + for (i = MBEDTLS_DES_KEY_SIZE * 2; i < MBEDTLS_DES_KEY_SIZE * 3; i++) + { + sk_b[i] = ((key[i - MBEDTLS_DES_KEY_SIZE * 2] & 0xFE) | parityLookup[key[i - MBEDTLS_DES_KEY_SIZE * 2] >> 1]); + } +#endif + ctx->mode = MBEDTLS_DES_ENCRYPT; + + return (0); +} + +/* + * Triple-DES key schedule (112-bit, decryption) + */ +int mbedtls_des3_set2key_dec(mbedtls_des3_context * ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 2]) +{ +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) || defined(MBEDTLS_FREESCALE_CAU3_DES) + memcpy(ctx->sk, key, MBEDTLS_DES_KEY_SIZE * 2); + memcpy(&ctx->sk[4], key, MBEDTLS_DES_KEY_SIZE); /* K3 = K1 */ +#if defined(MBEDTLS_FREESCALE_CAU3_DES) + crypto_detach_ctx_from_key_slot(ctx); +#endif +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + int i; + unsigned char * sk_b = (unsigned char *) ctx->sk; + + /* fix key parity, if needed */ + for (i = 0; i < MBEDTLS_DES_KEY_SIZE * 2; i++) + { + sk_b[i] = ((key[i] & 0xFE) | parityLookup[key[i] >> 1]); + } + for (i = MBEDTLS_DES_KEY_SIZE * 2; i < MBEDTLS_DES_KEY_SIZE * 3; i++) + { + sk_b[i] = ((key[i - MBEDTLS_DES_KEY_SIZE * 2] & 0xFE) | parityLookup[key[i - MBEDTLS_DES_KEY_SIZE * 2] >> 1]); + } +#endif + ctx->mode = MBEDTLS_DES_DECRYPT; + + return (0); +} + +/* + * Triple-DES key schedule (168-bit, encryption) + */ +int mbedtls_des3_set3key_enc(mbedtls_des3_context * ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3]) +{ +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) || defined(MBEDTLS_FREESCALE_CAU3_DES) + memcpy(ctx->sk, key, MBEDTLS_DES_KEY_SIZE * 3); +#if defined(MBEDTLS_FREESCALE_CAU3_DES) + crypto_detach_ctx_from_key_slot(ctx); +#endif +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + int i; + unsigned char * sk_b = (unsigned char *) ctx->sk; + + /* fix key parity, if needed */ + for (i = 0; i < MBEDTLS_DES_KEY_SIZE * 3; i++) + { + sk_b[i] = ((key[i] & 0xFE) | parityLookup[key[i] >> 1]); + } +#endif + ctx->mode = MBEDTLS_DES_ENCRYPT; + + return (0); +} + +/* + * Triple-DES key schedule (168-bit, decryption) + */ +int mbedtls_des3_set3key_dec(mbedtls_des3_context * ctx, const unsigned char key[MBEDTLS_DES_KEY_SIZE * 3]) +{ +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) || defined(MBEDTLS_FREESCALE_CAU3_DES) + memcpy(ctx->sk, key, MBEDTLS_DES_KEY_SIZE * 3); +#if defined(MBEDTLS_FREESCALE_CAU3_DES) + crypto_detach_ctx_from_key_slot(ctx); +#endif +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + int i; + unsigned char * sk_b = (unsigned char *) ctx->sk; + + /* fix key parity, if needed */ + for (i = 0; i < MBEDTLS_DES_KEY_SIZE * 3; i++) + { + sk_b[i] = ((key[i] & 0xFE) | parityLookup[key[i] >> 1]); + } +#endif + ctx->mode = MBEDTLS_DES_DECRYPT; + return (0); +} + +#if defined(MBEDTLS_FREESCALE_LTC_DES) || defined(MBEDTLS_FREESCALE_MMCAU_DES) || defined(MBEDTLS_FREESCALE_CAAM_DES) +/* + * DES-ECB block encryption/decryption + */ +int mbedtls_des_crypt_ecb(mbedtls_des_context * ctx, const unsigned char input[8], unsigned char output[8]) +{ + uint8_t * key = (uint8_t *) ctx->sk; +#if defined(MBEDTLS_FREESCALE_LTC_DES) + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + LTC_DES_EncryptEcb(LTC_INSTANCE, input, output, 8, key); + } + else + { + LTC_DES_DecryptEcb(LTC_INSTANCE, input, output, 8, key); + } +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + MMCAU_DES_EncryptEcb(input, key, output); + } + else + { + MMCAU_DES_DecryptEcb(input, key, output); + } +#elif defined(MBEDTLS_FREESCALE_CAAM_DES) + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + CAAM_DES_EncryptEcb(CAAM_INSTANCE, &s_caamHandle, input, output, 8, key); + } + else + { + CAAM_DES_DecryptEcb(CAAM_INSTANCE, &s_caamHandle, input, output, 8, key); + } +#endif + return (0); +} +#endif /* MBEDTLS_FREESCALE_LTC_DES || MBEDTLS_FREESCALE_MMCAU_DES || MBEDTLS_FREESCALE_CAAM_DES */ + +/* + * 3DES-ECB block encryption/decryption + */ +int mbedtls_des3_crypt_ecb(mbedtls_des3_context * ctx, const unsigned char input[8], unsigned char output[8]) +{ + uint8_t * key = (uint8_t *) ctx->sk; +#if defined(MBEDTLS_FREESCALE_LTC_DES) + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + LTC_DES3_EncryptEcb(LTC_INSTANCE, input, output, 8, key, key + 8, key + 16); + } + else + { + LTC_DES3_DecryptEcb(LTC_INSTANCE, input, output, 8, key, key + 8, key + 16); + } +#elif defined(MBEDTLS_FREESCALE_MMCAU_DES) + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + MMCAU_DES_EncryptEcb(input, key, output); + MMCAU_DES_DecryptEcb(output, key + 8, output); + MMCAU_DES_EncryptEcb(output, key + 16, output); + } + else + { + MMCAU_DES_DecryptEcb(input, key + 16, output); + MMCAU_DES_EncryptEcb(output, key + 8, output); + MMCAU_DES_DecryptEcb(output, key, output); + } +#elif defined(MBEDTLS_FREESCALE_CAAM_DES) + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + CAAM_DES3_EncryptEcb(CAAM_INSTANCE, &s_caamHandle, input, output, 8, key, key + 8, key + 16); + } + else + { + CAAM_DES3_DecryptEcb(CAAM_INSTANCE, &s_caamHandle, input, output, 8, key, key + 8, key + 16); + } +#elif defined(MBEDTLS_FREESCALE_CAU3_DES) + if (!crypto_key_is_loaded(ctx)) + { + CAU3_TDES_SetKey(CAU3, &s_cau3Handle, key, 24); + crypto_attach_ctx_to_key_slot(ctx, s_cau3Handle.keySlot); + } + + if (ctx->mode == MBEDTLS_DES_ENCRYPT) + { + CAU3_TDES_Encrypt(CAU3, &s_cau3Handle, input, output); + } + else + { + CAU3_TDES_Decrypt(CAU3, &s_cau3Handle, input, output); + } +#endif + return (0); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/* + * DES-CBC buffer encryption/decryption + */ +#if defined(MBEDTLS_FREESCALE_LTC_DES) +int mbedtls_des_crypt_cbc(mbedtls_des_context * ctx, int mode, size_t length, unsigned char iv[8], const unsigned char * input, + unsigned char * output) +{ + unsigned char temp[8]; + uint8_t * key = (uint8_t *) ctx->sk; + + if (length % 8) + return (MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH); + + if (mode == MBEDTLS_DES_ENCRYPT) + { + LTC_DES_EncryptCbc(LTC_INSTANCE, input, output, length, iv, key); + memcpy(iv, output + length - 8, 8); + } + else /* MBEDTLS_DES_DECRYPT */ + { + memcpy(temp, input + length - 8, 8); + LTC_DES_DecryptCbc(LTC_INSTANCE, input, output, length, iv, key); + memcpy(iv, temp, 8); + } + return (0); +} + +/* + * 3DES-CBC buffer encryption/decryption + */ +int mbedtls_des3_crypt_cbc(mbedtls_des3_context * ctx, int mode, size_t length, unsigned char iv[8], const unsigned char * input, + unsigned char * output) +{ + unsigned char temp[8]; + uint8_t * key = (uint8_t *) ctx->sk; + + if (length % 8) + return (MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH); + + if (mode == MBEDTLS_DES_ENCRYPT) + { + LTC_DES3_EncryptCbc(LTC_INSTANCE, input, output, length, iv, key, key + 8, key + 16); + memcpy(iv, output + length - 8, 8); + } + else /* MBEDTLS_DES_DECRYPT */ + { + memcpy(temp, input + length - 8, 8); + LTC_DES3_DecryptCbc(LTC_INSTANCE, input, output, length, iv, key, key + 8, key + 16); + memcpy(iv, temp, 8); + } + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_CAAM_DES) +int mbedtls_des_crypt_cbc(mbedtls_des_context * ctx, int mode, size_t length, unsigned char iv[8], const unsigned char * input, + unsigned char * output) +{ + unsigned char temp[8]; + uint8_t * key = (uint8_t *) ctx->sk; + + if (length % 8) + return (MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH); + + if (mode == MBEDTLS_DES_ENCRYPT) + { + CAAM_DES_EncryptCbc(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, key); + memcpy(iv, output + length - 8, 8); + } + else /* MBEDTLS_DES_DECRYPT */ + { + memcpy(temp, input + length - 8, 8); + CAAM_DES_DecryptCbc(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, key); + memcpy(iv, temp, 8); + } + return (0); +} + +/* + * 3DES-CBC buffer encryption/decryption + */ +int mbedtls_des3_crypt_cbc(mbedtls_des3_context * ctx, int mode, size_t length, unsigned char iv[8], const unsigned char * input, + unsigned char * output) +{ + unsigned char temp[8]; + uint8_t * key = (uint8_t *) ctx->sk; + + if (length % 8) + return (MBEDTLS_ERR_DES_INVALID_INPUT_LENGTH); + + if (mode == MBEDTLS_DES_ENCRYPT) + { + CAAM_DES3_EncryptCbc(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, key, key + 8, key + 16); + memcpy(iv, output + length - 8, 8); + } + else /* MBEDTLS_DES_DECRYPT */ + { + memcpy(temp, input + length - 8, 8); + CAAM_DES3_DecryptCbc(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, key, key + 8, key + 16); + memcpy(iv, temp, 8); + } + + return (0); +} + +#endif /* MBEDTLS_FREESCALE_LTC_DES */ +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#endif /*MBEDTLS_FREESCALE_LTC_DES || MBEDTLS_FREESCALE_MMCAU_DES || MBEDTLS_FREESCALE_CAAM_DES*/ + +#endif /* MBEDTLS_DES_C */ + +/******************************************************************************/ +/*************************** AES **********************************************/ +/******************************************************************************/ + +#if defined(MBEDTLS_AES_C) + +#if defined(MBEDTLS_FREESCALE_LTC_AES) || defined(MBEDTLS_FREESCALE_MMCAU_AES) || defined(MBEDTLS_FREESCALE_LPC_AES) || \ + defined(MBEDTLS_FREESCALE_CAU3_AES) || defined(MBEDTLS_FREESCALE_CAAM_AES) || defined(MBEDTLS_FREESCALE_DCP_AES) + +#include "mbedtls/aes.h" + +/* + * AES key schedule (encryption) + */ +int mbedtls_aes_setkey_enc(mbedtls_aes_context * ctx, const unsigned char * key, unsigned int keybits) +{ + uint32_t * RK; + +#ifdef MBEDTLS_AES_ALT_NO_192 + if (keybits == 192u) + { + return (MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE); + } +#endif + +#ifdef MBEDTLS_AES_ALT_NO_256 + if (keybits == 256u) + { + return (MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE); + } +#endif + +#if defined(MBEDTLS_FREESCALE_LTC_AES) || defined(MBEDTLS_FREESCALE_LPC_AES) || defined(MBEDTLS_FREESCALE_CAU3_AES) || \ + defined(MBEDTLS_FREESCALE_CAAM_AES) || defined(MBEDTLS_FREESCALE_DCP_AES) + const unsigned char * key_tmp = key; + ctx->rk = RK = ctx->buf; + memcpy(RK, key_tmp, keybits / 8); + +#if defined(MBEDTLS_FREESCALE_CAU3_AES) || defined(MBEDTLS_FREESCALE_DCP_AES) + crypto_detach_ctx_from_key_slot(ctx); +#endif /* MBEDTLS_FREESCALE_CAU3_AES || MBEDTLS_FREESCALE_DCP_AES */ + + switch (keybits) + { /* Set keysize in bytes.*/ + case 128: + ctx->nr = 16; + break; + case 192: + ctx->nr = 24; + break; + case 256: + ctx->nr = 32; + break; + default: + return (MBEDTLS_ERR_AES_INVALID_KEY_LENGTH); + } +#elif defined(MBEDTLS_FREESCALE_MMCAU_AES) + ctx->rk = RK = ctx->buf; + + switch (keybits) + { + case 128: + ctx->nr = 10; + break; + case 192: + ctx->nr = 12; + break; + case 256: + ctx->nr = 14; + break; + default: + return (MBEDTLS_ERR_AES_INVALID_KEY_LENGTH); + } + + MMCAU_AES_SetKey(key, keybits / 8, (uint8_t *) RK); +#endif + + return (0); +} + +/* + * AES key schedule (decryption) + */ +int mbedtls_aes_setkey_dec(mbedtls_aes_context * ctx, const unsigned char * key, unsigned int keybits) +{ + uint32_t * RK; + +#ifdef MBEDTLS_AES_ALT_NO_192 + if (keybits == 192u) + { + return (MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE); + } +#endif + +#ifdef MBEDTLS_AES_ALT_NO_256 + if (keybits == 256u) + { + return (MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE); + } +#endif + + ctx->rk = RK = ctx->buf; + +#if defined(MBEDTLS_FREESCALE_LTC_AES) || defined(MBEDTLS_FREESCALE_LPC_AES) || defined(MBEDTLS_FREESCALE_CAU3_AES) || \ + defined(MBEDTLS_FREESCALE_CAAM_AES) || defined(MBEDTLS_FREESCALE_DCP_AES) + const unsigned char * key_tmp = key; + memcpy(RK, key_tmp, keybits / 8); + +#if defined(MBEDTLS_FREESCALE_CAU3_AES) || defined(MBEDTLS_FREESCALE_DCP_AES) + crypto_detach_ctx_from_key_slot(ctx); +#endif /* MBEDTLS_FREESCALE_CAU3_AES || MBEDTLS_FREESCALE_DCP_AES */ + + switch (keybits) + { + case 128: + ctx->nr = 16; + break; + case 192: + ctx->nr = 24; + break; + case 256: + ctx->nr = 32; + break; + default: + return (MBEDTLS_ERR_AES_INVALID_KEY_LENGTH); + } +#elif defined(MBEDTLS_FREESCALE_MMCAU_AES) + ctx->rk = RK = ctx->buf; + + switch (keybits) + { + case 128: + ctx->nr = 10; + break; + case 192: + ctx->nr = 12; + break; + case 256: + ctx->nr = 14; + break; + default: + return (MBEDTLS_ERR_AES_INVALID_KEY_LENGTH); + } + + MMCAU_AES_SetKey(key, keybits / 8, (uint8_t *) RK); +#endif + + return 0; +} + +/* + * AES-ECB block encryption + */ +int mbedtls_internal_aes_encrypt(mbedtls_aes_context * ctx, const unsigned char input[16], unsigned char output[16]) +{ + uint8_t * key; + + key = (uint8_t *) ctx->rk; +#if defined(MBEDTLS_FREESCALE_LTC_AES) + LTC_AES_EncryptEcb(LTC_INSTANCE, input, output, 16, key, ctx->nr); +#elif defined(MBEDTLS_FREESCALE_MMCAU_AES) + MMCAU_AES_EncryptEcb(input, key, ctx->nr, output); +#elif defined(MBEDTLS_FREESCALE_CAU3_AES) + if (!crypto_key_is_loaded(ctx)) + { + CAU3_AES_SetKey(CAU3, &s_cau3Handle, key, ctx->nr); + crypto_attach_ctx_to_key_slot(ctx, s_cau3Handle.keySlot); + } + CAU3_AES_Encrypt(CAU3, &s_cau3Handle, input, output); +#elif defined(MBEDTLS_FREESCALE_LPC_AES) + AES_128_Encrypt(input, key, output); +#elif defined(MBEDTLS_FREESCALE_CAAM_AES) + CAAM_AES_EncryptEcb(CAAM_INSTANCE, &s_caamHandle, input, output, 16, key, ctx->nr); +#elif defined(MBEDTLS_FREESCALE_DCP_AES) + if (!crypto_key_is_loaded(ctx)) + { + DCP_AES_SetKey(DCP, &s_dcpHandle, key, ctx->nr); + crypto_attach_ctx_to_key_slot(ctx, s_dcpHandle.keySlot); + } + DCP_AES_EncryptEcb(DCP, &s_dcpHandle, input, output, 16); +#endif + + return (0); +} + +/* + * AES-ECB block decryption + */ +int mbedtls_internal_aes_decrypt(mbedtls_aes_context * ctx, const unsigned char input[16], unsigned char output[16]) +{ + uint8_t * key; + + key = (uint8_t *) ctx->rk; +#if defined(MBEDTLS_FREESCALE_LTC_AES) + LTC_AES_DecryptEcb(LTC_INSTANCE, input, output, 16, key, ctx->nr, kLTC_EncryptKey); +#elif defined(MBEDTLS_FREESCALE_MMCAU_AES) + MMCAU_AES_DecryptEcb(input, key, ctx->nr, output); +#elif defined(MBEDTLS_FREESCALE_CAU3_AES) + if (!crypto_key_is_loaded(ctx)) + { + CAU3_AES_SetKey(CAU3, &s_cau3Handle, key, ctx->nr); + crypto_attach_ctx_to_key_slot(ctx, s_cau3Handle.keySlot); + } + CAU3_AES_Decrypt(CAU3, &s_cau3Handle, input, output); +#elif defined(MBEDTLS_FREESCALE_LPC_AES) + AES_128_Decrypt(input, key, output); +#elif defined(MBEDTLS_FREESCALE_CAAM_AES) + CAAM_AES_DecryptEcb(CAAM_INSTANCE, &s_caamHandle, input, output, 16, key, ctx->nr); +#elif defined(MBEDTLS_FREESCALE_DCP_AES) + if (!crypto_key_is_loaded(ctx)) + { + DCP_AES_SetKey(DCP, &s_dcpHandle, key, ctx->nr); + crypto_attach_ctx_to_key_slot(ctx, s_dcpHandle.keySlot); + } + DCP_AES_DecryptEcb(DCP, &s_dcpHandle, input, output, 16); +#endif + + return (0); +} + +#if defined(MBEDTLS_CIPHER_MODE_CBC) +/* + * AES-CBC buffer encryption/decryption + */ +#if defined(MBEDTLS_FREESCALE_LTC_AES) +int mbedtls_aes_crypt_cbc(mbedtls_aes_context * ctx, int mode, size_t length, unsigned char iv[16], const unsigned char * input, + unsigned char * output) +{ + uint8_t * key = (uint8_t *) ctx->rk; + uint32_t keySize = ctx->nr; + + if (length % 16) + return (MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH); + + if (mode == MBEDTLS_AES_DECRYPT) + { + uint8_t tmp[16]; + memcpy(tmp, input + length - 16, 16); + LTC_AES_DecryptCbc(LTC_INSTANCE, input, output, length, iv, key, keySize, kLTC_EncryptKey); + memcpy(iv, tmp, 16); + } + else + { + LTC_AES_EncryptCbc(LTC_INSTANCE, input, output, length, iv, key, keySize); + memcpy(iv, output + length - 16, 16); + } + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_LPC_AES) +int mbedtls_aes_crypt_cbc(mbedtls_aes_context * ctx, int mode, size_t length, unsigned char iv[16], const unsigned char * input, + unsigned char * output) +{ + uint8_t * key; + size_t keySize; + + if (length % 16) + return (MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH); + + key = (uint8_t *) ctx->rk; + keySize = (size_t) ctx->nr; + + if (mode == MBEDTLS_AES_DECRYPT) + { + uint8_t tmp[16]; + memcpy(tmp, input + length - 16, 16); + AES_128_CBC_Decrypt_And_Depad(tmp, length, iv, key, output); + memcpy(iv, tmp, 16); + } + else + { + AES_128_CBC_Encrypt(input, length, iv, key, output); + memcpy(iv, output + length - 16, 16); + } + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_CAAM_AES) +int mbedtls_aes_crypt_cbc(mbedtls_aes_context * ctx, int mode, size_t length, unsigned char iv[16], const unsigned char * input, + unsigned char * output) +{ + uint8_t * key = (uint8_t *) ctx->rk; + uint32_t keySize = ctx->nr; + + if (length % 16) + return (MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH); + + if (mode == MBEDTLS_AES_DECRYPT) + { + uint8_t tmp[16]; + memcpy(tmp, input + length - 16, 16); + CAAM_AES_DecryptCbc(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, key, keySize); + memcpy(iv, tmp, 16); + } + else + { + CAAM_AES_EncryptCbc(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, key, keySize); + memcpy(iv, output + length - 16, 16); + } + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_DCP_AES) +int mbedtls_aes_crypt_cbc(mbedtls_aes_context * ctx, int mode, size_t length, unsigned char iv[16], const unsigned char * input, + unsigned char * output) +{ + uint8_t * key; + + if (length % 16) + return (MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH); + + key = (uint8_t *) ctx->rk; + if (!crypto_key_is_loaded(ctx)) + { + DCP_AES_SetKey(DCP, &s_dcpHandle, key, ctx->nr); + crypto_attach_ctx_to_key_slot(ctx, s_dcpHandle.keySlot); + } + + if (mode == MBEDTLS_AES_DECRYPT) + { + uint8_t tmp[16]; + memcpy(tmp, input + length - 16, 16); + DCP_AES_DecryptCbc(DCP, &s_dcpHandle, input, output, length, iv); + memcpy(iv, tmp, 16); + } + else + { + DCP_AES_EncryptCbc(DCP, &s_dcpHandle, input, output, length, iv); + memcpy(iv, output + length - 16, 16); + } + + return (0); +} +#endif +#endif /* MBEDTLS_CIPHER_MODE_CBC */ + +#if defined(MBEDTLS_CIPHER_MODE_CFB) +#if defined(MBEDTLS_FREESCALE_LPC_AES) +/* + * AES-CFB128 buffer encryption/decryption + */ +int mbedtls_aes_crypt_cfb128(mbedtls_aes_context * ctx, int mode, size_t length, size_t * iv_off, unsigned char iv[16], + const unsigned char * input, unsigned char * output) +{ + uint8_t * key; + size_t keySize; + + key = (uint8_t *) ctx->rk; + keySize = (size_t) ctx->nr; + AES_SetKey(AES_INSTANCE, key, keySize); + + if (mode == MBEDTLS_AES_DECRYPT) + { + AES_DecryptCfb(AES_INSTANCE, input, output, length, iv); + } + else + { + AES_EncryptCfb(AES_INSTANCE, input, output, length, iv); + } + + return (0); +} + +/* + * AES-CFB8 buffer encryption/decryption + */ +int mbedtls_aes_crypt_cfb8(mbedtls_aes_context * ctx, int mode, size_t length, unsigned char iv[16], const unsigned char * input, + unsigned char * output) +{ + int status; + unsigned char c; + unsigned char ov[17]; + + while (length--) + { + memcpy(ov, iv, 16); + status = mbedtls_aes_crypt_ecb(ctx, MBEDTLS_AES_ENCRYPT, iv, iv); + if (status != 0) + { + return status; + } + + if (mode == MBEDTLS_AES_DECRYPT) + ov[16] = *input; + + c = *output++ = (unsigned char) (iv[0] ^ *input++); + + if (mode == MBEDTLS_AES_ENCRYPT) + ov[16] = c; + + memcpy(iv, ov + 1, 16); + } + + return (0); +} +#endif /* MBEDTLS_FREESCALE_LPC_AES */ +#endif /* MBEDTLS_CIPHER_MODE_CFB */ + +#if defined(MBEDTLS_CIPHER_MODE_CTR) +/* + * AES-CTR buffer encryption/decryption + */ +#if defined(MBEDTLS_FREESCALE_LTC_AES) +int mbedtls_aes_crypt_ctr(mbedtls_aes_context * ctx, size_t length, size_t * nc_off, unsigned char nonce_counter[16], + unsigned char stream_block[16], const unsigned char * input, unsigned char * output) +{ + uint8_t * key; + uint32_t keySize; + + key = (uint8_t *) ctx->rk; + keySize = ctx->nr; + LTC_AES_CryptCtr(LTC_INSTANCE, input, output, length, nonce_counter, key, keySize, stream_block, (uint32_t *) nc_off); + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_LPC_AES) +int mbedtls_aes_crypt_ctr(mbedtls_aes_context * ctx, size_t length, size_t * nc_off, unsigned char nonce_counter[16], + unsigned char stream_block[16], const unsigned char * input, unsigned char * output) +{ + uint8_t * key; + size_t keySize; + + key = (uint8_t *) ctx->rk; + keySize = (size_t) ctx->nr; + + AES_128_CTR(input, length, nonce_counter, key, output); + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_CAAM_AES) +int mbedtls_aes_crypt_ctr(mbedtls_aes_context * ctx, size_t length, size_t * nc_off, unsigned char nonce_counter[16], + unsigned char stream_block[16], const unsigned char * input, unsigned char * output) +{ + uint8_t * key; + uint32_t keySize; + + key = (uint8_t *) ctx->rk; + keySize = ctx->nr; + + CAAM_AES_CryptCtr(CAAM_INSTANCE, &s_caamHandle, input, output, length, nonce_counter, key, keySize, stream_block, nc_off); + + return (0); +} +#endif +#endif /* MBEDTLS_CIPHER_MODE_CTR */ + +#if defined(MBEDTLS_CIPHER_CMAC_ALT) && defined(MBEDTLS_CMAC_C) + +#include "mbedtls/cipher.h" +#include "mbedtls/cmac.h" + +#if defined(MBEDTLS_FREESCALE_CAU3_CIPHER_CMAC) +int mbedtls_cipher_cmac(const mbedtls_cipher_info_t * cipher_info, const unsigned char * key, size_t keylen, + const unsigned char * input, size_t ilen, unsigned char * output) +{ + mbedtls_cipher_context_t ctx; + int ret; + + if (cipher_info == NULL || key == NULL || input == NULL || output == NULL) + return (MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA); + + mbedtls_cipher_init(&ctx); + + if ((ret = mbedtls_cipher_setup(&ctx, cipher_info)) != 0) + goto exit; + + ret = mbedtls_cipher_cmac_starts(&ctx, key, keylen); + if (ret != 0) + goto exit; + + /* AES-CMAC-128 is directly supported by CAU3 firmware */ + if (cipher_info->type == MBEDTLS_CIPHER_AES_128_ECB) + { + status_t status; + uint8_t mac[16]; + + status = CAU3_AES_SetKey(CAU3, &s_cau3Handle, key, keylen / 8u); + if (status != kStatus_Success) + { + ret = MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; + goto exit; + } + status = CAU3_AES_Cmac(CAU3, &s_cau3Handle, input, ilen, mac); + if (status != kStatus_Success) + { + ret = MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; + goto exit; + } + memcpy(output, mac, 16); + } +#if defined(MBEDTLS_CIPHER_CMAC_TDES_ENABLED) || defined(MBEDTLS_CIPHER_CMAC_AES_256_ENABLED) + else if (cipher_info->type == MBEDTLS_CIPHER_AES_192_ECB) + { + /* CAU3 initial firmware does not support AES 192 */ + ret = MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; + goto exit; + } + else + { + /* AES-CMAC-256 and TDES-CMAC. + * If both MBEDTLS_DES_C and MBEDTLS_CIPHER_CMAC_WANTS_AES_256 are undefined, + * this does not compile + */ + ret = mbedtls_cipher_cmac_update(&ctx, input, ilen); + if (ret != 0) + goto exit; + + ret = mbedtls_cipher_cmac_finish(&ctx, output); + } +#else + else + { + ret = MBEDTLS_ERR_CIPHER_BAD_INPUT_DATA; + goto exit; + } +#endif /* MBEDTLS_CIPHER_CMAC_TDES_ENABLED || MBEDTLS_CIPHER_CMAC_AES_256_ENABLED */ + +exit: + mbedtls_cipher_free(&ctx); + + return (ret); +} +#endif /* MBEDTLS_FREESCALE_CAU3_CIPHER_CMAC */ +#endif /* MBEDTLS_CIPHER_CMAC_ALT && MBEDTLS_CMAC_C */ + +#if defined(MBEDTLS_CCM_C) + +#include "mbedtls/ccm.h" + +#define CCM_ENCRYPT 0 +#define CCM_DECRYPT 1 + +/* + * Authenticated encryption or decryption + */ +#if defined(MBEDTLS_FREESCALE_LTC_AES) +static int ccm_auth_crypt(mbedtls_ccm_context * ctx, int mode, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + unsigned char * tag, size_t tag_len) +{ + status_t status; + const uint8_t * key; + uint8_t keySize; + mbedtls_aes_context * aes_ctx; + + aes_ctx = (mbedtls_aes_context *) ctx->cipher_ctx.cipher_ctx; + key = (uint8_t *) aes_ctx->rk; + keySize = aes_ctx->nr; + if (mode == CCM_ENCRYPT) + { + status = LTC_AES_EncryptTagCcm(LTC_INSTANCE, input, output, length, iv, iv_len, add, add_len, key, keySize, tag, tag_len); + } + else + { + status = LTC_AES_DecryptTagCcm(LTC_INSTANCE, input, output, length, iv, iv_len, add, add_len, key, keySize, tag, tag_len); + } + + if (status == kStatus_InvalidArgument) + { + return MBEDTLS_ERR_CCM_BAD_INPUT; + } + else if (status != kStatus_Success) + { + return MBEDTLS_ERR_CCM_AUTH_FAILED; + } + + return (0); +} +#elif defined(MBEDTLS_FREESCALE_CAAM_AES) +static int ccm_auth_crypt(mbedtls_ccm_context * ctx, int mode, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + unsigned char * tag, size_t tag_len) +{ + status_t status; + const uint8_t * key; + uint8_t keySize; + mbedtls_aes_context * aes_ctx; + + aes_ctx = (mbedtls_aes_context *) ctx->cipher_ctx.cipher_ctx; + key = (uint8_t *) aes_ctx->rk; + keySize = aes_ctx->nr; + if (mode == CCM_ENCRYPT) + { + status = CAAM_AES_EncryptTagCcm(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, iv_len, add, add_len, key, keySize, + tag, tag_len); + } + else + { + status = CAAM_AES_DecryptTagCcm(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, iv_len, add, add_len, key, keySize, + tag, tag_len); + } + + if (status == kStatus_InvalidArgument) + { + return MBEDTLS_ERR_CCM_BAD_INPUT; + } + else if (status != kStatus_Success) + { + return MBEDTLS_ERR_CCM_AUTH_FAILED; + } + + return (0); +} +#endif /* MBEDTLS_FREESCALE_LTC_AES */ + +#if defined(MBEDTLS_FREESCALE_LTC_AES) || defined(MBEDTLS_FREESCALE_CAAM_AES) +/* + * Authenticated encryption + */ +int mbedtls_ccm_encrypt_and_tag(mbedtls_ccm_context * ctx, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + unsigned char * tag, size_t tag_len) +{ + return (ccm_auth_crypt(ctx, CCM_ENCRYPT, length, iv, iv_len, add, add_len, input, output, tag, tag_len)); +} + +/* + * Authenticated decryption + */ +int mbedtls_ccm_auth_decrypt(mbedtls_ccm_context * ctx, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + const unsigned char * tag, size_t tag_len) +{ + unsigned char tagCopy[16]; + unsigned char * actTag = NULL; + if (tag) + { + memcpy(tagCopy, tag, tag_len); + actTag = tagCopy; + } + return (ccm_auth_crypt(ctx, CCM_DECRYPT, length, iv, iv_len, add, add_len, input, output, actTag, tag_len)); +} +#endif /* MBEDTLS_FREESCALE_LTC_AES || MBEDTLS_FREESCALE_CAAM_AES */ +#endif /* MBEDTLS_CCM_C */ + +#if defined(MBEDTLS_GCM_C) +#if defined(MBEDTLS_FREESCALE_LTC_AES_GCM) + +#include "mbedtls/gcm.h" + +int mbedtls_gcm_crypt_and_tag(mbedtls_gcm_context * ctx, int mode, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + size_t tag_len, unsigned char * tag) +{ + status_t status; + uint8_t * key; + uint32_t keySize; + mbedtls_aes_context * aes_ctx; + + ctx->len = length; + ctx->add_len = add_len; + aes_ctx = (mbedtls_aes_context *) ctx->cipher_ctx.cipher_ctx; + key = (uint8_t *) aes_ctx->rk; + keySize = aes_ctx->nr; + if (mode == MBEDTLS_GCM_ENCRYPT) + { + status = LTC_AES_EncryptTagGcm(LTC_INSTANCE, input, output, length, iv, iv_len, add, add_len, key, keySize, tag, tag_len); + } + else + { + status = LTC_AES_DecryptTagGcm(LTC_INSTANCE, input, output, length, iv, iv_len, add, add_len, key, keySize, tag, tag_len); + } + + if (status == kStatus_InvalidArgument) + { + return MBEDTLS_ERR_GCM_BAD_INPUT; + } + else if (status != kStatus_Success) + { + return MBEDTLS_ERR_GCM_AUTH_FAILED; + } + + return 0; +} + +int mbedtls_gcm_auth_decrypt(mbedtls_gcm_context * ctx, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * tag, size_t tag_len, + const unsigned char * input, unsigned char * output) +{ + unsigned char tag_copy[16]; + unsigned char * actTag = NULL; + if (tag) + { + memcpy(tag_copy, tag, tag_len); + actTag = tag_copy; + } + return (mbedtls_gcm_crypt_and_tag(ctx, MBEDTLS_GCM_DECRYPT, length, iv, iv_len, add, add_len, input, output, tag_len, actTag)); +} + +#elif defined(MBEDTLS_FREESCALE_LPC_AES_GCM) + +#include "mbedtls/gcm.h" + +int mbedtls_gcm_crypt_and_tag(mbedtls_gcm_context * ctx, int mode, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + size_t tag_len, unsigned char * tag) +{ + status_t status; + uint8_t * key; + size_t keySize; + mbedtls_aes_context * aes_ctx; + + ctx->len = length; + ctx->add_len = add_len; + aes_ctx = (mbedtls_aes_context *) ctx->cipher_ctx.cipher_ctx; + key = (uint8_t *) aes_ctx->rk; + keySize = (size_t) aes_ctx->nr; + + status = AES_SetKey(AES_INSTANCE, key, keySize); + if (status != kStatus_Success) + { + return MBEDTLS_ERR_GCM_BAD_INPUT; + } + + if (mode == MBEDTLS_GCM_ENCRYPT) + { + status = AES_EncryptTagGcm(AES_INSTANCE, input, output, length, iv, iv_len, add, add_len, tag, tag_len); + } + else + { + status = AES_DecryptTagGcm(AES_INSTANCE, input, output, length, iv, iv_len, add, add_len, tag, tag_len); + } + + if (status == kStatus_InvalidArgument) + { + return MBEDTLS_ERR_GCM_BAD_INPUT; + } + else if (status != kStatus_Success) + { + return MBEDTLS_ERR_GCM_AUTH_FAILED; + } + + return 0; +} + +int mbedtls_gcm_auth_decrypt(mbedtls_gcm_context * ctx, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * tag, size_t tag_len, + const unsigned char * input, unsigned char * output) +{ + unsigned char tag_copy[16]; + + memcpy(tag_copy, tag, tag_len); + return ( + mbedtls_gcm_crypt_and_tag(ctx, MBEDTLS_GCM_DECRYPT, length, iv, iv_len, add, add_len, input, output, tag_len, tag_copy)); +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_AES_GCM) + +#include "mbedtls/gcm.h" + +int mbedtls_gcm_crypt_and_tag(mbedtls_gcm_context * ctx, int mode, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * input, unsigned char * output, + size_t tag_len, unsigned char * tag) +{ + status_t status; + uint8_t * key; + uint32_t keySize; + mbedtls_aes_context * aes_ctx; + + ctx->len = length; + ctx->add_len = add_len; + aes_ctx = (mbedtls_aes_context *) ctx->cipher_ctx.cipher_ctx; + key = (uint8_t *) aes_ctx->rk; + keySize = aes_ctx->nr; + if (mode == MBEDTLS_GCM_ENCRYPT) + { + status = CAAM_AES_EncryptTagGcm(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, iv_len, add, add_len, key, keySize, + tag, tag_len); + } + else + { + status = CAAM_AES_DecryptTagGcm(CAAM_INSTANCE, &s_caamHandle, input, output, length, iv, iv_len, add, add_len, key, keySize, + tag, tag_len); + } + + if (status == kStatus_InvalidArgument) + { + return MBEDTLS_ERR_GCM_BAD_INPUT; + } + else if (status != kStatus_Success) + { + return MBEDTLS_ERR_GCM_AUTH_FAILED; + } + + return 0; +} + +int mbedtls_gcm_auth_decrypt(mbedtls_gcm_context * ctx, size_t length, const unsigned char * iv, size_t iv_len, + const unsigned char * add, size_t add_len, const unsigned char * tag, size_t tag_len, + const unsigned char * input, unsigned char * output) +{ + unsigned char tag_copy[16]; + unsigned char * actTag = NULL; + if (tag) + { + memcpy(tag_copy, tag, tag_len); + actTag = tag_copy; + } + return (mbedtls_gcm_crypt_and_tag(ctx, MBEDTLS_GCM_DECRYPT, length, iv, iv_len, add, add_len, input, output, tag_len, actTag)); +} +#endif +#endif /* MBEDTLS_GCM_C */ + +#endif /* MBEDTLS_FREESCALE_LTC_AES || MBEDTLS_FREESCALE_MMCAU_AES || MBEDTLS_FREESCALE_LPC_AES */ + +#endif /* MBEDTLS_AES_C */ + +/******************************************************************************/ +/*************************** PKHA *********************************************/ +/******************************************************************************/ + +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) || defined(MBEDTLS_FREESCALE_CAAM_PKHA) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +static void ltc_reverse_array(uint8_t * src, size_t src_len) +{ + int i; + + for (i = 0; i < src_len / 2; i++) + { + uint8_t tmp; + + tmp = src[i]; + src[i] = src[src_len - 1 - i]; + src[src_len - 1 - i] = tmp; + } +} + +#if defined(MBEDTLS_BIGNUM_C) + +#include "mbedtls/bignum.h" + +#if defined(MBEDTLS_FREESCALE_CAU3_PKHA) +#define LTC_PKHA_ModAdd CAU3_PKHA_ModAdd +#define LTC_PKHA_ModSub1 CAU3_PKHA_ModSub1 +#define LTC_PKHA_ModMul CAU3_PKHA_ModMul +#define LTC_PKHA_ModRed CAU3_PKHA_ModRed +#define LTC_PKHA_ModExp CAU3_PKHA_ModExp +#define LTC_PKHA_GCD CAU3_PKHA_ModGcd +#define LTC_PKHA_ModInv CAU3_PKHA_ModInv +#define LTC_PKHA_PrimalityTest CAU3_PKHA_PrimalityTest +#define LTC_INSTANCE ((CAU3_Type *) CAU3_BASE) + +#define kLTC_PKHA_IntegerArith kCAU3_PKHA_IntegerArith +#define kLTC_PKHA_NormalValue kCAU3_PKHA_NormalValue +#define kLTC_PKHA_TimingEqualized kCAU3_PKHA_TimingEqualized + +#define cau3_reverse_array ltc_reverse_array +#define cau3_get_from_mbedtls_mpi ltc_get_from_mbedtls_mpi +#endif + +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) +typedef uint16_t pkha_size_t; +#else +typedef size_t pkha_size_t; +#endif + +#if defined(MBEDTLS_MPI_ADD_ABS_ALT) + +/* Access to original version of mbedtls_mpi_add_abs function. */ +int mbedtls_mpi_add_abs_orig(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B); + +/* + * Unsigned addition: X = |A| + |B| (HAC 14.7) + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_add_abs(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + pkha_size_t sizeN = FREESCALE_PKHA_INT_MAX_BYTES; + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + /* + * Perform HW acceleration only if the size in bytes is less than maximum. + * Since modular add is used below, the result would be wrong + * if the real sum of operands exceeded LTC maximum number value. + */ + if ((sizeA < sizeN) && (sizeB < sizeN)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * N = mbedtls_calloc(4, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = N + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == N) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + memset(N, 0xFF, sizeN); + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(B, ptrB, sizeB); + ltc_reverse_array(ptrB, sizeB); + + ret = (int) LTC_PKHA_ModAdd(LTC_INSTANCE, ptrA, sizeA, ptrB, sizeB, N, sizeN, ptrC, &sizeC, kLTC_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrC, sizeC); + mbedtls_mpi_read_binary(X, ptrC, sizeC); + X->s = 1; + cleanup: + if (N) + { + mbedtls_free(N); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_add_abs_orig(X, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_add_abs(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + pkha_size_t sizeN = FREESCALE_PKHA_INT_MAX_BYTES; + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + /* + * Perform HW acceleration only if the size in bytes is less than maximum. + * Since modular add is used below, the result would be wrong + * if the real sum of operands exceeded CAAM maximum number value. + */ + if ((sizeA < sizeN) && (sizeB < sizeN)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * N = mbedtls_calloc(4, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = N + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == N) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + memset(N, 0xFF, sizeN); + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + mbedtls_mpi_write_binary(B, ptrB, sizeB); + + ret = (int) CAAM_PKHA_ModAdd(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrB, sizeB, N, sizeN, ptrC, &sizeC, + kCAAM_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(X, ptrC, sizeC); + X->s = 1; + cleanup: + if (N) + { + mbedtls_free(N); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_add_abs_orig(X, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_ADD_ABS_ALT */ + +#if defined(MBEDTLS_MPI_SUB_ABS_ALT) + +/* Access to original version of mbedtls_mpi_sub_abs function. */ +int mbedtls_mpi_sub_abs_orig(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B); + +/* + * Unsigned subtraction: X = |A| - |B| (HAC 14.9) + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_sub_abs(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + pkha_size_t sizeN = FREESCALE_PKHA_INT_MAX_BYTES; + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + /* + * Perform HW acceleration only if |A| >= |B|. Since modular subtraction is used below, + * the result would be wrong if the real sum of operands exceeded maximum. + */ + if ((sizeA <= sizeN) && (sizeB <= sizeN) && (mbedtls_mpi_cmp_abs(A, B) >= 0)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * N = mbedtls_calloc(4, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = N + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == N) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + memset(N, 0xFF, sizeN); + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(B, ptrB, sizeB); + ltc_reverse_array(ptrB, sizeB); + + ret = (int) LTC_PKHA_ModSub1(LTC_INSTANCE, ptrA, sizeA, ptrB, sizeB, N, sizeN, ptrC, &sizeC); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrC, sizeC); + mbedtls_mpi_read_binary(X, ptrC, sizeC); + X->s = 1; + cleanup: + if (N) + { + mbedtls_free(N); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_sub_abs_orig(X, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_sub_abs(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + pkha_size_t sizeN = FREESCALE_PKHA_INT_MAX_BYTES; + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + /* + * Perform HW acceleration only if |A| >= |B|. Since modular subtraction is used below, + * the result would be wrong if the real sum of operands exceeded maximum. + */ + if ((sizeA <= sizeN) && (sizeB <= sizeN) && (mbedtls_mpi_cmp_abs(A, B) >= 0)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * N = mbedtls_calloc(4, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = N + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == N) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + memset(N, 0xFF, sizeN); + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + mbedtls_mpi_write_binary(B, ptrB, sizeB); + + ret = (int) CAAM_PKHA_ModSub1(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrB, sizeB, N, sizeN, ptrC, &sizeC); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(X, ptrC, sizeC); + X->s = 1; + cleanup: + if (N) + { + mbedtls_free(N); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_sub_abs_orig(X, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_SUB_ABS_ALT */ + +#if defined(MBEDTLS_MPI_MUL_MPI_ALT) + +/* Access to original version of mbedtls_mpi_mul_mpi function. */ +int mbedtls_mpi_mul_mpi_orig(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B); + +/* + * Baseline multiplication: X = A * B (HAC 14.12) + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_mul_mpi(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + pkha_size_t sizeN = FREESCALE_PKHA_INT_MAX_BYTES; + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + /* + * Should be "if ((sizeA + sizeB) <= sizeN)", but if the multiplication result + * would be maximum LTC number (the same value as the modulus N below), + * zero would be returned instead, which is wrong value. + */ + if ((sizeA + sizeB) < sizeN) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + int sign = A->s * B->s; + + uint8_t * N = mbedtls_calloc(4, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = N + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == N) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + memset(N, 0xFF, sizeN); + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(B, ptrB, sizeB); + ltc_reverse_array(ptrB, sizeB); + + /* + * Modular multiplication operation is used here. Since the modulus N is larger + * than the expected result of A * B, the effect is normal multiplication. + * TODO use PKHA MUL_IM_OM instead. + */ + ret = (int) LTC_PKHA_ModMul(LTC_INSTANCE, ptrA, sizeA, ptrB, sizeB, N, sizeN, ptrC, &sizeC, kLTC_PKHA_IntegerArith, + kLTC_PKHA_NormalValue, kLTC_PKHA_NormalValue, kLTC_PKHA_TimingEqualized); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrC, sizeC); + mbedtls_mpi_read_binary(X, ptrC, sizeC); + X->s = sign; + cleanup: + if (N) + { + mbedtls_free(N); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_mul_mpi_orig(X, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_mul_mpi(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + pkha_size_t sizeN = FREESCALE_PKHA_INT_MAX_BYTES; + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + /* + * Should be "if ((sizeA + sizeB) <= sizeN)", but if the multiplication result + * would be maximum CAAM number (the same value as the modulus N below), + * zero would be returned instead, which is wrong value. + */ + if ((sizeA + sizeB) < sizeN) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + int sign = A->s * B->s; + + uint8_t * N = mbedtls_calloc(4, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = N + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == N) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + memset(N, 0xFF, sizeN); + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + mbedtls_mpi_write_binary(B, ptrB, sizeB); + + /* + * Modular multiplication operation is used here. Since the modulus N is larger + * than the expected result of A * B, the effect is normal multiplication. + * TODO use PKHA MUL_IM_OM instead. + */ + ret = (int) CAAM_PKHA_ModMul(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrB, sizeB, N, sizeN, ptrC, &sizeC, + kCAAM_PKHA_IntegerArith, kCAAM_PKHA_NormalValue, kCAAM_PKHA_NormalValue, + kCAAM_PKHA_TimingEqualized); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(X, ptrC, sizeC); + X->s = sign; + cleanup: + if (N) + { + mbedtls_free(N); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_mul_mpi_orig(X, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_MUL_MPI_ALT */ + +#if defined(MBEDTLS_MPI_MOD_MPI_ALT) + +/* Access to original version of mbedtls_mpi_mod_mpi function. */ +int mbedtls_mpi_mod_mpi_orig(mbedtls_mpi * R, const mbedtls_mpi * A, const mbedtls_mpi * B); + +/* + * Modulo: R = A mod B + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_mod_mpi(mbedtls_mpi * R, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeA <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeB <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + int sign = A->s; + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(B, ptrB, sizeB); + ltc_reverse_array(ptrB, sizeB); + + ret = (int) LTC_PKHA_ModRed(LTC_INSTANCE, ptrA, sizeA, ptrB, sizeB, ptrC, &sizeC, kLTC_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrC, sizeC); + mbedtls_mpi_read_binary(R, ptrC, sizeC); + R->s = sign; + + while (mbedtls_mpi_cmp_int(R, 0) < 0) + mbedtls_mpi_add_mpi(R, R, B); /* MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( R, R, B ) ); */ + + while (mbedtls_mpi_cmp_mpi(R, B) >= 0) + mbedtls_mpi_sub_mpi(R, R, B); /* MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( R, R, B ) ); cleanup:*/ + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_mod_mpi_orig(R, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_mod_mpi(mbedtls_mpi * R, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeA <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeB <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + int sign = A->s; + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + mbedtls_mpi_write_binary(B, ptrB, sizeB); + + ret = (int) CAAM_PKHA_ModRed(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrB, sizeB, ptrC, &sizeC, kCAAM_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(R, ptrC, sizeC); + R->s = sign; + + while (mbedtls_mpi_cmp_int(R, 0) < 0) + mbedtls_mpi_add_mpi(R, R, B); /* MBEDTLS_MPI_CHK( mbedtls_mpi_add_mpi( R, R, B ) ); */ + + while (mbedtls_mpi_cmp_mpi(R, B) >= 0) + mbedtls_mpi_sub_mpi(R, R, B); /* MBEDTLS_MPI_CHK( mbedtls_mpi_sub_mpi( R, R, B ) ); cleanup:*/ + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_mod_mpi_orig(R, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_MOD_MPI_ALT */ + +#if defined(MBEDTLS_MPI_EXP_MOD_ALT) + +/* Access to original version of mbedtls_mpi_exp_mod function. */ +int mbedtls_mpi_exp_mod_orig(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * E, const mbedtls_mpi * N, + mbedtls_mpi * _RR); + +/* + * Sliding-window exponentiation: X = A^E mod N (HAC 14.85) + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_exp_mod(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * E, const mbedtls_mpi * N, mbedtls_mpi * _RR) +{ + int ret; + pkha_size_t sizeE = mbedtls_mpi_size(E); + pkha_size_t sizeN = mbedtls_mpi_size(N); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeE <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeN <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + mbedtls_mpi * AA; // TODO rename etc. + + /* + * If number is greater than modulus, we must first reduce it due to LTC requirement + * on modular exponentiaton that it needs number less than modulus. + * We can take advantage of modular arithmetic rule that: A^B mod C = ( (A mod C)^B ) mod C. + * So we do (A mod N) first and if the size of A in bytes fits into LTC, it will be done in LTC + * (here LTC does not give size requirement on A versus N), otherwise it will be done in SW + * and since the size of N fits into LTC, the result of (A mod N) will also fit into LTC. + * Then we can do modular exponentiation in LTC. + */ + if (mbedtls_mpi_cmp_mpi(A, N) >= 0) + { + /* A >= N, perform X = (A mod N). */ + ret = mbedtls_mpi_mod_mpi(X, A, N); + + if (ret != kStatus_Success) + return (MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + /* Exponenciation will be performed with X. */ + AA = X; + } + else + { + /* Exponentiation will be performed with original A. */ + AA = (mbedtls_mpi *) A; + } + + pkha_size_t sizeA = mbedtls_mpi_size(AA); + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrE = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrN = ptrE + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(AA, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(E, ptrE, sizeE); + ltc_reverse_array(ptrE, sizeE); + + mbedtls_mpi_write_binary(N, ptrN, sizeN); + ltc_reverse_array(ptrN, sizeN); + + ret = (int) LTC_PKHA_ModExp(LTC_INSTANCE, ptrA, sizeA, ptrN, sizeN, ptrE, sizeE, ptrN, &sizeN, kLTC_PKHA_IntegerArith, + kLTC_PKHA_NormalValue, kLTC_PKHA_TimingEqualized); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrN, sizeN); + mbedtls_mpi_read_binary(X, ptrN, sizeN); + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_exp_mod_orig(X, A, E, N, _RR); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_exp_mod(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * E, const mbedtls_mpi * N, mbedtls_mpi * _RR) +{ + int ret; + pkha_size_t sizeE = mbedtls_mpi_size(E); + pkha_size_t sizeN = mbedtls_mpi_size(N); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeE <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeN <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + mbedtls_mpi * AA; // TODO rename etc. + + /* + * If number is greater than modulus, we must first reduce it due to CAAM requirement + * on modular exponentiaton that it needs number less than modulus. + * We can take advantage of modular arithmetic rule that: A^B mod C = ( (A mod C)^B ) mod C. + * So we do (A mod N) first and if the size of A in bytes fits into CAAM, it will be done in CAAM + * (here CAAM does not give size requirement on A versus N), otherwise it will be done in SW + * and since the size of N fits into CAAM, the result of (A mod N) will also fit into CAAM. + * Then we can do modular exponentiation in CAAM. + */ + if (mbedtls_mpi_cmp_mpi(A, N) >= 0) + { + /* A >= N, perform X = (A mod N). */ + ret = mbedtls_mpi_mod_mpi(X, A, N); + + if (ret != kStatus_Success) + return (MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + /* Exponenciation will be performed with X. */ + AA = X; + } + else + { + /* Exponentiation will be performed with original A. */ + AA = (mbedtls_mpi *) A; + } + + pkha_size_t sizeA = mbedtls_mpi_size(AA); + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrE = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrN = ptrE + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(AA, ptrA, sizeA); + mbedtls_mpi_write_binary(E, ptrE, sizeE); + mbedtls_mpi_write_binary(N, ptrN, sizeN); + + ret = (int) CAAM_PKHA_ModExp(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrN, sizeN, ptrE, sizeE, ptrN, &sizeN, + kCAAM_PKHA_IntegerArith, kCAAM_PKHA_NormalValue, kCAAM_PKHA_TimingEqualized); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(X, ptrN, sizeN); + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_exp_mod_orig(X, A, E, N, _RR); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_EXP_MOD_ALT */ + +#if defined(MBEDTLS_MPI_GCD_ALT) + +/* Access to original version of mbedtls_mpi_gcd function. */ +int mbedtls_mpi_gcd_orig(mbedtls_mpi * G, const mbedtls_mpi * A, const mbedtls_mpi * B); + +/* + * Greatest common divisor: G = gcd(A, B) (HAC 14.54) + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_gcd(mbedtls_mpi * G, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeA <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeB <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(B, ptrB, sizeB); + ltc_reverse_array(ptrB, sizeB); + + if (mbedtls_mpi_cmp_mpi(A, B) >= 0) + { + ret = (int) LTC_PKHA_ModRed(LTC_INSTANCE, ptrA, sizeA, ptrB, sizeB, ptrA, &sizeA, kLTC_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + + ret = (int) LTC_PKHA_GCD(LTC_INSTANCE, ptrA, sizeA, ptrB, sizeB, ptrC, &sizeC, kLTC_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrC, sizeC); + mbedtls_mpi_read_binary(G, ptrC, sizeC); + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_gcd_orig(G, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_gcd(mbedtls_mpi * G, const mbedtls_mpi * A, const mbedtls_mpi * B) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeB = mbedtls_mpi_size(B); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeA <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeB <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrB = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrB + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + mbedtls_mpi_write_binary(B, ptrB, sizeB); + + if (mbedtls_mpi_cmp_mpi(A, B) >= 0) + { + ret = (int) CAAM_PKHA_ModRed(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrB, sizeB, ptrA, &sizeA, + kCAAM_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + + ret = (int) CAAM_PKHA_ModGcd(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrB, sizeB, ptrC, &sizeC, kCAAM_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(G, ptrC, sizeC); + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_gcd_orig(G, A, B); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_GCD_ALT */ + +#if defined(MBEDTLS_MPI_INV_MOD_ALT) + +/* Access to original version of mbedtls_mpi_inv_mod function. */ +int mbedtls_mpi_inv_mod_orig(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * N); + +/* + * Modular inverse: X = A^-1 mod N (HAC 14.61 / 14.64) + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_inv_mod(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * N) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeN = mbedtls_mpi_size(N); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeA <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeN <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrN = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrN + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + /* N cannot be negative */ + if (N->s < 0 || mbedtls_mpi_cmp_int(N, 0) == 0) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_BAD_INPUT_DATA); + } + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + ltc_reverse_array(ptrA, sizeA); + + mbedtls_mpi_write_binary(N, ptrN, sizeN); + ltc_reverse_array(ptrN, sizeN); + + if (mbedtls_mpi_cmp_mpi(A, N) >= 0) + { + ret = (int) LTC_PKHA_ModRed(LTC_INSTANCE, ptrA, sizeA, ptrN, sizeN, ptrA, &sizeA, kLTC_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + + ret = (int) LTC_PKHA_ModInv(LTC_INSTANCE, ptrA, sizeA, ptrN, sizeN, ptrC, &sizeC, kLTC_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + ltc_reverse_array(ptrC, sizeC); + mbedtls_mpi_read_binary(X, ptrC, sizeC); + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_inv_mod_orig(X, A, N); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_inv_mod(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * N) +{ + pkha_size_t sizeA = mbedtls_mpi_size(A); + pkha_size_t sizeN = mbedtls_mpi_size(N); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if ((sizeA <= FREESCALE_PKHA_INT_MAX_BYTES) && (sizeN <= FREESCALE_PKHA_INT_MAX_BYTES)) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + pkha_size_t sizeC; + uint8_t * ptrA = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrN = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrC = ptrN + FREESCALE_PKHA_INT_MAX_BYTES; + if (NULL == ptrA) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + /* N cannot be negative */ + if (N->s < 0 || mbedtls_mpi_cmp_int(N, 0) == 0) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_BAD_INPUT_DATA); + } + + mbedtls_mpi_write_binary(A, ptrA, sizeA); + mbedtls_mpi_write_binary(N, ptrN, sizeN); + + if (mbedtls_mpi_cmp_mpi(A, N) >= 0) + { + ret = (int) CAAM_PKHA_ModRed(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrN, sizeN, ptrA, &sizeA, + kCAAM_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + + ret = (int) CAAM_PKHA_ModInv(CAAM_INSTANCE, &s_caamHandle, ptrA, sizeA, ptrN, sizeN, ptrC, &sizeC, kCAAM_PKHA_IntegerArith); + + if (ret != kStatus_Success) + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + + mbedtls_mpi_read_binary(X, ptrC, sizeC); + cleanup: + if (ptrA) + { + mbedtls_free(ptrA); + } + return (ret); +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_inv_mod_orig(X, A, N); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_INV_MOD_ALT */ + +#if defined(MBEDTLS_MPI_IS_PRIME_ALT) + +/* Access to original version of mbedtls_mpi_is_prime function. */ +int mbedtls_mpi_is_prime_orig(const mbedtls_mpi * X, int (*f_rng)(void *, unsigned char *, size_t), void * p_rng); + +/* + * Pseudo-primality test: small factors, then Miller-Rabin + */ +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int mbedtls_mpi_is_prime(const mbedtls_mpi * X, int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) +{ + pkha_size_t sizeX = mbedtls_mpi_size(X); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if (sizeX <= FREESCALE_PKHA_INT_MAX_BYTES) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + int random; + bool result = false; + uint8_t * ptrX = mbedtls_calloc(1, FREESCALE_PKHA_INT_MAX_BYTES); + if (NULL == ptrX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(X, ptrX, FREESCALE_PKHA_INT_MAX_BYTES); + ltc_reverse_array(ptrX, FREESCALE_PKHA_INT_MAX_BYTES); + + // Get the random seed number + f_rng(p_rng, (unsigned char *) (&random), sizeof(random)); + + ret = (int) LTC_PKHA_PrimalityTest(LTC_INSTANCE, (unsigned char *) &random, sizeof(random), (const uint8_t *) "1", 1u, ptrX, + sizeX, &result); + + if (ret != kStatus_Success) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + + if (result == false) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + cleanup: + if (ptrX) + { + mbedtls_free(ptrX); + } + return ret; +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_is_prime_orig(X, f_rng, p_rng); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int mbedtls_mpi_is_prime(const mbedtls_mpi * X, int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) +{ + pkha_size_t sizeX = mbedtls_mpi_size(X); + +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + if (sizeX <= FREESCALE_PKHA_INT_MAX_BYTES) + { +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ + int ret; + int random; + bool result = false; + uint8_t * ptrX = mbedtls_calloc(1, FREESCALE_PKHA_INT_MAX_BYTES); + if (NULL == ptrX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + mbedtls_mpi_write_binary(X, ptrX, FREESCALE_PKHA_INT_MAX_BYTES); + + // Get the random seed number + f_rng(p_rng, (unsigned char *) (&random), sizeof(random)); + + ret = (int) CAAM_PKHA_PrimalityTest(CAAM_INSTANCE, &s_caamHandle, (unsigned char *) &random, sizeof(random), + (const uint8_t *) "1", 1u, ptrX, sizeX, &result); + + if (ret != kStatus_Success) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + + if (result == false) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_NOT_ACCEPTABLE); + } + cleanup: + if (ptrX) + { + mbedtls_free(ptrX); + } + return ret; +#if defined(FREESCALE_PKHA_LONG_OPERANDS_ENABLE) + } + else + { + return mbedtls_mpi_is_prime_orig(X, f_rng, p_rng); + } +#endif /* FREESCALE_PKHA_LONG_OPERANDS_ENABLE */ +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA || MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_MPI_IS_PRIME_ALT */ + +#endif /* MBEDTLS_BIGNUM_C */ + +#if defined(MBEDTLS_ECP_C) + +#include "mbedtls/ecp.h" + +#define LTC_MAX_ECC (512) +#define CAAM_MAX_ECC (528) +#define CAU3_MAX_ECC (512) + +typedef enum +{ + kBigEndian = 0U, + kLittleEndian = 1U +} endian_t; + +/* convert from mbedtls_mpi to LTC or CAAM integer, as array of bytes of size sz. + * if mbedtls_mpi has less bytes than sz, add zero bytes at most significant byte positions. + * This is when for example modulus is 32 bytes (P-256 curve) + * and mbedtls_mpi has only 31 bytes, we add leading zeroes + * so that result array has 32 bytes, same as modulus (sz). + */ +#if defined(MBEDTLS_ECP_MUL_COMB_ALT) || defined(MBEDTLS_ECP_ADD_ALT) +static int get_and_extend_mbedtls_mpi(uint8_t * dst, const mbedtls_mpi * a, size_t sz, endian_t endian) +{ + size_t szbin; + int offset; + int ret; + + /* check how many bytes are in the mbedtls_mpi */ + szbin = mbedtls_mpi_size(a); + + /* compute offset from dst */ + offset = sz - szbin; + if (offset < 0) + offset = 0; + if (offset > sz) + offset = sz; + + /* add leading zeroes */ + if (offset) + memset(dst, 0, offset); + + /* convert mbedtls_mpi to array of bytes */ + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(a, dst + offset, szbin)); + + /* reverse array for LTC direct use */ + if (endian == kLittleEndian) + ltc_reverse_array(dst, sz); +cleanup: + return (ret); +} + +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) || defined(MBEDTLS_FREESCALE_CAU3_PKHA) +static int ltc_get_from_mbedtls_mpi(uint8_t * dst, const mbedtls_mpi * a, size_t sz) +{ + return get_and_extend_mbedtls_mpi(dst, a, sz, kLittleEndian); +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +static int caam_get_from_mbedtls_mpi(uint8_t * dst, const mbedtls_mpi * a, size_t sz) +{ + return get_and_extend_mbedtls_mpi(dst, a, sz, kBigEndian); +} +#endif /* MBEDTLS_FREESCALE_LTC_PKHA */ +#endif /* MBEDTLS_ECP_MUL_COMB_ALT || MBEDTLS_ECP_ADD_ALT */ + +/* + * Multiplication using the comb method, + * for curves in short Weierstrass form + */ +#if defined(MBEDTLS_ECP_MUL_COMB_ALT) +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) +int ecp_mul_comb(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, + int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) +{ + int ret; + bool is_inf; + size_t size; + size_t size_bin; + int sign = m->s; + + ltc_pkha_ecc_point_t A; + ltc_pkha_ecc_point_t result; + + /* Allocate 7 elements with size of (LTC_MAX_ECC / 8) plus ptrE with size of FREESCALE_PKHA_INT_MAX_BYTES */ + uint8_t * ptrAX = mbedtls_calloc((7 * (LTC_MAX_ECC / 8)) + FREESCALE_PKHA_INT_MAX_BYTES, 1); + uint8_t * ptrAY = ptrAX + (LTC_MAX_ECC / 8); + uint8_t * ptrRX = ptrAY + (LTC_MAX_ECC / 8); + uint8_t * ptrRY = ptrRX + (LTC_MAX_ECC / 8); + uint8_t * ptrN = ptrRY + (LTC_MAX_ECC / 8); + uint8_t * ptrParamA = ptrN + (LTC_MAX_ECC / 8); + uint8_t * ptrParamB = ptrParamA + (LTC_MAX_ECC / 8); + uint8_t * ptrE = ptrParamB + (LTC_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + A.X = ptrAX; + A.Y = ptrAY; + result.X = ptrRX; + result.Y = ptrRY; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (LTC_MAX_ECC / 8) || (mbedtls_mpi_get_bit(&grp->N, 0) != 1)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(A.X, &P->X, size)); + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(A.Y, &P->Y, size)); + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(ptrParamA, &grp->A, size)); + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(ptrParamB, &grp->B, size)); + + /* scalar multiplier integer of any size */ + size_bin = mbedtls_mpi_size(m); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(m, ptrE, size_bin)); + ltc_reverse_array(ptrE, size_bin); + + /* modulus */ + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&grp->P, ptrN, size)); + ltc_reverse_array(ptrN, size); + + /* Multiply */ + LTC_PKHA_ECC_PointMul(LTC_INSTANCE, &A, ptrE, size_bin, ptrN, NULL, ptrParamA, ptrParamB, size, kLTC_PKHA_TimingEqualized, + kLTC_PKHA_IntegerArith, &result, &is_inf); + /* Convert result */ + ltc_reverse_array(ptrRX, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + ltc_reverse_array(ptrRY, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->Y, ptrRY, size)); + /* if the integer multiplier is negative, the computation happens with abs() value + * and the result (x,y) is changed to (x, -y) + */ + R->Y.s = sign; + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int ecp_mul_comb(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, + int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) +{ + int ret; + size_t size; + size_t size_bin; + int sign = m->s; + + caam_pkha_ecc_point_t A; + caam_pkha_ecc_point_t result; + + /* Allocate 7 elements with size of (CAAM_MAX_ECC / 8) plus ptrE with size of FREESCALE_PKHA_INT_MAX_BYTES */ + uint8_t * ptrAX = mbedtls_calloc((7 * (CAAM_MAX_ECC / 8)) + FREESCALE_PKHA_INT_MAX_BYTES, 1); + uint8_t * ptrAY = ptrAX + (CAAM_MAX_ECC / 8); + uint8_t * ptrRX = ptrAY + (CAAM_MAX_ECC / 8); + uint8_t * ptrRY = ptrRX + (CAAM_MAX_ECC / 8); + uint8_t * ptrN = ptrRY + (CAAM_MAX_ECC / 8); + uint8_t * ptrParamA = ptrN + (CAAM_MAX_ECC / 8); + uint8_t * ptrParamB = ptrParamA + (CAAM_MAX_ECC / 8); + uint8_t * ptrE = ptrParamB + (CAAM_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + A.X = ptrAX; + A.Y = ptrAY; + result.X = ptrRX; + result.Y = ptrRY; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (CAAM_MAX_ECC / 8) || (mbedtls_mpi_get_bit(&grp->N, 0) != 1)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(A.X, &P->X, size)); + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(A.Y, &P->Y, size)); + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(ptrParamA, &grp->A, size)); + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(ptrParamB, &grp->B, size)); + + /* scalar multiplier integer of any size */ + size_bin = mbedtls_mpi_size(m); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(m, ptrE, size_bin)); + + /* modulus */ + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&grp->P, ptrN, size)); + + /* Multiply */ + CAAM_PKHA_ECC_PointMul(CAAM_INSTANCE, &s_caamHandle, &A, ptrE, size_bin, ptrN, NULL, ptrParamA, ptrParamB, size, + kCAAM_PKHA_TimingEqualized, kCAAM_PKHA_IntegerArith, &result); + /* Convert result */ + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->Y, ptrRY, size)); + /* if the integer multiplier is negative, the computation happens with abs() value + * and the result (x,y) is changed to (x, -y) + */ + R->Y.s = sign; + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#elif defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int ecp_mul_comb(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, + int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) +{ + int ret; + status_t status; + size_t size; + size_t size_bin; + int sign = m->s; + + cau3_pkha_ecc_point_t A; + cau3_pkha_ecc_point_t result; + + /* Allocate 7 elements with size of (CAU3_MAX_ECC / 8) plus ptrE with size of FREESCALE_PKHA_INT_MAX_BYTES */ + uint8_t * ptrAX = mbedtls_calloc((7 * (CAU3_MAX_ECC / 8)) + FREESCALE_PKHA_INT_MAX_BYTES, 1); + uint8_t * ptrAY = ptrAX + (CAU3_MAX_ECC / 8); + uint8_t * ptrRX = ptrAY + (CAU3_MAX_ECC / 8); + uint8_t * ptrRY = ptrRX + (CAU3_MAX_ECC / 8); + uint8_t * ptrN = ptrRY + (CAU3_MAX_ECC / 8); + uint8_t * ptrParamA = ptrN + (CAU3_MAX_ECC / 8); + uint8_t * ptrParamB = ptrParamA + (CAU3_MAX_ECC / 8); + uint8_t * ptrE = ptrParamB + (CAU3_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + A.X = ptrAX; + A.Y = ptrAY; + result.X = ptrRX; + result.Y = ptrRY; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (CAU3_MAX_ECC / 8) || (mbedtls_mpi_get_bit(&grp->N, 0) != 1)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(A.X, &P->X, size)); + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(A.Y, &P->Y, size)); + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(ptrParamA, &grp->A, size)); + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(ptrParamB, &grp->B, size)); + + /* scalar multiplier integer of any size */ + size_bin = mbedtls_mpi_size(m); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(m, ptrE, size_bin)); + cau3_reverse_array(ptrE, size_bin); + + /* modulus */ + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&grp->P, ptrN, size)); + cau3_reverse_array(ptrN, size); + + /* Multiply */ + status = CAU3_PKHA_ECC_PointMul(CAU3, &A, ptrE, size_bin, ptrN, NULL, ptrParamA, ptrParamB, size, kCAU3_PKHA_TimingEqualized, + kCAU3_PKHA_IntegerArith, &result); + + if (status != kStatus_Success) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert result */ + cau3_reverse_array(ptrRX, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + cau3_reverse_array(ptrRY, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->Y, ptrRY, size)); + /* if the integer multiplier is negative, the computation happens with abs() value + * and the result (x,y) is changed to (x, -y) + */ + R->Y.s = sign; + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#endif /* MBEDTLS_FREESCALE_LTC_PKHA */ +#endif /* MBEDTLS_ECP_MUL_COMB_ALT */ + +/* + * Curve types: internal for now, might be exposed later + */ +typedef enum +{ + ECP_TYPE_NONE = 0, + ECP_TYPE_SHORT_WEIERSTRASS, /* y^2 = x^3 + a x + b */ + ECP_TYPE_MONTGOMERY, /* y^2 = x^3 + a x^2 + x */ +} ecp_curve_type; +/* + * Get the type of a curve + */ +static inline ecp_curve_type ecp_get_type(const mbedtls_ecp_group * grp) +{ + if (grp->G.X.p == NULL) + return (ECP_TYPE_NONE); + + if (grp->G.Y.p == NULL) + return (ECP_TYPE_MONTGOMERY); + else + return (ECP_TYPE_SHORT_WEIERSTRASS); +} + +/* + * Addition: R = P + Q, result's coordinates normalized + */ +#if defined(MBEDTLS_ECP_ADD_ALT) +#if defined(MBEDTLS_FREESCALE_LTC_PKHA) +int ecp_add(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_ecp_point * P, const mbedtls_ecp_point * Q) +{ + int ret; + size_t size; + ltc_pkha_ecc_point_t A; + ltc_pkha_ecc_point_t B; + ltc_pkha_ecc_point_t result; + + uint8_t * ptrAX = mbedtls_calloc(9, (LTC_MAX_ECC / 8)); + uint8_t * ptrAY = ptrAX + (LTC_MAX_ECC / 8); + uint8_t * ptrBX = ptrAY + (LTC_MAX_ECC / 8); + uint8_t * ptrBY = ptrBX + (LTC_MAX_ECC / 8); + uint8_t * ptrRX = ptrBY + (LTC_MAX_ECC / 8); + uint8_t * ptrRY = ptrRX + (LTC_MAX_ECC / 8); + uint8_t * ptrN = ptrRY + (LTC_MAX_ECC / 8); + uint8_t * ptrParamA = ptrN + (LTC_MAX_ECC / 8); + uint8_t * ptrParamB = ptrParamA + (LTC_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + if (ecp_get_type(grp) != ECP_TYPE_SHORT_WEIERSTRASS) + CLEAN_RETURN(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); + + A.X = ptrAX; + A.Y = ptrAY; + B.X = ptrBX; + B.Y = ptrBY; + result.X = ptrRX; + result.Y = ptrRY; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (LTC_MAX_ECC / 8) || (mbedtls_mpi_get_bit(&grp->P, 0) != 1)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(A.X, &P->X, size)); + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(A.Y, &P->Y, size)); + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(B.X, &Q->X, size)); + MBEDTLS_MPI_CHK(ltc_get_from_mbedtls_mpi(B.Y, &Q->Y, size)); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&grp->P, ptrN, size)); + ltc_reverse_array(ptrN, size); + /* Multiply */ + LTC_PKHA_ECC_PointAdd(LTC_INSTANCE, &A, &B, ptrN, NULL, ptrParamA, ptrParamB, size, kLTC_PKHA_IntegerArith, &result); + /* Convert result */ + ltc_reverse_array(ptrRX, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + ltc_reverse_array(ptrRY, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->Y, ptrRY, size)); + R->X.s = P->X.s; + R->Y.s = P->Y.s; + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_PKHA) +int ecp_add(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_ecp_point * P, const mbedtls_ecp_point * Q) +{ + int ret; + size_t size; + caam_pkha_ecc_point_t A; + caam_pkha_ecc_point_t B; + caam_pkha_ecc_point_t result; + + uint8_t * ptrAX = mbedtls_calloc(9, (CAAM_MAX_ECC / 8)); + uint8_t * ptrAY = ptrAX + (CAAM_MAX_ECC / 8); + uint8_t * ptrBX = ptrAY + (CAAM_MAX_ECC / 8); + uint8_t * ptrBY = ptrBX + (CAAM_MAX_ECC / 8); + uint8_t * ptrRX = ptrBY + (CAAM_MAX_ECC / 8); + uint8_t * ptrRY = ptrRX + (CAAM_MAX_ECC / 8); + uint8_t * ptrN = ptrRY + (CAAM_MAX_ECC / 8); + uint8_t * ptrParamA = ptrN + (CAAM_MAX_ECC / 8); + uint8_t * ptrParamB = ptrParamA + (CAAM_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + if (ecp_get_type(grp) != ECP_TYPE_SHORT_WEIERSTRASS) + CLEAN_RETURN(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); + + A.X = ptrAX; + A.Y = ptrAY; + B.X = ptrBX; + B.Y = ptrBY; + result.X = ptrRX; + result.Y = ptrRY; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (CAAM_MAX_ECC / 8) || (mbedtls_mpi_get_bit(&grp->P, 0) != 1)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(A.X, &P->X, size)); + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(A.Y, &P->Y, size)); + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(B.X, &Q->X, size)); + MBEDTLS_MPI_CHK(caam_get_from_mbedtls_mpi(B.Y, &Q->Y, size)); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&grp->P, ptrN, size)); + + /* Multiply */ + CAAM_PKHA_ECC_PointAdd(CAAM_INSTANCE, &s_caamHandle, &A, &B, ptrN, NULL, ptrParamA, ptrParamB, size, kCAAM_PKHA_IntegerArith, + &result); + /* Convert result */ + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->Y, ptrRY, size)); + R->X.s = P->X.s; + R->Y.s = P->Y.s; + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#elif defined(MBEDTLS_FREESCALE_CAU3_PKHA) +int ecp_add(const mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_ecp_point * P, const mbedtls_ecp_point * Q) +{ + int ret; + status_t status; + size_t size; + cau3_pkha_ecc_point_t A; + cau3_pkha_ecc_point_t B; + cau3_pkha_ecc_point_t result; + + uint8_t * ptrAX = mbedtls_calloc(9, (CAU3_MAX_ECC / 8)); + uint8_t * ptrAY = ptrAX + (CAU3_MAX_ECC / 8); + uint8_t * ptrBX = ptrAY + (CAU3_MAX_ECC / 8); + uint8_t * ptrBY = ptrBX + (CAU3_MAX_ECC / 8); + uint8_t * ptrRX = ptrBY + (CAU3_MAX_ECC / 8); + uint8_t * ptrRY = ptrRX + (CAU3_MAX_ECC / 8); + uint8_t * ptrN = ptrRY + (CAU3_MAX_ECC / 8); + uint8_t * ptrParamA = ptrN + (CAU3_MAX_ECC / 8); + uint8_t * ptrParamB = ptrParamA + (CAU3_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + if (ecp_get_type(grp) != ECP_TYPE_SHORT_WEIERSTRASS) + CLEAN_RETURN(MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE); + + A.X = ptrAX; + A.Y = ptrAY; + B.X = ptrBX; + B.Y = ptrBY; + result.X = ptrRX; + result.Y = ptrRY; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (CAU3_MAX_ECC / 8) || (mbedtls_mpi_get_bit(&grp->P, 0) != 1)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(A.X, &P->X, size)); + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(A.Y, &P->Y, size)); + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(B.X, &Q->X, size)); + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(B.Y, &Q->Y, size)); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&grp->P, ptrN, size)); + cau3_reverse_array(ptrN, size); + /* Multiply */ + status = CAU3_PKHA_ECC_PointAdd(CAU3, &A, &B, ptrN, NULL, ptrParamA, ptrParamB, size, kCAU3_PKHA_IntegerArith, &result); + + if (status != kStatus_Success) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert result */ + cau3_reverse_array(ptrRX, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + cau3_reverse_array(ptrRY, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->Y, ptrRY, size)); + R->X.s = P->X.s; + R->Y.s = P->Y.s; + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#endif /* MBEDTLS_FREESCALE_LTC_PKHA */ + +#endif /* MBEDTLS_ECP_ADD_ALT */ + +#if defined(MBEDTLS_ECP_MUL_MXZ_ALT) +#if defined(MBEDTLS_FREESCALE_CAU3_PKHA) + +/* curve25519 params - in little endian for CAU3 */ +static const uint8_t s_curve25519_A24[] = { 0x42, 0xdb, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +static const uint8_t s_curve25519_N[] = { 0xed, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f }; + +static const uint8_t s_curve25519_R2modN[] = { 0xa4, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + +int ecp_mul_mxz(mbedtls_ecp_group * grp, mbedtls_ecp_point * R, const mbedtls_mpi * m, const mbedtls_ecp_point * P, + int (*f_rng)(void *, unsigned char *, size_t), void * p_rng) +{ + int ret; + status_t status; + size_t size; + size_t size_bin; + + cau3_pkha_ecc_point_t A; + cau3_pkha_ecc_point_t result; + + /* Allocate 2 elements with size of (CAU3_MAX_ECC / 8) plus ptrE with size of FREESCALE_PKHA_INT_MAX_BYTES */ + uint8_t * ptrAX = mbedtls_calloc((2 * (CAU3_MAX_ECC / 8)) + FREESCALE_PKHA_INT_MAX_BYTES, 1); + uint8_t * ptrRX = ptrAX + (CAU3_MAX_ECC / 8); + uint8_t * ptrE = ptrRX + (CAU3_MAX_ECC / 8); + if (NULL == ptrAX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + A.X = ptrAX; + result.X = ptrRX; + size = mbedtls_mpi_size(&grp->P); + if (mbedtls_mpi_size(&P->X) > (CAAM_MAX_ECC / 8)) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert multi precision integers to arrays */ + MBEDTLS_MPI_CHK(cau3_get_from_mbedtls_mpi(A.X, &P->X, size)); + + /* scalar multiplier integer of any size */ + size_bin = mbedtls_mpi_size(m); + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(m, ptrE, size_bin)); + cau3_reverse_array(ptrE, size_bin); + + /* Multiply */ + status = CAU3_PKHA_ECM_PointMul(CAU3, ptrE, size_bin, A.X, s_curve25519_A24, s_curve25519_N, s_curve25519_R2modN, size, + kCAU3_PKHA_TimingEqualized, result.X); + + if (status != kStatus_Success) + { + CLEAN_RETURN(MBEDTLS_ERR_ECP_BAD_INPUT_DATA); + } + + /* Convert result */ + cau3_reverse_array(ptrRX, size); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&R->X, ptrRX, size)); + MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&R->Z, 1)); + +cleanup: + if (ptrAX) + { + mbedtls_free(ptrAX); + } + return (ret); +} + +#endif /* MBEDTLS_FREESCALE_CAU3_PKHA */ +#endif /* MBEDTLS_ECP_MUL_MXZ_ALT */ + +#endif /* MBEDTLS_ECP_C */ + +#endif /* MBEDTLS_FREESCALE_LTC_PKHA */ + +#if defined(MBEDTLS_RSA_PUBLIC_ALT) +#if defined(MBEDTLS_FREESCALE_CASPER_PKHA) + +#if defined(MBEDTLS_PLATFORM_C) +#include "mbedtls/platform.h" +#else +#include +#define mbedtls_calloc calloc +#define mbedtls_free free +#endif + +#include "mbedtls/bignum.h" +#include "mbedtls/rsa.h" + +static void reverse_array(uint8_t * src, size_t src_len) +{ + int i; + + for (i = 0; i < src_len / 2; i++) + { + uint8_t tmp; + + tmp = src[i]; + src[i] = src[src_len - 1 - i]; + src[src_len - 1 - i] = tmp; + } +} +/* + * Do an RSA public key operation + */ +static int mbedtls_mpi_exp_mod_shim(mbedtls_mpi * X, const mbedtls_mpi * A, const mbedtls_mpi * E, + const mbedtls_mpi * N /*, mbedtls_mpi *_RR */) +{ + int ret = MBEDTLS_ERR_MPI_ALLOC_FAILED; + size_t sizeA = mbedtls_mpi_size(A); + size_t sizeN = mbedtls_mpi_size(N); + uint8_t * ptrX = mbedtls_calloc(3, FREESCALE_PKHA_INT_MAX_BYTES); + uint8_t * ptrA = ptrX + FREESCALE_PKHA_INT_MAX_BYTES; + uint8_t * ptrN = ptrA + FREESCALE_PKHA_INT_MAX_BYTES; + + if (NULL == ptrX) + { + CLEAN_RETURN(MBEDTLS_ERR_MPI_ALLOC_FAILED); + } + + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(A, ptrA, sizeA)); + reverse_array(ptrA, sizeA); + + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(N, ptrN, sizeN)); + reverse_array(ptrN, sizeN); + + CASPER_ModExp(CASPER, ptrA, ptrN, sizeN / 4, E->p[0], ptrX); + + reverse_array(ptrX, sizeN); + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(X, ptrX, sizeN)); +cleanup: + if (ptrX != NULL) + { + mbedtls_free(ptrX); + } + + return ret; +} + +int mbedtls_rsa_public(mbedtls_rsa_context * ctx, const unsigned char * input, unsigned char * output) +{ + int ret; + size_t olen; + mbedtls_mpi T; + + mbedtls_mpi_init(&T); + +#if defined(MBEDTLS_THREADING_C) + if ((ret = mbedtls_mutex_lock(&ctx->mutex)) != 0) + return (ret); +#endif + + MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&T, input, ctx->len)); + + if (mbedtls_mpi_cmp_mpi(&T, &ctx->N) >= 0) + { + ret = MBEDTLS_ERR_MPI_BAD_INPUT_DATA; + goto cleanup; + } + + olen = ctx->len; + + MBEDTLS_MPI_CHK(mbedtls_mpi_exp_mod_shim(&T, &T, &ctx->E, &ctx->N /*, &ctx->RN */)); + + MBEDTLS_MPI_CHK(mbedtls_mpi_write_binary(&T, output, olen)); + +cleanup: +#if defined(MBEDTLS_THREADING_C) + if (mbedtls_mutex_unlock(&ctx->mutex) != 0) + return (MBEDTLS_ERR_THREADING_MUTEX_ERROR); +#endif + + mbedtls_mpi_free(&T); + + if (ret != 0) + return (MBEDTLS_ERR_RSA_PUBLIC_FAILED + ret); + + return (0); +} + +#endif /* MBEDTLS_FREESCALE_CASPER_PKHA */ +#endif /* MBEDTLS_RSA_PUBLIC_ALT */ + +/******************************************************************************/ +/*************************** MD5 **********************************************/ +/******************************************************************************/ + +#if defined(MBEDTLS_MD5_C) + +#if defined(MBEDTLS_FREESCALE_MMCAU_MD5) + +#include "mbedtls/md5.h" + +int mbedtls_internal_md5_process(mbedtls_md5_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = MMCAU_MD5_HashN(data, 1, ctx->state); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_MD5_HW_ACCEL_FAILED; + } + return 0; +} + +#endif /* MBEDTLS_FREESCALE_MMCAU_MD5 */ + +#endif /* MBEDTLS_MD5_C */ + +/******************************************************************************/ +/*************************** SHA1 *********************************************/ +/******************************************************************************/ + +#if defined(MBEDTLS_SHA1_C) + +#if defined(MBEDTLS_FREESCALE_LTC_SHA1) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_init(mbedtls_sha1_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_free(mbedtls_sha1_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_clone(mbedtls_sha1_context * dst, const mbedtls_sha1_context * src) +{ + memcpy(dst, src, sizeof(mbedtls_sha1_context)); +} + +/* + * SHA-1 context setup + */ +int mbedtls_sha1_starts_ret(mbedtls_sha1_context * ctx) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Init(LTC_INSTANCE, ctx, kLTC_Sha1, NULL, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Update(ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 process buffer + */ +int mbedtls_sha1_update_ret(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Update(ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 final digest + */ +int mbedtls_sha1_finish_ret(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Finish(ctx, output, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_MMCAU_SHA1) + +#include "mbedtls/sha1.h" + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = MMCAU_SHA1_HashN(data, 1, ctx->state); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_LPC_SHA1) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_init(mbedtls_sha1_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_free(mbedtls_sha1_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_clone(mbedtls_sha1_context * dst, const mbedtls_sha1_context * src) +{ + memcpy(dst, src, sizeof(mbedtls_sha1_context)); +} + +/* + * SHA-1 context setup + */ +int mbedtls_sha1_starts_ret(mbedtls_sha1_context * ctx) +{ + status_t ret = kStatus_Fail; + ret = SHA_Init(SHA_INSTANCE, ctx, kSHA_Sha1); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = SHA_Update(SHA_INSTANCE, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 process buffer + */ +int mbedtls_sha1_update_ret(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = SHA_Update(SHA_INSTANCE, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 final digest + */ +int mbedtls_sha1_finish_ret(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + size_t outputSize = 20u; + status_t ret = kStatus_Fail; + ret = SHA_Finish(SHA_INSTANCE, ctx, output, &outputSize); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} +#elif defined(MBEDTLS_FREESCALE_CAAM_SHA1) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_init(mbedtls_sha1_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_free(mbedtls_sha1_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_clone(mbedtls_sha1_context * dst, const mbedtls_sha1_context * src) +{ + memcpy(dst, src, sizeof(mbedtls_sha1_context)); +} + +/* + * SHA-1 context setup + */ +int mbedtls_sha1_starts_ret(mbedtls_sha1_context * ctx) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Init(CAAM_INSTANCE, &s_caamHandle, ctx, kCAAM_Sha1, NULL, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Update(ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 process buffer + */ +int mbedtls_sha1_update_ret(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Update(ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 final digest + */ +int mbedtls_sha1_finish_ret(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Finish(ctx, output, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_CAU3_SHA1) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_init(mbedtls_sha1_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_free(mbedtls_sha1_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_clone(mbedtls_sha1_context * dst, const mbedtls_sha1_context * src) +{ + memcpy(dst, src, sizeof(mbedtls_sha1_context)); +} + +/* + * SHA-1 context setup + */ +int mbedtls_sha1_starts_ret(mbedtls_sha1_context * ctx) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Init(CAU3, ctx, kCAU3_Sha1); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Update(CAU3, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 process buffer + */ +int mbedtls_sha1_update_ret(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Update(CAU3, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 final digest + */ +int mbedtls_sha1_finish_ret(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Finish(CAU3, ctx, output, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_DCP_SHA1) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_init(mbedtls_sha1_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_free(mbedtls_sha1_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_clone(mbedtls_sha1_context * dst, const mbedtls_sha1_context * src) +{ + memcpy(dst, src, sizeof(mbedtls_sha1_context)); +} + +/* + * SHA-1 context setup + */ +int mbedtls_sha1_starts_ret(mbedtls_sha1_context * ctx) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Init(DCP, &s_dcpHandle, ctx, kDCP_Sha1); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Update(DCP, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 process buffer + */ +int mbedtls_sha1_update_ret(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Update(DCP, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 final digest + */ +int mbedtls_sha1_finish_ret(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Finish(DCP, ctx, output, NULL); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_HASHCRYPT_SHA1) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_init(mbedtls_sha1_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_free(mbedtls_sha1_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha1_context)); +} + +void mbedtls_sha1_clone(mbedtls_sha1_context * dst, const mbedtls_sha1_context * src) +{ + memcpy(dst, src, sizeof(mbedtls_sha1_context)); +} + +/* + * SHA-1 context setup + */ +int mbedtls_sha1_starts_ret(mbedtls_sha1_context * ctx) +{ + status_t ret = kStatus_Fail; + ret = HASHCRYPT_SHA_Init(HASHCRYPT, ctx, kHASHCRYPT_Sha1); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = HASHCRYPT_SHA_Update(HASHCRYPT, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 process buffer + */ +int mbedtls_sha1_update_ret(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = HASHCRYPT_SHA_Update(HASHCRYPT, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-1 final digest + */ +int mbedtls_sha1_finish_ret(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + status_t ret = kStatus_Fail; + size_t outputSize = 20; + ret = HASHCRYPT_SHA_Finish(HASHCRYPT, ctx, output, &outputSize); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA1_HW_ACCEL_FAILED; + } + return 0; +} +#endif /* MBEDTLS_FREESCALE_LPC_SHA1 */ +#if !defined(MBEDTLS_DEPRECATED_REMOVED) && defined(MBEDTLS_SHA1_ALT) +#include "mbedtls/sha1.h" + +void mbedtls_sha1_starts(mbedtls_sha1_context * ctx) +{ + mbedtls_sha1_starts_ret(ctx); +} + +void mbedtls_sha1_update(mbedtls_sha1_context * ctx, const unsigned char * input, size_t ilen) +{ + mbedtls_sha1_update_ret(ctx, input, ilen); +} + +void mbedtls_sha1_finish(mbedtls_sha1_context * ctx, unsigned char output[20]) +{ + mbedtls_sha1_finish_ret(ctx, output); +} + +void mbedtls_sha1_process(mbedtls_sha1_context * ctx, const unsigned char data[64]) +{ + mbedtls_internal_sha1_process(ctx, data); +} +#endif /* MBEDTLS_DEPRECATED_REMOVED */ +#endif /* MBEDTLS_SHA1_C */ + +/******************************************************************************/ +/*************************** SHA256********************************************/ +/******************************************************************************/ + +#if defined(MBEDTLS_SHA256_C) + +#if defined(MBEDTLS_FREESCALE_LTC_SHA256) +#include "mbedtls/sha256.h" + +void mbedtls_sha256_init(mbedtls_sha256_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_free(mbedtls_sha256_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_clone(mbedtls_sha256_context * dst, const mbedtls_sha256_context * src) +{ + memcpy(dst, src, sizeof(*dst)); +} + +/* + * SHA-256 context setup + */ +int mbedtls_sha256_starts_ret(mbedtls_sha256_context * ctx, int is224) +{ + status_t ret = kStatus_Fail; + if (is224) + { + ret = LTC_HASH_Init(LTC_INSTANCE, ctx, kLTC_Sha224, NULL, 0); + } + else + { + ret = LTC_HASH_Init(LTC_INSTANCE, ctx, kLTC_Sha256, NULL, 0); + } + + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Update(ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 process buffer + */ +int mbedtls_sha256_update_ret(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Update(ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 final digest + */ +int mbedtls_sha256_finish_ret(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + status_t ret = kStatus_Fail; + ret = LTC_HASH_Finish(ctx, output, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_MMCAU_SHA256) + +#include "mbedtls/sha256.h" + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = MMCAU_SHA256_HashN(data, 1, ctx->state); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_CAU3_SHA256) + +#include "mbedtls/sha256.h" + +void mbedtls_sha256_init(mbedtls_sha256_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_free(mbedtls_sha256_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_clone(mbedtls_sha256_context * dst, const mbedtls_sha256_context * src) +{ + memcpy(dst, src, sizeof(*dst)); +} + +/* + * SHA-256 context setup + */ +int mbedtls_sha256_starts_ret(mbedtls_sha256_context * ctx, int is224) +{ + status_t ret = kStatus_Fail; + if (!is224) /* SHA-224 not supported at the moment */ + { + ret = CAU3_HASH_Init(CAU3, ctx, kCAU3_Sha256); + } + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Update(CAU3, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 process buffer + */ +int mbedtls_sha256_update_ret(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Update(CAU3, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 final digest + */ +int mbedtls_sha256_finish_ret(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + status_t ret = kStatus_Fail; + ret = CAU3_HASH_Finish(CAU3, ctx, output, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_LPC_SHA256) +#include "mbedtls/sha256.h" + +void mbedtls_sha256_init(mbedtls_sha256_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_free(mbedtls_sha256_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_clone(mbedtls_sha256_context * dst, const mbedtls_sha256_context * src) +{ + memcpy(dst, src, sizeof(*dst)); +} + +/* + * SHA-256 context setup + */ +int mbedtls_sha256_starts_ret(mbedtls_sha256_context * ctx, int is224) +{ + int status = MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + if (!is224) /* SHA-224 not supported */ + { + SHA256_Init(ctx); + status = 0; + } + return status; +} + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + SHA256_HashUpdate(ctx, data, 64); + return 0; +} + +/* + * SHA-256 process buffer + */ +int mbedtls_sha256_update_ret(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + SHA256_HashUpdate(ctx, input, ilen); + + return 0; +} + +/* + * SHA-256 final digest + */ +int mbedtls_sha256_finish_ret(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + SHA256_HashFinish(ctx, output); + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_CAAM_SHA256) +#include "mbedtls/sha256.h" + +void mbedtls_sha256_init(mbedtls_sha256_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_free(mbedtls_sha256_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_clone(mbedtls_sha256_context * dst, const mbedtls_sha256_context * src) +{ + memcpy(dst, src, sizeof(*dst)); +} + +/* + * SHA-256 context setup + */ +int mbedtls_sha256_starts_ret(mbedtls_sha256_context * ctx, int is224) +{ + status_t ret = kStatus_Fail; + if (is224) + { + ret = CAAM_HASH_Init(CAAM_INSTANCE, &s_caamHandle, ctx, kCAAM_Sha224, NULL, 0); + } + else + { + ret = CAAM_HASH_Init(CAAM_INSTANCE, &s_caamHandle, ctx, kCAAM_Sha256, NULL, 0); + } + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Update(ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 process buffer + */ +int mbedtls_sha256_update_ret(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Update(ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 final digest + */ +int mbedtls_sha256_finish_ret(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + status_t ret = kStatus_Fail; + ret = CAAM_HASH_Finish(ctx, output, 0); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_DCP_SHA256) +#include "mbedtls/sha256.h" + +void mbedtls_sha256_init(mbedtls_sha256_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_free(mbedtls_sha256_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_clone(mbedtls_sha256_context * dst, const mbedtls_sha256_context * src) +{ + memcpy(dst, src, sizeof(*dst)); +} + +/* + * SHA-256 context setup + */ +int mbedtls_sha256_starts_ret(mbedtls_sha256_context * ctx, int is224) +{ + status_t ret = kStatus_Fail; + if (!is224) + { + ret = DCP_HASH_Init(DCP, &s_dcpHandle, ctx, kDCP_Sha256); + } + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Update(DCP, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 process buffer + */ +int mbedtls_sha256_update_ret(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Update(DCP, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 final digest + */ +int mbedtls_sha256_finish_ret(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + status_t ret = kStatus_Fail; + ret = DCP_HASH_Finish(DCP, ctx, output, NULL); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +#elif defined(MBEDTLS_FREESCALE_HASHCRYPT_SHA256) +#include "mbedtls/sha256.h" + +void mbedtls_sha256_init(mbedtls_sha256_context * ctx) +{ + memset(ctx, 0, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_free(mbedtls_sha256_context * ctx) +{ + if (ctx == NULL) + return; + + mbedtls_zeroize(ctx, sizeof(mbedtls_sha256_context)); +} + +void mbedtls_sha256_clone(mbedtls_sha256_context * dst, const mbedtls_sha256_context * src) +{ + memcpy(dst, src, sizeof(*dst)); +} + +/* + * SHA-256 context setup + */ +int mbedtls_sha256_starts_ret(mbedtls_sha256_context * ctx, int is224) +{ + status_t ret = kStatus_Fail; + if (!is224) /* SHA-224 not supported */ + { + ret = HASHCRYPT_SHA_Init(HASHCRYPT, ctx, kHASHCRYPT_Sha256); + } + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +int mbedtls_internal_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + status_t ret = kStatus_Fail; + ret = HASHCRYPT_SHA_Update(HASHCRYPT, ctx, data, 64); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 process buffer + */ +int mbedtls_sha256_update_ret(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + status_t ret = kStatus_Fail; + ret = HASHCRYPT_SHA_Update(HASHCRYPT, ctx, input, ilen); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} + +/* + * SHA-256 final digest + */ +int mbedtls_sha256_finish_ret(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + status_t ret = kStatus_Fail; + size_t outputSize = 32; + ret = HASHCRYPT_SHA_Finish(HASHCRYPT, ctx, output, &outputSize); + if (ret != kStatus_Success) + { + return MBEDTLS_ERR_SHA256_HW_ACCEL_FAILED; + } + return 0; +} +#endif /* MBEDTLS_FREESCALE_LTC_SHA256 */ +#if !defined(MBEDTLS_DEPRECATED_REMOVED) && defined(MBEDTLS_SHA256_ALT) +#include "mbedtls/sha256.h" + +void mbedtls_sha256_starts(mbedtls_sha256_context * ctx, int is224) +{ + mbedtls_sha256_starts_ret(ctx, is224); +} + +void mbedtls_sha256_update(mbedtls_sha256_context * ctx, const unsigned char * input, size_t ilen) +{ + mbedtls_sha256_update_ret(ctx, input, ilen); +} + +void mbedtls_sha256_finish(mbedtls_sha256_context * ctx, unsigned char output[32]) +{ + mbedtls_sha256_finish_ret(ctx, output); +} + +void mbedtls_sha256_process(mbedtls_sha256_context * ctx, const unsigned char data[64]) +{ + mbedtls_internal_sha256_process(ctx, data); +} +#endif /* MBEDTLS_DEPRECATED_REMOVED */ +#endif /* MBEDTLS_SHA256_C */ + +/* Entropy poll callback for a hardware source */ +#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT) + +#if defined(FSL_FEATURE_SOC_TRNG_COUNT) && (FSL_FEATURE_SOC_TRNG_COUNT > 0) +#if defined CPU_JN518X +#include "fsl_rng.h" +#else +#include "fsl_trng.h" +#endif +#elif defined(FSL_FEATURE_SOC_RNG_COUNT) && (FSL_FEATURE_SOC_RNG_COUNT > 0) +#include "fsl_rnga.h" +#elif defined(FSL_FEATURE_SOC_LPC_RNG_COUNT) && (FSL_FEATURE_SOC_LPC_RNG_COUNT > 0) +#include "fsl_rng.h" +#elif defined(FSL_FEATURE_SOC_LPC_RNG1_COUNT) && (FSL_FEATURE_SOC_LPC_RNG1_COUNT > 0) +#include "fsl_rng.h" +#endif + +int mbedtls_hardware_poll(void * data, unsigned char * output, size_t len, size_t * olen) +{ + status_t result = kStatus_Success; + +#if defined(FSL_FEATURE_SOC_TRNG_COUNT) && (FSL_FEATURE_SOC_TRNG_COUNT > 0) +#if defined CPU_JN518X +#ifndef TRNG0 +#define TRNG0 RNG +#endif +#else +#ifndef TRNG0 +#define TRNG0 TRNG +#endif +#endif + result = TRNG_GetRandomData(TRNG0, output, len); +#elif defined(FSL_FEATURE_SOC_RNG_COUNT) && (FSL_FEATURE_SOC_RNG_COUNT > 0) + result = RNGA_GetRandomData(RNG, (void *) output, len); +#elif defined(FSL_FEATURE_SOC_CAAM_COUNT) && (FSL_FEATURE_SOC_CAAM_COUNT > 0) && defined(CRYPTO_USE_DRIVER_CAAM) + result = CAAM_RNG_GetRandomData(CAAM_INSTANCE, &s_caamHandle, kCAAM_RngStateHandle0, output, len, kCAAM_RngDataAny, NULL); +#elif defined(FSL_FEATURE_SOC_LPC_RNG_COUNT) && (FSL_FEATURE_SOC_LPC_RNG_COUNT > 0) + uint32_t rn; + size_t length; + int i; + + length = len; + + while (length > 0) + { + rn = RNG_GetRandomData(); + + if (length >= sizeof(uint32_t)) + { + memcpy(output, &rn, sizeof(uint32_t)); + length -= sizeof(uint32_t); + output += sizeof(uint32_t); + } + else + { + memcpy(output, &rn, length); + output += length; + len = 0U; + } + + /* Discard next 32 random words for better entropy */ + for (i = 0; i < 32; i++) + { + RNG_GetRandomData(); + } + } + + result = kStatus_Success; +#elif defined(FSL_FEATURE_SOC_LPC_RNG1_COUNT) && (FSL_FEATURE_SOC_LPC_RNG1_COUNT > 0) + status_t status = kStatus_Fail; + + while (status != kStatus_Success) + { + status = RNG_GetRandomData(RNG, output, len); + + if (status == kStatus_Fail) + { + RNG_Init(RNG); + } + } + + result = status; +#endif + if (result == kStatus_Success) + { + *olen = len; + return 0; + } + else + { + return result; + } +} + +#endif + +/******************************************************************************/ +/*************************** FreeRTOS ********************************************/ +/******************************************************************************/ +#if USE_RTOS && defined(FSL_RTOS_FREE_RTOS) && defined(MBEDTLS_FREESCALE_FREERTOS_CALLOC_ALT) +#include "FreeRTOS.h" +#include "task.h" +#include + +/*---------HEAP_3 calloc --------------------------------------------------*/ + +void * pvPortCalloc(size_t num, size_t size) +{ + void * pvReturn; + + vTaskSuspendAll(); + { + pvReturn = calloc(num, size); + traceMALLOC(pvReturn, xWantedSize); + } + (void) xTaskResumeAll(); + +#if (configUSE_MALLOC_FAILED_HOOK == 1) + { + if (pvReturn == NULL) + { + extern void vApplicationMallocFailedHook(void); + vApplicationMallocFailedHook(); + } + } +#endif + + return pvReturn; +} +#endif /* USE_RTOS && defined(FSL_RTOS_FREE_RTOS) && defined(MBEDTLS_FREESCALE_FREERTOS_CALLOC_ALT) */ diff --git a/third_party/nxp/k32w0_sdk/BUILD.gn b/third_party/nxp/k32w0_sdk/BUILD.gn index 79d2e2a6ee1a6a..c6cff80b87c915 100644 --- a/third_party/nxp/k32w0_sdk/BUILD.gn +++ b/third_party/nxp/k32w0_sdk/BUILD.gn @@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build_overrides/chip.gni") import("//build_overrides/k32w0_sdk.gni") import("//build_overrides/mbedtls.gni") @@ -60,6 +61,13 @@ config("mbedtls_k32w0_config") { ] } + if (chip_with_factory_data == 1) { + defines += [ + "MBEDTLS_X509_CRT_PARSE_C", + "MBEDTLS_X509_USE_C", + ] + } + if (chip_crypto == "tinycrypt") { defines += [ "MBEDTLS_USE_TINYCRYPT", @@ -76,8 +84,8 @@ config("mbedtls_k32w0_config") { mbedtls_target("mbedtls") { sources = [ + "${chip_root}/src/platform/nxp/k32w/k32w0/crypto/ksdk_mbedtls.c", "${k32w0_sdk_root}/middleware/mbedtls/port/ksdk/aes_alt.c", - "${k32w0_sdk_root}/middleware/mbedtls/port/ksdk/ksdk_mbedtls.c", ] if (chip_crypto == "tinycrypt") { diff --git a/third_party/nxp/k32w0_sdk/k32w0_sdk.gni b/third_party/nxp/k32w0_sdk/k32w0_sdk.gni index d0aa619d6a6968..0f48c70daffeaf 100644 --- a/third_party/nxp/k32w0_sdk/k32w0_sdk.gni +++ b/third_party/nxp/k32w0_sdk/k32w0_sdk.gni @@ -37,6 +37,7 @@ declare_args() { board = "k32w061dk6" chip_with_ntag = 1 chip_with_high_power = 0 + chip_with_factory_data = 0 } assert(k32w0_sdk_root != "", "k32w0_sdk_root must be specified") @@ -64,6 +65,13 @@ template("k32w0_sdk") { chip_with_ot_cli == 0 && chip_with_se05x == 0), "Please disable low power if expansion board, openthread CLI or SE is needed!") + assert(chip_with_low_power == 0 || + (invoker.chip_detail_logging == false && + invoker.chip_progress_logging == false && + invoker.chip_automation_logging == false && + invoker.chip_error_logging == false), + "Please disable all logs when low power is enabled!") + if (build_for_k32w041am == 1 || build_for_k32w041a == 1 || build_for_k32w041 == 1) { build_for_k32w061 = 0 @@ -75,7 +83,7 @@ template("k32w0_sdk") { "Please build for only one platform") device = "K32W061" board = "k32w061dk6" - chip_with_ntag = 1 + chip_with_ntag = 0 chip_with_high_power = 0 } if (build_for_k32w041am == 1) { @@ -221,8 +229,7 @@ template("k32w0_sdk") { "USE_SDK_OSA=0", "gSerialManagerMaxInterfaces_c=2", "FSL_RTOS_FREE_RTOS=1", - "gTotalHeapSize_c=0xC8BC", - "gUartDebugConsole_d=1", + "gTotalHeapSize_c=0x10000", "DEBUG_SERIAL_INTERFACE_INSTANCE=0", "APP_SERIAL_INTERFACE_INSTANCE=1", "gOTA_externalFlash_d=1", @@ -238,7 +245,6 @@ template("k32w0_sdk") { "ENABLE_RAM_VECTOR_TABLE=1", "gTMR_Enabled_d=1", "gTimestamp_Enabled_d=0", - "K32W_LOG_ENABLED=1", "CHIP_ENABLE_OPENTHREAD=1", "gOtaMemPoolId_c=1", "PoolsDetails_c=_block_size_ 32 _number_of_blocks_ 6 _pool_id_(0) _eol_ _block_size_ 256 _number_of_blocks_ 3 _pool_id_(0) _eol_ _block_size_ 512 _number_of_blocks_ 2 _pool_id_(0) _eol_ _block_size_ 768 _number_of_blocks_ 1 _pool_id_(0) _eol_ _block_size_ 268 _number_of_blocks_ 8 _pool_id_(gOtaMemPoolId_c) _eol_", @@ -295,7 +301,7 @@ template("k32w0_sdk") { } else { defines += [ "gKeyBoardSupported_d=1", - "gKBD_KeysCount_c=1", + "gKBD_KeysCount_c=2", ] } @@ -322,11 +328,15 @@ template("k32w0_sdk") { "mAppUseTickLessMode_c=1", "App_SuppressTickInStopMode=0", "cPWR_DiscardRunningTimerForPowerDown=1", + "K32W_LOG_ENABLED=0", + "gUartDebugConsole_d=0", ] } else { defines += [ "cPWR_UsePowerDownMode=0", "cPWR_FullPowerDownMode=0", + "K32W_LOG_ENABLED=1", + "gUartDebugConsole_d=1", ] } @@ -358,6 +368,10 @@ template("k32w0_sdk") { ] } + if (chip_with_factory_data == 1) { + defines += [ "CONFIG_CHIP_K32W0_REAL_FACTORY_DATA=1" ] + } + if (defined(invoker.defines)) { defines += invoker.defines } diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/Eeprom_MX25R8035F_c.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/Eeprom_MX25R8035F_c.patch deleted file mode 100644 index c017836bfa83aa..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/Eeprom_MX25R8035F_c.patch +++ /dev/null @@ -1,112 +0,0 @@ ---- a/Eeprom_MX25R8035F.c -+++ b//Eeprom_MX25R8035F.c -@@ -146,7 +146,7 @@ static uint32_t EEPROM_ReadStatusReq(void); - static uint32_t EEPROM_ReadIDReq(void); - static uint32_t EEPROM_ReadResReq(void); - -- -+static uint8_t EEPROM_isBusyPrivate(void); - - #define MX25_SR_WIP_POS 0 /* Write In Progress */ - #define MX25_SR_WEL_POS 1 /* Write Enable Latch */ -@@ -316,7 +316,7 @@ ee_err_t EEPROM_Init(void) - { - initialized = 1; - } -- while (EEPROM_isBusy()); -+ while (EEPROM_isBusyPrivate()); - } - - return status; -@@ -366,7 +366,7 @@ ee_err_t EEPROM_ChipErase(void) - - /* Wait for idle state : check before operation in order to let previous - * operation terminate rather than blocking */ -- while (EEPROM_isBusy()); -+ while (EEPROM_isBusyPrivate()); - - /* Enable write */ - EEPROM_WriteEnable(); -@@ -410,7 +410,7 @@ ee_err_t EEPROM_EraseBlock(uint32_t Addr, uint32_t block_size) - - OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); - -- while (EEPROM_isBusy()); -+ while (EEPROM_isBusyPrivate()); - - EEPROM_WriteEnable(); - -@@ -485,7 +485,7 @@ ee_err_t EEPROM_EraseArea(uint32_t *Addr, int32_t *size, bool non_blocking) - { - OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); - -- if (non_blocking && EEPROM_isBusy()) -+ if (non_blocking && EEPROM_isBusyPrivate()) - { - status = ee_busy; - OSA_SemaphorePost(mExtEepromSemaphoreId); -@@ -679,7 +679,7 @@ void EEPROM_SetRead(void) - - OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); - -- while (EEPROM_isBusy()); -+ while (EEPROM_isBusyPrivate()); - - /* Set start address */ - SPIFI_SetCommandAddress(SPIFI, FSL_FEATURE_SPIFI_START_ADDR ); -@@ -714,7 +714,7 @@ ee_err_t EEPROM_ReadData(uint16_t NoOfBytes, uint32_t Addr, uint8_t *inbuf) - - OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); - -- while (EEPROM_isBusy()); -+ while (EEPROM_isBusyPrivate()); - - /* Set start address */ - SPIFI_SetCommandAddress(SPIFI, FSL_FEATURE_SPIFI_START_ADDR + Addr); -@@ -750,7 +750,12 @@ ee_err_t EEPROM_ReadData(uint16_t NoOfBytes, uint32_t Addr, uint8_t *inbuf) - ********************************************************************************** */ - uint8_t EEPROM_isBusy(void) - { -- return (EEPROM_ReadStatusReq() & EEPROM_BUSY_FLAG_MASK) == EEPROM_BUSY_FLAG_MASK; -+ uint8_t res = 0; -+ -+ OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); -+ res = EEPROM_isBusyPrivate(); -+ OSA_SemaphorePost(mExtEepromSemaphoreId); -+ return res; - } - - /*! ********************************************************************************* -@@ -759,6 +764,11 @@ uint8_t EEPROM_isBusy(void) - ************************************************************************************* - ********************************************************************************** */ - -+static uint8_t EEPROM_isBusyPrivate(void) -+{ -+ return (EEPROM_ReadStatusReq() & EEPROM_BUSY_FLAG_MASK) == EEPROM_BUSY_FLAG_MASK; -+} -+ - /*! ********************************************************************************* - * \brief Read the memory controller status register - * -@@ -882,6 +892,7 @@ void EepromWritePage(uint32_t NoOfBytes, uint32_t Addr, uint8_t *Outbuf) - #endif /* gFlashBlockBitmap_d */ - - OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); -+ while (EEPROM_isBusyPrivate()); - - EEPROM_WriteEnable(); - SPIFI_SetCommandAddress(SPIFI, Addr + FSL_FEATURE_SPIFI_START_ADDR); -@@ -917,12 +928,6 @@ static ee_err_t EEPROM_WritePage(uint32_t NoOfBytes, uint32_t Addr, uint8_t *Out - - if (NoOfBytes > 0) - { -- OSA_SemaphoreWait(mExtEepromSemaphoreId, osaWaitForever_c); -- -- while (EEPROM_isBusy()); -- -- OSA_SemaphorePost(mExtEepromSemaphoreId); -- - EepromWritePage(NoOfBytes, Addr, Outbuf); - } - diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/MemManager_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/MemManager_h.patch deleted file mode 100644 index 49ed7e803738cd..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/MemManager_h.patch +++ /dev/null @@ -1,22 +0,0 @@ ---- a/MemManager.h -+++ b/MemManager.h -@@ -24,6 +24,9 @@ - #include "EmbeddedTypes.h" - #include "GenericList.h" - -+#ifdef __cplusplus -+extern "C" { -+#endif - - /*! ********************************************************************************* - ************************************************************************************* -@@ -220,4 +223,8 @@ extern __attribute__((weak)) uint32_t MEM_GetTimeStamp(void); - - #endif /*MEM_TRACKING*/ - -+#ifdef __cplusplus -+} -+#endif -+ - #endif /* _MEM_MANAGER_H_ */ - diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/OtaSupport_c.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/OtaSupport_c.patch deleted file mode 100644 index 0ff1c9ec118651..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/OtaSupport_c.patch +++ /dev/null @@ -1,144 +0,0 @@ ---- a/OtaSupport.c -+++ b/OtaSupport.c -@@ -116,10 +116,9 @@ typedef bool (*efuse_AESKeyPresent_t)(void); - typedef int (*efuse_LoadUniqueKey_t)(void); - typedef uint32_t (*aesLoadKeyFromOTP_t)(AES_KEY_SIZE_T keySize); - --const static efuse_LoadUniqueKey_t efuse_LoadUniqueKey = (efuse_LoadUniqueKey_t)ROM_API_efuse_LoadUniqueKey; --const static aesLoadKeyFromOTP_t aesLoadKeyFromOTP = (aesLoadKeyFromOTP_t)ROM_API_aesLoadKeyFromOTP; --const static efuse_AESKeyPresent_t efuse_AESKeyPresent = (efuse_AESKeyPresent_t)ROM_API_efuse_AESKeyPresent; -- -+static const efuse_LoadUniqueKey_t efuse_LoadUniqueKey = (efuse_LoadUniqueKey_t)ROM_API_efuse_LoadUniqueKey; -+static const aesLoadKeyFromOTP_t aesLoadKeyFromOTP = (aesLoadKeyFromOTP_t)ROM_API_aesLoadKeyFromOTP; -+static const efuse_AESKeyPresent_t efuse_AESKeyPresent = (efuse_AESKeyPresent_t)ROM_API_efuse_AESKeyPresent; - - #if gUsePasswordCiphering_d - const static uint32_t (*aesLoadKeyFromSW)(AES_KEY_SIZE_T keySize, -@@ -187,6 +186,7 @@ typedef struct { - int max_cnt_idle; - int q_sz; - int q_max; -+ osaMutexId_t msgQueueMutex; - #endif - eEncryptionKeyType ciphered_mode; - #if gExternalFlashIsCiphered_d -@@ -207,6 +207,7 @@ typedef struct { - #if ( gEepromParams_bufferedWrite_c == 1) - bool_t gOtaInvalidateHeader; - #endif -+ bool_t isInitialized; - } OtaFlashTaskContext_t; - - /****************************************************************************** -@@ -287,6 +288,7 @@ static OtaFlashTaskContext_t mHandle = { - #if ( gEepromParams_bufferedWrite_c == 1) - .gOtaInvalidateHeader = FALSE, - #endif -+ .isInitialized = FALSE, - }; - - -@@ -460,6 +462,11 @@ otaResult_t OTA_StartImageWithMaxSize(uint32_t length, uint32_t maxAllowedArchSi - int OTA_TransactionResume(void) - { - int nb_treated = 0; -+ -+ if (mHandle.isInitialized) -+ { -+ OSA_MutexLock(mHandle.msgQueueMutex, osaWaitForever_c); -+ - while ( OTA_IsTransactionPending() /* There are queued flash operations pending in queue */ - && (nb_treated < MAX_CONSECUTIVE_TRANSACTIONS)) /* ... but do not schedule too many in a same pass */ - { -@@ -553,6 +560,9 @@ int OTA_TransactionResume(void) - /* There were transactions pending but we consumed some */ - mHandle.cnt_idle_op = 0; - -+ OSA_MutexUnlock(mHandle.msgQueueMutex); -+ } -+ - return nb_treated; - } - /***************************************************************************** -@@ -578,7 +588,11 @@ void OTA_WritePendingData(void) - - while (EEPROM_isBusy()); - /* Always take head of queue : we just queued something so we know it is not empty */ -- OTA_TransactionResume(); -+ while (OTA_IsTransactionPending()) -+ { -+ OTA_TransactionResume(); -+ } -+ - while (EEPROM_isBusy()); - - } while (0); -@@ -877,7 +891,14 @@ otaResult_t OTA_PushImageChunk(uint8_t* pData, uint16_t length, uint32_t* pImage - OTA_MsgQueue(pMsg); - - OTA_DBG_LOG("Submitted page Addr=%x", pMsg->flash_addr); -- mHandle.cur_transaction = NULL; -+ if (mHandle.cur_transaction != NULL) -+ { -+ mHandle.cur_transaction = NULL; -+ } -+ else -+ { -+ Addr += PROGRAM_PAGE_SZ; -+ } - } - else - { -@@ -1229,6 +1250,9 @@ otaResult_t OTA_ClientInit(void) - OTA_DEBUG_TRACE("%s\r\n", __FUNCTION__); - otaResult_t res = gOtaSuccess_c; - -+ if (!mHandle.isInitialized) -+ { -+ - mHandle.LoadOtaImageInEepromInProgress = FALSE; - mHandle.OtaImageTotalLength = 0; - mHandle.OtaImageCurrentLength = 0; -@@ -1255,6 +1279,7 @@ otaResult_t OTA_ClientInit(void) - - #if gOtaEepromPostedOperations_d - MSG_InitQueue(&mHandle.op_queue); -+ mHandle.msgQueueMutex = OSA_MutexCreate(); - #endif - #if gExternalFlashIsCiphered_d - mHandle.ciphered_mode = (efuse_AESKeyPresent()) ? eEfuseKey : eSoftwareKey; -@@ -1262,6 +1287,9 @@ otaResult_t OTA_ClientInit(void) - mHandle.ciphered_mode = eCipherKeyNone; - #endif - res = OTA_InitExternalMemory(); -+ -+ mHandle.isInitialized = TRUE; -+ } - return res; - } - -@@ -1645,7 +1673,7 @@ static uint32_t OTA_GetMaxAllowedArchSize(void) - return gFlashMaxStatedSize*2 - current_app_stated_size; - #else - /* Read the value from the psector img directory */ -- uint32_t allowedSize = 0; -+ uint32_t maxImgPages = 0; - uint8_t i; - psector_page_data_t * mPage0Hdl = psector_GetPage0Handle(); - if (mPage0Hdl != NULL) -@@ -1653,12 +1681,12 @@ static uint32_t OTA_GetMaxAllowedArchSize(void) - image_directory_entry_t * currentEntry = mPage0Hdl->page0_v3.img_directory; - for (i=0; iimg_nb_pages > allowedSize) -- allowedSize = currentEntry->img_nb_pages*512; -+ if (currentEntry->img_nb_pages > maxImgPages) -+ maxImgPages = currentEntry->img_nb_pages; - currentEntry++; - } - } -- return allowedSize; -+ return maxImgPages*512; /* 512 corresponding to the size of one page in the internal flash */ - #endif - - } diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_c.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_c.patch deleted file mode 100644 index 1814f74bb15502..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_c.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/OtaUtils.c -+++ b/OtaUtils.c -@@ -92,11 +92,11 @@ typedef uint32_t (*flash_GetDmaccStatus_t)(uint8_t *address); - ************************************************************************************* - ************************************************************************************/ - --const static efuse_LoadUniqueKey_t efuse_LoadUniqueKey = (efuse_LoadUniqueKey_t) ROM_API_efuse_LoadUniqueKey; --const static aesLoadKeyFromOTP_t aesLoadKeyFromOTP = (aesLoadKeyFromOTP_t) ROM_API_aesLoadKeyFromOTP; --const static crc_update_t crc_update = (crc_update_t)ROM_API_crc_update; --const static boot_CheckVectorSum_t boot_CheckVectorSum = (boot_CheckVectorSum_t)ROM_API_boot_CheckVectorSum; --const static flash_GetDmaccStatus_t flash_GetDmaccStatus = (flash_GetDmaccStatus_t) ROM_API_flash_GetDmaccStatus; -+static const efuse_LoadUniqueKey_t efuse_LoadUniqueKey = (efuse_LoadUniqueKey_t) ROM_API_efuse_LoadUniqueKey; -+static const aesLoadKeyFromOTP_t aesLoadKeyFromOTP = (aesLoadKeyFromOTP_t) ROM_API_aesLoadKeyFromOTP; -+static const crc_update_t crc_update = (crc_update_t)ROM_API_crc_update; -+static const boot_CheckVectorSum_t boot_CheckVectorSum = (boot_CheckVectorSum_t)ROM_API_boot_CheckVectorSum; -+static const flash_GetDmaccStatus_t flash_GetDmaccStatus = (flash_GetDmaccStatus_t) ROM_API_flash_GetDmaccStatus; - - /****************************************************************************** - ******************************************************************************* diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_h.patch new file mode 100644 index 00000000000000..35e998bc6e68ca --- /dev/null +++ b/third_party/nxp/k32w0_sdk/sdk_fixes/OtaUtils_h.patch @@ -0,0 +1,24 @@ +--- a/OtaUtils.h ++++ b/OtaUtils.h +@@ -77,6 +77,10 @@ typedef otaUtilsResult_t (*OtaUtils_ReadBytes)(uint16_t nbBytes, + ************************************************************************************* + ********************************************************************************** */ + ++#ifdef __cplusplus ++extern "C" { ++#endif ++ + /*! ********************************************************************************* + * \brief Allows to read bytes from the Internal Flash + * +@@ -185,6 +189,8 @@ uint32_t OtaUtils_ValidateImage(OtaUtils_ReadBytes pFunctionRead, + ********************************************************************************** */ + otaUtilsResult_t OtaUtils_ReconstructRootCert(IMAGE_CERT_T *pCert, const psector_page_data_t* pPage0, const psector_page_data_t* pFlashPage); + +- ++#ifdef __cplusplus ++} ++#endif + + #endif /* _OTA_UTILS_H_ */ +\ No newline at end of file diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/SecLib_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/SecLib_h.patch deleted file mode 100644 index a65b5c6537271e..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/SecLib_h.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/SecLib.h -+++ b/SecLib.h -@@ -174,6 +174,10 @@ typedef void(*secLibCallback_t)(computeDhKeyParam_t* pData); - ************************************************************************************* - ************************************************************************************/ - -+#ifdef __cplusplus -+extern "C" { -+#endif -+ - /*! ********************************************************************************* - * \brief This function performs initialization of the cryptographic HW acceleration. - * -@@ -999,5 +1003,10 @@ uint32_t u32Reverse(uint32_t u32InWord); - void vSwipeEndian( AESSW_Block_u *puBlock, - tsReg128 *psReg, - bool_t bBlockToReg ); -+ -+#ifdef __cplusplus -+} -+#endif -+ - #endif /* _SEC_LIB_H_ */ - diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_low_power_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_low_power_h.patch deleted file mode 100644 index 54a6eb7190697b..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_low_power_h.patch +++ /dev/null @@ -1,24 +0,0 @@ ---- a/app_dual_mode_low_power.h -+++ b/app_dual_mode_low_power.h -@@ -43,6 +43,9 @@ typedef enum - * Public prototypes - ************************************************************************************* - ********************************************************************************** */ -+#ifdef __cplusplus -+extern "C" { -+#endif - - void dm_lp_init(void); - -@@ -50,6 +53,10 @@ void dm_lp_preSleep(void); - - void dm_lp_wakeup(void); - --void dm_lp_processEvent(void *pParam); -+void dm_lp_processEvent(void * pParam); -+ -+#ifdef __cplusplus -+} -+#endif - - #endif /* _APP_DUAL_MODE_LOW_POWER_H_ */ diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_switch_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_switch_h.patch deleted file mode 100644 index 8ec94c488ea5d9..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/app_dual_mode_switch_h.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/app_dual_mode_switch.h -+++ b/app_dual_mode_switch.h -@@ -61,6 +61,9 @@ typedef enum { - ************************************************************************************* - ********************************************************************************** */ - -+#ifdef __cplusplus -+extern "C" { -+#endif - /*! ********************************************************************************* - * \brief Runs the dual mode switch Idle Task - * -@@ -91,4 +94,8 @@ uint32_t dm_switch_get15_4InitWakeUpTime(void); - ********************************************************************************** */ - void dm_switch_init15_4AfterWakeUp(void); - -+#ifdef __cplusplus -+} -+#endif -+ - #endif /* _APP_DUAL_MODE_SWITCH_H_ */ diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/ble_utils_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/ble_utils_h.patch deleted file mode 100644 index a3fff72f0f33ce..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/ble_utils_h.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/ble_utils.h 2022-01-07 16:41:34.017433835 +0000 -+++ b/ble_utils.h 2022-01-07 16:42:09.797788620 +0000 -@@ -73,11 +73,6 @@ - #define ALIGN_64BIT #pragma pack(8) - #endif - --/*! Marks that this variable is in the interface. */ --#ifndef global --#define global --#endif -- - /*! Marks a function that never returns. */ - #if !defined(__IAR_SYSTEMS_ICC__) - #ifndef __noreturn diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/fsl_os_abstraction_free_rtos_c.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/fsl_os_abstraction_free_rtos_c.patch new file mode 100644 index 00000000000000..2221c979f07b72 --- /dev/null +++ b/third_party/nxp/k32w0_sdk/sdk_fixes/fsl_os_abstraction_free_rtos_c.patch @@ -0,0 +1,54 @@ +--- a/fsl_os_abstraction_free_rtos.c ++++ b/fsl_os_abstraction_free_rtos.c +@@ -344,6 +344,12 @@ osaStatus_t OSA_SemaphoreWait(osaSemaphoreId_t semId, uint32_t millisec) + { + #if osNumberOfSemaphores + uint32_t timeoutTicks; ++ ++ if (xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED) ++ { ++ return osaStatus_Success; ++ } ++ + if(semId == NULL) + { + return osaStatus_Error; +@@ -388,6 +394,12 @@ osaStatus_t OSA_SemaphorePost(osaSemaphoreId_t semId) + { + #if osNumberOfSemaphores + osaStatus_t status = osaStatus_Error; ++ ++ if (xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED) ++ { ++ return osaStatus_Success; ++ } ++ + if(semId) + { + semaphore_t sem = (semaphore_t)semId; +@@ -461,6 +473,12 @@ osaStatus_t OSA_MutexLock(osaMutexId_t mutexId, uint32_t millisec) + #if osNumberOfMutexes + uint32_t timeoutTicks; + mutex_t mutex = (mutex_t)mutexId; ++ ++ if (xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED) ++ { ++ return osaStatus_Success; ++ } ++ + if(mutexId == NULL) + { + return osaStatus_Error; +@@ -506,6 +524,12 @@ osaStatus_t OSA_MutexUnlock(osaMutexId_t mutexId) + { + #if osNumberOfMutexes + mutex_t mutex = (mutex_t)mutexId; ++ ++ if (xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED) ++ { ++ return osaStatus_Success; ++ } ++ + if(mutexId == NULL) + { + return osaStatus_Error; diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/gpio_pins_h.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/gpio_pins_h.patch deleted file mode 100644 index 7dd6f75fa8bdc7..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/gpio_pins_h.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/gpio_pins.h -+++ b/gpio_pins.h -@@ -76,6 +76,11 @@ - #define BOARD_USER_BUTTON3_GPIO_PIN 4U - #define IOCON_USER_BUTTON3_PIN BOARD_USER_BUTTON3_GPIO_PIN - -+#define BOARD_USER_BUTTON4_GPIO GPIO -+#define BOARD_USER_BUTTON4_GPIO_PORT 0U -+#define BOARD_USER_BUTTON4_GPIO_PIN 1U -+#define IOCON_USER_BUTTON4_PIN BOARD_USER_BUTTON4_GPIO_PIN -+ - #endif /* OM15082 */ - - #define IOCON_USER_BUTTON_MODE_FUNC (0U) diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh b/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh index 1ae747ee5dcf23..5d2a66bae9283d 100755 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh +++ b/third_party/nxp/k32w0_sdk/sdk_fixes/patch_k32w_sdk.sh @@ -15,5 +15,11 @@ convert_to_dos() { SOURCE=${BASH_SOURCE[0]} SOURCE_DIR=$(cd "$(dirname "$SOURCE")" >/dev/null 2>&1 && pwd) -echo "SDK 2.6.6 doesn't need any patching!" +convert_to_dos "$NXP_K32W0_SDK_ROOT"/middleware/wireless/framework/OSAbstraction/Source/fsl_os_abstraction_free_rtos.c +convert_to_dos "$NXP_K32W0_SDK_ROOT"/middleware/wireless/framework/OtaSupport/Interface/OtaUtils.h + +patch -N --binary -d "$NXP_K32W0_SDK_ROOT"/middleware/wireless/framework/OSAbstraction/Source/ -p1 <"$SOURCE_DIR/fsl_os_abstraction_free_rtos_c.patch" +patch -N --binary -d "$NXP_K32W0_SDK_ROOT"/middleware/wireless/framework/OtaSupport/Interface/ -p1 <"$SOURCE_DIR/OtaUtils_h.patch" + +echo "K32W SDK 2.6.7 was patched!" exit 0 diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/settings_k32w_c.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/settings_k32w_c.patch deleted file mode 100644 index 08571a4d66b795..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/settings_k32w_c.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/settings_k32w.c -+++ b/settings_k32w.c -@@ -52,7 +52,7 @@ - #define NVM_START_ID 0x4F00 - - /* WARNING - the defines below must be in sync with OT NVM datasets from Settings.hpp */ --#define NVM_MAX_ID 7 -+#define NVM_MAX_ID 20 - - static uint8_t sPdmBuffer[pdmBufferSize] __attribute__((aligned(4))) = {0}; - diff --git a/third_party/nxp/k32w0_sdk/sdk_fixes/sign_images_sh.patch b/third_party/nxp/k32w0_sdk/sdk_fixes/sign_images_sh.patch deleted file mode 100644 index 43ebc1ed8023b1..00000000000000 --- a/third_party/nxp/k32w0_sdk/sdk_fixes/sign_images_sh.patch +++ /dev/null @@ -1,18 +0,0 @@ ---- a/sign_images.sh -+++ b/sign_images.sh -@@ -56,7 +56,14 @@ if [ "$#" -gt 0 ]; then - MIME_SET="$(file -ib $FILENAME)" - - if [[ $MIME_SET == *"$MIME_PATTERN"* ]]; then -- python3 $SIGNING_TOOL $FILENAME -+ OTA_ENABLED=0 -+ APP_START=`arm-none-eabi-nm $FILENAME | grep -i m_app_start | cut -d " " -f 1` -+ -+ if [ "$APP_START" -gt 0 ]; then -+ OTA_ENABLED=1 -+ fi -+ -+ python3 $SIGNING_TOOL -i="$OTA_ENABLED" $FILENAME - arm-none-eabi-objcopy -O binary $FILENAME $FILENAME.bin - fi - done diff --git a/third_party/openthread/ot-nxp b/third_party/openthread/ot-nxp index 611561714fed15..24bf5d185d039e 160000 --- a/third_party/openthread/ot-nxp +++ b/third_party/openthread/ot-nxp @@ -1 +1 @@ -Subproject commit 611561714fed15d8046c30933f3d3b84b6a9908c +Subproject commit 24bf5d185d039e89f651310c7f690f3cc72a55ff diff --git a/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn b/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn index c6946d3d1d06ab..1edf9ab9e960c4 100644 --- a/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn +++ b/third_party/openthread/platforms/nxp/k32w/k32w0/BUILD.gn @@ -37,6 +37,8 @@ config("openthread_k32w0_config") { defines = [ "OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1", "OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1", + "PDM_SAVE_IDLE=1", + "K32W0_RADIO_NUM_OF_RX_BUFS=16", ] } diff --git a/zzz_generated/lighting-app/nxp/zap-generated/CHIPClientCallbacks.h b/zzz_generated/lighting-app/nxp/zap-generated/CHIPClientCallbacks.h new file mode 100644 index 00000000000000..4458f51745a59b --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/CHIPClientCallbacks.h @@ -0,0 +1,32 @@ +/* + * + * Copyright (c) 2022 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// List specific responses diff --git a/zzz_generated/lighting-app/nxp/zap-generated/CHIPClusters.h b/zzz_generated/lighting-app/nxp/zap-generated/CHIPClusters.h new file mode 100644 index 00000000000000..fffb265ae9c797 --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/CHIPClusters.h @@ -0,0 +1,44 @@ +/* + * + * Copyright (c) 2022 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +// Prevent multiple inclusion +#pragma once + +#include +#include + +#include +#include +#include + +namespace chip { +namespace Controller { + +class DLL_EXPORT OtaSoftwareUpdateProviderCluster : public ClusterBase +{ +public: + OtaSoftwareUpdateProviderCluster(Messaging::ExchangeManager & exchangeManager, const SessionHandle & session, + EndpointId endpoint) : + ClusterBase(exchangeManager, session, app::Clusters::OtaSoftwareUpdateProvider::Id, endpoint) + {} + ~OtaSoftwareUpdateProviderCluster() {} +}; + +} // namespace Controller +} // namespace chip diff --git a/zzz_generated/lighting-app/nxp/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/lighting-app/nxp/zap-generated/IMClusterCommandHandler.cpp new file mode 100644 index 00000000000000..ca173e1ae470bc --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/IMClusterCommandHandler.cpp @@ -0,0 +1,905 @@ +/* + * + * Copyright (c) 2022 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Currently we need some work to keep compatible with ember lib. +#include + +namespace chip { +namespace app { + +// Cluster specific command parsing + +namespace Clusters { + +namespace AdministratorCommissioning { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::OpenCommissioningWindow::Id: { + Commands::OpenCommissioningWindow::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfAdministratorCommissioningClusterOpenCommissioningWindowCallback(apCommandObj, aCommandPath, + commandData); + } + break; + } + case Commands::RevokeCommissioning::Id: { + Commands::RevokeCommissioning::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfAdministratorCommissioningClusterRevokeCommissioningCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace AdministratorCommissioning + +namespace GeneralCommissioning { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::ArmFailSafe::Id: { + Commands::ArmFailSafe::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGeneralCommissioningClusterArmFailSafeCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::SetRegulatoryConfig::Id: { + Commands::SetRegulatoryConfig::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::CommissioningComplete::Id: { + Commands::CommissioningComplete::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfGeneralCommissioningClusterCommissioningCompleteCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace GeneralCommissioning + +namespace GeneralDiagnostics { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::TestEventTrigger::Id: { + Commands::TestEventTrigger::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGeneralDiagnosticsClusterTestEventTriggerCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace GeneralDiagnostics + +namespace GroupKeyManagement { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::KeySetWrite::Id: { + Commands::KeySetWrite::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupKeyManagementClusterKeySetWriteCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::KeySetRead::Id: { + Commands::KeySetRead::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupKeyManagementClusterKeySetReadCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::KeySetRemove::Id: { + Commands::KeySetRemove::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupKeyManagementClusterKeySetRemoveCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::KeySetReadAllIndices::Id: { + Commands::KeySetReadAllIndices::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupKeyManagementClusterKeySetReadAllIndicesCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace GroupKeyManagement + +namespace Groups { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::AddGroup::Id: { + Commands::AddGroup::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupsClusterAddGroupCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::ViewGroup::Id: { + Commands::ViewGroup::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupsClusterViewGroupCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::GetGroupMembership::Id: { + Commands::GetGroupMembership::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupsClusterGetGroupMembershipCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::RemoveGroup::Id: { + Commands::RemoveGroup::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupsClusterRemoveGroupCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::RemoveAllGroups::Id: { + Commands::RemoveAllGroups::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupsClusterRemoveAllGroupsCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::AddGroupIfIdentifying::Id: { + Commands::AddGroupIfIdentifying::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfGroupsClusterAddGroupIfIdentifyingCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace Groups + +namespace Identify { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::Identify::Id: { + Commands::Identify::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfIdentifyClusterIdentifyCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::TriggerEffect::Id: { + Commands::TriggerEffect::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfIdentifyClusterTriggerEffectCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace Identify + +namespace LevelControl { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::MoveToLevel::Id: { + Commands::MoveToLevel::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterMoveToLevelCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::Move::Id: { + Commands::Move::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterMoveCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::Step::Id: { + Commands::Step::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterStepCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::Stop::Id: { + Commands::Stop::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterStopCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::MoveToLevelWithOnOff::Id: { + Commands::MoveToLevelWithOnOff::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterMoveToLevelWithOnOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::MoveWithOnOff::Id: { + Commands::MoveWithOnOff::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterMoveWithOnOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::StepWithOnOff::Id: { + Commands::StepWithOnOff::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterStepWithOnOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::StopWithOnOff::Id: { + Commands::StopWithOnOff::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfLevelControlClusterStopWithOnOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace LevelControl + +namespace NetworkCommissioning { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::ScanNetworks::Id: { + Commands::ScanNetworks::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfNetworkCommissioningClusterScanNetworksCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::AddOrUpdateThreadNetwork::Id: { + Commands::AddOrUpdateThreadNetwork::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfNetworkCommissioningClusterAddOrUpdateThreadNetworkCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::RemoveNetwork::Id: { + Commands::RemoveNetwork::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfNetworkCommissioningClusterRemoveNetworkCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::ConnectNetwork::Id: { + Commands::ConnectNetwork::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfNetworkCommissioningClusterConnectNetworkCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::ReorderNetwork::Id: { + Commands::ReorderNetwork::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfNetworkCommissioningClusterReorderNetworkCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace NetworkCommissioning + +namespace OtaSoftwareUpdateRequestor { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::AnnounceOtaProvider::Id: { + Commands::AnnounceOtaProvider::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfOtaSoftwareUpdateRequestorClusterAnnounceOtaProviderCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace OtaSoftwareUpdateRequestor + +namespace OnOff { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::Off::Id: { + Commands::Off::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::On::Id: { + Commands::On::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOnCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::Toggle::Id: { + Commands::Toggle::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterToggleCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::OffWithEffect::Id: { + Commands::OffWithEffect::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOffWithEffectCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::OnWithRecallGlobalScene::Id: { + Commands::OnWithRecallGlobalScene::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOnWithRecallGlobalSceneCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::OnWithTimedOff::Id: { + Commands::OnWithTimedOff::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOnOffClusterOnWithTimedOffCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace OnOff + +namespace OperationalCredentials { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::AttestationRequest::Id: { + Commands::AttestationRequest::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfOperationalCredentialsClusterAttestationRequestCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::CertificateChainRequest::Id: { + Commands::CertificateChainRequest::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfOperationalCredentialsClusterCertificateChainRequestCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::CSRRequest::Id: { + Commands::CSRRequest::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOperationalCredentialsClusterCSRRequestCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::AddNOC::Id: { + Commands::AddNOC::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOperationalCredentialsClusterAddNOCCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::UpdateNOC::Id: { + Commands::UpdateNOC::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOperationalCredentialsClusterUpdateNOCCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::UpdateFabricLabel::Id: { + Commands::UpdateFabricLabel::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::RemoveFabric::Id: { + Commands::RemoveFabric::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfOperationalCredentialsClusterRemoveFabricCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + case Commands::AddTrustedRootCertificate::Id: { + Commands::AddTrustedRootCertificate::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace OperationalCredentials + +namespace SoftwareDiagnostics { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::ResetWatermarks::Id: { + Commands::ResetWatermarks::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfSoftwareDiagnosticsClusterResetWatermarksCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace SoftwareDiagnostics + +namespace ThreadNetworkDiagnostics { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) +{ + CHIP_ERROR TLVError = CHIP_NO_ERROR; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::ResetCounts::Id: { + Commands::ResetCounts::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAfThreadNetworkDiagnosticsClusterResetCountsCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace ThreadNetworkDiagnostics + +} // namespace Clusters + +void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aReader, CommandHandler * apCommandObj) +{ + Compatibility::SetupEmberAfCommandHandler(apCommandObj, aCommandPath); + + switch (aCommandPath.mClusterId) + { + case Clusters::AdministratorCommissioning::Id: + Clusters::AdministratorCommissioning::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::GeneralCommissioning::Id: + Clusters::GeneralCommissioning::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::GeneralDiagnostics::Id: + Clusters::GeneralDiagnostics::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::GroupKeyManagement::Id: + Clusters::GroupKeyManagement::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::Groups::Id: + Clusters::Groups::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::Identify::Id: + Clusters::Identify::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::LevelControl::Id: + Clusters::LevelControl::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::NetworkCommissioning::Id: + Clusters::NetworkCommissioning::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::OtaSoftwareUpdateRequestor::Id: + Clusters::OtaSoftwareUpdateRequestor::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::OnOff::Id: + Clusters::OnOff::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::OperationalCredentials::Id: + Clusters::OperationalCredentials::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::SoftwareDiagnostics::Id: + Clusters::SoftwareDiagnostics::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + case Clusters::ThreadNetworkDiagnostics::Id: + Clusters::ThreadNetworkDiagnostics::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; + default: + ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandPath.mClusterId)); + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCluster); + break; + } + + Compatibility::ResetEmberAfObjects(); +} + +} // namespace app +} // namespace chip diff --git a/zzz_generated/lighting-app/nxp/zap-generated/PluginApplicationCallbacks.h b/zzz_generated/lighting-app/nxp/zap-generated/PluginApplicationCallbacks.h new file mode 100644 index 00000000000000..0cfb01937c9d9f --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/PluginApplicationCallbacks.h @@ -0,0 +1,41 @@ +/* + * + * Copyright (c) 2022 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +#pragma once + +#include + +#define MATTER_PLUGINS_INIT \ + MatterIdentifyPluginServerInitCallback(); \ + MatterGroupsPluginServerInitCallback(); \ + MatterOnOffPluginServerInitCallback(); \ + MatterLevelControlPluginServerInitCallback(); \ + MatterDescriptorPluginServerInitCallback(); \ + MatterAccessControlPluginServerInitCallback(); \ + MatterBasicPluginServerInitCallback(); \ + MatterOtaSoftwareUpdateProviderPluginClientInitCallback(); \ + MatterOtaSoftwareUpdateRequestorPluginServerInitCallback(); \ + MatterGeneralCommissioningPluginServerInitCallback(); \ + MatterNetworkCommissioningPluginServerInitCallback(); \ + MatterGeneralDiagnosticsPluginServerInitCallback(); \ + MatterSoftwareDiagnosticsPluginServerInitCallback(); \ + MatterThreadNetworkDiagnosticsPluginServerInitCallback(); \ + MatterAdministratorCommissioningPluginServerInitCallback(); \ + MatterOperationalCredentialsPluginServerInitCallback(); \ + MatterGroupKeyManagementPluginServerInitCallback(); diff --git a/zzz_generated/lighting-app/nxp/zap-generated/access.h b/zzz_generated/lighting-app/nxp/zap-generated/access.h new file mode 100644 index 00000000000000..b1932aec7b2088 --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/access.h @@ -0,0 +1,254 @@ +/* + * + * Copyright (c) 2022 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +// Prevent multiple inclusion +#pragma once + +#include + +// Prevent changing generated format +// clang-format off + +//////////////////////////////////////////////////////////////////////////////// + +// Parallel array data (*cluster*, attribute, privilege) for read attribute +#define GENERATED_ACCESS_READ_ATTRIBUTE__CLUSTER { \ + /* Cluster: On/Off, Attribute: StartUpOnOff, Privilege: view */ \ + /* Cluster: Level Control, Attribute: StartUpCurrentLevel, Privilege: view */ \ + 31, /* Cluster: Access Control, Attribute: ACL, Privilege: administer */ \ + /* Cluster: Access Control, Attribute: SubjectsPerAccessControlEntry, Privilege: view */ \ + /* Cluster: Access Control, Attribute: TargetsPerAccessControlEntry, Privilege: view */ \ + /* Cluster: Access Control, Attribute: AccessControlEntriesPerFabric, Privilege: view */ \ + /* Cluster: Basic, Attribute: NodeLabel, Privilege: view */ \ + /* Cluster: Basic, Attribute: Location, Privilege: view */ \ + /* Cluster: General Commissioning, Attribute: Breadcrumb, Privilege: view */ \ + 49, /* Cluster: Network Commissioning, Attribute: MaxNetworks, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Attribute: Networks, Privilege: administer */ \ + /* Cluster: Network Commissioning, Attribute: InterfaceEnabled, Privilege: view */ \ + 49, /* Cluster: Network Commissioning, Attribute: LastNetworkingStatus, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Attribute: LastNetworkID, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Attribute: LastConnectErrorValue, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Attribute: NOCs, Privilege: administer */ \ + /* Cluster: Group Key Management, Attribute: GroupKeyMap, Privilege: view */ \ +} + +// Parallel array data (cluster, *attribute*, privilege) for read attribute +#define GENERATED_ACCESS_READ_ATTRIBUTE__ATTRIBUTE { \ + /* Cluster: On/Off, Attribute: StartUpOnOff, Privilege: view */ \ + /* Cluster: Level Control, Attribute: StartUpCurrentLevel, Privilege: view */ \ + 0, /* Cluster: Access Control, Attribute: ACL, Privilege: administer */ \ + /* Cluster: Access Control, Attribute: SubjectsPerAccessControlEntry, Privilege: view */ \ + /* Cluster: Access Control, Attribute: TargetsPerAccessControlEntry, Privilege: view */ \ + /* Cluster: Access Control, Attribute: AccessControlEntriesPerFabric, Privilege: view */ \ + /* Cluster: Basic, Attribute: NodeLabel, Privilege: view */ \ + /* Cluster: Basic, Attribute: Location, Privilege: view */ \ + /* Cluster: General Commissioning, Attribute: Breadcrumb, Privilege: view */ \ + 0, /* Cluster: Network Commissioning, Attribute: MaxNetworks, Privilege: administer */ \ + 1, /* Cluster: Network Commissioning, Attribute: Networks, Privilege: administer */ \ + /* Cluster: Network Commissioning, Attribute: InterfaceEnabled, Privilege: view */ \ + 5, /* Cluster: Network Commissioning, Attribute: LastNetworkingStatus, Privilege: administer */ \ + 6, /* Cluster: Network Commissioning, Attribute: LastNetworkID, Privilege: administer */ \ + 7, /* Cluster: Network Commissioning, Attribute: LastConnectErrorValue, Privilege: administer */ \ + 0, /* Cluster: Operational Credentials, Attribute: NOCs, Privilege: administer */ \ + /* Cluster: Group Key Management, Attribute: GroupKeyMap, Privilege: view */ \ +} + +// Parallel array data (cluster, attribute, *privilege*) for read attribute +#define GENERATED_ACCESS_READ_ATTRIBUTE__PRIVILEGE { \ + /* Cluster: On/Off, Attribute: StartUpOnOff, Privilege: view */ \ + /* Cluster: Level Control, Attribute: StartUpCurrentLevel, Privilege: view */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Access Control, Attribute: ACL, Privilege: administer */ \ + /* Cluster: Access Control, Attribute: SubjectsPerAccessControlEntry, Privilege: view */ \ + /* Cluster: Access Control, Attribute: TargetsPerAccessControlEntry, Privilege: view */ \ + /* Cluster: Access Control, Attribute: AccessControlEntriesPerFabric, Privilege: view */ \ + /* Cluster: Basic, Attribute: NodeLabel, Privilege: view */ \ + /* Cluster: Basic, Attribute: Location, Privilege: view */ \ + /* Cluster: General Commissioning, Attribute: Breadcrumb, Privilege: view */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Attribute: MaxNetworks, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Attribute: Networks, Privilege: administer */ \ + /* Cluster: Network Commissioning, Attribute: InterfaceEnabled, Privilege: view */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Attribute: LastNetworkingStatus, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Attribute: LastNetworkID, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Attribute: LastConnectErrorValue, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Attribute: NOCs, Privilege: administer */ \ + /* Cluster: Group Key Management, Attribute: GroupKeyMap, Privilege: view */ \ +} + +//////////////////////////////////////////////////////////////////////////////// + +// Parallel array data (*cluster*, attribute, privilege) for write attribute +#define GENERATED_ACCESS_WRITE_ATTRIBUTE__CLUSTER { \ + 6, /* Cluster: On/Off, Attribute: StartUpOnOff, Privilege: manage */ \ + 8, /* Cluster: Level Control, Attribute: StartUpCurrentLevel, Privilege: manage */ \ + 31, /* Cluster: Access Control, Attribute: ACL, Privilege: administer */ \ + 40, /* Cluster: Basic, Attribute: NodeLabel, Privilege: manage */ \ + 40, /* Cluster: Basic, Attribute: Location, Privilege: administer */ \ + 48, /* Cluster: General Commissioning, Attribute: Breadcrumb, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Attribute: InterfaceEnabled, Privilege: administer */ \ + 63, /* Cluster: Group Key Management, Attribute: GroupKeyMap, Privilege: manage */ \ +} + +// Parallel array data (cluster, *attribute*, privilege) for write attribute +#define GENERATED_ACCESS_WRITE_ATTRIBUTE__ATTRIBUTE { \ + 16387, /* Cluster: On/Off, Attribute: StartUpOnOff, Privilege: manage */ \ + 16384, /* Cluster: Level Control, Attribute: StartUpCurrentLevel, Privilege: manage */ \ + 0, /* Cluster: Access Control, Attribute: ACL, Privilege: administer */ \ + 5, /* Cluster: Basic, Attribute: NodeLabel, Privilege: manage */ \ + 6, /* Cluster: Basic, Attribute: Location, Privilege: administer */ \ + 0, /* Cluster: General Commissioning, Attribute: Breadcrumb, Privilege: administer */ \ + 4, /* Cluster: Network Commissioning, Attribute: InterfaceEnabled, Privilege: administer */ \ + 0, /* Cluster: Group Key Management, Attribute: GroupKeyMap, Privilege: manage */ \ +} + +// Parallel array data (cluster, attribute, *privilege*) for write attribute +#define GENERATED_ACCESS_WRITE_ATTRIBUTE__PRIVILEGE { \ + kMatterAccessPrivilegeManage, /* Cluster: On/Off, Attribute: StartUpOnOff, Privilege: manage */ \ + kMatterAccessPrivilegeManage, /* Cluster: Level Control, Attribute: StartUpCurrentLevel, Privilege: manage */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Access Control, Attribute: ACL, Privilege: administer */ \ + kMatterAccessPrivilegeManage, /* Cluster: Basic, Attribute: NodeLabel, Privilege: manage */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Basic, Attribute: Location, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: General Commissioning, Attribute: Breadcrumb, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Attribute: InterfaceEnabled, Privilege: administer */ \ + kMatterAccessPrivilegeManage, /* Cluster: Group Key Management, Attribute: GroupKeyMap, Privilege: manage */ \ +} + +//////////////////////////////////////////////////////////////////////////////// + +// Parallel array data (*cluster*, command, privilege) for invoke command +#define GENERATED_ACCESS_INVOKE_COMMAND__CLUSTER { \ + 3, /* Cluster: Identify, Command: Identify, Privilege: manage */ \ + 3, /* Cluster: Identify, Command: TriggerEffect, Privilege: manage */ \ + 4, /* Cluster: Groups, Command: AddGroup, Privilege: manage */ \ + 4, /* Cluster: Groups, Command: RemoveGroup, Privilege: manage */ \ + 4, /* Cluster: Groups, Command: RemoveAllGroups, Privilege: manage */ \ + 4, /* Cluster: Groups, Command: AddGroupIfIdentifying, Privilege: manage */ \ + 48, /* Cluster: General Commissioning, Command: ArmFailSafe, Privilege: administer */ \ + 48, /* Cluster: General Commissioning, Command: SetRegulatoryConfig, Privilege: administer */ \ + 48, /* Cluster: General Commissioning, Command: CommissioningComplete, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Command: ScanNetworks, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Command: AddOrUpdateThreadNetwork, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Command: RemoveNetwork, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Command: ConnectNetwork, Privilege: administer */ \ + 49, /* Cluster: Network Commissioning, Command: ReorderNetwork, Privilege: administer */ \ + 51, /* Cluster: General Diagnostics, Command: TestEventTrigger, Privilege: manage */ \ + 60, /* Cluster: AdministratorCommissioning, Command: OpenCommissioningWindow, Privilege: administer */ \ + 60, /* Cluster: AdministratorCommissioning, Command: RevokeCommissioning, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: AttestationRequest, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: CertificateChainRequest, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: CSRRequest, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: AddNOC, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: UpdateNOC, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: UpdateFabricLabel, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: RemoveFabric, Privilege: administer */ \ + 62, /* Cluster: Operational Credentials, Command: AddTrustedRootCertificate, Privilege: administer */ \ + 63, /* Cluster: Group Key Management, Command: KeySetWrite, Privilege: administer */ \ + 63, /* Cluster: Group Key Management, Command: KeySetRead, Privilege: administer */ \ + 63, /* Cluster: Group Key Management, Command: KeySetRemove, Privilege: administer */ \ + 63, /* Cluster: Group Key Management, Command: KeySetReadAllIndices, Privilege: administer */ \ +} + +// Parallel array data (cluster, *command*, privilege) for invoke command +#define GENERATED_ACCESS_INVOKE_COMMAND__COMMAND { \ + 0, /* Cluster: Identify, Command: Identify, Privilege: manage */ \ + 64, /* Cluster: Identify, Command: TriggerEffect, Privilege: manage */ \ + 0, /* Cluster: Groups, Command: AddGroup, Privilege: manage */ \ + 3, /* Cluster: Groups, Command: RemoveGroup, Privilege: manage */ \ + 4, /* Cluster: Groups, Command: RemoveAllGroups, Privilege: manage */ \ + 5, /* Cluster: Groups, Command: AddGroupIfIdentifying, Privilege: manage */ \ + 0, /* Cluster: General Commissioning, Command: ArmFailSafe, Privilege: administer */ \ + 2, /* Cluster: General Commissioning, Command: SetRegulatoryConfig, Privilege: administer */ \ + 4, /* Cluster: General Commissioning, Command: CommissioningComplete, Privilege: administer */ \ + 0, /* Cluster: Network Commissioning, Command: ScanNetworks, Privilege: administer */ \ + 3, /* Cluster: Network Commissioning, Command: AddOrUpdateThreadNetwork, Privilege: administer */ \ + 4, /* Cluster: Network Commissioning, Command: RemoveNetwork, Privilege: administer */ \ + 6, /* Cluster: Network Commissioning, Command: ConnectNetwork, Privilege: administer */ \ + 8, /* Cluster: Network Commissioning, Command: ReorderNetwork, Privilege: administer */ \ + 0, /* Cluster: General Diagnostics, Command: TestEventTrigger, Privilege: manage */ \ + 0, /* Cluster: AdministratorCommissioning, Command: OpenCommissioningWindow, Privilege: administer */ \ + 2, /* Cluster: AdministratorCommissioning, Command: RevokeCommissioning, Privilege: administer */ \ + 0, /* Cluster: Operational Credentials, Command: AttestationRequest, Privilege: administer */ \ + 2, /* Cluster: Operational Credentials, Command: CertificateChainRequest, Privilege: administer */ \ + 4, /* Cluster: Operational Credentials, Command: CSRRequest, Privilege: administer */ \ + 6, /* Cluster: Operational Credentials, Command: AddNOC, Privilege: administer */ \ + 7, /* Cluster: Operational Credentials, Command: UpdateNOC, Privilege: administer */ \ + 9, /* Cluster: Operational Credentials, Command: UpdateFabricLabel, Privilege: administer */ \ + 10, /* Cluster: Operational Credentials, Command: RemoveFabric, Privilege: administer */ \ + 11, /* Cluster: Operational Credentials, Command: AddTrustedRootCertificate, Privilege: administer */ \ + 0, /* Cluster: Group Key Management, Command: KeySetWrite, Privilege: administer */ \ + 1, /* Cluster: Group Key Management, Command: KeySetRead, Privilege: administer */ \ + 3, /* Cluster: Group Key Management, Command: KeySetRemove, Privilege: administer */ \ + 4, /* Cluster: Group Key Management, Command: KeySetReadAllIndices, Privilege: administer */ \ +} + +// Parallel array data (cluster, command, *privilege*) for invoke command +#define GENERATED_ACCESS_INVOKE_COMMAND__PRIVILEGE { \ + kMatterAccessPrivilegeManage, /* Cluster: Identify, Command: Identify, Privilege: manage */ \ + kMatterAccessPrivilegeManage, /* Cluster: Identify, Command: TriggerEffect, Privilege: manage */ \ + kMatterAccessPrivilegeManage, /* Cluster: Groups, Command: AddGroup, Privilege: manage */ \ + kMatterAccessPrivilegeManage, /* Cluster: Groups, Command: RemoveGroup, Privilege: manage */ \ + kMatterAccessPrivilegeManage, /* Cluster: Groups, Command: RemoveAllGroups, Privilege: manage */ \ + kMatterAccessPrivilegeManage, /* Cluster: Groups, Command: AddGroupIfIdentifying, Privilege: manage */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: General Commissioning, Command: ArmFailSafe, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: General Commissioning, Command: SetRegulatoryConfig, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: General Commissioning, Command: CommissioningComplete, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Command: ScanNetworks, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Command: AddOrUpdateThreadNetwork, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Command: RemoveNetwork, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Command: ConnectNetwork, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Network Commissioning, Command: ReorderNetwork, Privilege: administer */ \ + kMatterAccessPrivilegeManage, /* Cluster: General Diagnostics, Command: TestEventTrigger, Privilege: manage */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: AdministratorCommissioning, Command: OpenCommissioningWindow, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: AdministratorCommissioning, Command: RevokeCommissioning, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: AttestationRequest, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: CertificateChainRequest, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: CSRRequest, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: AddNOC, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: UpdateNOC, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: UpdateFabricLabel, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: RemoveFabric, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Operational Credentials, Command: AddTrustedRootCertificate, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Group Key Management, Command: KeySetWrite, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Group Key Management, Command: KeySetRead, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Group Key Management, Command: KeySetRemove, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Group Key Management, Command: KeySetReadAllIndices, Privilege: administer */ \ +} + +//////////////////////////////////////////////////////////////////////////////// + +// Parallel array data (*cluster*, event, privilege) for read event +#define GENERATED_ACCESS_READ_EVENT__CLUSTER { \ + 31, /* Cluster: Access Control, Event: AccessControlEntryChanged, Privilege: administer */ \ + 31, /* Cluster: Access Control, Event: AccessControlExtensionChanged, Privilege: administer */ \ +} + +// Parallel array data (cluster, *event*, privilege) for read event +#define GENERATED_ACCESS_READ_EVENT__EVENT { \ + 0, /* Cluster: Access Control, Event: AccessControlEntryChanged, Privilege: administer */ \ + 1, /* Cluster: Access Control, Event: AccessControlExtensionChanged, Privilege: administer */ \ +} + +// Parallel array data (cluster, event, *privilege*) for read event +#define GENERATED_ACCESS_READ_EVENT__PRIVILEGE { \ + kMatterAccessPrivilegeAdminister, /* Cluster: Access Control, Event: AccessControlEntryChanged, Privilege: administer */ \ + kMatterAccessPrivilegeAdminister, /* Cluster: Access Control, Event: AccessControlExtensionChanged, Privilege: administer */ \ +} + +//////////////////////////////////////////////////////////////////////////////// + +// clang-format on diff --git a/zzz_generated/lighting-app/nxp/zap-generated/af-gen-event.h b/zzz_generated/lighting-app/nxp/zap-generated/af-gen-event.h new file mode 100644 index 00000000000000..814d4aab6b8bec --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/af-gen-event.h @@ -0,0 +1,39 @@ +/** + * + * 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. + */ + +/** + * + * Copyright (c) 2020 Silicon Labs + * + * 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. + */ + +// Enclosing macro to prevent multiple inclusion +#ifndef __AF_GEN_EVENT__ +#define __AF_GEN_EVENT__ + +#endif // __AF_GEN_EVENT__ diff --git a/zzz_generated/lighting-app/nxp/zap-generated/callback-stub.cpp b/zzz_generated/lighting-app/nxp/zap-generated/callback-stub.cpp new file mode 100644 index 00000000000000..b809a1f1b65cb6 --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/callback-stub.cpp @@ -0,0 +1,263 @@ +/* + * + * Copyright (c) 2022 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +#include +#include +#include +#include + +using namespace chip; + +// Cluster Init Functions +void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) +{ + switch (clusterId) + { + case ZCL_ACCESS_CONTROL_CLUSTER_ID: + emberAfAccessControlClusterInitCallback(endpoint); + break; + case ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_ID: + emberAfAdministratorCommissioningClusterInitCallback(endpoint); + break; + case ZCL_BASIC_CLUSTER_ID: + emberAfBasicClusterInitCallback(endpoint); + break; + case ZCL_DESCRIPTOR_CLUSTER_ID: + emberAfDescriptorClusterInitCallback(endpoint); + break; + case ZCL_GENERAL_COMMISSIONING_CLUSTER_ID: + emberAfGeneralCommissioningClusterInitCallback(endpoint); + break; + case ZCL_GENERAL_DIAGNOSTICS_CLUSTER_ID: + emberAfGeneralDiagnosticsClusterInitCallback(endpoint); + break; + case ZCL_GROUP_KEY_MANAGEMENT_CLUSTER_ID: + emberAfGroupKeyManagementClusterInitCallback(endpoint); + break; + case ZCL_GROUPS_CLUSTER_ID: + emberAfGroupsClusterInitCallback(endpoint); + break; + case ZCL_IDENTIFY_CLUSTER_ID: + emberAfIdentifyClusterInitCallback(endpoint); + break; + case ZCL_LEVEL_CONTROL_CLUSTER_ID: + emberAfLevelControlClusterInitCallback(endpoint); + break; + case ZCL_NETWORK_COMMISSIONING_CLUSTER_ID: + emberAfNetworkCommissioningClusterInitCallback(endpoint); + break; + case ZCL_OTA_PROVIDER_CLUSTER_ID: + emberAfOtaSoftwareUpdateProviderClusterInitCallback(endpoint); + break; + case ZCL_OTA_REQUESTOR_CLUSTER_ID: + emberAfOtaSoftwareUpdateRequestorClusterInitCallback(endpoint); + break; + case ZCL_ON_OFF_CLUSTER_ID: + emberAfOnOffClusterInitCallback(endpoint); + break; + case ZCL_OPERATIONAL_CREDENTIALS_CLUSTER_ID: + emberAfOperationalCredentialsClusterInitCallback(endpoint); + break; + case ZCL_SOFTWARE_DIAGNOSTICS_CLUSTER_ID: + emberAfSoftwareDiagnosticsClusterInitCallback(endpoint); + break; + case ZCL_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_ID: + emberAfThreadNetworkDiagnosticsClusterInitCallback(endpoint); + break; + default: + // Unrecognized cluster ID + break; + } +} + +void __attribute__((weak)) emberAfAccessControlClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfAdministratorCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfBasicClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfDescriptorClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfGeneralCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfGeneralDiagnosticsClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfGroupKeyManagementClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfGroupsClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfIdentifyClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfLevelControlClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfNetworkCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfOtaSoftwareUpdateProviderClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfOtaSoftwareUpdateRequestorClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfOnOffClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfOperationalCredentialsClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfSoftwareDiagnosticsClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} +void __attribute__((weak)) emberAfThreadNetworkDiagnosticsClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} + +// +// Non-Cluster Related Callbacks +// + +void __attribute__((weak)) emberAfAddToCurrentAppTasksCallback(EmberAfApplicationTask tasks) {} + +void __attribute__((weak)) emberAfRemoveFromCurrentAppTasksCallback(EmberAfApplicationTask tasks) {} + +EmberAfAttributeWritePermission __attribute__((weak)) +emberAfAllowNetworkWriteAttributeCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId, uint8_t * value, + uint8_t type) +{ + return EMBER_ZCL_ATTRIBUTE_WRITE_PERMISSION_ALLOW_WRITE_NORMAL; // Default +} + +bool __attribute__((weak)) emberAfAttributeReadAccessCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId) +{ + return true; +} + +bool __attribute__((weak)) emberAfAttributeWriteAccessCallback(EndpointId endpoint, ClusterId clusterId, AttributeId attributeId) +{ + return true; +} + +bool __attribute__((weak)) emberAfDefaultResponseCallback(ClusterId clusterId, CommandId commandId, EmberAfStatus status) +{ + return false; +} + +bool __attribute__((weak)) emberAfPreMessageSendCallback(EmberAfMessageStruct * messageStruct, EmberStatus * status) +{ + return false; +} + +bool __attribute__((weak)) emberAfMessageSentCallback(const MessageSendDestination & destination, EmberApsFrame * apsFrame, + uint16_t msgLen, uint8_t * message, EmberStatus status) +{ + return false; +} + +EmberAfStatus __attribute__((weak)) +emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer, uint16_t maxReadLength) +{ + return EMBER_ZCL_STATUS_FAILURE; +} + +EmberAfStatus __attribute__((weak)) +emberAfExternalAttributeWriteCallback(EndpointId endpoint, ClusterId clusterId, const EmberAfAttributeMetadata * attributeMetadata, + uint8_t * buffer) +{ + return EMBER_ZCL_STATUS_FAILURE; +} + +uint32_t __attribute__((weak)) emberAfGetCurrentTimeCallback() +{ + return 0; +} + +bool __attribute__((weak)) +emberAfGetEndpointInfoCallback(EndpointId endpoint, uint8_t * returnNetworkIndex, EmberAfEndpointInfoStruct * returnEndpointInfo) +{ + return false; +} + +void __attribute__((weak)) emberAfRegistrationAbortCallback() {} + +EmberStatus __attribute__((weak)) +emberAfInterpanSendMessageCallback(EmberAfInterpanHeader * header, uint16_t messageLength, uint8_t * message) +{ + return EMBER_LIBRARY_NOT_PRESENT; +} + +bool __attribute__((weak)) emberAfStartMoveCallback() +{ + return false; +} + +chip::Protocols::InteractionModel::Status __attribute__((weak)) +MatterPreAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, + uint8_t * value) +{ + return chip::Protocols::InteractionModel::Status::Success; +} + +void __attribute__((weak)) MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, + uint16_t size, uint8_t * value) +{} diff --git a/zzz_generated/lighting-app/nxp/zap-generated/endpoint_config.h b/zzz_generated/lighting-app/nxp/zap-generated/endpoint_config.h new file mode 100644 index 00000000000000..7caf9b7ee0ce99 --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/endpoint_config.h @@ -0,0 +1,779 @@ +/* + * + * Copyright (c) 2022 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +// Prevent multiple inclusion +#pragma once + +#include + +// Default values for the attributes longer than a pointer, +// in a form of a binary blob +// Separate block is generated for big-endian and little-endian cases. +#if BIGENDIAN_CPU +#define GENERATED_DEFAULTS \ + { \ + \ + /* Endpoint: 0, Cluster: General Commissioning (server), big-endian */ \ + \ + /* 0 - Breadcrumb, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + } + +#else // !BIGENDIAN_CPU +#define GENERATED_DEFAULTS \ + { \ + \ + /* Endpoint: 0, Cluster: General Commissioning (server), little-endian */ \ + \ + /* 0 - Breadcrumb, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + } + +#endif // BIGENDIAN_CPU + +#define GENERATED_DEFAULTS_COUNT (1) + +#define ZAP_TYPE(type) ZCL_##type##_ATTRIBUTE_TYPE +#define ZAP_LONG_DEFAULTS_INDEX(index) \ + { \ + &generatedDefaults[index] \ + } +#define ZAP_MIN_MAX_DEFAULTS_INDEX(index) \ + { \ + &minMaxDefaults[index] \ + } +#define ZAP_EMPTY_DEFAULT() \ + { \ + (uint32_t) 0 \ + } +#define ZAP_SIMPLE_DEFAULT(x) \ + { \ + (uint32_t) x \ + } + +// This is an array of EmberAfAttributeMinMaxValue structures. +#define GENERATED_MIN_MAX_DEFAULT_COUNT 2 +#define GENERATED_MIN_MAX_DEFAULTS \ + { \ + \ + /* Endpoint: 1, Cluster: On/Off (server) */ \ + { (uint16_t) 0xFF, (uint16_t) 0x0, (uint16_t) 0x2 }, /* StartUpOnOff */ \ + \ + /* Endpoint: 1, Cluster: Level Control (server) */ { (uint16_t) 0x0, (uint16_t) 0x0, (uint16_t) 0x3 } /* Options */ \ + } + +#define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask +// This is an array of EmberAfAttributeMetadata structures. +#define GENERATED_ATTRIBUTE_COUNT 170 +#define GENERATED_ATTRIBUTES \ + { \ + \ + /* Endpoint: 0, Cluster: Descriptor (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* DeviceTypeList */ \ + { 0x00000001, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ServerList */ \ + { 0x00000002, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ClientList */ \ + { 0x00000003, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* PartsList */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Access Control (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_EMPTY_DEFAULT() }, /* ACL */ \ + { 0x00000002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* SubjectsPerAccessControlEntry */ \ + { 0x00000003, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TargetsPerAccessControlEntry */ \ + { 0x00000004, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* AccessControlEntriesPerFabric */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Basic (server) */ \ + { 0x00000000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* DataModelRevision */ \ + { 0x00000001, ZAP_TYPE(CHAR_STRING), 33, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* VendorName */ \ + { 0x00000002, ZAP_TYPE(VENDOR_ID), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* VendorID */ \ + { 0x00000003, ZAP_TYPE(CHAR_STRING), 33, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* ProductName */ \ + { 0x00000004, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* ProductID */ \ + { 0x00000005, ZAP_TYPE(CHAR_STRING), 33, \ + ZAP_ATTRIBUTE_MASK(TOKENIZE) | ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_EMPTY_DEFAULT() }, /* NodeLabel */ \ + { 0x00000006, ZAP_TYPE(CHAR_STRING), 3, \ + ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_EMPTY_DEFAULT() }, /* Location */ \ + { 0x00000007, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* HardwareVersion */ \ + { 0x00000008, ZAP_TYPE(CHAR_STRING), 65, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* HardwareVersionString */ \ + { 0x00000009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* SoftwareVersion */ \ + { 0x0000000A, ZAP_TYPE(CHAR_STRING), 65, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(SINGLETON), \ + ZAP_EMPTY_DEFAULT() }, /* SoftwareVersionString */ \ + { 0x00000013, ZAP_TYPE(STRUCT), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* CapabilityMinima */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: OTA Software Update Requestor (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_EMPTY_DEFAULT() }, /* DefaultOtaProviders */ \ + { 0x00000001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(1) }, /* UpdatePossible */ \ + { 0x00000002, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0) }, /* UpdateState */ \ + { 0x00000003, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0) }, /* UpdateStateProgress */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: General Commissioning (server) */ \ + { 0x00000000, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_LONG_DEFAULTS_INDEX(0) }, /* Breadcrumb */ \ + { 0x00000001, ZAP_TYPE(STRUCT), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* BasicCommissioningInfo */ \ + { 0x00000002, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RegulatoryConfig */ \ + { 0x00000003, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* LocationCapability */ \ + { 0x00000004, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* SupportsConcurrentConnection */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ + { 0x00000000, ZAP_TYPE(INT8U), 1, 0, ZAP_EMPTY_DEFAULT() }, /* MaxNetworks */ \ + { 0x00000001, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* Networks */ \ + { 0x00000002, ZAP_TYPE(INT8U), 1, 0, ZAP_EMPTY_DEFAULT() }, /* ScanMaxTimeSeconds */ \ + { 0x00000003, ZAP_TYPE(INT8U), 1, 0, ZAP_EMPTY_DEFAULT() }, /* ConnectMaxTimeSeconds */ \ + { 0x00000004, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_EMPTY_DEFAULT() }, /* InterfaceEnabled */ \ + { 0x00000005, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* LastNetworkingStatus */ \ + { 0x00000006, ZAP_TYPE(OCTET_STRING), 33, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* LastNetworkID */ \ + { 0x00000007, ZAP_TYPE(INT32S), 4, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_EMPTY_DEFAULT() }, /* LastConnectErrorValue */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(2) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: General Diagnostics (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* NetworkInterfaces */ \ + { 0x00000001, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RebootCount */ \ + { 0x00000008, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TestEventTriggersEnabled */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Software Diagnostics (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ThreadMetrics */ \ + { 0x00000001, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* CurrentHeapFree */ \ + { 0x00000002, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* CurrentHeapUsed */ \ + { 0x00000003, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* CurrentHeapHighWatermark */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(1) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Thread Network Diagnostics (server) */ \ + { 0x00000000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* channel */ \ + { 0x00000001, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* RoutingRole */ \ + { 0x00000002, ZAP_TYPE(CHAR_STRING), 17, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* NetworkName */ \ + { 0x00000003, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* PanId */ \ + { 0x00000004, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* ExtendedPanId */ \ + { 0x00000005, ZAP_TYPE(OCTET_STRING), 18, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* MeshLocalPrefix */ \ + { 0x00000006, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* OverrunCount */ \ + { 0x00000007, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* NeighborTableList */ \ + { 0x00000008, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RouteTableList */ \ + { 0x00000009, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* PartitionId */ \ + { 0x0000000A, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* weighting */ \ + { 0x0000000B, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* DataVersion */ \ + { 0x0000000C, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* StableDataVersion */ \ + { 0x0000000D, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* LeaderRouterId */ \ + { 0x0000000E, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* DetachedRoleCount */ \ + { 0x0000000F, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ChildRoleCount */ \ + { 0x00000010, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RouterRoleCount */ \ + { 0x00000011, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* LeaderRoleCount */ \ + { 0x00000012, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* AttachAttemptCount */ \ + { 0x00000013, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* PartitionIdChangeCount */ \ + { 0x00000014, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* BetterPartitionAttachAttemptCount */ \ + { 0x00000015, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* ParentChangeCount */ \ + { 0x00000016, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxTotalCount */ \ + { 0x00000017, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxUnicastCount */ \ + { 0x00000018, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxBroadcastCount */ \ + { 0x00000019, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TxAckRequestedCount */ \ + { 0x0000001A, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxAckedCount */ \ + { 0x0000001B, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TxNoAckRequestedCount */ \ + { 0x0000001C, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxDataCount */ \ + { 0x0000001D, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxDataPollCount */ \ + { 0x0000001E, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxBeaconCount */ \ + { 0x0000001F, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TxBeaconRequestCount */ \ + { 0x00000020, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxOtherCount */ \ + { 0x00000021, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxRetryCount */ \ + { 0x00000022, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TxDirectMaxRetryExpiryCount */ \ + { 0x00000023, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TxIndirectMaxRetryExpiryCount */ \ + { 0x00000024, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxErrCcaCount */ \ + { 0x00000025, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* TxErrAbortCount */ \ + { 0x00000026, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TxErrBusyChannelCount */ \ + { 0x00000027, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxTotalCount */ \ + { 0x00000028, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxUnicastCount */ \ + { 0x00000029, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxBroadcastCount */ \ + { 0x0000002A, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxDataCount */ \ + { 0x0000002B, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxDataPollCount */ \ + { 0x0000002C, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxBeaconCount */ \ + { 0x0000002D, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxBeaconRequestCount */ \ + { 0x0000002E, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxOtherCount */ \ + { 0x0000002F, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxAddressFilteredCount */ \ + { 0x00000030, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxDestAddrFilteredCount */ \ + { 0x00000031, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxDuplicatedCount */ \ + { 0x00000032, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxErrNoFrameCount */ \ + { 0x00000033, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxErrUnknownNeighborCount */ \ + { 0x00000034, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* RxErrInvalidSrcAddrCount */ \ + { 0x00000035, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxErrSecCount */ \ + { 0x00000036, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxErrFcsCount */ \ + { 0x00000037, ZAP_TYPE(INT32U), 4, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* RxErrOtherCount */ \ + { 0x0000003B, ZAP_TYPE(STRUCT), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* SecurityPolicy */ \ + { 0x0000003C, ZAP_TYPE(OCTET_STRING), 5, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* ChannelPage0Mask */ \ + { 0x0000003D, ZAP_TYPE(STRUCT), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* OperationalDatasetComponents */ \ + { 0x0000003E, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* ActiveNetworkFaultsList */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0x000F) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ + { 0x00000000, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* WindowStatus */ \ + { 0x00000001, ZAP_TYPE(FABRIC_IDX), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* AdminFabricIndex */ \ + { 0x00000002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_EMPTY_DEFAULT() }, /* AdminVendorId */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* NOCs */ \ + { 0x00000001, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* Fabrics */ \ + { 0x00000002, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* SupportedFabrics */ \ + { 0x00000003, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* CommissionedFabrics */ \ + { 0x00000004, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* TrustedRootCertificates */ \ + { 0x00000005, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* CurrentFabricIndex */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: Group Key Management (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_EMPTY_DEFAULT() }, /* GroupKeyMap */ \ + { 0x00000001, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* GroupTable */ \ + { 0x00000002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* MaxGroupsPerFabric */ \ + { 0x00000003, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), \ + ZAP_EMPTY_DEFAULT() }, /* MaxGroupKeysPerFabric */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + \ + /* Endpoint: 1, Cluster: Identify (server) */ \ + { 0x00000000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* identify time */ \ + { 0x00000001, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0x0) }, /* identify type */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(4) }, /* ClusterRevision */ \ + \ + /* Endpoint: 1, Cluster: Groups (server) */ \ + { 0x00000000, ZAP_TYPE(BITMAP8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* name support */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(4) }, /* ClusterRevision */ \ + \ + /* Endpoint: 1, Cluster: On/Off (server) */ \ + { 0x00000000, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(TOKENIZE), ZAP_SIMPLE_DEFAULT(0x00) }, /* OnOff */ \ + { 0x00004000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* GlobalSceneControl */ \ + { 0x00004001, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* OnTime */ \ + { 0x00004002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* OffWaitTime */ \ + { 0x00004003, ZAP_TYPE(ENUM8), 1, \ + ZAP_ATTRIBUTE_MASK(MIN_MAX) | ZAP_ATTRIBUTE_MASK(TOKENIZE) | ZAP_ATTRIBUTE_MASK(WRITABLE) | \ + ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_MIN_MAX_DEFAULTS_INDEX(0) }, /* StartUpOnOff */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(1) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(4) }, /* ClusterRevision */ \ + \ + /* Endpoint: 1, Cluster: Level Control (server) */ \ + { 0x00000000, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(TOKENIZE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_SIMPLE_DEFAULT(0x01) }, /* CurrentLevel */ \ + { 0x00000001, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0000) }, /* RemainingTime */ \ + { 0x00000002, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* MinLevel */ \ + { 0x00000003, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0xFE) }, /* MaxLevel */ \ + { 0x0000000F, ZAP_TYPE(BITMAP8), 1, ZAP_ATTRIBUTE_MASK(MIN_MAX) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_MIN_MAX_DEFAULTS_INDEX(1) }, /* Options */ \ + { 0x00000011, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(WRITABLE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_SIMPLE_DEFAULT(0xFF) }, /* OnLevel */ \ + { 0x00004000, ZAP_TYPE(INT8U), 1, \ + ZAP_ATTRIBUTE_MASK(TOKENIZE) | ZAP_ATTRIBUTE_MASK(WRITABLE) | ZAP_ATTRIBUTE_MASK(NULLABLE), \ + ZAP_SIMPLE_DEFAULT(254) }, /* StartUpCurrentLevel */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(3) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(5) }, /* ClusterRevision */ \ + \ + /* Endpoint: 1, Cluster: Descriptor (server) */ \ + { 0x00000000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* DeviceTypeList */ \ + { 0x00000001, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ServerList */ \ + { 0x00000002, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ClientList */ \ + { 0x00000003, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* PartsList */ \ + { 0x0000FFFC, ZAP_TYPE(BITMAP32), 4, 0, ZAP_SIMPLE_DEFAULT(0) }, /* FeatureMap */ \ + { 0x0000FFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* ClusterRevision */ \ + } + +// This is an array of EmberAfCluster structures. +#define ZAP_ATTRIBUTE_INDEX(index) (&generatedAttributes[index]) + +#define ZAP_GENERATED_COMMANDS_INDEX(index) ((chip::CommandId *) (&generatedCommands[index])) + +// Cluster function static arrays +#define GENERATED_FUNCTION_ARRAYS \ + const EmberAfGenericClusterFunction chipFuncArrayBasicServer[] = { \ + (EmberAfGenericClusterFunction) emberAfBasicClusterServerInitCallback, \ + }; \ + const EmberAfGenericClusterFunction chipFuncArrayIdentifyServer[] = { \ + (EmberAfGenericClusterFunction) emberAfIdentifyClusterServerInitCallback, \ + (EmberAfGenericClusterFunction) MatterIdentifyClusterServerAttributeChangedCallback, \ + }; \ + const EmberAfGenericClusterFunction chipFuncArrayGroupsServer[] = { \ + (EmberAfGenericClusterFunction) emberAfGroupsClusterServerInitCallback, \ + }; \ + const EmberAfGenericClusterFunction chipFuncArrayOnOffServer[] = { \ + (EmberAfGenericClusterFunction) emberAfOnOffClusterServerInitCallback, \ + }; \ + const EmberAfGenericClusterFunction chipFuncArrayLevelControlServer[] = { \ + (EmberAfGenericClusterFunction) emberAfLevelControlClusterServerInitCallback, \ + }; + +// clang-format off +#define GENERATED_COMMANDS { \ + /* Endpoint: 0, Cluster: OTA Software Update Requestor (server) */\ + /* AcceptedCommandList (index=0) */ \ + 0x00000000 /* AnnounceOtaProvider */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: General Commissioning (server) */\ + /* AcceptedCommandList (index=2) */ \ + 0x00000000 /* ArmFailSafe */, \ + 0x00000002 /* SetRegulatoryConfig */, \ + 0x00000004 /* CommissioningComplete */, \ + chip::kInvalidCommandId /* end of list */, \ + /* GeneratedCommandList (index=6)*/ \ + 0x00000001 /* ArmFailSafeResponse */, \ + 0x00000003 /* SetRegulatoryConfigResponse */, \ + 0x00000005 /* CommissioningCompleteResponse */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: Network Commissioning (server) */\ + /* AcceptedCommandList (index=10) */ \ + 0x00000000 /* ScanNetworks */, \ + 0x00000003 /* AddOrUpdateThreadNetwork */, \ + 0x00000004 /* RemoveNetwork */, \ + 0x00000006 /* ConnectNetwork */, \ + 0x00000008 /* ReorderNetwork */, \ + chip::kInvalidCommandId /* end of list */, \ + /* GeneratedCommandList (index=16)*/ \ + 0x00000001 /* ScanNetworksResponse */, \ + 0x00000005 /* NetworkConfigResponse */, \ + 0x00000007 /* ConnectNetworkResponse */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: General Diagnostics (server) */\ + /* AcceptedCommandList (index=20) */ \ + 0x00000000 /* TestEventTrigger */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: Software Diagnostics (server) */\ + /* AcceptedCommandList (index=22) */ \ + 0x00000000 /* ResetWatermarks */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: Thread Network Diagnostics (server) */\ + /* AcceptedCommandList (index=24) */ \ + 0x00000000 /* ResetCounts */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */\ + /* AcceptedCommandList (index=26) */ \ + 0x00000000 /* OpenCommissioningWindow */, \ + 0x00000002 /* RevokeCommissioning */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: Operational Credentials (server) */\ + /* AcceptedCommandList (index=29) */ \ + 0x00000000 /* AttestationRequest */, \ + 0x00000002 /* CertificateChainRequest */, \ + 0x00000004 /* CSRRequest */, \ + 0x00000006 /* AddNOC */, \ + 0x00000007 /* UpdateNOC */, \ + 0x00000009 /* UpdateFabricLabel */, \ + 0x0000000A /* RemoveFabric */, \ + 0x0000000B /* AddTrustedRootCertificate */, \ + chip::kInvalidCommandId /* end of list */, \ + /* GeneratedCommandList (index=38)*/ \ + 0x00000001 /* AttestationResponse */, \ + 0x00000003 /* CertificateChainResponse */, \ + 0x00000005 /* CSRResponse */, \ + 0x00000008 /* NOCResponse */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 0, Cluster: Group Key Management (server) */\ + /* AcceptedCommandList (index=43) */ \ + 0x00000000 /* KeySetWrite */, \ + 0x00000001 /* KeySetRead */, \ + 0x00000003 /* KeySetRemove */, \ + 0x00000004 /* KeySetReadAllIndices */, \ + chip::kInvalidCommandId /* end of list */, \ + /* GeneratedCommandList (index=48)*/ \ + 0x00000002 /* KeySetReadResponse */, \ + 0x00000005 /* KeySetReadAllIndicesResponse */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 1, Cluster: Identify (server) */\ + /* AcceptedCommandList (index=51) */ \ + 0x00000000 /* Identify */, \ + 0x00000040 /* TriggerEffect */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 1, Cluster: Groups (server) */\ + /* AcceptedCommandList (index=54) */ \ + 0x00000000 /* AddGroup */, \ + 0x00000001 /* ViewGroup */, \ + 0x00000002 /* GetGroupMembership */, \ + 0x00000003 /* RemoveGroup */, \ + 0x00000004 /* RemoveAllGroups */, \ + 0x00000005 /* AddGroupIfIdentifying */, \ + chip::kInvalidCommandId /* end of list */, \ + /* GeneratedCommandList (index=61)*/ \ + 0x00000000 /* AddGroupResponse */, \ + 0x00000001 /* ViewGroupResponse */, \ + 0x00000002 /* GetGroupMembershipResponse */, \ + 0x00000003 /* RemoveGroupResponse */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 1, Cluster: On/Off (server) */\ + /* AcceptedCommandList (index=66) */ \ + 0x00000000 /* Off */, \ + 0x00000001 /* On */, \ + 0x00000002 /* Toggle */, \ + 0x00000040 /* OffWithEffect */, \ + 0x00000041 /* OnWithRecallGlobalScene */, \ + 0x00000042 /* OnWithTimedOff */, \ + chip::kInvalidCommandId /* end of list */, \ + /* Endpoint: 1, Cluster: Level Control (server) */\ + /* AcceptedCommandList (index=73) */ \ + 0x00000000 /* MoveToLevel */, \ + 0x00000001 /* Move */, \ + 0x00000002 /* Step */, \ + 0x00000003 /* Stop */, \ + 0x00000004 /* MoveToLevelWithOnOff */, \ + 0x00000005 /* MoveWithOnOff */, \ + 0x00000006 /* StepWithOnOff */, \ + 0x00000007 /* StopWithOnOff */, \ + chip::kInvalidCommandId /* end of list */, \ +} + +// clang-format on + +#define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask +#define GENERATED_CLUSTER_COUNT 18 + +// clang-format off +#define GENERATED_CLUSTERS { \ + { \ + /* Endpoint: 0, Cluster: Descriptor (server) */ \ + .clusterId = 0x0000001D, \ + .attributes = ZAP_ATTRIBUTE_INDEX(0), \ + .attributeCount = 6, \ + .clusterSize = 4, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = nullptr ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Access Control (server) */ \ + .clusterId = 0x0000001F, \ + .attributes = ZAP_ATTRIBUTE_INDEX(6), \ + .attributeCount = 6, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = nullptr ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Basic (server) */ \ + .clusterId = 0x00000028, \ + .attributes = ZAP_ATTRIBUTE_INDEX(12), \ + .attributeCount = 14, \ + .clusterSize = 39, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + .functions = chipFuncArrayBasicServer, \ + .acceptedCommandList = nullptr ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: OTA Software Update Provider (client) */ \ + .clusterId = 0x00000029, \ + .attributes = ZAP_ATTRIBUTE_INDEX(26), \ + .attributeCount = 0, \ + .clusterSize = 0, \ + .mask = ZAP_CLUSTER_MASK(CLIENT), \ + .functions = NULL, \ + .acceptedCommandList = nullptr ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: OTA Software Update Requestor (server) */ \ + .clusterId = 0x0000002A, \ + .attributes = ZAP_ATTRIBUTE_INDEX(26), \ + .attributeCount = 6, \ + .clusterSize = 9, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 0 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: General Commissioning (server) */ \ + .clusterId = 0x00000030, \ + .attributes = ZAP_ATTRIBUTE_INDEX(32), \ + .attributeCount = 7, \ + .clusterSize = 14, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 2 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 6 ) ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ + .clusterId = 0x00000031, \ + .attributes = ZAP_ATTRIBUTE_INDEX(39), \ + .attributeCount = 10, \ + .clusterSize = 48, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 10 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 16 ) ,\ + },\ + { \ + /* Endpoint: 0, Cluster: General Diagnostics (server) */ \ + .clusterId = 0x00000033, \ + .attributes = ZAP_ATTRIBUTE_INDEX(49), \ + .attributeCount = 5, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 20 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Software Diagnostics (server) */ \ + .clusterId = 0x00000034, \ + .attributes = ZAP_ATTRIBUTE_INDEX(54), \ + .attributeCount = 6, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 22 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Thread Network Diagnostics (server) */ \ + .clusterId = 0x00000035, \ + .attributes = ZAP_ATTRIBUTE_INDEX(60), \ + .attributeCount = 62, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 24 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ + .clusterId = 0x0000003C, \ + .attributes = ZAP_ATTRIBUTE_INDEX(122), \ + .attributeCount = 5, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 26 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ + .clusterId = 0x0000003E, \ + .attributes = ZAP_ATTRIBUTE_INDEX(127), \ + .attributeCount = 8, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 29 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 38 ) ,\ + },\ + { \ + /* Endpoint: 0, Cluster: Group Key Management (server) */ \ + .clusterId = 0x0000003F, \ + .attributes = ZAP_ATTRIBUTE_INDEX(135), \ + .attributeCount = 6, \ + .clusterSize = 6, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 43 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 48 ) ,\ + },\ + { \ + /* Endpoint: 1, Cluster: Identify (server) */ \ + .clusterId = 0x00000003, \ + .attributes = ZAP_ATTRIBUTE_INDEX(141), \ + .attributeCount = 4, \ + .clusterSize = 9, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ + .functions = chipFuncArrayIdentifyServer, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 51 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 1, Cluster: Groups (server) */ \ + .clusterId = 0x00000004, \ + .attributes = ZAP_ATTRIBUTE_INDEX(145), \ + .attributeCount = 3, \ + .clusterSize = 7, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + .functions = chipFuncArrayGroupsServer, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 54 ) ,\ + .generatedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 61 ) ,\ + },\ + { \ + /* Endpoint: 1, Cluster: On/Off (server) */ \ + .clusterId = 0x00000006, \ + .attributes = ZAP_ATTRIBUTE_INDEX(148), \ + .attributeCount = 7, \ + .clusterSize = 13, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + .functions = chipFuncArrayOnOffServer, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 66 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 1, Cluster: Level Control (server) */ \ + .clusterId = 0x00000008, \ + .attributes = ZAP_ATTRIBUTE_INDEX(155), \ + .attributeCount = 9, \ + .clusterSize = 14, \ + .mask = ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ + .functions = chipFuncArrayLevelControlServer, \ + .acceptedCommandList = ZAP_GENERATED_COMMANDS_INDEX( 73 ) ,\ + .generatedCommandList = nullptr ,\ + },\ + { \ + /* Endpoint: 1, Cluster: Descriptor (server) */ \ + .clusterId = 0x0000001D, \ + .attributes = ZAP_ATTRIBUTE_INDEX(164), \ + .attributeCount = 6, \ + .clusterSize = 4, \ + .mask = ZAP_CLUSTER_MASK(SERVER), \ + .functions = NULL, \ + .acceptedCommandList = nullptr ,\ + .generatedCommandList = nullptr ,\ + },\ +} + +// clang-format on + +#define ZAP_CLUSTER_INDEX(index) (&generatedClusters[index]) + +#define ZAP_FIXED_ENDPOINT_DATA_VERSION_COUNT 17 + +// This is an array of EmberAfEndpointType structures. +#define GENERATED_ENDPOINT_TYPES \ + { \ + { ZAP_CLUSTER_INDEX(0), 13, 156 }, { ZAP_CLUSTER_INDEX(13), 5, 47 }, \ + } + +// Largest attribute size is needed for various buffers +#define ATTRIBUTE_LARGEST (66) + +static_assert(ATTRIBUTE_LARGEST <= CHIP_CONFIG_MAX_ATTRIBUTE_STORE_ELEMENT_SIZE, "ATTRIBUTE_LARGEST larger than expected"); + +// Total size of singleton attributes +#define ATTRIBUTE_SINGLETONS_SIZE (35) + +// Total size of attribute storage +#define ATTRIBUTE_MAX_SIZE (203) + +// Number of fixed endpoints +#define FIXED_ENDPOINT_COUNT (2) + +// Array of endpoints that are supported, the data inside +// the array is the endpoint number. +#define FIXED_ENDPOINT_ARRAY \ + { \ + 0x0000, 0x0001 \ + } + +// Array of profile ids +#define FIXED_PROFILE_IDS \ + { \ + 0x0103, 0x0103 \ + } + +// Array of device types +#define FIXED_DEVICE_TYPES \ + { \ + { 0x0016, 1 }, { 0x0100, 1 } \ + } + +// Array of device type offsets +#define FIXED_DEVICE_TYPE_OFFSETS \ + { \ + 0, 1 \ + } + +// Array of device type lengths +#define FIXED_DEVICE_TYPE_LENGTHS \ + { \ + 1, 1 \ + } + +// Array of endpoint types supported on each endpoint +#define FIXED_ENDPOINT_TYPES \ + { \ + 0, 1 \ + } + +// Array of networks supported on each endpoint +#define FIXED_NETWORKS \ + { \ + 0, 0 \ + } diff --git a/zzz_generated/lighting-app/nxp/zap-generated/gen_config.h b/zzz_generated/lighting-app/nxp/zap-generated/gen_config.h new file mode 100644 index 00000000000000..f6c553a605b857 --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/gen_config.h @@ -0,0 +1,138 @@ +/* + * + * Copyright (c) 2022 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +// Prevent multiple inclusion +#pragma once + +// User options for plugin Binding Table Library +#define EMBER_BINDING_TABLE_SIZE 10 + +/**** Network Section ****/ +#define EMBER_SUPPORTED_NETWORKS (1) + +#define EMBER_APS_UNICAST_MESSAGE_COUNT 10 + +/**** Cluster endpoint counts ****/ +#define EMBER_AF_IDENTIFY_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_GROUPS_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_ON_OFF_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_LEVEL_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_DESCRIPTOR_CLUSTER_SERVER_ENDPOINT_COUNT (2) +#define EMBER_AF_ACCESS_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_OTA_PROVIDER_CLUSTER_CLIENT_ENDPOINT_COUNT (1) +#define EMBER_AF_OTA_REQUESTOR_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_GENERAL_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_NETWORK_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_GENERAL_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_SOFTWARE_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_ADMINISTRATOR_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_OPERATIONAL_CREDENTIALS_CLUSTER_SERVER_ENDPOINT_COUNT (1) +#define EMBER_AF_GROUP_KEY_MANAGEMENT_CLUSTER_SERVER_ENDPOINT_COUNT (1) + +/**** Cluster Plugins ****/ + +// Use this macro to check if the server side of the Identify cluster is included +#define ZCL_USING_IDENTIFY_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_IDENTIFY_SERVER +#define EMBER_AF_PLUGIN_IDENTIFY + +// Use this macro to check if the server side of the Groups cluster is included +#define ZCL_USING_GROUPS_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_GROUPS_SERVER +#define EMBER_AF_PLUGIN_GROUPS + +// Use this macro to check if the server side of the On/Off cluster is included +#define ZCL_USING_ON_OFF_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_ON_OFF_SERVER +#define EMBER_AF_PLUGIN_ON_OFF + +// Use this macro to check if the server side of the Level Control cluster is included +#define ZCL_USING_LEVEL_CONTROL_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_LEVEL_CONTROL_SERVER +#define EMBER_AF_PLUGIN_LEVEL_CONTROL +// User options for server plugin Level Control +#define EMBER_AF_PLUGIN_LEVEL_CONTROL_MAXIMUM_LEVEL 254 +#define EMBER_AF_PLUGIN_LEVEL_CONTROL_MINIMUM_LEVEL 0 +#define EMBER_AF_PLUGIN_LEVEL_CONTROL_RATE 0 + +// Use this macro to check if the server side of the Descriptor cluster is included +#define ZCL_USING_DESCRIPTOR_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_DESCRIPTOR_SERVER +#define EMBER_AF_PLUGIN_DESCRIPTOR + +// Use this macro to check if the server side of the Access Control cluster is included +#define ZCL_USING_ACCESS_CONTROL_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_ACCESS_CONTROL_SERVER +#define EMBER_AF_PLUGIN_ACCESS_CONTROL + +// Use this macro to check if the server side of the Basic cluster is included +#define ZCL_USING_BASIC_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_BASIC_SERVER +#define EMBER_AF_PLUGIN_BASIC + +// Use this macro to check if the client side of the OTA Software Update Provider cluster is included +#define ZCL_USING_OTA_PROVIDER_CLUSTER_CLIENT +#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_PROVIDER_CLIENT + +// Use this macro to check if the server side of the OTA Software Update Requestor cluster is included +#define ZCL_USING_OTA_REQUESTOR_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_REQUESTOR_SERVER +#define EMBER_AF_PLUGIN_OTA_SOFTWARE_UPDATE_REQUESTOR + +// Use this macro to check if the server side of the General Commissioning cluster is included +#define ZCL_USING_GENERAL_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_GENERAL_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_GENERAL_COMMISSIONING + +// Use this macro to check if the server side of the Network Commissioning cluster is included +#define ZCL_USING_NETWORK_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING + +// Use this macro to check if the server side of the General Diagnostics cluster is included +#define ZCL_USING_GENERAL_DIAGNOSTICS_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_GENERAL_DIAGNOSTICS_SERVER +#define EMBER_AF_PLUGIN_GENERAL_DIAGNOSTICS + +// Use this macro to check if the server side of the Software Diagnostics cluster is included +#define ZCL_USING_SOFTWARE_DIAGNOSTICS_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_SOFTWARE_DIAGNOSTICS_SERVER +#define EMBER_AF_PLUGIN_SOFTWARE_DIAGNOSTICS + +// Use this macro to check if the server side of the Thread Network Diagnostics cluster is included +#define ZCL_USING_THREAD_NETWORK_DIAGNOSTICS_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_THREAD_NETWORK_DIAGNOSTICS_SERVER +#define EMBER_AF_PLUGIN_THREAD_NETWORK_DIAGNOSTICS + +// Use this macro to check if the server side of the AdministratorCommissioning cluster is included +#define ZCL_USING_ADMINISTRATOR_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_ADMINISTRATOR_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_ADMINISTRATOR_COMMISSIONING + +// Use this macro to check if the server side of the Operational Credentials cluster is included +#define ZCL_USING_OPERATIONAL_CREDENTIALS_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_OPERATIONAL_CREDENTIALS_SERVER +#define EMBER_AF_PLUGIN_OPERATIONAL_CREDENTIALS + +// Use this macro to check if the server side of the Group Key Management cluster is included +#define ZCL_USING_GROUP_KEY_MANAGEMENT_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_GROUP_KEY_MANAGEMENT_SERVER +#define EMBER_AF_PLUGIN_GROUP_KEY_MANAGEMENT diff --git a/zzz_generated/lighting-app/nxp/zap-generated/gen_tokens.h b/zzz_generated/lighting-app/nxp/zap-generated/gen_tokens.h new file mode 100644 index 00000000000000..dcc229f5b2c306 --- /dev/null +++ b/zzz_generated/lighting-app/nxp/zap-generated/gen_tokens.h @@ -0,0 +1,45 @@ +/* + * + * Copyright (c) 2022 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. + */ + +// THIS FILE IS GENERATED BY ZAP + +// Prevent multiple inclusion +#pragma once + +// This file contains the tokens for attributes stored in flash + +// Identifier tags for tokens + +// Types for the tokens +#ifdef DEFINETYPES +#endif // DEFINETYPES + +// Actual token definitions +#ifdef DEFINETOKENS +#endif // DEFINETOKENS + +// Macro snippet that loads all the attributes from tokens +#define GENERATED_TOKEN_LOADER(endpoint) \ + do \ + { \ + } while (false) + +// Macro snippet that saves the attribute to token +#define GENERATED_TOKEN_SAVER \ + do \ + { \ + } while (false)