diff --git a/examples/all-clusters-app/esp32/README.md b/examples/all-clusters-app/esp32/README.md index 15dce596e041e0..1f4ca1ca5a630e 100644 --- a/examples/all-clusters-app/esp32/README.md +++ b/examples/all-clusters-app/esp32/README.md @@ -195,7 +195,7 @@ remote device, as well as the network credentials to use. The command below uses the default values hard-coded into the debug versions of the ESP32 all-clusters-app to commission it onto a Wi-Fi network: - $ .out/debug/chip-tool pairing ble-wifi 12344321 ${SSID} ${PASSWORD} 20202021 3840 + $ ./out/debug/chip-tool pairing ble-wifi 12344321 ${SSID} ${PASSWORD} 20202021 3840 Parameters: @@ -210,7 +210,7 @@ Parameters: To use the Client to send Matter commands, run the built executable and pass it the target cluster name, the target command name as well as an endpoint id. - $ .out/debug/chip-tool onoff on 12344321 1 + $ ./out/debug/chip-tool onoff on 12344321 1 The client will send a single command packet and then exit. diff --git a/examples/bridge-app/esp32/README.md b/examples/bridge-app/esp32/README.md index 96e1a60f3ffb98..3e04f1bb30aad2 100644 --- a/examples/bridge-app/esp32/README.md +++ b/examples/bridge-app/esp32/README.md @@ -227,7 +227,7 @@ remote device, as well as the network credentials to use. The command below uses the default values hard-coded into the debug versions of the ESP32 all-clusters-app to commission it onto a Wi-Fi network: - $ .out/debug/chip-tool pairing ble-wifi 12344321 ${SSID} ${PASSWORD} 20202021 3840 + $ ./out/debug/chip-tool pairing ble-wifi 12344321 ${SSID} ${PASSWORD} 20202021 3840 Parameters: @@ -242,6 +242,6 @@ Parameters: To use the Client to send Matter commands, run the built executable and pass it the target cluster name, the target command name as well as an endpoint id. - $ .out/debug/chip-tool onoff on 12344321 1 + $ ./out/debug/chip-tool onoff on 12344321 2 The client will send a single command packet and then exit. diff --git a/examples/lighting-app/esp32/README.md b/examples/lighting-app/esp32/README.md index 99a847938d8d63..534e6ec3df0c16 100644 --- a/examples/lighting-app/esp32/README.md +++ b/examples/lighting-app/esp32/README.md @@ -9,6 +9,7 @@ This example demonstrates the Matter Lighting application on ESP platforms. - [Building the Example Application](#building-the-example-application) - [Commissioning over BLE using chip-tool](#commissioning-over-ble-using-chip-tool) - [Cluster Control](#cluster-control) +- [Steps to Try Lighting app OTA Requestor](#steps-to-try-lighting-app-ota-requestor) --- @@ -122,3 +123,41 @@ make sure the IDF_PATH has been exported(See the manual setup steps above). control the color attributes: $ ./out/debug/chip-tool colorcontrol move-to-hue-and-saturation 240 100 0 0 0 12345 1 + +# Steps to Try Lighting app OTA Requestor + +Before moving ahead, make sure your device is commissioned and running. + +- Build the Linux OTA Provider + +``` +scripts/examples/gn_build_example.sh examples/ota-provider-app/linux out/debug chip_config_network_layer_ble=false +``` + +- Run the Linux OTA Provider with OTA image. + +``` +./out/debug/chip-ota-provider-app -f hello-world.bin +``` + +hello-world.bin can be obtained from compiling the hello-world ESP-IDF example. + +- Provision the Linux OTA Provider using chip-tool + +``` +./out/debug/chip-tool pairing onnetwork 12345 20202021 +``` + +## Query for an OTA Image + +After commissioning is successful, press Enter in requestor device console and +type below query. + +``` +>matter ota query 1 12345 0 +``` + +## Apply update + +Once transfer is complete, reboot the device manually to boot from upgraded OTA +image. diff --git a/examples/lighting-app/esp32/main/CMakeLists.txt b/examples/lighting-app/esp32/main/CMakeLists.txt index 9f1b54cccfc3d6..4413f141070491 100644 --- a/examples/lighting-app/esp32/main/CMakeLists.txt +++ b/examples/lighting-app/esp32/main/CMakeLists.txt @@ -55,7 +55,8 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/thread-network-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/user-label-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/wifi-network-diagnostics-server" - PRIV_REQUIRES chip QRCode bt led_strip) + "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" + PRIV_REQUIRES chip QRCode bt led_strip app_update) set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17) target_compile_options(${COMPONENT_LIB} PRIVATE "-DLWIP_IPV6_SCOPES=0" "-DCHIP_HAVE_CONFIG_H") diff --git a/examples/lighting-app/esp32/main/main.cpp b/examples/lighting-app/esp32/main/main.cpp index 5a703183850757..b26a2fa6afd2e6 100644 --- a/examples/lighting-app/esp32/main/main.cpp +++ b/examples/lighting-app/esp32/main/main.cpp @@ -26,22 +26,46 @@ #include "freertos/task.h" #include "nvs_flash.h" #include "shell_extension/launch.h" +#include +#include #include #include #include #include +#include +#include using namespace ::chip; using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; +#if CONFIG_ENABLE_OTA_REQUESTOR +OTARequestor gRequestorCore; +GenericOTARequestorDriver gRequestorUser; +BDXDownloader gDownloader; +OTAImageProcessorImpl gImageProcessor; +#endif + LEDWidget AppLED; static const char * TAG = "light-app"; static DeviceCallbacks EchoCallbacks; +static void InitOTARequestor(void) +{ +#if CONFIG_ENABLE_OTA_REQUESTOR + SetRequestorInstance(&gRequestorCore); + gRequestorCore.SetServerInstance(&Server::GetInstance()); + gRequestorCore.SetOtaRequestorDriver(&gRequestorUser); + gImageProcessor.SetOTADownloader(&gDownloader); + gDownloader.SetImageProcessorDelegate(&gImageProcessor); + gRequestorUser.Init(&gRequestorCore, &gImageProcessor); + gRequestorCore.SetBDXDownloader(&gDownloader); +#endif +} + static void InitServer(intptr_t context) { // Print QR Code URL @@ -82,5 +106,7 @@ extern "C" void app_main() AppLED.Init(); + InitOTARequestor(); + chip::DeviceLayer::PlatformMgr().ScheduleWork(InitServer, reinterpret_cast(nullptr)); } diff --git a/examples/lighting-app/esp32/partitions.csv b/examples/lighting-app/esp32/partitions.csv index b338ff11a11589..9c801081f71c04 100644 --- a/examples/lighting-app/esp32/partitions.csv +++ b/examples/lighting-app/esp32/partitions.csv @@ -1,6 +1,7 @@ # Name, Type, SubType, Offset, Size, Flags # Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap nvs, data, nvs, , 0x6000, +otadata, data, ota, , 0x2000, phy_init, data, phy, , 0x1000, -# Factory partition size about 1.9MB -factory, app, factory, , 1945K, +ota_0, app, ota_0, , 1500K, +ota_1, app, ota_1, , 1500K, diff --git a/examples/lighting-app/esp32/sdkconfig.defaults b/examples/lighting-app/esp32/sdkconfig.defaults index 85e84a2001e385..23a3766c340c04 100644 --- a/examples/lighting-app/esp32/sdkconfig.defaults +++ b/examples/lighting-app/esp32/sdkconfig.defaults @@ -39,3 +39,7 @@ CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" #enable lwIP route hooks CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y + +# Serial Flasher config +CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y +CONFIG_ESPTOOLPY_FLASHSIZE="4MB" diff --git a/examples/lock-app/esp32/README.md b/examples/lock-app/esp32/README.md index fa9aab5abcff86..4fd81bc2bf5d53 100644 --- a/examples/lock-app/esp32/README.md +++ b/examples/lock-app/esp32/README.md @@ -171,7 +171,7 @@ remote device, as well as the network credentials to use. The command below uses the default values hard-coded into the debug versions of the ESP32 all-clusters-app to commission it onto a Wi-Fi network: - $ .out/debug/chip-tool pairing ble-wifi 12344321 ${SSID} ${PASSWORD} 20202021 3840 + $ ./out/debug/chip-tool pairing ble-wifi 12344321 ${SSID} ${PASSWORD} 20202021 3840 Parameters: @@ -186,7 +186,7 @@ Parameters: To use the Client to send Matter commands, run the built executable and pass it the target cluster name, the target command name as well as an endpoint id. - $ .out/debug/chip-tool onoff on 12344321 1 + $ ./out/debug/chip-tool onoff on 12344321 1 The client will send a single command packet and then exit. diff --git a/examples/ota-requestor-app/esp32/README.md b/examples/ota-requestor-app/esp32/README.md index 3fa1a299b5e53a..20534f43393f8c 100644 --- a/examples/ota-requestor-app/esp32/README.md +++ b/examples/ota-requestor-app/esp32/README.md @@ -40,20 +40,13 @@ After commissioning is successful, announce OTA provider's presence using chip-tool. On receiving this command OTA requestor will query for OTA image. ``` -./out/debug/chip-tool otasoftwareupdaterequestor announce-ota-provider 12345 0 0 12346 0 +./out/debug/chip-tool otasoftwareupdaterequestor announce-ota-provider 12345 0 0 0 12346 0 ``` -## Apply update request +## Apply update -Once transfer is complete OTA Requestor should take permission from the OTA -Provider for applying the OTA image. Use the following command from OTA -requestor prompt - -``` -esp32> ApplyUpdateRequest -``` - -Then reboot the device manually to boot from upgraded OTA image. +Once transfer is complete, reboot the device manually to boot from upgraded OTA +image. ## ESP32 OTA Requestor with Linux OTA Provider diff --git a/examples/ota-requestor-app/esp32/main/main.cpp b/examples/ota-requestor-app/esp32/main/main.cpp index e53dc1bb341dc1..06084e7994a004 100644 --- a/examples/ota-requestor-app/esp32/main/main.cpp +++ b/examples/ota-requestor-app/esp32/main/main.cpp @@ -32,11 +32,6 @@ #include #include -#include -#include -#include -#include - #include #include @@ -45,8 +40,6 @@ #include "OTAImageProcessorImpl.h" #include "platform/GenericOTARequestorDriver.h" #include "platform/OTARequestorInterface.h" -#include -#include using namespace ::chip; using namespace ::chip::System; @@ -54,15 +47,9 @@ using namespace ::chip::Credentials; using namespace ::chip::DeviceManager; using namespace ::chip::DeviceLayer; -struct CmdArgs -{ - struct arg_end * end; -}; - namespace { const char * TAG = "ota-requester-app"; static DeviceCallbacks EchoCallbacks; -CmdArgs applyUpdateCmdArgs; OTARequestor gRequestorCore; GenericOTARequestorDriver gRequestorUser; @@ -70,39 +57,6 @@ BDXDownloader gDownloader; OTAImageProcessorImpl gImageProcessor; } // namespace -int ESPApplyUpdateCmdHandler(int argc, char ** argv) -{ - gRequestorCore.ApplyUpdate(); - ESP_LOGI(TAG, "Apply the Update"); - return 0; -} - -void ESPInitConsole(void) -{ - esp_console_repl_t * repl = NULL; - esp_console_repl_config_t replConfig = ESP_CONSOLE_REPL_CONFIG_DEFAULT(); - esp_console_dev_uart_config_t uartConfig = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT(); - /* Prompt to be printed before each line. - * This can be customized, made dynamic, etc. - */ - replConfig.prompt = "esp32 >"; - - esp_console_register_help_command(); - - esp_console_cmd_t applyUpdateCommand; - memset(&applyUpdateCommand, 0, sizeof(applyUpdateCommand)); - - applyUpdateCmdArgs.end = arg_end(1); - - applyUpdateCommand.command = "ApplyUpdateRequest", applyUpdateCommand.help = "Request to OTA update image", - applyUpdateCommand.func = &ESPApplyUpdateCmdHandler, applyUpdateCommand.argtable = &applyUpdateCmdArgs; - - esp_console_cmd_register(&applyUpdateCommand); - - esp_console_new_repl_uart(&uartConfig, &replConfig, &repl); - esp_console_start_repl(repl); -} - extern "C" void app_main() { ESP_LOGI(TAG, "OTA Requester!"); @@ -140,7 +94,6 @@ extern "C" void app_main() // Initialize device attestation config SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); - ESPInitConsole(); SetRequestorInstance(&gRequestorCore); gRequestorCore.Init(&(Server::GetInstance()), &gRequestorUser, &gDownloader); gImageProcessor.SetOTADownloader(&gDownloader); diff --git a/examples/temperature-measurement-app/esp32/README.md b/examples/temperature-measurement-app/esp32/README.md index 63834903af093e..13b2e745c6103e 100644 --- a/examples/temperature-measurement-app/esp32/README.md +++ b/examples/temperature-measurement-app/esp32/README.md @@ -171,7 +171,7 @@ remote device, as well as the network credentials to use. The command below uses the default values hard-coded into the debug versions of the ESP32 all-clusters-app to commission it onto a Wi-Fi network: - $ .out/debug/chip-tool pairing ble-wifi 12344321 ${SSID} ${PASSWORD} 20202021 3840 + $ ./out/debug/chip-tool pairing ble-wifi 12344321 ${SSID} ${PASSWORD} 20202021 3840 Parameters: