diff --git a/config/nrfconnect/chip-module/CMakeLists.txt b/config/nrfconnect/chip-module/CMakeLists.txt index 13bb2e70c47305..92d88e95112fa6 100644 --- a/config/nrfconnect/chip-module/CMakeLists.txt +++ b/config/nrfconnect/chip-module/CMakeLists.txt @@ -220,6 +220,13 @@ chip_gn_arg_bool ("chip_detail_logging" CONFIG_MATTER_LOG_LE chip_gn_arg_bool ("chip_automation_logging" "false") chip_gn_arg_bool ("chip_malloc_sys_heap" CONFIG_CHIP_MALLOC_SYS_HEAP) +if (CONFIG_CHIP_FACTORY_DATA) + chip_gn_arg_bool ("chip_use_transitional_commissionable_data_provider" "false") + chip_gn_arg_bool ("chip_enable_factory_data" "true") +elseif (CONFIG_CHIP_FACTORY_DATA_CUSTOM_BACKEND) + chip_gn_arg_bool ("chip_use_transitional_commissionable_data_provider" "false") +endif() + if (CONFIG_CHIP_ROTATING_DEVICE_ID) chip_gn_arg_bool("chip_enable_rotating_device_id" "true") chip_gn_arg_bool("chip_enable_additional_data_advertising" "true") diff --git a/config/nrfconnect/chip-module/Kconfig b/config/nrfconnect/chip-module/Kconfig index 54dbe2cd8ef750..9bf628cdb1a63e 100644 --- a/config/nrfconnect/chip-module/Kconfig +++ b/config/nrfconnect/chip-module/Kconfig @@ -16,6 +16,8 @@ rsource "../../zephyr/Kconfig" +if CHIP + config CHIP_NFC_COMMISSIONING bool "Enable NFC commissioning support" default n @@ -73,6 +75,22 @@ config CHIP_DEBUG_SYMBOLS help Build the application with debug symbols. +config CHIP_FACTORY_DATA + bool "Enable Factory Data support" + select ZCBOR + help + Enables support for reading factory data from flash memory partition. + It requires factory_data partition to exist in the partition manager + configuration file pm_static.yml. + +config CHIP_FACTORY_DATA_CUSTOM_BACKEND + bool "Enable Factory Data custom backend" + depends on !CHIP_FACTORY_DATA + help + Enables user custom factory data implementation. It cannot be used + with the CHIP_FACTORY_DATA that enabled default nRF Connect factory data + implementation. + config CHIP_FACTORY_DATA_BUILD bool "Enable Factory Data build" default n @@ -82,10 +100,20 @@ config CHIP_FACTORY_DATA_BUILD configuration file pm_static.yml. As a result a new output file factory_data.hex will be created. +config CHIP_FACTORY_DATA_VERSION + int + default 1 + help + The Factory data version contains a current version of a factory data + parameter set that the user cannot change. + After moving to the next version of the factory data set, change the default value. + This config is used to validate the version of a factory data set on a device-side + with the version of factory data saved in the Flash memory. + if CHIP_FACTORY_DATA_BUILD # Factory data definitions -config CHIP_MERGE_FACTORY_DATA_WITH_FIRMWARE +config CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE bool "Enable merging generated factory data with the build target .hex file" default y help @@ -224,3 +252,5 @@ config CHIP_DEVICE_ROTATING_DEVICE_UID help A device rotating id unique id which will be generated if this config is not set in prj.conf file. + +endif diff --git a/config/nrfconnect/chip-module/generate_factory_data.cmake b/config/nrfconnect/chip-module/generate_factory_data.cmake index 1928b3e4ff1441..02b6e6ce4c0ac0 100644 --- a/config/nrfconnect/chip-module/generate_factory_data.cmake +++ b/config/nrfconnect/chip-module/generate_factory_data.cmake @@ -21,7 +21,7 @@ # Created JSON file can be checked using JSON SCHEMA file if it is provided. # # This script can be manipulated using following kConfigs: -# - To merge generated factory data with final zephyr.hex file set kConfig CONFIG_CHIP_MERGE_FACTORY_DATA_WITH_FIRMWARE=y +# - To merge generated factory data with final zephyr.hex file set kConfig CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE=y # - To use default certification paths set CONFIG_CHIP_FACTORY_DATA_USE_DEFAULTS_CERTS_PATH=y # # During generation process a some file will be created in zephyr's build directory: @@ -187,7 +187,7 @@ nrfconnect_create_factory_data_hex_file(factory_data ${OUTPUT_FILE_PATH} factory_data_hex) -if(CONFIG_CHIP_MERGE_FACTORY_DATA_WITH_FIRMWARE) +if(CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE) # set custom target for merging factory_data hex file add_custom_target(factory_data_merge DEPENDS ${factory_data_hex} diff --git a/examples/all-clusters-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml b/examples/all-clusters-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml index 1847733295425b..ce42b39e55ee87 100644 --- a/examples/all-clusters-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml +++ b/examples/all-clusters-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml @@ -7,32 +7,36 @@ mcuboot_pad: size: 0x200 app: address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0x7000 - size: 0xf5000 + size: 0xf4000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 region: flash_primary mcuboot_secondary: address: 0x0 - size: 0xf5000 + size: 0xf4000 device: MX25R64 region: external_flash external_flash: - address: 0xf5000 - size: 0x70b000 + address: 0xf4000 + size: 0x70c000 device: MX25R64 region: external_flash diff --git a/examples/all-clusters-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml b/examples/all-clusters-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml index ba02c6e5645eea..3c56dc0ddb1968 100644 --- a/examples/all-clusters-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml +++ b/examples/all-clusters-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml @@ -7,21 +7,25 @@ mcuboot_pad: size: 0x200 app: address: 0xC200 - size: 0xefe00 + size: 0xeee00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0xC000 - size: 0xf0000 + size: 0xef000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0xC200 - size: 0xefe00 + size: 0xeee00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 @@ -33,17 +37,17 @@ mcuboot_primary_1: region: ram_flash mcuboot_secondary: address: 0x0 - size: 0xf0000 + size: 0xef000 device: MX25R64 region: external_flash mcuboot_secondary_1: - address: 0xf0000 + address: 0xef000 size: 0x40000 device: MX25R64 region: external_flash external_flash: - address: 0x130000 - size: 0x6D0000 + address: 0x12f000 + size: 0x6D1000 device: MX25R64 region: external_flash pcd_sram: diff --git a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp index 0dfbac06c45396..43b6043b73d256 100644 --- a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp +++ b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp @@ -186,7 +186,14 @@ CHIP_ERROR AppTask::Init() k_timer_user_data_set(&sFunctionTimer, this); // Initialize CHIP server +#if CONFIG_CHIP_FACTORY_DATA + ReturnErrorOnFailure(mFactoryDataProvider.Init()); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetCommissionableDataProvider(&mFactoryDataProvider); +#else SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif static CommonCaseDeviceServerInitParams initParams; static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(kTestEventTriggerEnableKey) }; diff --git a/examples/all-clusters-app/nrfconnect/main/include/AppTask.h b/examples/all-clusters-app/nrfconnect/main/include/AppTask.h index e7402653f7237c..04f44f41e49551 100644 --- a/examples/all-clusters-app/nrfconnect/main/include/AppTask.h +++ b/examples/all-clusters-app/nrfconnect/main/include/AppTask.h @@ -19,6 +19,10 @@ #include +#if CONFIG_CHIP_FACTORY_DATA +#include +#endif + struct k_timer; class AppEvent; class LEDWidget; @@ -63,4 +67,8 @@ class AppTask bool mIsThreadProvisioned{ false }; bool mIsThreadEnabled{ false }; bool mHaveBLEConnections{ false }; + +#if CONFIG_CHIP_FACTORY_DATA + chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; +#endif }; diff --git a/examples/all-clusters-minimal-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml b/examples/all-clusters-minimal-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml index 1847733295425b..ce42b39e55ee87 100644 --- a/examples/all-clusters-minimal-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml +++ b/examples/all-clusters-minimal-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml @@ -7,32 +7,36 @@ mcuboot_pad: size: 0x200 app: address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0x7000 - size: 0xf5000 + size: 0xf4000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 region: flash_primary mcuboot_secondary: address: 0x0 - size: 0xf5000 + size: 0xf4000 device: MX25R64 region: external_flash external_flash: - address: 0xf5000 - size: 0x70b000 + address: 0xf4000 + size: 0x70c000 device: MX25R64 region: external_flash diff --git a/examples/all-clusters-minimal-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml b/examples/all-clusters-minimal-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml index ba02c6e5645eea..3c56dc0ddb1968 100644 --- a/examples/all-clusters-minimal-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml +++ b/examples/all-clusters-minimal-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml @@ -7,21 +7,25 @@ mcuboot_pad: size: 0x200 app: address: 0xC200 - size: 0xefe00 + size: 0xeee00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0xC000 - size: 0xf0000 + size: 0xef000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0xC200 - size: 0xefe00 + size: 0xeee00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 @@ -33,17 +37,17 @@ mcuboot_primary_1: region: ram_flash mcuboot_secondary: address: 0x0 - size: 0xf0000 + size: 0xef000 device: MX25R64 region: external_flash mcuboot_secondary_1: - address: 0xf0000 + address: 0xef000 size: 0x40000 device: MX25R64 region: external_flash external_flash: - address: 0x130000 - size: 0x6D0000 + address: 0x12f000 + size: 0x6D1000 device: MX25R64 region: external_flash pcd_sram: diff --git a/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp b/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp index 8f7c646bd8471d..ff778d944c6c76 100644 --- a/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp +++ b/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp @@ -137,7 +137,14 @@ CHIP_ERROR AppTask::Init() k_timer_user_data_set(&sFunctionTimer, this); // Initialize CHIP server +#if CONFIG_CHIP_FACTORY_DATA + ReturnErrorOnFailure(mFactoryDataProvider.Init()); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetCommissionableDataProvider(&mFactoryDataProvider); +#else SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif static chip::CommonCaseDeviceServerInitParams initParams; (void) initParams.InitializeStaticResourcesBeforeServerInit(); diff --git a/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h b/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h index e7402653f7237c..04f44f41e49551 100644 --- a/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h +++ b/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h @@ -19,6 +19,10 @@ #include +#if CONFIG_CHIP_FACTORY_DATA +#include +#endif + struct k_timer; class AppEvent; class LEDWidget; @@ -63,4 +67,8 @@ class AppTask bool mIsThreadProvisioned{ false }; bool mIsThreadEnabled{ false }; bool mHaveBLEConnections{ false }; + +#if CONFIG_CHIP_FACTORY_DATA + chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; +#endif }; diff --git a/examples/chef/nrfconnect/prj.conf b/examples/chef/nrfconnect/prj.conf index 71679d01cbba43..ed3dcf6ea976e3 100644 --- a/examples/chef/nrfconnect/prj.conf +++ b/examples/chef/nrfconnect/prj.conf @@ -60,3 +60,7 @@ CONFIG_CHIP_ENABLE_PAIRING_AUTOSTART=y # Configure CHIP shell CONFIG_CHIP_LIB_SHELL=y CONFIG_OPENTHREAD_SHELL=n + +# Disable factory data support. +CONFIG_CHIP_FACTORY_DATA=n +CONFIG_CHIP_FACTORY_DATA_BUILD=n diff --git a/examples/light-switch-app/efr32/README.md b/examples/light-switch-app/efr32/README.md index 831b66406cd7d2..b30234be2c3def 100644 --- a/examples/light-switch-app/efr32/README.md +++ b/examples/light-switch-app/efr32/README.md @@ -224,7 +224,7 @@ combination with JLinkRTTClient as follows: a URL can be found in the RTT logs. [SVR] Copy/paste the below URL in a browser to see the QR Code: - [SVR] https://dhrishi.github.io/connectedhomeip/qrcode.html?data=CH%3AI34NM%20-00%200C9SS0 + [SVR] https://project-chip.github.io/connectedhomeip/qrcode.html?data=CH%3AI34NM%20-00%200C9SS0 **LED 0** shows the overall state of the device and its connectivity. The following states are possible: diff --git a/examples/light-switch-app/esp32/README.md b/examples/light-switch-app/esp32/README.md index ef79f82c709d00..9616c250526933 100644 --- a/examples/light-switch-app/esp32/README.md +++ b/examples/light-switch-app/esp32/README.md @@ -118,13 +118,16 @@ make sure the IDF_PATH has been exported(See the manual setup steps above). $ ./out/debug/chip-tool accesscontrol write acl '[{"fabricIndex": 1, "privilege": 5, "authMode": 2, "subjects": [112233], "targets": null },{"fabricIndex": 1, "privilege": 3, "authMode": 2, "subjects": [12344320], "targets": null }]' 12344321 0 -- we use matter shell to bind and test. +- After successful commissioning, use the chip-tool for binding in + Lighting-switch. - binding: + $ ./out/debug/chip-tool binding write binding '[{"fabricIndex": 1, "node":20836, "endpoint":1, "cluster":6}]' 12344320 1 - matter switch binding unicast 1 12344321 1 +- Test toggle: - on: + Press `boot` button to toggle LED. + + Using matter shell on: matter switch onoff on diff --git a/examples/light-switch-app/esp32/main/AppTask.cpp b/examples/light-switch-app/esp32/main/AppTask.cpp index 309e6d9f92476d..f29b4a0927f783 100644 --- a/examples/light-switch-app/esp32/main/AppTask.cpp +++ b/examples/light-switch-app/esp32/main/AppTask.cpp @@ -31,6 +31,8 @@ using namespace chip; static const char * TAG = "app-task"; +Button AppButton; + namespace { QueueHandle_t sAppEventQueue; @@ -59,6 +61,10 @@ CHIP_ERROR AppTask::Init() { CHIP_ERROR err = CHIP_NO_ERROR; + AppButton.Init(); + + AppButton.SetButtonPressCallback(ButtonPressCallback); + return err; } @@ -132,15 +138,10 @@ void AppTask::SwitchActionEventHandler(AppEvent * aEvent) } } -void AppTask::ButtonEventHandler(const uint8_t buttonHandle, uint8_t btnAction) +void AppTask::ButtonPressCallback() { - AppEvent button_event = {}; - button_event.Type = AppEvent::kEventType_Button; - button_event.ButtonEvent.Action = btnAction; - - if (buttonHandle == APP_LIGHT_SWITCH && btnAction == BUTTON_PRESSED) - { - button_event.mHandler = SwitchActionEventHandler; - sAppTask.PostEvent(&button_event); - } + AppEvent button_event; + button_event.Type = AppEvent::kEventType_Button; + button_event.mHandler = AppTask::SwitchActionEventHandler; + sAppTask.PostEvent(&button_event); } diff --git a/examples/light-switch-app/esp32/main/Button.cpp b/examples/light-switch-app/esp32/main/Button.cpp new file mode 100644 index 00000000000000..5ee8d6886c079f --- /dev/null +++ b/examples/light-switch-app/esp32/main/Button.cpp @@ -0,0 +1,66 @@ +/* + * + * 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 "Button.h" + +#define GPIO_INPUT_IO_0 CONFIG_EXAMPLE_BOARD_BUTTON_GPIO + +#define GPIO_INPUT_PIN_SEL (1ULL << GPIO_INPUT_IO_0) +#define ESP_INTR_FLAG_DEFAULT 0 + +static const char * TAG = "Button"; + +static Button::ButtonPressCallback button_press_handler = nullptr; + +static void IRAM_ATTR gpio_isr_handler(void * arg) +{ + if (button_press_handler != nullptr) + { + button_press_handler(); + } +} + +void Button::Init() +{ + /* Initialize button interrupt*/ + // zero-initialize the config structure. + gpio_config_t io_conf = {}; + // interrupt of rising edge + io_conf.intr_type = GPIO_INTR_NEGEDGE; + // bit mask of the pins, use GPIO4/5 here + io_conf.pin_bit_mask = GPIO_INPUT_PIN_SEL; + // set as input mode + io_conf.mode = GPIO_MODE_INPUT; + // enable pull-up mode + io_conf.pull_up_en = GPIO_PULLUP_ENABLE; + gpio_config(&io_conf); + + // install gpio isr service + gpio_install_isr_service(ESP_INTR_FLAG_DEFAULT); + // hook isr handler for specific gpio pin + gpio_isr_handler_add(static_cast(GPIO_INPUT_IO_0), gpio_isr_handler, (void *) GPIO_INPUT_IO_0); + + ESP_LOGI(TAG, "Button initialized.."); +} + +void Button::SetButtonPressCallback(ButtonPressCallback button_callback) +{ + if (button_callback != nullptr) + { + button_press_handler = button_callback; + } +} diff --git a/examples/light-switch-app/esp32/main/Kconfig.projbuild b/examples/light-switch-app/esp32/main/Kconfig.projbuild index 9fbfa68ab1a7aa..79964c0e2b1f9c 100644 --- a/examples/light-switch-app/esp32/main/Kconfig.projbuild +++ b/examples/light-switch-app/esp32/main/Kconfig.projbuild @@ -71,5 +71,12 @@ menu "Demo" default 2 if RENDEZVOUS_MODE_BLE default 4 if RENDEZVOUS_MODE_THREAD default 8 if RENDEZVOUS_MODE_ETHERNET - + + config EXAMPLE_BOARD_BUTTON_GPIO + int "Boot Button GPIO" + default 0 if !IDF_TARGET_ESP32C3 + default 9 if IDF_TARGET_ESP32C3 + help + GPIO number on which the "Boot" button is connected. This is generally used + by the application for custom operations like toggling states. endmenu diff --git a/examples/light-switch-app/esp32/main/include/AppTask.h b/examples/light-switch-app/esp32/main/include/AppTask.h index 7b2c813ca362e8..b07b5e67bd83f9 100644 --- a/examples/light-switch-app/esp32/main/include/AppTask.h +++ b/examples/light-switch-app/esp32/main/include/AppTask.h @@ -22,6 +22,7 @@ #include #include "AppEvent.h" +#include "Button.h" #include "freertos/FreeRTOS.h" #include @@ -33,6 +34,8 @@ #define APP_ERROR_START_TIMER_FAILED CHIP_APPLICATION_ERROR(0x05) #define APP_ERROR_STOP_TIMER_FAILED CHIP_APPLICATION_ERROR(0x06) +extern Button AppButton; + class AppTask { @@ -40,8 +43,7 @@ class AppTask CHIP_ERROR StartAppTask(); static void AppTaskMain(void * pvParameter); void PostEvent(const AppEvent * event); - - void ButtonEventHandler(const uint8_t buttonHandle, uint8_t btnAction); + static void ButtonPressCallback(); private: friend AppTask & GetAppTask(void); diff --git a/examples/light-switch-app/esp32/main/include/Button.h b/examples/light-switch-app/esp32/main/include/Button.h new file mode 100644 index 00000000000000..df70ef4ed93649 --- /dev/null +++ b/examples/light-switch-app/esp32/main/include/Button.h @@ -0,0 +1,30 @@ +/* + * + * 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 "driver/gpio.h" +#include "esp_log.h" + +class Button +{ +public: + typedef void (*ButtonPressCallback)(void); + + void Init(void); + void SetButtonPressCallback(ButtonPressCallback button_callback); +}; diff --git a/examples/light-switch-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml b/examples/light-switch-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml index 1847733295425b..ce42b39e55ee87 100644 --- a/examples/light-switch-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml +++ b/examples/light-switch-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml @@ -7,32 +7,36 @@ mcuboot_pad: size: 0x200 app: address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0x7000 - size: 0xf5000 + size: 0xf4000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 region: flash_primary mcuboot_secondary: address: 0x0 - size: 0xf5000 + size: 0xf4000 device: MX25R64 region: external_flash external_flash: - address: 0xf5000 - size: 0x70b000 + address: 0xf4000 + size: 0x70c000 device: MX25R64 region: external_flash diff --git a/examples/light-switch-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml b/examples/light-switch-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml index ba02c6e5645eea..3c56dc0ddb1968 100644 --- a/examples/light-switch-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml +++ b/examples/light-switch-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml @@ -7,21 +7,25 @@ mcuboot_pad: size: 0x200 app: address: 0xC200 - size: 0xefe00 + size: 0xeee00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0xC000 - size: 0xf0000 + size: 0xef000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0xC200 - size: 0xefe00 + size: 0xeee00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 @@ -33,17 +37,17 @@ mcuboot_primary_1: region: ram_flash mcuboot_secondary: address: 0x0 - size: 0xf0000 + size: 0xef000 device: MX25R64 region: external_flash mcuboot_secondary_1: - address: 0xf0000 + address: 0xef000 size: 0x40000 device: MX25R64 region: external_flash external_flash: - address: 0x130000 - size: 0x6D0000 + address: 0x12f000 + size: 0x6D1000 device: MX25R64 region: external_flash pcd_sram: diff --git a/examples/light-switch-app/nrfconnect/main/AppTask.cpp b/examples/light-switch-app/nrfconnect/main/AppTask.cpp index 4b98212214a41c..14ac3779f39d1e 100644 --- a/examples/light-switch-app/nrfconnect/main/AppTask.cpp +++ b/examples/light-switch-app/nrfconnect/main/AppTask.cpp @@ -158,7 +158,14 @@ CHIP_ERROR AppTask::Init() #endif // Print initial configs +#if CONFIG_CHIP_FACTORY_DATA + ReturnErrorOnFailure(mFactoryDataProvider.Init()); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetCommissionableDataProvider(&mFactoryDataProvider); +#else SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif static chip::CommonCaseDeviceServerInitParams initParams; ReturnErrorOnFailure(initParams.InitializeStaticResourcesBeforeServerInit()); ReturnErrorOnFailure(Server::GetInstance().Init(initParams)); diff --git a/examples/light-switch-app/nrfconnect/main/include/AppTask.h b/examples/light-switch-app/nrfconnect/main/include/AppTask.h index 2f72dd5758b6c2..f392046c236410 100644 --- a/examples/light-switch-app/nrfconnect/main/include/AppTask.h +++ b/examples/light-switch-app/nrfconnect/main/include/AppTask.h @@ -24,6 +24,10 @@ #include #include +#if CONFIG_CHIP_FACTORY_DATA +#include +#endif + #ifdef CONFIG_MCUMGR_SMP_BT #include "DFUOverSMP.h" #endif @@ -88,6 +92,10 @@ class AppTask #ifdef CONFIG_MCUMGR_SMP_BT static void RequestSMPAdvertisingStart(void); #endif + +#if CONFIG_CHIP_FACTORY_DATA + chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; +#endif }; inline AppTask & GetAppTask() diff --git a/examples/lighting-app/bouffalolab/bl602/BUILD.gn b/examples/lighting-app/bouffalolab/bl602/BUILD.gn index 25e4b8c92e95c9..ec6b1198c2d3c4 100644 --- a/examples/lighting-app/bouffalolab/bl602/BUILD.gn +++ b/examples/lighting-app/bouffalolab/bl602/BUILD.gn @@ -80,6 +80,7 @@ bl602_executable("lighting_app") { ":sdk", "${chip_root}/examples/common/QRCode", "${chip_root}/examples/lighting-app/lighting-common", + "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/lib", "${chip_root}/src/setup_payload", ] diff --git a/examples/lighting-app/bouffalolab/bl602/include/CHIPProjectConfig.h b/examples/lighting-app/bouffalolab/bl602/include/CHIPProjectConfig.h index 2be12f7d113334..10563ef351f037 100644 --- a/examples/lighting-app/bouffalolab/bl602/include/CHIPProjectConfig.h +++ b/examples/lighting-app/bouffalolab/bl602/include/CHIPProjectConfig.h @@ -68,7 +68,38 @@ * TODO: 3R */ //#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0xF001 -#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8005 +#define CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID 0x8001 + +/** + * CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION + * + * The hardware version number assigned to device or product by the device vendor. This + * number is scoped to the device product id, and typically corresponds to a revision of the + * physical device, a change to its packaging, and/or a change to its marketing presentation. + * This value is generally *not* incremented for device software versions. + */ +#define CHIP_DEVICE_CONFIG_DEVICE_HARDWARE_VERSION 1 + +/** + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING + * + * A string identifying the software version running on the device. + * CHIP service currently expects the software version to be in the format + * {MAJOR_VERSION}.0d{MINOR_VERSION} + */ +#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "0.1ALPHA" + +/** + * CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION + * + * A uint32_t identifying the software version running on the device. + */ +/* The SoftwareVersion attribute of the Basic cluster. */ +#ifndef CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION +#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION 0x0001 +#endif +#endif /** * CHIP_DEVICE_CONFIG_DEVICE_PRODUCT_REVISION diff --git a/examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp b/examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp index a67ca012b56438..83a10251270356 100644 --- a/examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp +++ b/examples/lighting-app/bouffalolab/bl602/src/AppTask.cpp @@ -21,10 +21,15 @@ #include "CHIPDeviceManager.h" #include "DeviceCallbacks.h" #include "LEDWidget.h" +#include #include #include #include #include +#include +#include +#include +#include #include #include #include @@ -34,6 +39,7 @@ #include #include #include +#include #include #include @@ -72,6 +78,12 @@ chip::app::Clusters::NetworkCommissioning::Instance using namespace ::chip::System; +DefaultOTARequestor gRequestorCore; +DefaultOTARequestorStorage gRequestorStorage; +DefaultOTARequestorDriver gRequestorUser; +BDXDownloader gDownloader; +OTAImageProcessorImpl gImageProcessor; + AppTask AppTask::sAppTask; static DeviceCallbacks EchoCallbacks; @@ -121,7 +133,13 @@ CHIP_ERROR AppTask::Init() LightMgr().SetCallbacks(ActionInitiated, ActionCompleted); - UpdateClusterState(); + SetRequestorInstance(&gRequestorCore); + gRequestorStorage.Init(chip::Server::GetInstance().GetPersistentStorage()); + gRequestorCore.Init(chip::Server::GetInstance(), gRequestorStorage, gRequestorUser, gDownloader); + gImageProcessor.SetOTADownloader(&gDownloader); + gDownloader.SetImageProcessorDelegate(&gImageProcessor); + gRequestorUser.Init(&gRequestorCore, &gImageProcessor); + SetDeviceInfoProvider(&DeviceInfoProviderImpl::GetDefaultInstance()); ConfigurationMgr().LogDeviceConfig(); diff --git a/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp b/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp index 852522e7832e07..146559b3552d6b 100644 --- a/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp +++ b/examples/lighting-app/bouffalolab/bl602/src/DeviceCallbacks.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -250,3 +251,38 @@ bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::CommandHandler * comm emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS); return true; } + +void OnIdentifyStart(Identify *) +{ + ChipLogProgress(Zcl, "OnIdentifyStart"); +} + +void OnIdentifyStop(Identify *) +{ + ChipLogProgress(Zcl, "OnIdentifyStop"); +} + +void OnTriggerEffect(Identify * identify) +{ + switch (identify->mCurrentEffectIdentifier) + { + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK"); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE"); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY: + ChipLogProgress(Zcl, "EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY"); + break; + case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE: + break; + default: + ChipLogProgress(Zcl, "No identifier effect"); + return; + } +} + +static Identify gIdentify1 = { + chip::EndpointId{ 1 }, OnIdentifyStart, OnIdentifyStop, EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED, OnTriggerEffect, +}; diff --git a/examples/lighting-app/efr32/README.md b/examples/lighting-app/efr32/README.md index 79c2831ad3dff4..e97dec2cbd382a 100644 --- a/examples/lighting-app/efr32/README.md +++ b/examples/lighting-app/efr32/README.md @@ -242,7 +242,7 @@ combination with JLinkRTTClient as follows: a URL can be found in the RTT logs. [SVR] Copy/paste the below URL in a browser to see the QR Code: - [SVR] https://dhrishi.github.io/connectedhomeip/qrcode.html?data=CH%3AI34NM%20-00%200C9SS0 + [SVR] https://project-chip.github.io/connectedhomeip/qrcode.html?data=CH%3AI34NM%20-00%200C9SS0 **LED 0** shows the overall state of the device and its connectivity. The following states are possible: diff --git a/examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840_no_dfu.conf b/examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840_no_dfu.conf index 1525056853f5bd..7e9d26f886667c 100644 --- a/examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840_no_dfu.conf +++ b/examples/lighting-app/nrfconnect/boards/nrf52840dongle_nrf52840_no_dfu.conf @@ -37,3 +37,7 @@ CONFIG_OPENTHREAD_SHELL=n # Use partition manager to configure the settings partition not to overlap with Open Bootloader CONFIG_PM_SINGLE_IMAGE=y + +# Disable factory data support. +CONFIG_CHIP_FACTORY_DATA=n +CONFIG_CHIP_FACTORY_DATA_BUILD=n diff --git a/examples/lighting-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml b/examples/lighting-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml index 1847733295425b..ce42b39e55ee87 100644 --- a/examples/lighting-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml +++ b/examples/lighting-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml @@ -7,32 +7,36 @@ mcuboot_pad: size: 0x200 app: address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0x7000 - size: 0xf5000 + size: 0xf4000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 region: flash_primary mcuboot_secondary: address: 0x0 - size: 0xf5000 + size: 0xf4000 device: MX25R64 region: external_flash external_flash: - address: 0xf5000 - size: 0x70b000 + address: 0xf4000 + size: 0x70c000 device: MX25R64 region: external_flash diff --git a/examples/lighting-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml b/examples/lighting-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml index ba02c6e5645eea..3c56dc0ddb1968 100644 --- a/examples/lighting-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml +++ b/examples/lighting-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml @@ -7,21 +7,25 @@ mcuboot_pad: size: 0x200 app: address: 0xC200 - size: 0xefe00 + size: 0xeee00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0xC000 - size: 0xf0000 + size: 0xef000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0xC200 - size: 0xefe00 + size: 0xeee00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 @@ -33,17 +37,17 @@ mcuboot_primary_1: region: ram_flash mcuboot_secondary: address: 0x0 - size: 0xf0000 + size: 0xef000 device: MX25R64 region: external_flash mcuboot_secondary_1: - address: 0xf0000 + address: 0xef000 size: 0x40000 device: MX25R64 region: external_flash external_flash: - address: 0x130000 - size: 0x6D0000 + address: 0x12f000 + size: 0x6D1000 device: MX25R64 region: external_flash pcd_sram: diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp index d01a327d62275e..0b7436a70bdb2c 100644 --- a/examples/lighting-app/nrfconnect/main/AppTask.cpp +++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp @@ -168,7 +168,14 @@ CHIP_ERROR AppTask::Init() #endif // Initialize CHIP server +#if CONFIG_CHIP_FACTORY_DATA + ReturnErrorOnFailure(mFactoryDataProvider.Init()); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetCommissionableDataProvider(&mFactoryDataProvider); +#else SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif static CommonCaseDeviceServerInitParams initParams; static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(kTestEventTriggerEnableKey) }; diff --git a/examples/lighting-app/nrfconnect/main/include/AppTask.h b/examples/lighting-app/nrfconnect/main/include/AppTask.h index 4b0be0004efffe..3c76f131f632fc 100644 --- a/examples/lighting-app/nrfconnect/main/include/AppTask.h +++ b/examples/lighting-app/nrfconnect/main/include/AppTask.h @@ -24,6 +24,10 @@ #include +#if CONFIG_CHIP_FACTORY_DATA +#include +#endif + #ifdef CONFIG_CHIP_PW_RPC #include "Rpc.h" #endif @@ -98,6 +102,10 @@ class AppTask bool mFunctionTimerActive = false; PWMDevice mPWMDevice; static AppTask sAppTask; + +#if CONFIG_CHIP_FACTORY_DATA + chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; +#endif }; inline AppTask & GetAppTask(void) diff --git a/examples/lock-app/efr32/README.md b/examples/lock-app/efr32/README.md index b8a4e5e1730d8b..00dda0f6829c02 100644 --- a/examples/lock-app/efr32/README.md +++ b/examples/lock-app/efr32/README.md @@ -240,7 +240,7 @@ combination with JLinkRTTClient as follows: a URL can be found in the RTT logs. [SVR] Copy/paste the below URL in a browser to see the QR Code: - [SVR] https://dhrishi.github.io/connectedhomeip/qrcode.html?data=CH%3AI34NM%20-00%200C9SS0 + [SVR] https://project-chip.github.io/connectedhomeip/qrcode.html?data=CH%3AI34NM%20-00%200C9SS0 **LED 0** shows the overall state of the device and its connectivity. The following states are possible: diff --git a/examples/lock-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml b/examples/lock-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml index 1847733295425b..ce42b39e55ee87 100644 --- a/examples/lock-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml +++ b/examples/lock-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml @@ -7,32 +7,36 @@ mcuboot_pad: size: 0x200 app: address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0x7000 - size: 0xf5000 + size: 0xf4000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 region: flash_primary mcuboot_secondary: address: 0x0 - size: 0xf5000 + size: 0xf4000 device: MX25R64 region: external_flash external_flash: - address: 0xf5000 - size: 0x70b000 + address: 0xf4000 + size: 0x70c000 device: MX25R64 region: external_flash diff --git a/examples/lock-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml b/examples/lock-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml index ba02c6e5645eea..3c56dc0ddb1968 100644 --- a/examples/lock-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml +++ b/examples/lock-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml @@ -7,21 +7,25 @@ mcuboot_pad: size: 0x200 app: address: 0xC200 - size: 0xefe00 + size: 0xeee00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0xC000 - size: 0xf0000 + size: 0xef000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0xC200 - size: 0xefe00 + size: 0xeee00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 @@ -33,17 +37,17 @@ mcuboot_primary_1: region: ram_flash mcuboot_secondary: address: 0x0 - size: 0xf0000 + size: 0xef000 device: MX25R64 region: external_flash mcuboot_secondary_1: - address: 0xf0000 + address: 0xef000 size: 0x40000 device: MX25R64 region: external_flash external_flash: - address: 0x130000 - size: 0x6D0000 + address: 0x12f000 + size: 0x6D1000 device: MX25R64 region: external_flash pcd_sram: diff --git a/examples/lock-app/nrfconnect/main/AppTask.cpp b/examples/lock-app/nrfconnect/main/AppTask.cpp index 8cd120d40a283e..19e8c3c7873ce5 100644 --- a/examples/lock-app/nrfconnect/main/AppTask.cpp +++ b/examples/lock-app/nrfconnect/main/AppTask.cpp @@ -156,7 +156,14 @@ CHIP_ERROR AppTask::Init() #endif // Initialize CHIP server +#if CONFIG_CHIP_FACTORY_DATA + ReturnErrorOnFailure(mFactoryDataProvider.Init()); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetCommissionableDataProvider(&mFactoryDataProvider); +#else SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif static CommonCaseDeviceServerInitParams initParams; static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(kTestEventTriggerEnableKey) }; diff --git a/examples/lock-app/nrfconnect/main/include/AppTask.h b/examples/lock-app/nrfconnect/main/include/AppTask.h index 7fb211df3ed248..8e57d8c166ca7f 100644 --- a/examples/lock-app/nrfconnect/main/include/AppTask.h +++ b/examples/lock-app/nrfconnect/main/include/AppTask.h @@ -25,6 +25,10 @@ #include +#if CONFIG_CHIP_FACTORY_DATA +#include +#endif + #ifdef CONFIG_MCUMGR_SMP_BT #include "DFUOverSMP.h" #endif @@ -82,6 +86,10 @@ class AppTask Function_t mFunction = kFunction_NoneSelected; bool mFunctionTimerActive = false; static AppTask sAppTask; + +#if CONFIG_CHIP_FACTORY_DATA + chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; +#endif }; inline AppTask & GetAppTask(void) diff --git a/examples/pigweed-app/nrfconnect/prj.conf b/examples/pigweed-app/nrfconnect/prj.conf index ff25bac4606447..c8802d315a0e7e 100644 --- a/examples/pigweed-app/nrfconnect/prj.conf +++ b/examples/pigweed-app/nrfconnect/prj.conf @@ -62,3 +62,7 @@ CONFIG_LOG_MODE_MINIMAL=n CONFIG_LOG_MODE_IMMEDIATE=y CONFIG_LOG_BACKEND_UART=n CONFIG_LOG_BACKEND_RTT=n + +# Disable factory data support. +CONFIG_CHIP_FACTORY_DATA=n +CONFIG_CHIP_FACTORY_DATA_BUILD=n diff --git a/examples/pump-app/cc13x2x7_26x2x7/README.md b/examples/pump-app/cc13x2x7_26x2x7/README.md index 8120bd2b031ef1..d0de9a55929ce1 100644 --- a/examples/pump-app/cc13x2x7_26x2x7/README.md +++ b/examples/pump-app/cc13x2x7_26x2x7/README.md @@ -171,7 +171,7 @@ log ([UART terminal](#viewing-logging-output)). It will look like the following: ``` SetupQRCode: [MT:.81TM -00 0C9SS0] Copy/paste the below URL in a browser to see the QR Code: -https://dhrishi.github.io/connectedhomeip/qrcode.html?data=CH%3A.81TM%20-00%200C9SS0 +https://project-chip.github.io/connectedhomeip/qrcode.html?data=CH%3A.81TM%20-00%200C9SS0 ``` You can directly navigate to the webpage URL displayed (which has QR payload @@ -203,4 +203,4 @@ Additionally, we welcome any feedback. https://www.ti.com/wireless-connectivity/thread/design-development.html [ot_border_router_setup]: https://openthread.io/guides/border-router/beaglebone-black -[qr_code_generator]: https://dhrishi.github.io/connectedhomeip/qrcode.html +[qr_code_generator]: https://project-chip.github.io/connectedhomeip/qrcode.html diff --git a/examples/pump-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml b/examples/pump-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml index 1847733295425b..ce42b39e55ee87 100644 --- a/examples/pump-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml +++ b/examples/pump-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml @@ -7,32 +7,36 @@ mcuboot_pad: size: 0x200 app: address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0x7000 - size: 0xf5000 + size: 0xf4000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 region: flash_primary mcuboot_secondary: address: 0x0 - size: 0xf5000 + size: 0xf4000 device: MX25R64 region: external_flash external_flash: - address: 0xf5000 - size: 0x70b000 + address: 0xf4000 + size: 0x70c000 device: MX25R64 region: external_flash diff --git a/examples/pump-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml b/examples/pump-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml index ba02c6e5645eea..3c56dc0ddb1968 100644 --- a/examples/pump-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml +++ b/examples/pump-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml @@ -7,21 +7,25 @@ mcuboot_pad: size: 0x200 app: address: 0xC200 - size: 0xefe00 + size: 0xeee00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0xC000 - size: 0xf0000 + size: 0xef000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0xC200 - size: 0xefe00 + size: 0xeee00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 @@ -33,17 +37,17 @@ mcuboot_primary_1: region: ram_flash mcuboot_secondary: address: 0x0 - size: 0xf0000 + size: 0xef000 device: MX25R64 region: external_flash mcuboot_secondary_1: - address: 0xf0000 + address: 0xef000 size: 0x40000 device: MX25R64 region: external_flash external_flash: - address: 0x130000 - size: 0x6D0000 + address: 0x12f000 + size: 0x6D1000 device: MX25R64 region: external_flash pcd_sram: diff --git a/examples/pump-app/nrfconnect/main/AppTask.cpp b/examples/pump-app/nrfconnect/main/AppTask.cpp index 45ca1d5a06599c..35de7711981720 100644 --- a/examples/pump-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-app/nrfconnect/main/AppTask.cpp @@ -154,7 +154,14 @@ CHIP_ERROR AppTask::Init() #endif // Initialize CHIP server +#if CONFIG_CHIP_FACTORY_DATA + ReturnErrorOnFailure(mFactoryDataProvider.Init()); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetCommissionableDataProvider(&mFactoryDataProvider); +#else SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif static CommonCaseDeviceServerInitParams initParams; static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(kTestEventTriggerEnableKey) }; diff --git a/examples/pump-app/nrfconnect/main/include/AppTask.h b/examples/pump-app/nrfconnect/main/include/AppTask.h index 7ca19cdc923f5c..25545ee9507f54 100644 --- a/examples/pump-app/nrfconnect/main/include/AppTask.h +++ b/examples/pump-app/nrfconnect/main/include/AppTask.h @@ -25,6 +25,10 @@ #include +#if CONFIG_CHIP_FACTORY_DATA +#include +#endif + #ifdef CONFIG_MCUMGR_SMP_BT #include "DFUOverSMP.h" #endif @@ -84,6 +88,10 @@ class AppTask Function_t mFunction = kFunction_NoneSelected; bool mFunctionTimerActive = false; static AppTask sAppTask; + +#if CONFIG_CHIP_FACTORY_DATA + chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; +#endif }; inline AppTask & GetAppTask(void) diff --git a/examples/pump-controller-app/cc13x2x7_26x2x7/README.md b/examples/pump-controller-app/cc13x2x7_26x2x7/README.md index d397ce3f01884f..47cc63f680bb07 100644 --- a/examples/pump-controller-app/cc13x2x7_26x2x7/README.md +++ b/examples/pump-controller-app/cc13x2x7_26x2x7/README.md @@ -172,7 +172,7 @@ log ([UART terminal](#viewing-logging-output)). It will look like the following: ``` SetupQRCode: [MT:.81TM -00 0C9SS0] Copy/paste the below URL in a browser to see the QR Code: -https://dhrishi.github.io/connectedhomeip/qrcode.html?data=CH%3A.81TM%20-00%200C9SS0 +https://project-chip.github.io/connectedhomeip/qrcode.html?data=CH%3A.81TM%20-00%200C9SS0 ``` You can directly navigate to the webpage URL displayed (which has QR payload @@ -204,4 +204,4 @@ Additionally, we welcome any feedback. https://www.ti.com/wireless-connectivity/thread/design-development.html [ot_border_router_setup]: https://openthread.io/guides/border-router/beaglebone-black -[qr_code_generator]: https://dhrishi.github.io/connectedhomeip/qrcode.html +[qr_code_generator]: https://project-chip.github.io/connectedhomeip/qrcode.html diff --git a/examples/pump-controller-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml b/examples/pump-controller-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml index 1847733295425b..ce42b39e55ee87 100644 --- a/examples/pump-controller-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml +++ b/examples/pump-controller-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml @@ -7,32 +7,36 @@ mcuboot_pad: size: 0x200 app: address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0x7000 - size: 0xf5000 + size: 0xf4000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 region: flash_primary mcuboot_secondary: address: 0x0 - size: 0xf5000 + size: 0xf4000 device: MX25R64 region: external_flash external_flash: - address: 0xf5000 - size: 0x70b000 + address: 0xf4000 + size: 0x70c000 device: MX25R64 region: external_flash diff --git a/examples/pump-controller-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml b/examples/pump-controller-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml index ba02c6e5645eea..3c56dc0ddb1968 100644 --- a/examples/pump-controller-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml +++ b/examples/pump-controller-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml @@ -7,21 +7,25 @@ mcuboot_pad: size: 0x200 app: address: 0xC200 - size: 0xefe00 + size: 0xeee00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0xC000 - size: 0xf0000 + size: 0xef000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0xC200 - size: 0xefe00 + size: 0xeee00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 @@ -33,17 +37,17 @@ mcuboot_primary_1: region: ram_flash mcuboot_secondary: address: 0x0 - size: 0xf0000 + size: 0xef000 device: MX25R64 region: external_flash mcuboot_secondary_1: - address: 0xf0000 + address: 0xef000 size: 0x40000 device: MX25R64 region: external_flash external_flash: - address: 0x130000 - size: 0x6D0000 + address: 0x12f000 + size: 0x6D1000 device: MX25R64 region: external_flash pcd_sram: diff --git a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp index 621d4f97af16e9..79b0a43adf42df 100644 --- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp @@ -151,7 +151,14 @@ CHIP_ERROR AppTask::Init() #endif // Initialize CHIP server +#if CONFIG_CHIP_FACTORY_DATA + ReturnErrorOnFailure(mFactoryDataProvider.Init()); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetCommissionableDataProvider(&mFactoryDataProvider); +#else SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif static CommonCaseDeviceServerInitParams initParams; static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(kTestEventTriggerEnableKey) }; diff --git a/examples/pump-controller-app/nrfconnect/main/include/AppTask.h b/examples/pump-controller-app/nrfconnect/main/include/AppTask.h index 7ca19cdc923f5c..25545ee9507f54 100644 --- a/examples/pump-controller-app/nrfconnect/main/include/AppTask.h +++ b/examples/pump-controller-app/nrfconnect/main/include/AppTask.h @@ -25,6 +25,10 @@ #include +#if CONFIG_CHIP_FACTORY_DATA +#include +#endif + #ifdef CONFIG_MCUMGR_SMP_BT #include "DFUOverSMP.h" #endif @@ -84,6 +88,10 @@ class AppTask Function_t mFunction = kFunction_NoneSelected; bool mFunctionTimerActive = false; static AppTask sAppTask; + +#if CONFIG_CHIP_FACTORY_DATA + chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; +#endif }; inline AppTask & GetAppTask(void) diff --git a/examples/shell/nrfconnect/prj.conf b/examples/shell/nrfconnect/prj.conf index 77317f6a180ee5..5dc6ee81f42645 100644 --- a/examples/shell/nrfconnect/prj.conf +++ b/examples/shell/nrfconnect/prj.conf @@ -49,3 +49,7 @@ CONFIG_CHIP_PROJECT_CONFIG="CHIPProjectConfig.h" # 32786 == 0x8012 (example shell-app) CONFIG_CHIP_DEVICE_PRODUCT_ID=32786 CONFIG_CHIP_NFC_COMMISSIONING=n + +# Disable factory data support. +CONFIG_CHIP_FACTORY_DATA=n +CONFIG_CHIP_FACTORY_DATA_BUILD=n diff --git a/examples/tv-casting-app/darwin/TvCasting/MatterBridge/CastingServerBridge.mm b/examples/tv-casting-app/darwin/TvCasting/MatterBridge/CastingServerBridge.mm index 3c870da50313c9..d523d991d3c8a0 100644 --- a/examples/tv-casting-app/darwin/TvCasting/MatterBridge/CastingServerBridge.mm +++ b/examples/tv-casting-app/darwin/TvCasting/MatterBridge/CastingServerBridge.mm @@ -20,6 +20,10 @@ #import "DiscoveredNodeDataConverter.hpp" +#include +#include +#include +#include #include #include @@ -57,6 +61,16 @@ - (instancetype)init return nil; } + // Initialize device attestation config + SetDeviceAttestationCredentialsProvider(chip::Credentials::Examples::GetExampleDACProvider()); + + // Initialize device attestation verifier from a constant version + { + // TODO: Replace testingRootStore with a AttestationTrustStore that has the necessary official PAA roots available + const chip::Credentials::AttestationTrustStore * testingRootStore = chip::Credentials::GetTestAttestationTrustStore(); + SetDeviceAttestationVerifier(GetDefaultDACVerifier(testingRootStore)); + } + // init app Server static chip::CommonCaseDeviceServerInitParams initParams; err = initParams.InitializeStaticResourcesBeforeServerInit(); @@ -161,9 +175,10 @@ - (void)openBasicCommissioningWindow:(nullable void (^)(bool))commissioningCompl { ChipLogProgress(AppServer, "CastingServerBridge().openBasicCommissioningWindow() called"); + _commissioningCompleteCallback = commissioningCompleteCallback; dispatch_async(_chipWorkQueue, ^{ CHIP_ERROR err = CastingServer::GetInstance()->OpenBasicCommissioningWindow( - [&commissioningCompleteCallback](CHIP_ERROR err) { commissioningCompleteCallback(CHIP_NO_ERROR == err); }); + [](CHIP_ERROR err) { [CastingServerBridge getSharedInstance].commissioningCompleteCallback(CHIP_NO_ERROR == err); }); dispatch_async(clientQueue, ^{ commissioningWindowRequestedHandler(CHIP_NO_ERROR == err); @@ -179,10 +194,11 @@ - (void)contentLauncherLaunchUrl:(NSString * _Nonnull)contentUrl { ChipLogProgress(AppServer, "CastingServerBridge().contentLauncherLaunchUrl() called"); + _launchUrlResponseCallback = launchUrlResponseCallback; dispatch_async(_chipWorkQueue, ^{ CHIP_ERROR err = CastingServer::GetInstance()->ContentLauncherLaunchURL([contentUrl UTF8String], [contentDisplayStr UTF8String], - [&launchUrlResponseCallback](CHIP_ERROR err) { launchUrlResponseCallback(CHIP_NO_ERROR == err); }); + [](CHIP_ERROR err) { [CastingServerBridge getSharedInstance].launchUrlResponseCallback(CHIP_NO_ERROR == err); }); dispatch_async(clientQueue, ^{ launchUrlRequestSentHandler(CHIP_NO_ERROR == err); }); diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj b/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj index b03976f499ccd2..22dccecf8e6e0d 100644 --- a/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting.xcodeproj/project.pbxproj @@ -390,6 +390,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( CHIP_HAVE_CONFIG_H, "CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=", + "CHIP_CONFIG_KVS_PATH=\"chip_casting_kvs\"", "DEBUG=1", "$(inherited)", ); @@ -410,9 +411,12 @@ "$(CHIP_ROOT)/zzz_generated/app-common", "$(CHIP_ROOT)/zzz_generated/controller-clusters", ); + INFOPLIST_FILE = TvCasting/Info.plist; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UIRequiredDeviceCapabilities = armv7; + INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; LD_RUNPATH_SEARCH_PATHS = ( @@ -477,6 +481,7 @@ GCC_PREPROCESSOR_DEFINITIONS = ( CHIP_HAVE_CONFIG_H, "CHIP_ADDRESS_RESOLVE_IMPL_INCLUDE_HEADER=", + "CHIP_CONFIG_KVS_PATH=\"chip_casting_kvs\"", "$(inherited)", ); GENERATE_INFOPLIST_FILE = YES; @@ -496,9 +501,12 @@ "$(CHIP_ROOT)/zzz_generated/app-common", "$(CHIP_ROOT)/zzz_generated/controller-clusters", ); + INFOPLIST_FILE = TvCasting/Info.plist; INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UIRequiredDeviceCapabilities = armv7; + INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/examples/tv-casting-app/darwin/TvCasting/TvCasting/Info.plist b/examples/tv-casting-app/darwin/TvCasting/TvCasting/Info.plist new file mode 100644 index 00000000000000..858e110f19e0ff --- /dev/null +++ b/examples/tv-casting-app/darwin/TvCasting/TvCasting/Info.plist @@ -0,0 +1,23 @@ + + + + + CFBundleURLTypes + + + CFBundleURLName + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleURLSchemes + + mt + + + + NSBonjourServices + + _matter._tcp + _matterc._udp + _matterd._udp + + + diff --git a/examples/tv-casting-app/tv-casting-common/BUILD.gn b/examples/tv-casting-app/tv-casting-common/BUILD.gn index fc3135ab8d263a..ac4e85fb3f06a7 100644 --- a/examples/tv-casting-app/tv-casting-common/BUILD.gn +++ b/examples/tv-casting-app/tv-casting-common/BUILD.gn @@ -74,7 +74,10 @@ chip_data_model("tv-casting-common") { } static_library("tvCastingCommon") { - public_deps = [ "${chip_root}/examples/tv-casting-app/tv-casting-common" ] + public_deps = [ + "${chip_root}/examples/tv-casting-app/tv-casting-common", + "${chip_root}/src/credentials:default_attestation_verifier", + ] cflags = [ "-Wconversion" ] diff --git a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h index 999e1236e0ff4e..bc50cb335e274f 100644 --- a/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h +++ b/examples/tv-casting-app/tv-casting-common/include/CHIPProjectAppConfig.h @@ -29,7 +29,9 @@ // include the CHIPProjectConfig from config/standalone +#ifndef CHIP_CONFIG_KVS_PATH #define CHIP_CONFIG_KVS_PATH "/tmp/chip_casting_kvs" +#endif #include diff --git a/examples/window-app/efr32/README.md b/examples/window-app/efr32/README.md index 8756365f3a7570..bcc4b2fa61944d 100644 --- a/examples/window-app/efr32/README.md +++ b/examples/window-app/efr32/README.md @@ -215,7 +215,7 @@ combination with JLinkRTTClient as follows: a URL can be found in the RTT logs. [SVR] Copy/paste the below URL in a browser to see the QR Code: - [SVR] https://dhrishi.github.io/connectedhomeip/qrcode.html?data=CH%3AI34NM%20-00%200C9SS0 + [SVR] https://project-chip.github.io/connectedhomeip/qrcode.html?data=CH%3AI34NM%20-00%200C9SS0 **LED 0** shows the overall state of the device and its connectivity. The following states are possible: diff --git a/examples/window-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml b/examples/window-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml index 1847733295425b..ce42b39e55ee87 100644 --- a/examples/window-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml +++ b/examples/window-app/nrfconnect/configuration/nrf52840dk_nrf52840/pm_static_dfu.yml @@ -7,32 +7,36 @@ mcuboot_pad: size: 0x200 app: address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0x7000 - size: 0xf5000 + size: 0xf4000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0x7200 - size: 0xf4e00 + size: 0xf3e00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 region: flash_primary mcuboot_secondary: address: 0x0 - size: 0xf5000 + size: 0xf4000 device: MX25R64 region: external_flash external_flash: - address: 0xf5000 - size: 0x70b000 + address: 0xf4000 + size: 0x70c000 device: MX25R64 region: external_flash diff --git a/examples/window-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml b/examples/window-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml index ba02c6e5645eea..3c56dc0ddb1968 100644 --- a/examples/window-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml +++ b/examples/window-app/nrfconnect/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml @@ -7,21 +7,25 @@ mcuboot_pad: size: 0x200 app: address: 0xC200 - size: 0xefe00 + size: 0xeee00 mcuboot_primary: orig_span: &id001 - mcuboot_pad - app span: *id001 address: 0xC000 - size: 0xf0000 + size: 0xef000 region: flash_primary mcuboot_primary_app: orig_span: &id002 - app span: *id002 address: 0xC200 - size: 0xefe00 + size: 0xeee00 +factory_data: + address: 0xfb000 + size: 0x1000 + region: flash_primary settings_storage: address: 0xfc000 size: 0x4000 @@ -33,17 +37,17 @@ mcuboot_primary_1: region: ram_flash mcuboot_secondary: address: 0x0 - size: 0xf0000 + size: 0xef000 device: MX25R64 region: external_flash mcuboot_secondary_1: - address: 0xf0000 + address: 0xef000 size: 0x40000 device: MX25R64 region: external_flash external_flash: - address: 0x130000 - size: 0x6D0000 + address: 0x12f000 + size: 0x6D1000 device: MX25R64 region: external_flash pcd_sram: diff --git a/examples/window-app/nrfconnect/main/AppTask.cpp b/examples/window-app/nrfconnect/main/AppTask.cpp index 44c42effffef50..0c80759cb4f25f 100644 --- a/examples/window-app/nrfconnect/main/AppTask.cpp +++ b/examples/window-app/nrfconnect/main/AppTask.cpp @@ -154,7 +154,14 @@ CHIP_ERROR AppTask::Init() #endif // Initialize CHIP server +#if CONFIG_CHIP_FACTORY_DATA + ReturnErrorOnFailure(mFactoryDataProvider.Init()); + SetDeviceInstanceInfoProvider(&mFactoryDataProvider); + SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); + SetCommissionableDataProvider(&mFactoryDataProvider); +#else SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); +#endif static CommonCaseDeviceServerInitParams initParams; static OTATestEventTriggerDelegate testEventTriggerDelegate{ ByteSpan(kTestEventTriggerEnableKey) }; diff --git a/examples/window-app/nrfconnect/main/include/AppTask.h b/examples/window-app/nrfconnect/main/include/AppTask.h index eb0d2f9cf83bbe..a082c4582aaf59 100644 --- a/examples/window-app/nrfconnect/main/include/AppTask.h +++ b/examples/window-app/nrfconnect/main/include/AppTask.h @@ -20,6 +20,10 @@ #include "WindowCovering.h" #include +#if CONFIG_CHIP_FACTORY_DATA +#include +#endif + struct k_timer; class AppEvent; class LEDWidget; @@ -75,4 +79,8 @@ class AppTask bool mOpenButtonIsPressed{ false }; bool mCloseButtonIsPressed{ false }; bool mMoveTypeRecentlyChanged{ false }; + +#if CONFIG_CHIP_FACTORY_DATA + chip::DeviceLayer::FactoryDataProvider mFactoryDataProvider; +#endif }; diff --git a/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py b/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py index eea02e7f98e0e0..d8425c1e6e805f 100644 --- a/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py +++ b/scripts/tools/nrfconnect/generate_nrfconnect_chip_factory_data.py @@ -217,7 +217,7 @@ def _generate_rotating_device_uid(self): """ If rotating device unique ID has not been provided it should be generated """ log.warning("Can not find rotating device UID in provided arguments list. A new one will be generated.") rdu = secrets.token_bytes(16) - log.info("\n\nThe new rotate device UID: {}\n".format(rdu).hex()) + log.info("\n\nThe new rotate device UID: {}\n".format(rdu.hex())) return rdu def _validate_output_json(self, output_json: str): @@ -326,9 +326,6 @@ def allow_any_int(i): return int(i, 0) help="[string] Provide additional user-specific keys in Json format: {'name_1': 'value_1', 'name_2': 'value_2', ... 'name_n', 'value_n'}.") args = parser.parse_args() - if(args.chip_cert_path): - print("Generating DAC and PAI certificates is not supported yet") - if args.verbose: log.basicConfig(format='[%(asctime)s][%(levelname)s] %(message)s', level=log.DEBUG) else: diff --git a/scripts/tools/nrfconnect/nrfconnect_factory_data.schema b/scripts/tools/nrfconnect/nrfconnect_factory_data.schema index 6d61795f0bc9e1..621e20fc6c4074 100644 --- a/scripts/tools/nrfconnect/nrfconnect_factory_data.schema +++ b/scripts/tools/nrfconnect/nrfconnect_factory_data.schema @@ -4,6 +4,7 @@ "description": "A representation of all factory data used in Matter's NrfConnect device", "type": "object", "required": [ + "version", "sn", "vendor_id", "product_id", @@ -21,6 +22,12 @@ "discriminator" ], "properties": { + "version": { + "description": "Current version of the factory data set", + "type": "integer", + "minimum": 0, + "maximum": 255 + }, "sn": { "description": "Serial number of device", "type": "string", diff --git a/src/app/server/OnboardingCodesUtil.cpp b/src/app/server/OnboardingCodesUtil.cpp index 2d2ce20b5fbfe2..d5578b8fd9e63f 100644 --- a/src/app/server/OnboardingCodesUtil.cpp +++ b/src/app/server/OnboardingCodesUtil.cpp @@ -30,7 +30,7 @@ #include #include -constexpr char kQrCodeBaseUrl[] = "https://dhrishi.github.io/connectedhomeip/qrcode.html"; +constexpr char kQrCodeBaseUrl[] = "https://project-chip.github.io/connectedhomeip/qrcode.html"; constexpr char kUrlDataAssignmentPhrase[] = "?data="; constexpr char kSpecialCharsUnreservedInRfc3986[] = "-._~"; diff --git a/src/app/tests/suites/certification/Test_TC_DD_1_10.yaml b/src/app/tests/suites/certification/Test_TC_DD_1_10.yaml index 9014add6256612..908777d73e20b4 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_1_10.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_1_10.yaml @@ -38,7 +38,7 @@ tests: [1646286638.377664][11651:11651] CHIP:DL: Device Type: 65535 (0xFFFF) [1646286638.377771][11651:11651] CHIP:SVR: SetupQRCode: [MT:-24J042C00KA0648G00] [1646286638.377865][11651:11651] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - [1646286638.377915][11651:11651] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J042C00KA0648G00 + [1646286638.377915][11651:11651] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J042C00KA0648G00 [1646286638.377986][11651:11651] CHIP:SVR: Manual pairing code: [34970112332] [1646286638.378089][11651:11651] CHIP:SVR: Long manual pairing code: [749701123365521327694] disabled: true diff --git a/src/app/tests/suites/certification/Test_TC_DD_1_11.yaml b/src/app/tests/suites/certification/Test_TC_DD_1_11.yaml index ab0845035509cd..1632e9ee09c4e3 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_1_11.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_1_11.yaml @@ -41,7 +41,7 @@ tests: [1646286638.377664][11651:11651] CHIP:DL: Device Type: 65535 (0xFFFF) [1646286638.377771][11651:11651] CHIP:SVR: SetupQRCode: [MT:-24J042C00KA0648G00] [1646286638.377865][11651:11651] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - [1646286638.377915][11651:11651] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J042C00KA0648G00 + [1646286638.377915][11651:11651] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J042C00KA0648G00 [1646286638.377986][11651:11651] CHIP:SVR: Manual pairing code: [34970112332] [1646286638.378089][11651:11651] CHIP:SVR: Long manual pairing code: [749701123365521327694] diff --git a/src/app/tests/suites/certification/Test_TC_DD_1_12.yaml b/src/app/tests/suites/certification/Test_TC_DD_1_12.yaml index 402470617d0bfa..3d7d87e912b5c3 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_1_12.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_1_12.yaml @@ -37,7 +37,7 @@ tests: [1641836544619] [16162:695667] CHIP: [DL] Device Type: 257 (0x101) [1641836544619] [16162:695667] CHIP: [SVR] SetupQRCode: [MT:YNJV7VSC00KA0648G00] [1641836544619] [16162:695667] CHIP: [SVR] Copy/paste the below URL in a browser to see the QR Code: - [1641836544619] [16162:695667] CHIP: [SVR] https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3AYNJV7VSC00KA0648G00 + [1641836544619] [16162:695667] CHIP: [SVR] https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3AYNJV7VSC00KA0648G00 [1641836544619] [16162:695667] CHIP: [SVR] Manual pairing code: [34970112332] @@ -86,7 +86,7 @@ tests: [1641836544690] [16162:695667] CHIP: [DL] Device Type: 257 (0x101) [1641836544690] [16162:695667] CHIP: [SVR] SetupQRCode: [MT:YNJV7VSC00KA0648G00] [1641836544690] [16162:695667] CHIP: [SVR] Copy/paste the below URL in a browser to see the QR Code: - [1641836544690] [16162:695667] CHIP: [SVR] https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3AYNJV7VSC00KA0648G00 + [1641836544690] [16162:695667] CHIP: [SVR] https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3AYNJV7VSC00KA0648G00 [1641836544690] [16162:695667] CHIP: [SVR] Manual pairing code: [34970112332] [1641836544690] [16162:695684] CHIP: [DL] _OnPlatformEvent [1641836544690] [16162:695684] CHIP: [DIS] DNS-SD StartServer mode=0 diff --git a/src/app/tests/suites/certification/Test_TC_DD_1_8.yaml b/src/app/tests/suites/certification/Test_TC_DD_1_8.yaml index dabfdb05ea765d..7005b2279f7a3d 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_1_8.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_1_8.yaml @@ -41,11 +41,11 @@ tests: CHIP:DL: Device Type: 65535 (0xFFFF) CHIP:SVR: SetupQRCode: [MT:-24J0CEK01KA0648G00] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0CEK01KA0648G00 + CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0CEK01KA0648G00 CHIP:SVR: Manual pairing code: [34970112332] CHIP:SVR: SetupQRCode: [MT:-24J048N01KA0648G00] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J048N01KA0648G00 + CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J048N01KA0648G00 2. Parse the DUT's QR Code using the TH commissioner: chip-tool ubuntu@matter-7:~/Apr18_cntrl/connectedhomeip/examples/chip-tool/out/debug$ ./chip-tool payload parse-setup-payload MT:-24J048N01KA0648G00 diff --git a/src/app/tests/suites/certification/Test_TC_DD_1_9.yaml b/src/app/tests/suites/certification/Test_TC_DD_1_9.yaml index f83e5caaca9f2a..9f3d1c65ffc459 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_1_9.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_1_9.yaml @@ -44,11 +44,11 @@ tests: CHIP:DL: Device Type: 65535 (0xFFFF) CHIP:SVR: SetupQRCode: [MT:-24J0CEK01KA0648G00] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0CEK01KA0648G00 + CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0CEK01KA0648G00 CHIP:SVR: Manual pairing code: [34970112332] CHIP:SVR: SetupQRCode: [MT:-24J048N01KA0648G00] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J048N01KA0648G00 + CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J048N01KA0648G00 ubuntu@matter-7:~/Apr18_cntrl/connectedhomeip/examples/chip-tool/out/debug$ ./chip-tool payload parse-setup-payload 34970112332 diff --git a/src/app/tests/suites/certification/Test_TC_DD_2_2.yaml b/src/app/tests/suites/certification/Test_TC_DD_2_2.yaml index 9b05ee8684c3d6..e98611f7b38e63 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_2_2.yaml @@ -41,7 +41,7 @@ tests: [1653087913.251732][8083:8083] CHIP:DL: Device Type: 65535 (0xFFFF) [1653087913.252171][8083:8083] CHIP:SVR: SetupQRCode: [MT:-24J048N01KA0648G00] [1653087913.252710][8083:8083] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - [1653087913.253175][8083:8083] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J048N01KA0648G00 + [1653087913.253175][8083:8083] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J048N01KA0648G00 [1653087913.253681][8083:8083] CHIP:SVR: Manual pairing code: [749701123365521327694] [1653087913.254268][8083:8083] CHIP:DMG: Endpoint 0, Cluster 0x0000_001D update version to 29f72814 disabled: true @@ -179,7 +179,7 @@ tests: [1653087913.251732][8083:8083] CHIP:DL: Device Type: 65535 (0xFFFF) [1653087913.252171][8083:8083] CHIP:SVR: SetupQRCode: [MT:-24J048N01KA0648G00] [1653087913.252710][8083:8083] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - [1653087913.253175][8083:8083] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J048N01KA0648G00 + [1653087913.253175][8083:8083] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J048N01KA0648G00 [1653087913.253681][8083:8083] CHIP:SVR: Manual pairing code: [749701123365521327694] [1653087913.254268][8083:8083] CHIP:DMG: Endpoint 0, Cluster 0x0000_001D update version to 29f72814 disabled: true diff --git a/src/app/tests/suites/certification/Test_TC_DD_3_1.yaml b/src/app/tests/suites/certification/Test_TC_DD_3_1.yaml index 6ba0a3508c2a62..13f0ef81e0eaa9 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_3_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_3_1.yaml @@ -41,12 +41,12 @@ tests: [1653471956.972509][10713:10713] CHIP:-: ==== Onboarding payload for Standard Commissioning Flow ==== [1653471956.972546][10713:10713] CHIP:SVR: SetupQRCode: [MT:-24J0CEK01KA0648G00] [1653471956.972579][10713:10713] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - [1653471956.972600][10713:10713] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0CEK01KA0648G00 + [1653471956.972600][10713:10713] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0CEK01KA0648G00 [1653471956.972632][10713:10713] CHIP:SVR: Manual pairing code: [34970112332] [1653471956.972654][10713:10713] CHIP:-: ==== Onboarding payload for Custom Commissioning Flows ==== [1653471956.972715][10713:10713] CHIP:SVR: SetupQRCode: [MT:-24J048N01KA0648G00] [1653471956.972748][10713:10713] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - [1653471956.972769][10713:10713] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J048N01KA0648G00 + [1653471956.972769][10713:10713] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J048N01KA0648G00 [1653471956.972803][10713:10713] CHIP:SVR: Manual pairing code: [749701123365521327694] diff --git a/src/app/tests/suites/certification/Test_TC_DD_3_11.yaml b/src/app/tests/suites/certification/Test_TC_DD_3_11.yaml index d3dc52de5cc531..e383a5cac0b158 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_3_11.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_3_11.yaml @@ -43,7 +43,7 @@ tests: [1651101335.733693][22353:22353] CHIP:-: ==== Onboarding payload for Standard Commissioning Flow ==== [1651101335.734598][22353:22353] CHIP:SVR: SetupQRCode: [MT:-24J042C00KA0648G00] [1651101335.735182][22353:22353] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - [1651101335.735618][22353:22353] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J042C00KA0648G00 + [1651101335.735618][22353:22353] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J042C00KA0648G00 ubuntu@ubuntu:~/apps$ ./chip-tool payload parse-setup-payload MT:-24J0YXE00KA0648G00 diff --git a/src/app/tests/suites/certification/Test_TC_DD_3_15.yaml b/src/app/tests/suites/certification/Test_TC_DD_3_15.yaml index aa4f13e1626f4d..f58f9030cdb819 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_3_15.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_3_15.yaml @@ -42,7 +42,7 @@ tests: [1651108891.390744][30833:30833] CHIP:-: ==== Onboarding payload for Standard Commissioning Flow ==== [1651108891.390809][30833:30833] CHIP:SVR: SetupQRCode: [MT:-24J0AFN00KA0648G00] [1651108891.390848][30833:30833] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - [1651108891.390876][30833:30833] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0AFN00KA0648G00 + [1651108891.390876][30833:30833] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0AFN00KA0648G00 [1651108891.390917][30833:30833] CHIP:SVR: Manual pairing code: [34970112332] disabled: true @@ -89,12 +89,12 @@ tests: [1651109167.022753][30980:30980] CHIP:-: ==== Onboarding payload for Standard Commissioning Flow ==== [1651109167.022825][30980:30980] CHIP:SVR: SetupQRCode: [MT:-24J0AFN00KA0648G00] [1651109167.022868][30980:30980] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - [1651109167.022898][30980:30980] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0AFN00KA0648G00 + [1651109167.022898][30980:30980] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0AFN00KA0648G00 [1651109167.022942][30980:30980] CHIP:SVR: Manual pairing code: [34970112332] [1651109167.022974][30980:30980] CHIP:-: ==== Onboarding payload for Custom Commissioning Flows ==== [1651109167.023050][30980:30980] CHIP:SVR: SetupQRCode: [MT:-24J029Q00KA0648G00] [1651109167.023090][30980:30980] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - [1651109167.023120][30980:30980] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J029Q00KA0648G00 + [1651109167.023120][30980:30980] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J029Q00KA0648G00 [1651109167.023167][30980:30980] CHIP:SVR: Manual pairing code: [749701123365521327694] disabled: true diff --git a/src/app/tests/suites/certification/Test_TC_DD_3_16.yaml b/src/app/tests/suites/certification/Test_TC_DD_3_16.yaml index 8d8854841bfeb0..43b278e8d22d02 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_3_16.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_3_16.yaml @@ -41,7 +41,7 @@ tests: [1651180718.960671][13218:13218] CHIP:-: ==== Onboarding payload for Standard Commissioning Flow ==== [1651180718.960729][13218:13218] CHIP:SVR: SetupQRCode: [MT:-24J0AFN00KA0648G00] [1651180718.960760][13218:13218] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - [1651180718.960781][13218:13218] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0AFN00KA0648G00 + [1651180718.960781][13218:13218] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0AFN00KA0648G00 [1651180718.960814][13218:13218] CHIP:SVR: Manual pairing code: [34970112332] disabled: true diff --git a/src/app/tests/suites/certification/Test_TC_DD_3_3.yaml b/src/app/tests/suites/certification/Test_TC_DD_3_3.yaml index 100857b6d231a1..46c4c342d3b93a 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_3_3.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_3_3.yaml @@ -59,7 +59,7 @@ tests: CHIP:DL: Device Type: 35 (0x23) CHIP:SVR: SetupQRCode: [MT:YNJV7VSC00KA0648G00] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3AYNJV7VSC00KA0648G00 + CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3AYNJV7VSC00KA0648G00 CHIP:SVR: Manual pairing code: [34970112332] CHIP:ZCL: Using ZAP configuration... ] CHIP:ZCL: OpCreds: Initiating OpCreds cluster by writing fabrics list from fabric table. @@ -435,7 +435,7 @@ tests: CHIP:DL: Device Type: 35 (0x23) CHIP:SVR: SetupQRCode: [MT:YNJV7VSC00KA0648G00] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3AYNJV7VSC00KA0648G00 + CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3AYNJV7VSC00KA0648G00 CHIP:SVR: Manual pairing code: [34970112332] CHIP:SVR: Retrieved value from server storage. CHIP:SVR: Retrieved value from server storage. diff --git a/src/app/tests/suites/certification/Test_TC_DD_3_4.yaml b/src/app/tests/suites/certification/Test_TC_DD_3_4.yaml index 0a135c6b7872a0..34a7f960647881 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_3_4.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_3_4.yaml @@ -54,7 +54,7 @@ tests: CHIP:DL: Device Type: 35 (0x23) CHIP:SVR: SetupQRCode: [MT:YNJV7VSC00KA0648G00] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3AYNJV7VSC00KA0648G00 + CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3AYNJV7VSC00KA0648G00 CHIP:SVR: Manual pairing code: [34970112332] CHIP:ZCL: Using ZAP configuration... ] CHIP:ZCL: OpCreds: Initiating OpCreds cluster by writing fabrics list from fabric table. @@ -430,7 +430,7 @@ tests: CHIP:DL: Device Type: 35 (0x23) CHIP:SVR: SetupQRCode: [MT:YNJV7VSC00KA0648G00] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3AYNJV7VSC00KA0648G00 + CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3AYNJV7VSC00KA0648G00 CHIP:SVR: Manual pairing code: [34970112332] CHIP:SVR: Retrieved value from server storage. CHIP:SVR: Retrieved value from server storage. diff --git a/src/app/tests/suites/certification/Test_TC_DD_3_5.yaml b/src/app/tests/suites/certification/Test_TC_DD_3_5.yaml index b1470b33a347fe..f90a91e12147de 100644 --- a/src/app/tests/suites/certification/Test_TC_DD_3_5.yaml +++ b/src/app/tests/suites/certification/Test_TC_DD_3_5.yaml @@ -41,12 +41,12 @@ tests: [1653471956.972509][10713:10713] CHIP:-: ==== Onboarding payload for Standard Commissioning Flow ==== [1653471956.972546][10713:10713] CHIP:SVR: SetupQRCode: [MT:-24J0CEK01KA0648G00] [1653471956.972579][10713:10713] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - [1653471956.972600][10713:10713] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0CEK01KA0648G00 + [1653471956.972600][10713:10713] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J0CEK01KA0648G00 [1653471956.972632][10713:10713] CHIP:SVR: Manual pairing code: [34970112332] [1653471956.972654][10713:10713] CHIP:-: ==== Onboarding payload for Custom Commissioning Flows ==== [1653471956.972715][10713:10713] CHIP:SVR: SetupQRCode: [MT:-24J048N01KA0648G00] [1653471956.972748][10713:10713] CHIP:SVR: Copy/paste the below URL in a browser to see the QR Code: - [1653471956.972769][10713:10713] CHIP:SVR: https://dhrishi.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J048N01KA0648G00 + [1653471956.972769][10713:10713] CHIP:SVR: https://project-chip.github.io/connectedhomeip/qrcode.html?data=MT%3A-24J048N01KA0648G00 [1653471956.972803][10713:10713] CHIP:SVR: Manual pairing code: [749701123365521327694] diff --git a/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml b/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml index 2b3cd830e7fa40..e68035401b9d4f 100644 --- a/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml +++ b/src/app/zap-templates/zcl/data-model/chip/matter-devices.xml @@ -1256,42 +1256,6 @@ limitations under the License. CLIENT_LIST PARTS_LIST - - BINDING - - - GROUP_NAME_SUPPORT - AddGroup - AddGroupResponse - ViewGroup - ViewGroupResponse - GetGroupMembership - GetGroupMembershipResponse - RemoveGroup - RemoveGroupResponse - RemoveAllGroups - AddGroupIfIdentifying - - - SCENE_COUNT - CURRENT_SCENE - CURRENT_GROUP - SCENE_VALID - SCENE_NAME_SUPPORT - AddScene - AddSceneResponse - ViewScene - ViewSceneResponse - RemoveScene - RemoveSceneResponse - RemoveAllScenes - RemoveAllScenesResponse - StoreScene - StoreSceneResponse - RecallScene - GetSceneMembership - GetSceneMembershipResponse - diff --git a/src/lib/core/CHIPConfig.h b/src/lib/core/CHIPConfig.h index 831a5183c94827..d43b4332c61023 100644 --- a/src/lib/core/CHIPConfig.h +++ b/src/lib/core/CHIPConfig.h @@ -829,9 +829,7 @@ extern const char CHIP_NON_PRODUCTION_MARKER[]; * @brief The maximum number of path objects for subscriptions, limits the number of attributes being subscribed at the same time. */ #ifndef CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_SUBSCRIPTIONS -// #define CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS (CHIP_IM_MAX_NUM_SUBSCRIPTIONS * 3) -// TODO: (#17085) Should be (CHIP_IM_MAX_NUM_SUBSCRIPTIONS * 3) -#define CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_SUBSCRIPTIONS (CHIP_IM_MAX_NUM_SUBSCRIPTIONS * 2) +#define CHIP_IM_SERVER_MAX_NUM_PATH_GROUPS_FOR_SUBSCRIPTIONS (CHIP_IM_MAX_NUM_SUBSCRIPTIONS * 3) #endif /** diff --git a/src/platform/CYW30739/DiagnosticDataProviderImpl.cpp b/src/platform/CYW30739/DiagnosticDataProviderImpl.cpp index b286b474531867..a205ffb84a23be 100644 --- a/src/platform/CYW30739/DiagnosticDataProviderImpl.cpp +++ b/src/platform/CYW30739/DiagnosticDataProviderImpl.cpp @@ -98,7 +98,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetBootReason(BootReasonType & bootReason #if CHIP_DEVICE_CONFIG_ENABLE_THREAD CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** netifpp) { - auto ifp = Platform::New(); + auto ifp = Platform::New(); VerifyOrReturnError(ifp != nullptr, CHIP_ERROR_NO_MEMORY); const char * threadNetworkName = otThreadGetNetworkName(ThreadStackMgrImpl().OTInstance()); @@ -106,10 +106,25 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** ifp->isOperational = true; ifp->offPremiseServicesReachableIPv4.SetNull(); ifp->offPremiseServicesReachableIPv6.SetNull(); - ifp->hardwareAddress = ByteSpan(ifp->macBuffer); + ifp->hardwareAddress = ByteSpan(ifp->MacAddress); ifp->type = app::Clusters::GeneralDiagnostics::InterfaceType::EMBER_ZCL_INTERFACE_TYPE_THREAD; - ConfigurationMgr().GetPrimary802154MACAddress(ifp->macBuffer); + static_assert(sizeof(ifp->MacAddress) >= ConfigurationManager::kPrimaryMACAddressLength, "Invalid MacAddress buffer size"); + ConfigurationMgr().GetPrimary802154MACAddress(ifp->MacAddress); + + /* Thread only support IPv6 */ + uint8_t ipv6AddressesCount = 0; + for (Inet::InterfaceAddressIterator iterator; iterator.Next() && ipv6AddressesCount < kMaxIPv6AddrCount;) + { + chip::Inet::IPAddress ipv6Address; + if (iterator.GetAddress(ipv6Address) == CHIP_NO_ERROR) + { + memcpy(ifp->Ipv6AddressesBuffer[ipv6AddressesCount], ipv6Address.Addr, kMaxIPv6AddrSize); + ifp->Ipv6AddressSpans[ipv6AddressesCount] = ByteSpan(ifp->Ipv6AddressesBuffer[ipv6AddressesCount]); + ipv6AddressesCount++; + } + } + ifp->IPv6Addresses = app::DataModel::List(ifp->Ipv6AddressSpans, ipv6AddressesCount); *netifpp = ifp; return CHIP_NO_ERROR; diff --git a/src/platform/CYW30739/DiagnosticDataProviderImpl.h b/src/platform/CYW30739/DiagnosticDataProviderImpl.h index 9e6dd337244d02..8776da5f43157b 100644 --- a/src/platform/CYW30739/DiagnosticDataProviderImpl.h +++ b/src/platform/CYW30739/DiagnosticDataProviderImpl.h @@ -48,16 +48,6 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider CHIP_ERROR GetNetworkInterfaces(NetworkInterface ** netifpp) override; void ReleaseNetworkInterfaces(NetworkInterface * netifp) override; #endif /* CHIP_DEVICE_CONFIG_ENABLE_THREAD */ - -private: -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - struct ThreadNetworkInterface : public NetworkInterface - { - ~ThreadNetworkInterface() = delete; - - uint8_t macBuffer[ConfigurationManager::kPrimaryMACAddressLength]; - }; -#endif /* CHIP_DEVICE_CONFIG_ENABLE_THREAD */ }; } // namespace DeviceLayer diff --git a/src/platform/bouffalolab/BL602/BUILD.gn b/src/platform/bouffalolab/BL602/BUILD.gn index 8d7114a0c60975..d82cb53b1ab3b0 100644 --- a/src/platform/bouffalolab/BL602/BUILD.gn +++ b/src/platform/bouffalolab/BL602/BUILD.gn @@ -40,16 +40,19 @@ static_library("BL602") { "DeviceNetworkProvisioningDelegateImpl.h", "DiagnosticDataProviderImpl.cpp", "DiagnosticDataProviderImpl.h", - "DnssdImpl.cpp", "InetPlatformConfig.h", "Logging.cpp", "NetworkCommissioningDriver.cpp", + "OTAImageProcessorImpl.cpp", "PlatformManagerImpl.cpp", "PlatformManagerImpl.h", "SystemPlatformConfig.h", ] - deps = [ "${chip_root}/src/lib/dnssd:platform_header" ] + deps = [ + "${chip_root}/src/lib/dnssd:platform_header", + "${chip_root}/src/setup_payload", + ] public_deps = [ "${chip_root}/src/platform:platform_base" ] diff --git a/src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.cpp b/src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.cpp index 3dcb1098fcd41e..a1ed8ae7e1a732 100644 --- a/src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.cpp +++ b/src/platform/bouffalolab/BL602/DiagnosticDataProviderImpl.cpp @@ -23,9 +23,8 @@ #include +#include #include -#include -#include #include diff --git a/src/platform/bouffalolab/BL602/DnssdImpl.cpp b/src/platform/bouffalolab/BL602/DnssdImpl.cpp index 9f0f3a1a02f2a7..2caacae72b86d4 100644 --- a/src/platform/bouffalolab/BL602/DnssdImpl.cpp +++ b/src/platform/bouffalolab/BL602/DnssdImpl.cpp @@ -42,6 +42,25 @@ namespace chip { namespace Dnssd { #define MDNS_MAX_PACKET_SIZE 64 +typedef struct +{ + const char * key; /*!< item key name */ + const char * value; /*!< item value string */ + size_t value_len; +} mdns_txt_item_t; + +typedef struct mdns +{ + struct netif * netif; + uint8_t slot[10]; + uint8_t slot_idx; + int txt_cnt; +} mdns_t; + +#define MDNS_TXT_MAX_LEN 128 +static mdns_t mdns = { NULL, 0, 0, 0, 0 }; +mdns_txt_item_t * items = nullptr; +uint8_t packet[MDNS_TXT_MAX_LEN]; static const DnssdService * glservice; @@ -50,6 +69,7 @@ CHIP_ERROR ChipDnssdInit(DnssdAsyncReturnCallback initCallback, DnssdAsyncReturn CHIP_ERROR error = CHIP_NO_ERROR; mdns_resp_init(); + mdns.slot_idx = 0; initCallback(context, error); glservice = static_cast(chip::Platform::MemoryCalloc(1, sizeof(DnssdService))); @@ -67,24 +87,6 @@ static const char * GetProtocolString(DnssdServiceProtocol protocol) return protocol == DnssdServiceProtocol::kDnssdProtocolTcp ? "_tcp" : "_udp"; } -typedef struct -{ - const char * key; /*!< item key name */ - const char * value; /*!< item value string */ - size_t value_len; -} mdns_txt_item_t; - -typedef struct mdns -{ - struct netif * netif; - int slot; -} mdns_t; - -#define MDNS_TXT_MAX_LEN 128 -static mdns_t mdns = { NULL, -1 }; -mdns_txt_item_t * items = nullptr; -uint8_t packet[MDNS_TXT_MAX_LEN]; - static inline uint8_t _mdns_append_u8(uint8_t * packet, uint16_t * index, uint8_t value) { if (*index >= MDNS_MAX_PACKET_SIZE) @@ -139,7 +141,7 @@ static void srv_txt(struct mdns_service * service, void * txt_userdata) int i, ret; int index = 0; - for (i = 0; i < 3; i++) + for (i = 0; i < mdns.txt_cnt; i++) { ret = mdns_resp_add_service_txtitem(service, &(packet[index + 1]), packet[index]); if (ret) @@ -179,18 +181,21 @@ int mdns_responder_ops(struct netif * netif) return -1; } - mdns.netif = netif; - - ret = mdns_resp_add_netif(netif, glservice->mHostName, 10); - if (ret != 0) + if (!(mdns.netif)) { - mdns_resp_deinit(); - log_info("add netif failed:%d\r\n", ret); - return -1; - } + mdns.netif = netif; - items = static_cast(chip::Platform::MemoryCalloc(glservice->mTextEntrySize, sizeof(mdns_txt_item_t))); + ret = mdns_resp_add_netif(netif, glservice->mHostName, 10); + if (ret != 0) + { + mdns_resp_deinit(); + log_info("add netif failed:%d\r\n", ret); + return -1; + } + } + items = static_cast(chip::Platform::MemoryCalloc(glservice->mTextEntrySize, sizeof(mdns_txt_item_t))); + mdns.txt_cnt = glservice->mTextEntrySize; for (size_t i = 0; i < glservice->mTextEntrySize; i++) { items[i].key = glservice->mTextEntries[i].mKey; @@ -199,8 +204,6 @@ int mdns_responder_ops(struct netif * netif) packet_len = packet_len + strlen(items[i].key) + items[i].value_len + 1; } - // todo:use malloc? - // packet = static_cast(chip::Platform::MemoryCalloc(packet_len, sizeof(uint8_t))); if (MDNS_TXT_MAX_LEN < packet_len) { return -1; @@ -220,6 +223,11 @@ int mdns_responder_ops(struct netif * netif) return -1; } + mdns.slot[mdns.slot_idx] = slot; + mdns.slot_idx++; + mdns_resp_announce(netif); + +#if 0 // for ota slot = mdns_resp_add_service(netif, "MATTER OTA", "_ota", static_cast(glservice->mProtocol), 3333, 1000, ota_txt, NULL); @@ -229,6 +237,7 @@ int mdns_responder_ops(struct netif * netif) mdns_resp_deinit(); log_info("ota mdns fail.\r\n"); } +#endif return slot; } @@ -262,6 +271,8 @@ CHIP_ERROR ChipDnssdPublishService(const DnssdService * service, DnssdPublishCal return CHIP_ERROR_INTERNAL; } + // mdns_responder_ops(netif); + slot = netifapi_netif_common(netif, NULL, mdns_responder_start_netifapi_errt_fn); if (slot < 0) { @@ -274,7 +285,23 @@ CHIP_ERROR ChipDnssdPublishService(const DnssdService * service, DnssdPublishCal CHIP_ERROR ChipDnssdRemoveServices() { - // netifapi_netif_common(mdns.netif, NULL, mdns_responder_stop_netifapi_errt_fn); + struct netif * netif; + int i = 0; + + netif = wifi_mgmr_sta_netif_get(); + if (netif == NULL) + { + log_info("find failed\r\n"); + return CHIP_ERROR_INTERNAL; + } + + for (i = 0; i < mdns.slot_idx; i++) + { + mdns_resp_del_service(netif, mdns.slot[i]); + } + + mdns.slot_idx = 0; + return CHIP_NO_ERROR; } diff --git a/src/platform/bouffalolab/BL602/InetPlatformConfig.h b/src/platform/bouffalolab/BL602/InetPlatformConfig.h index c79c5fc061e0a5..cdf045a928069d 100644 --- a/src/platform/bouffalolab/BL602/InetPlatformConfig.h +++ b/src/platform/bouffalolab/BL602/InetPlatformConfig.h @@ -34,11 +34,7 @@ #define INET_CONFIG_ERROR_MIN 1000000 #define INET_CONFIG_ERROR_MAX 1000999 -#if LWIP_CONFIG_ENABLE_IPV4 #define INET_CONFIG_ENABLE_IPV4 1 -#else -#define INET_CONFIG_ENABLE_IPV4 0 -#endif // ========== Platform-specific Configuration Overrides ========= diff --git a/src/platform/bouffalolab/BL602/NetworkCommissioningDriver.cpp b/src/platform/bouffalolab/BL602/NetworkCommissioningDriver.cpp index 72b95ebbbff639..0fa7a0513db580 100644 --- a/src/platform/bouffalolab/BL602/NetworkCommissioningDriver.cpp +++ b/src/platform/bouffalolab/BL602/NetworkCommissioningDriver.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -304,12 +305,67 @@ void BLWiFiDriver::ScanNetworks(ByteSpan ssid, WiFiDriver::ScanCallback * callba } } -#if 0 -CHIP_ERROR GetConnectedNetwork(Network & network) +CHIP_ERROR GetConfiguredNetwork(Network & network) { + uint8_t ssid[64]; + uint16_t ssid_len; + + ssid_len = wifi_mgmr_profile_ssid_get(ssid); + if (!ssid_len || ssid_len > DeviceLayer::Internal::kMaxWiFiSSIDLength) + { + return CHIP_ERROR_INTERNAL; + } + + memcpy(network.networkID, ssid, ssid_len); + network.networkIDLen = ssid_len; + + return CHIP_NO_ERROR; +} + +void BLWiFiDriver::OnNetworkStatusChange() +{ + Network configuredNetwork; + bool staEnabled = false, staConnected = false; + // VerifyOrReturn(ESP32Utils::IsStationEnabled(staEnabled) == CHIP_NO_ERROR); + VerifyOrReturn(staEnabled && mpStatusChangeCallback != nullptr); + CHIP_ERROR err = GetConfiguredNetwork(configuredNetwork); + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to get configured network when updating network status: %s", err.AsString()); + return; + } + + if (ConnectivityManagerImpl::mWiFiStationState == ConnectivityManager::kWiFiStationState_Connected) + { + staConnected = true; + } + + if (staConnected) + { + mpStatusChangeCallback->OnNetworkingStatusChange( + Status::kSuccess, MakeOptional(ByteSpan(configuredNetwork.networkID, configuredNetwork.networkIDLen)), NullOptional); + return; + } + mpStatusChangeCallback->OnNetworkingStatusChange( + Status::kSuccess, MakeOptional(ByteSpan(configuredNetwork.networkID, configuredNetwork.networkIDLen)), NullOptional); +} + +CHIP_ERROR BLWiFiDriver::SetLastDisconnectReason(const ChipDeviceEvent * event) +{ + // VerifyOrReturnError(event->Type == DeviceEventType::kRtkWiFiStationDisconnectedEvent, CHIP_ERROR_INVALID_ARGUMENT); + + uint16_t status_code, reason_code; + + wifi_mgmr_conn_result_get(&status_code, &reason_code); + mLastDisconnectedReason = reason_code; + return CHIP_NO_ERROR; } -#endif + +int32_t BLWiFiDriver::GetLastDisconnectReason() +{ + return mLastDisconnectedReason; +} size_t BLWiFiDriver::WiFiNetworkIterator::Count() { @@ -318,7 +374,6 @@ size_t BLWiFiDriver::WiFiNetworkIterator::Count() bool BLWiFiDriver::WiFiNetworkIterator::Next(Network & item) { -#if 0 if (mExhausted || mDriver->mStagingNetwork.ssidLen == 0) { return false; @@ -329,7 +384,7 @@ bool BLWiFiDriver::WiFiNetworkIterator::Next(Network & item) mExhausted = true; Network connectedNetwork; - CHIP_ERROR err = GetConnectedNetwork(connectedNetwork); + CHIP_ERROR err = GetConfiguredNetwork(connectedNetwork); if (err == CHIP_NO_ERROR) { if (connectedNetwork.networkIDLen == item.networkIDLen && @@ -338,7 +393,6 @@ bool BLWiFiDriver::WiFiNetworkIterator::Next(Network & item) item.connected = true; } } -#endif return true; } diff --git a/src/platform/bouffalolab/BL602/NetworkCommissioningDriver.h b/src/platform/bouffalolab/BL602/NetworkCommissioningDriver.h index 2664415198f6a3..31b7f4c395d5a8 100644 --- a/src/platform/bouffalolab/BL602/NetworkCommissioningDriver.h +++ b/src/platform/bouffalolab/BL602/NetworkCommissioningDriver.h @@ -114,6 +114,11 @@ class BLWiFiDriver final : public WiFiDriver CHIP_ERROR ReConnectWiFiNetwork(void); void OnConnectWiFiNetwork(); void OnScanWiFiNetworkDone(); + void OnNetworkStatusChange(); + + CHIP_ERROR SetLastDisconnectReason(const ChipDeviceEvent * event); + int32_t GetLastDisconnectReason(); + static BLWiFiDriver & GetInstance() { static BLWiFiDriver instance; @@ -130,6 +135,7 @@ class BLWiFiDriver final : public WiFiDriver ScanCallback * mpScanCallback; ConnectCallback * mpConnectCallback; NetworkStatusChangeCallback * mpStatusChangeCallback = nullptr; + int32_t mLastDisconnectedReason; }; // #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI diff --git a/src/platform/bouffalolab/BL602/OTAImageProcessorImpl.cpp b/src/platform/bouffalolab/BL602/OTAImageProcessorImpl.cpp new file mode 100644 index 00000000000000..f5d9c29fd2557f --- /dev/null +++ b/src/platform/bouffalolab/BL602/OTAImageProcessorImpl.cpp @@ -0,0 +1,268 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include "OTAImageProcessorImpl.h" +#include "lib/core/CHIPError.h" +#include +#include + +#define TAG "OTAImageProcessor" +using namespace chip::System; +using namespace ::chip::DeviceLayer::Internal; + +namespace chip { +namespace { + +void HandleRestart(Layer * systemLayer, void * appState) +{ + hal_reboot(); + + return; +} +} // namespace + +bool OTAImageProcessorImpl::IsFirstImageRun() +{ + OTARequestorInterface * requestor = chip::GetRequestorInstance(); + if (requestor == nullptr) + { + return false; + } + + return requestor->GetCurrentUpdateState() == OTARequestorInterface::OTAUpdateStateEnum::kApplying; +} + +CHIP_ERROR OTAImageProcessorImpl::ConfirmCurrentImage() +{ + OTARequestorInterface * requestor = chip::GetRequestorInstance(); + if (requestor == nullptr) + { + return CHIP_ERROR_INTERNAL; + } + + uint32_t currentVersion; + ReturnErrorOnFailure(DeviceLayer::ConfigurationMgr().GetSoftwareVersion(currentVersion)); + if (currentVersion != requestor->GetTargetVersion()) + { + return CHIP_ERROR_INCORRECT_STATE; + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::PrepareDownload() +{ + DeviceLayer::PlatformMgr().ScheduleWork(HandlePrepareDownload, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::Finalize() +{ + DeviceLayer::PlatformMgr().ScheduleWork(HandleFinalize, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::Apply() +{ + DeviceLayer::PlatformMgr().ScheduleWork(HandleApply, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::Abort() +{ + DeviceLayer::PlatformMgr().ScheduleWork(HandleAbort, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::ProcessBlock(ByteSpan & block) +{ + CHIP_ERROR err = SetBlock(block); + if (err != CHIP_NO_ERROR) + { + ChipLogError(SoftwareUpdate, "Cannot set block data: %" CHIP_ERROR_FORMAT, err.Format()); + return err; + } + DeviceLayer::PlatformMgr().ScheduleWork(HandleProcessBlock, reinterpret_cast(this)); + return CHIP_NO_ERROR; +} + +void OTAImageProcessorImpl::HandlePrepareDownload(intptr_t context) +{ + int err = 0; + + auto * imageProcessor = reinterpret_cast(context); + if (imageProcessor == nullptr) + { + ChipLogError(SoftwareUpdate, "ImageProcessor context is null"); + return; + } + else if (imageProcessor->mDownloader == nullptr) + { + ChipLogError(SoftwareUpdate, "mDownloader is null"); + return; + } + + err = hosal_ota_start(); + if (err != 0) + { + return; + } + + imageProcessor->offset = 0; + imageProcessor->mHeaderParser.Init(); + imageProcessor->mDownloader->OnPreparedForDownload(CHIP_NO_ERROR); +} + +void OTAImageProcessorImpl::HandleFinalize(intptr_t context) +{ + int err = 0; + auto * imageProcessor = reinterpret_cast(context); + if (imageProcessor == nullptr) + { + ChipLogError(SoftwareUpdate, "ImageProcessor context is null"); + return; + } + + err = hosal_ota_finish(0, 0); + if (err != 0) + { + log_info("HandleApply: %d!", err); + return; + } + + imageProcessor->ReleaseBlock(); +} + +void OTAImageProcessorImpl::HandleAbort(intptr_t context) +{ + auto * imageProcessor = reinterpret_cast(context); + if (imageProcessor == nullptr) + { + ChipLogError(SoftwareUpdate, "ImageProcessor context is null"); + return; + } + imageProcessor->ReleaseBlock(); +} + +void OTAImageProcessorImpl::HandleProcessBlock(intptr_t context) +{ + int err = 0; + + auto * imageProcessor = reinterpret_cast(context); + if (imageProcessor == nullptr) + { + ChipLogError(SoftwareUpdate, "ImageProcessor context is null"); + return; + } + else if (imageProcessor->mDownloader == nullptr) + { + ChipLogError(SoftwareUpdate, "mDownloader is null"); + return; + } + + ByteSpan block = ByteSpan(imageProcessor->mBlock.data(), imageProcessor->mBlock.size()); + + CHIP_ERROR error = imageProcessor->ProcessHeader(block); + if (error != CHIP_NO_ERROR) + { + log_info("Failed to process OTA image header"); + imageProcessor->mDownloader->EndDownload(error); + return; + } + + err = hosal_ota_update(imageProcessor->offset, block.data(), block.size()); + if (err != 0) + { + log_info("Update ota failed.\r\n"); + imageProcessor->mDownloader->EndDownload(CHIP_ERROR_WRITE_FAILED); + return; + } + + imageProcessor->offset += block.size(); + + imageProcessor->mParams.downloadedBytes += block.size(); + imageProcessor->mDownloader->FetchNextData(); +} + +void OTAImageProcessorImpl::HandleApply(intptr_t context) +{ + auto * imageProcessor = reinterpret_cast(context); + + hal_reboot(); +} + +CHIP_ERROR OTAImageProcessorImpl::SetBlock(ByteSpan & block) +{ + if (!IsSpanUsable(block)) + { + ReleaseBlock(); + return CHIP_NO_ERROR; + } + if (mBlock.size() < block.size()) + { + if (!mBlock.empty()) + { + ReleaseBlock(); + } + uint8_t * mBlock_ptr = static_cast(chip::Platform::MemoryAlloc(block.size())); + if (mBlock_ptr == nullptr) + { + return CHIP_ERROR_NO_MEMORY; + } + mBlock = MutableByteSpan(mBlock_ptr, block.size()); + } + CHIP_ERROR err = CopySpanToMutableSpan(block, mBlock); + if (err != CHIP_NO_ERROR) + { + ChipLogError(SoftwareUpdate, "Cannot copy block data: %" CHIP_ERROR_FORMAT, err.Format()); + return err; + } + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::ReleaseBlock() +{ + if (mBlock.data() != nullptr) + { + chip::Platform::MemoryFree(mBlock.data()); + } + mBlock = MutableByteSpan(); + return CHIP_NO_ERROR; +} + +CHIP_ERROR OTAImageProcessorImpl::ProcessHeader(ByteSpan & block) +{ + if (mHeaderParser.IsInitialized()) + { + OTAImageHeader header; + CHIP_ERROR error = mHeaderParser.AccumulateAndDecode(block, header); + + // Need more data to decode the header + ReturnErrorCodeIf(error == CHIP_ERROR_BUFFER_TOO_SMALL, CHIP_NO_ERROR); + ReturnErrorOnFailure(error); + + mParams.totalFileBytes = header.mPayloadSize; + mHeaderParser.Clear(); + } + + return CHIP_NO_ERROR; +} + +} // namespace chip diff --git a/src/platform/bouffalolab/BL602/OTAImageProcessorImpl.h b/src/platform/bouffalolab/BL602/OTAImageProcessorImpl.h new file mode 100644 index 00000000000000..1be325e8098f10 --- /dev/null +++ b/src/platform/bouffalolab/BL602/OTAImageProcessorImpl.h @@ -0,0 +1,57 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include +#include + +namespace chip { + +class OTAImageProcessorImpl : public OTAImageProcessorInterface +{ +public: + //////////// OTAImageProcessorInterface Implementation /////////////// + CHIP_ERROR PrepareDownload() override; + CHIP_ERROR Finalize() override; + CHIP_ERROR Apply() override; + CHIP_ERROR Abort() override; + CHIP_ERROR ProcessBlock(ByteSpan & block) override; + void SetOTADownloader(OTADownloader * downloader) { mDownloader = downloader; }; + bool IsFirstImageRun() override; + CHIP_ERROR ConfirmCurrentImage() override; + +private: + static void HandlePrepareDownload(intptr_t context); + static void HandleFinalize(intptr_t context); + static void HandleAbort(intptr_t context); + static void HandleProcessBlock(intptr_t context); + static void HandleApply(intptr_t context); + + CHIP_ERROR SetBlock(ByteSpan & block); + CHIP_ERROR ReleaseBlock(); + CHIP_ERROR ProcessHeader(ByteSpan & block); + + OTADownloader * mDownloader = nullptr; + MutableByteSpan mBlock; + uint32_t offset = 0; + OTAImageHeaderParser mHeaderParser; +}; + +} // namespace chip diff --git a/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp b/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp index c61b6dec23d377..c2c2ef5410e3ab 100644 --- a/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp +++ b/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp @@ -84,6 +84,10 @@ void event_cb_wifi_event(input_event_t * event, void * private_data) NetworkCommissioning::BLWiFiDriver::GetInstance().OnScanWiFiNetworkDone(); } break; + case CODE_WIFI_ON_DISCONNECT: { + printf("[APP] [EVT] disconnect %lld, Reason: %s\r\n", aos_now_ms(), wifi_mgmr_status_code_str(event->value)); + } + break; case CODE_WIFI_ON_CONNECTING: { log_info("[APP] [EVT] Connecting %lld\r\n", aos_now_ms()); ConnectivityManagerImpl::mWiFiStationState = ConnectivityManager::kWiFiStationState_Connecting; diff --git a/src/platform/bouffalolab/BL602/args.gni b/src/platform/bouffalolab/BL602/args.gni index f7a568013a4795..8fe6c1a52b7de0 100644 --- a/src/platform/bouffalolab/BL602/args.gni +++ b/src/platform/bouffalolab/BL602/args.gni @@ -23,7 +23,6 @@ riscv_platform_config = "${bl602_sdk_build_root}/bl602_riscv.gni" mbedtls_target = "${bl602_sdk_build_root}:bl602_sdk" chip_device_platform = "bl602" -chip_mdns = "platform" lwip_platform = "bl602" diff --git a/src/platform/device.gni b/src/platform/device.gni index ec758393b98664..96fb8432be2bb6 100755 --- a/src/platform/device.gni +++ b/src/platform/device.gni @@ -80,7 +80,8 @@ declare_args() { # Select DNS-SD implementation if (chip_device_platform == "linux" || chip_device_platform == "esp32" || chip_device_platform == "mbed" || chip_device_platform == "p6" || - chip_device_platform == "ameba" || chip_device_platform == "webos") { + chip_device_platform == "ameba" || chip_device_platform == "webos" || + chip_device_platform == "bl602") { chip_mdns = "minimal" } else if (chip_device_platform == "darwin" || chip_device_platform == "cc13x2_26x2" || current_os == "android" || diff --git a/src/platform/nrfconnect/BUILD.gn b/src/platform/nrfconnect/BUILD.gn index d6a6a2dfc7adae..e95a2742eb6f75 100644 --- a/src/platform/nrfconnect/BUILD.gn +++ b/src/platform/nrfconnect/BUILD.gn @@ -49,8 +49,19 @@ static_library("nrfconnect") { "SystemPlatformConfig.h", ] + public = [ "${chip_root}/src/credentials/DeviceAttestationCredsProvider.h" ] + public_deps = [ "${chip_root}/src/platform:platform_base" ] + if (chip_enable_factory_data) { + sources += [ + "FactoryDataParser.c", + "FactoryDataParser.h", + "FactoryDataProvider.cpp", + "FactoryDataProvider.h", + ] + } + if (chip_enable_openthread) { sources += [ "../OpenThread/OpenThreadUtils.cpp", diff --git a/src/platform/nrfconnect/FactoryDataParser.c b/src/platform/nrfconnect/FactoryDataParser.c new file mode 100644 index 00000000000000..c297a8d29008b7 --- /dev/null +++ b/src/platform/nrfconnect/FactoryDataParser.c @@ -0,0 +1,163 @@ +/* + * + * 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 "FactoryDataParser.h" + +#include +#include + +#include +#include + +#define MAX_FACTORY_DATA_NESTING_LEVEL 3 + +LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL); + +static inline bool uint16_decode(zcbor_state_t * states, uint16_t * value) +{ + uint32_t u32; + + if (zcbor_uint32_decode(states, &u32)) + { + *value = (uint16_t) u32; + return true; + } + + return false; +} + +bool ParseFactoryData(uint8_t * buffer, uint16_t bufferSize, struct FactoryData * factoryData) +{ + memset(factoryData, 0, sizeof(*factoryData)); + ZCBOR_STATE_D(states, MAX_FACTORY_DATA_NESTING_LEVEL, buffer, bufferSize, 1); + + bool res = zcbor_map_start_decode(states); + struct zcbor_string currentString; + + while (res) + { + res = zcbor_tstr_decode(states, ¤tString); + + if (!res) + { + res = true; + break; + } + + if (strncmp("version", (const char *) currentString.value, currentString.len) == 0) + { + res = res && uint16_decode(states, &factoryData->version); + } + else if (strncmp("hw_ver", (const char *) currentString.value, currentString.len) == 0) + { + res = res && uint16_decode(states, &factoryData->hw_ver); + factoryData->hwVerPresent = res; + } + else if (strncmp("spake2_it", (const char *) currentString.value, currentString.len) == 0) + { + res = res && zcbor_uint32_decode(states, &factoryData->spake2_it); + } + else if (strncmp("vendor_id", (const char *) currentString.value, currentString.len) == 0) + { + res = res && uint16_decode(states, &factoryData->vendor_id); + factoryData->vendorIdPresent = res; + } + else if (strncmp("product_id", (const char *) currentString.value, currentString.len) == 0) + { + res = res && uint16_decode(states, &factoryData->product_id); + factoryData->productIdPresent = res; + } + else if (strncmp("discriminator", (const char *) currentString.value, currentString.len) == 0) + { + res = res && uint16_decode(states, &factoryData->discriminator); + factoryData->discriminatorPresent = res; + } + else if (strncmp("passcode", (const char *) currentString.value, currentString.len) == 0) + { + res = res && zcbor_uint32_decode(states, &factoryData->passcode); + } + else if (strncmp("sn", (const char *) currentString.value, currentString.len) == 0) + { + res = res && zcbor_bstr_decode(states, (struct zcbor_string *) &factoryData->sn); + } + else if (strncmp("date", (const char *) currentString.value, currentString.len) == 0) + { + // Date format is YYYY-MM-DD, so format needs to be validated and string parse to integer parts. + struct zcbor_string date; + res = res && zcbor_bstr_decode(states, &date); + if (date.len == 10 && isdigit(date.value[0]) && isdigit(date.value[1]) && isdigit(date.value[2]) && + isdigit(date.value[3]) && date.value[4] == '-' && isdigit(date.value[5]) && isdigit(date.value[6]) && + date.value[7] == '-' && isdigit(date.value[8]) && isdigit(date.value[9])) + { + factoryData->date_year = + 1000 * (date.value[0] - '0') + 100 * (date.value[1] - '0') + 10 * (date.value[2] - '0') + date.value[3] - '0'; + factoryData->date_month = 10 * (date.value[5] - '0') + date.value[6] - '0'; + factoryData->date_day = 10 * (date.value[8] - '0') + date.value[9] - '0'; + } + else + { + LOG_ERR("Parsing error - wrong date format"); + } + } + else if (strncmp("hw_ver_str", (const char *) currentString.value, currentString.len) == 0) + { + res = res && zcbor_bstr_decode(states, (struct zcbor_string *) &factoryData->hw_ver_str); + } + else if (strncmp("rd_uid", (const char *) currentString.value, currentString.len) == 0) + { + res = res && zcbor_bstr_decode(states, (struct zcbor_string *) &factoryData->rd_uid); + } + else if (strncmp("dac_cert", (const char *) currentString.value, currentString.len) == 0) + { + res = res && zcbor_bstr_decode(states, (struct zcbor_string *) &factoryData->dac_cert); + } + else if (strncmp("dac_key", (const char *) currentString.value, currentString.len) == 0) + { + res = res && zcbor_bstr_decode(states, (struct zcbor_string *) &factoryData->dac_priv_key); + } + else if (strncmp("pai_cert", (const char *) currentString.value, currentString.len) == 0) + { + res = res && zcbor_bstr_decode(states, (struct zcbor_string *) &factoryData->pai_cert); + } + else if (strncmp("spake2_salt", (const char *) currentString.value, currentString.len) == 0) + { + res = res && zcbor_bstr_decode(states, (struct zcbor_string *) &factoryData->spake2_salt); + } + else if (strncmp("spake2_verifier", (const char *) currentString.value, currentString.len) == 0) + { + res = res && zcbor_bstr_decode(states, (struct zcbor_string *) &factoryData->spake2_verifier); + } + else if (strncmp("vendor_name", (const char *) currentString.value, currentString.len) == 0) + { + res = res && zcbor_bstr_decode(states, (struct zcbor_string *) &factoryData->vendor_name); + } + else if (strncmp("product_name", (const char *) currentString.value, currentString.len) == 0) + { + res = res && zcbor_bstr_decode(states, (struct zcbor_string *) &factoryData->product_name); + } + else if (strncmp("user", (const char *) currentString.value, currentString.len) == 0) + { + res = res && zcbor_bstr_decode(states, (struct zcbor_string *) &factoryData->user); + } + else + { + res = res && zcbor_any_skip(states, NULL); + } + } + + return res && zcbor_list_map_end_force_decode(states); +} diff --git a/src/platform/nrfconnect/FactoryDataParser.h b/src/platform/nrfconnect/FactoryDataParser.h new file mode 100644 index 00000000000000..53b78a816ae142 --- /dev/null +++ b/src/platform/nrfconnect/FactoryDataParser.h @@ -0,0 +1,77 @@ +/* + * + * 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 + +#ifdef __cplusplus +extern "C" { +#endif + +struct FactoryDataString +{ + void * data; + size_t len; +}; + +struct FactoryData +{ + uint16_t version; + struct FactoryDataString sn; + uint16_t date_year; + uint8_t date_month; + uint8_t date_day; + uint16_t vendor_id; + uint16_t product_id; + struct FactoryDataString vendor_name; + struct FactoryDataString product_name; + uint16_t hw_ver; + struct FactoryDataString hw_ver_str; + struct FactoryDataString rd_uid; + struct FactoryDataString dac_cert; + struct FactoryDataString dac_priv_key; + struct FactoryDataString pai_cert; + uint32_t spake2_it; + struct FactoryDataString spake2_salt; + struct FactoryDataString spake2_verifier; + uint16_t discriminator; + uint32_t passcode; + struct FactoryDataString user; + + bool vendorIdPresent; + bool productIdPresent; + bool hwVerPresent; + bool discriminatorPresent; +}; + +/** + * @brief Parses raw factory data into the factory data structure. + * + * @param[in] buffer Buffer containing raw factory data. + * @param[in] bufferSize Size of factory data. + * @param[out] factoryData address of object to be filled with parsed factory data. + * + * @returns true on success, false otherwise. + */ +bool ParseFactoryData(uint8_t * buffer, uint16_t bufferSize, struct FactoryData * factoryData); + +#ifdef __cplusplus +} +#endif diff --git a/src/platform/nrfconnect/FactoryDataProvider.cpp b/src/platform/nrfconnect/FactoryDataProvider.cpp new file mode 100644 index 00000000000000..68cf3d4952c2be --- /dev/null +++ b/src/platform/nrfconnect/FactoryDataProvider.cpp @@ -0,0 +1,344 @@ +/* + * + * 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 "FactoryDataProvider.h" +#include "CHIPDevicePlatformConfig.h" +#include + +#include + +namespace chip { +namespace { + +CHIP_ERROR LoadKeypairFromRaw(ByteSpan privateKey, ByteSpan publicKey, Crypto::P256Keypair & keypair) +{ + Crypto::P256SerializedKeypair serializedKeypair; + ReturnErrorOnFailure(serializedKeypair.SetLength(privateKey.size() + publicKey.size())); + memcpy(serializedKeypair.Bytes(), publicKey.data(), publicKey.size()); + memcpy(serializedKeypair.Bytes() + publicKey.size(), privateKey.data(), privateKey.size()); + return keypair.Deserialize(serializedKeypair); +} +} // namespace + +namespace DeviceLayer { + +template +CHIP_ERROR FactoryDataProvider::Init() +{ + uint8_t * factoryData = nullptr; + size_t factoryDataSize; + + CHIP_ERROR error = mFlashFactoryData.GetFactoryDataPartition(factoryData, factoryDataSize); + + if (error != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to read factory data partition"); + return error; + } + + if (!ParseFactoryData(factoryData, factoryDataSize, &mFactoryData)) + { + ChipLogError(DeviceLayer, "Failed to parse factory data"); + return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; + } + + // Check if factory data version is correct + if (mFactoryData.version != CONFIG_CHIP_FACTORY_DATA_VERSION) + { + ChipLogError(DeviceLayer, "Factory data version mismatch. Flash version: %d vs code version: %d", mFactoryData.version, + CONFIG_CHIP_FACTORY_DATA_VERSION); + return CHIP_ERROR_VERSION_MISMATCH; + } + + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetCertificationDeclaration(MutableByteSpan & outBuffer) +{ + //-> 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 + const uint8_t kCdForAllExamples[541] = { + 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, 0xf1, 0xff, 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, 0x05, 0x1a, 0x80, 0x05, 0x1b, 0x80, 0x05, 0x1c, + 0x80, 0x05, 0x1d, 0x80, 0x05, 0x1e, 0x80, 0x05, 0x1f, 0x80, 0x05, 0x20, 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, + }; + + return CopySpanToMutableSpan(ByteSpan{ kCdForAllExamples }, outBuffer); +} + +template +CHIP_ERROR FactoryDataProvider::GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer) +{ + out_firmware_info_buffer.reduce_size(0); + + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetDeviceAttestationCert(MutableByteSpan & outBuffer) +{ + ReturnErrorCodeIf(outBuffer.size() < mFactoryData.dac_cert.len, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(!mFactoryData.dac_cert.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + memcpy(outBuffer.data(), mFactoryData.dac_cert.data, mFactoryData.dac_cert.len); + + outBuffer.reduce_size(mFactoryData.dac_cert.len); + + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetProductAttestationIntermediateCert(MutableByteSpan & outBuffer) +{ + ReturnErrorCodeIf(outBuffer.size() < mFactoryData.pai_cert.len, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(!mFactoryData.pai_cert.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + memcpy(outBuffer.data(), mFactoryData.pai_cert.data, mFactoryData.pai_cert.len); + + outBuffer.reduce_size(mFactoryData.pai_cert.len); + + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::SignWithDeviceAttestationKey(const ByteSpan & digestToSign, + MutableByteSpan & outSignBuffer) +{ + Crypto::P256ECDSASignature signature; + Crypto::P256Keypair keypair; + + VerifyOrReturnError(outSignBuffer.size() >= signature.Capacity(), CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(!mFactoryData.dac_cert.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + ReturnErrorCodeIf(!mFactoryData.dac_priv_key.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + // Extract public key from DAC cert. + ByteSpan dacCertSpan{ reinterpret_cast(mFactoryData.dac_cert.data), mFactoryData.dac_cert.len }; + chip::Crypto::P256PublicKey dacPublicKey; + + ReturnErrorOnFailure(chip::Crypto::ExtractPubkeyFromX509Cert(dacCertSpan, dacPublicKey)); + ReturnErrorOnFailure( + LoadKeypairFromRaw(ByteSpan(reinterpret_cast(mFactoryData.dac_priv_key.data), mFactoryData.dac_priv_key.len), + ByteSpan(dacPublicKey.Bytes(), dacPublicKey.Length()), keypair)); + ReturnErrorOnFailure(keypair.ECDSA_sign_hash(digestToSign.data(), digestToSign.size(), signature)); + + return CopySpanToMutableSpan(ByteSpan{ signature.ConstBytes(), signature.Length() }, outSignBuffer); +} + +template +CHIP_ERROR FactoryDataProvider::GetSetupDiscriminator(uint16_t & setupDiscriminator) +{ + VerifyOrReturnError(mFactoryData.discriminatorPresent, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + setupDiscriminator = mFactoryData.discriminator; + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::SetSetupDiscriminator(uint16_t setupDiscriminator) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +template +CHIP_ERROR FactoryDataProvider::GetSpake2pIterationCount(uint32_t & iterationCount) +{ + ReturnErrorCodeIf(mFactoryData.spake2_it == 0, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + iterationCount = mFactoryData.spake2_it; + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetSpake2pSalt(MutableByteSpan & saltBuf) +{ + ReturnErrorCodeIf(saltBuf.size() < mFactoryData.spake2_salt.len, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(!mFactoryData.spake2_salt.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + memcpy(saltBuf.data(), mFactoryData.spake2_salt.data, mFactoryData.spake2_salt.len); + + saltBuf.reduce_size(mFactoryData.spake2_salt.len); + + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetSpake2pVerifier(MutableByteSpan & verifierBuf, size_t & verifierLen) +{ + ReturnErrorCodeIf(verifierBuf.size() < mFactoryData.spake2_verifier.len, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(!mFactoryData.spake2_verifier.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + memcpy(verifierBuf.data(), mFactoryData.spake2_verifier.data, mFactoryData.spake2_verifier.len); + + verifierLen = mFactoryData.spake2_verifier.len; + + verifierBuf.reduce_size(verifierLen); + + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetSetupPasscode(uint32_t & setupPasscode) +{ + ReturnErrorCodeIf(mFactoryData.passcode == 0, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + setupPasscode = mFactoryData.passcode; + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +template +CHIP_ERROR FactoryDataProvider::SetSetupPasscode(uint32_t setupPasscode) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +template +CHIP_ERROR FactoryDataProvider::GetVendorName(char * buf, size_t bufSize) +{ + ReturnErrorCodeIf(bufSize < mFactoryData.vendor_name.len + 1, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(!mFactoryData.vendor_name.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + memcpy(buf, mFactoryData.vendor_name.data, mFactoryData.vendor_name.len); + buf[mFactoryData.vendor_name.len] = 0; + + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetVendorId(uint16_t & vendorId) +{ + VerifyOrReturnError(mFactoryData.vendorIdPresent, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + vendorId = mFactoryData.vendor_id; + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetProductName(char * buf, size_t bufSize) +{ + ReturnErrorCodeIf(bufSize < mFactoryData.product_name.len + 1, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(!mFactoryData.product_name.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + memcpy(buf, mFactoryData.product_name.data, mFactoryData.product_name.len); + buf[mFactoryData.product_name.len] = 0; + + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetProductId(uint16_t & productId) +{ + VerifyOrReturnError(mFactoryData.productIdPresent, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + productId = mFactoryData.product_id; + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetSerialNumber(char * buf, size_t bufSize) +{ + ReturnErrorCodeIf(bufSize < mFactoryData.sn.len + 1, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(!mFactoryData.sn.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + memcpy(buf, mFactoryData.sn.data, mFactoryData.sn.len); + buf[mFactoryData.sn.len] = 0; + + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetManufacturingDate(uint16_t & year, uint8_t & month, uint8_t & day) +{ + VerifyOrReturnError(mFactoryData.date_year != 0, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + year = mFactoryData.date_year; + month = mFactoryData.date_month; + day = mFactoryData.date_day; + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetHardwareVersion(uint16_t & hardwareVersion) +{ + VerifyOrReturnError(mFactoryData.hwVerPresent, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + hardwareVersion = mFactoryData.hw_ver; + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetHardwareVersionString(char * buf, size_t bufSize) +{ + ReturnErrorCodeIf(bufSize < mFactoryData.hw_ver_str.len + 1, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(!mFactoryData.hw_ver_str.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + memcpy(buf, mFactoryData.hw_ver_str.data, mFactoryData.hw_ver_str.len); + buf[mFactoryData.hw_ver_str.len] = 0; + + return CHIP_NO_ERROR; +} + +template +CHIP_ERROR FactoryDataProvider::GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) +{ + ReturnErrorCodeIf(uniqueIdSpan.size() < mFactoryData.rd_uid.len, CHIP_ERROR_BUFFER_TOO_SMALL); + ReturnErrorCodeIf(!mFactoryData.rd_uid.data, CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND); + + memcpy(uniqueIdSpan.data(), mFactoryData.rd_uid.data, mFactoryData.rd_uid.len); + + return CHIP_NO_ERROR; +} + +// Fully instantiate the template class in whatever compilation unit includes this file. +template class FactoryDataProvider; +template class FactoryDataProvider; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nrfconnect/FactoryDataProvider.h b/src/platform/nrfconnect/FactoryDataProvider.h new file mode 100644 index 00000000000000..a027135c6fe74e --- /dev/null +++ b/src/platform/nrfconnect/FactoryDataProvider.h @@ -0,0 +1,109 @@ +/* + * + * 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 +#include + +#include "FactoryDataParser.h" + +namespace chip { +namespace DeviceLayer { + +struct InternalFlashFactoryData +{ + CHIP_ERROR GetFactoryDataPartition(uint8_t *& data, size_t & dataSize) + { + data = reinterpret_cast(PM_FACTORY_DATA_ADDRESS); + dataSize = PM_FACTORY_DATA_SIZE; + return CHIP_NO_ERROR; + } +}; + +struct ExternalFlashFactoryData +{ + CHIP_ERROR GetFactoryDataPartition(uint8_t *& data, size_t & dataSize) + { + int ret = flash_read(mFlashDevice, PM_FACTORY_DATA_ADDRESS, mFactoryDataBuffer, PM_FACTORY_DATA_SIZE); + + if (ret != 0) + { + return CHIP_ERROR_READ_FAILED; + } + + data = mFactoryDataBuffer; + dataSize = PM_FACTORY_DATA_SIZE; + + return CHIP_NO_ERROR; + } + + const struct device * mFlashDevice = DEVICE_DT_GET(DT_CHOSEN(zephyr_flash_controller)); + uint8_t mFactoryDataBuffer[PM_FACTORY_DATA_SIZE]; +}; + +template +class FactoryDataProvider : public chip::Credentials::DeviceAttestationCredentialsProvider, + public CommissionableDataProvider, + public DeviceInstanceInfoProvider +{ +public: + CHIP_ERROR Init(); + + // ===== 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 & digestToSign, MutableByteSpan & outSignBuffer) override; + + // ===== 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 DeviceInstanceInfoProvider + 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 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 GetHardwareVersionString(char * buf, size_t bufSize) override; + CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) override; + +private: + static constexpr uint16_t kFactoryDataPartitionSize = PM_FACTORY_DATA_SIZE; + static constexpr uint32_t kFactoryDataPartitionAddress = PM_FACTORY_DATA_ADDRESS; + static constexpr uint8_t kDACPrivateKeyLength = 32; + static constexpr uint8_t kDACPublicKeyLength = 65; + + struct FactoryData mFactoryData; + FlashFactoryData mFlashFactoryData; +}; + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nrfconnect/args.gni b/src/platform/nrfconnect/args.gni index 64e4dcb1f7585a..902804219d6cb9 100644 --- a/src/platform/nrfconnect/args.gni +++ b/src/platform/nrfconnect/args.gni @@ -14,4 +14,7 @@ declare_args() { chip_malloc_sys_heap = false + + # Enable factory data support + chip_enable_factory_data = false } diff --git a/third_party/bouffalolab/bl602_sdk/bl602_sdk.gni b/third_party/bouffalolab/bl602_sdk/bl602_sdk.gni index 8145dc55fe4442..92fbcffb7befba 100644 --- a/third_party/bouffalolab/bl602_sdk/bl602_sdk.gni +++ b/third_party/bouffalolab/bl602_sdk/bl602_sdk.gni @@ -267,6 +267,7 @@ template("bl602_sdk") { cflags_cc = [ "-fpermissive" ] cflags_cc += [ "-std=c++17" ] + cflags_cc += [ "-D _GNU_SOURCE" ] foreach(include_dir, _include_dirs) { cflags += [ "-isystem" + rebase_path(include_dir, root_build_dir) ] diff --git a/third_party/bouffalolab/bl602_sdk/repo b/third_party/bouffalolab/bl602_sdk/repo index 5894617d02ec7d..de9c79bc72de94 160000 --- a/third_party/bouffalolab/bl602_sdk/repo +++ b/third_party/bouffalolab/bl602_sdk/repo @@ -1 +1 @@ -Subproject commit 5894617d02ec7d7d95916e72b3bdc197ab50da0d +Subproject commit de9c79bc72de94c3237af4987d907c1478bcef23