From 58ede577efebfa17bab7ac261e29da9fa75f88fa Mon Sep 17 00:00:00 2001 From: Chirag Atal Date: Mon, 23 May 2022 12:11:41 +0530 Subject: [PATCH] esp-matter: Minor miscellaneous fixes examples: Changes to events and comments. switch: Rename to light_switch. docs: Minor changes. --- docs/_static/supported_services.png | Bin 0 -> 7499 bytes docs/en/developing.rst | 6 +-- .../examples/{switch.rst => light_switch.rst} | 4 +- docs/en/faq.rst | 35 +++++++++--------- docs/en/introduction.rst | 9 ++++- examples/light/README.md | 2 +- examples/light/main/app_main.cpp | 19 +++++++--- .../{switch => light_switch}/CMakeLists.txt | 4 +- examples/{switch => light_switch}/README.md | 2 +- .../main/CMakeLists.txt | 0 .../main/app_driver.cpp | 0 .../main/app_main.cpp | 19 +++++++--- .../{switch => light_switch}/main/app_priv.h | 0 .../PluginApplicationCallbacks.h | 0 .../main/zap-generated/af-gen-event.h | 0 .../main/zap-generated/empty_file.cpp | 0 .../main/zap-generated/endpoint_config.h | 0 .../{switch => light_switch}/partitions.csv | 0 .../partitions_h2.csv | 0 .../sdkconfig.defaults | 0 .../sdkconfig.defaults.esp32h2 | 0 .../sdkconfig.defaults.esp32s2 | 0 examples/rainmaker_light/main/app_main.cpp | 19 +++++++--- examples/zap_light/README.md | 2 +- examples/zap_light/main/app_main.cpp | 12 +++++- examples/zigbee_bridge/main/app_main.cpp | 18 +++++++-- 26 files changed, 100 insertions(+), 51 deletions(-) create mode 100644 docs/_static/supported_services.png rename docs/en/examples/{switch.rst => light_switch.rst} (99%) rename examples/{switch => light_switch}/CMakeLists.txt (95%) rename examples/{switch => light_switch}/README.md (98%) rename examples/{switch => light_switch}/main/CMakeLists.txt (100%) rename examples/{switch => light_switch}/main/app_driver.cpp (100%) rename examples/{switch => light_switch}/main/app_main.cpp (86%) rename examples/{switch => light_switch}/main/app_priv.h (100%) rename examples/{switch => light_switch}/main/zap-generated/PluginApplicationCallbacks.h (100%) rename examples/{switch => light_switch}/main/zap-generated/af-gen-event.h (100%) rename examples/{switch => light_switch}/main/zap-generated/empty_file.cpp (100%) rename examples/{switch => light_switch}/main/zap-generated/endpoint_config.h (100%) rename examples/{switch => light_switch}/partitions.csv (100%) rename examples/{switch => light_switch}/partitions_h2.csv (100%) rename examples/{switch => light_switch}/sdkconfig.defaults (100%) rename examples/{switch => light_switch}/sdkconfig.defaults.esp32h2 (100%) rename examples/{switch => light_switch}/sdkconfig.defaults.esp32s2 (100%) diff --git a/docs/_static/supported_services.png b/docs/_static/supported_services.png new file mode 100644 index 0000000000000000000000000000000000000000..4c7b69213945af896d7ea5fbea5708ae23f848f5 GIT binary patch literal 7499 zcmeHMXHZjZw><%rB27_1ilC?n2&hPr78M&^Md=--8A3BcXo&@Q6#0>D1*BhPOEUhcA8sQ!SvfI{!yyb2obIE&!E2nOA92nB!x693*HAUju@yW#e2 zi+k5O98OP94<3(aGMP9WuD`z@3G75!KQ&R(n!|m+s*lf0pjEsPQ0F6egudmO_%5rjYN=!`D*Vo_N+|13* zjf#pgGBT2tm2GTnjERYHb#<+(syce~sDXHS8UV7n)5s-3f8H$7qi7QSxDo&petdlt89(wsu5}v~mQ7FD^TKuOsAQ>~av(|JBX09qv z@9X{a2eO}AkpI8_YYe0k!A21aAyMWCul0Fl*Lp=fVPqs`^Uut7I@`Od3$gU+Kr{dP z0VD^$lPnpo;*TUVnUrZ$Q!@xhddD zsVp*~kZl>cEf*Vog6B=3=NDYks6)f!gKlqAq#Tr&_Kk122lW|S2j{;4rk$kq_9T#& zfoFgWC7l(mG=>T{m#5?jvlDX=57TeClTPvJ_Oq6%I6qmh>D#o4GmUxe4KaItk*3zSF9Q z{_%r_r~x~_CI!dgV>M7$Smbcvaw6aOg<~TTvcZzck!x(C$*JLpg?A0|fhPe>^Jk(P zhlhTo{HD>3NF|VT%=FOKIo-oA{9!wP_Q6dkw}3bnHm2?B4^lN<#=pbA(cpETwd35Q zu}+J2XEi`sbLzWx^9X4BupNGBOSWS7iF~(3ZhzDye4W)FhHBAw-8Sys2oDV8#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>g^ce**U<8! zC8&+W7HMRE-~3Iwu_5Nb@JphDqvhfSN`7RTkG3k1LFW?{d-9A0LvHnCD>@Moru2kF*%y0q~aE*{fMHyu=tCo>5dNMO0l6=}FXO(&p(aqe{Uamy7UfLZQeVh<6cy!11iECZ=fwM_6n2uLD z1}PeegyBXM3KL214K6n*6}OBxFvvHKrkJ)=V;{8^wc6HW4chaYmZK~avJ6gq>7S0V zZO_k{dayOQn8K#q-Z0w7Xt*;8r7uTaYGU?Wxxnl;{1Yr1W;}+;EH?|x$l-I>?qGc; zq7G_D;0;E|b!uJRdy*RJE0q8%W=hqAY4^(QEWi6wSpZ{+(exrRHow=K&?eioMHO=j zd!&2R!$1ltW{zNxr>ygna!AllF;;`;6lFZ6Sm&Q*&)2Ux&2B{ac3JYQ@h`kE<67h%Xh`8t7R+g6>VqKY z42P1?+Im}?+@ua&VO`md0n7BBiZNFB?vP`p9w}BPzC z)jtq=(}N=A40ENYo#{c!FoMJW;JlpCW5V9Hy89X!p)(lze)o0Mbw&s&FfST+Gj;Xa z9w>Zamtj=5K*Wu0Th)A}?3Dd(k3mt+iH-j_QE~(NFO|cBLuiYO9M(sT ziG_h6(A-={r{0Q-R0;M-#^0A%)rmwrmE!*`GbX{SO1j2p+S)75I}@DmoRsUM-*&(l zcPU?ww$qmZYszfsR3%ikvutf`%xg2tjb@kr3eMY8^`YCX^8h9f;4?l85{R + Light Switch RainMaker Light - Switch Zap Light ZigBee Bridge @@ -178,8 +178,8 @@ for it to work. Check the example's "Post Commissioning Setup" section for more :maxdepth: 1 Light + Light Switch RainMaker Light - Switch Zap Light ZigBee Bridge @@ -636,7 +636,7 @@ As an example, you can build *light* example on ``ESP32_custom`` platform with f ~~~~~~~~~~~~~~~~~~~ - In the examples, the boot button on the devkit is mapped to - ``toggle``. In case the device is a client (eg. switch), the toggle + ``toggle``. In case the device is a client (eg. light_switch), the toggle command is sent to the binded devices. - Factory reset has also been mapped to the same boot button. When the button is pressed for more than 5 seconds, factory reset is diff --git a/docs/en/examples/switch.rst b/docs/en/examples/light_switch.rst similarity index 99% rename from docs/en/examples/switch.rst rename to docs/en/examples/light_switch.rst index 0aec255a9..b32ae78b6 100644 --- a/docs/en/examples/switch.rst +++ b/docs/en/examples/light_switch.rst @@ -1,5 +1,5 @@ -Switch -====== +Light Switch +============ 1. Additional Environment Setup ------------------------------- diff --git a/docs/en/faq.rst b/docs/en/faq.rst index 343f35e12..b3ccb655c 100644 --- a/docs/en/faq.rst +++ b/docs/en/faq.rst @@ -6,18 +6,17 @@ A1.1 Compilation errors I cannot build the application: -- Make sure you are on the correct esp-idf branch. Run ``git submodule +- Make sure you are on the correct esp-idf branch/release. Run ``git submodule update —init —recursive`` to make sure the submodules are at the correct heads -- Make sure you have the correct ESP_MATTER_PATH (and any other paths) - is (are) exported. +- Make sure you have the correct ESP_MATTER_PATH (and any other required paths). - Delete the build/ directory and also sdkconfig and sdkconfig.old and then build again. -- If you are still facing issues, reproduce the issue on the default - example and then raise an `issue `__. Please make sure to +- If you are still facing issues, reproduce it on the default + example and then raise it `here `__. Please make sure to share these: - - The complete build logs. + - The complete device logs taken over UART. - The esp-matter and esp-idf branch you are using. A1.2 Device commissioning using chip-tool @@ -28,8 +27,8 @@ I cannot commission a new device through the chip-tool: - If the ``chip-tool pairing ble-wifi`` command is failing, make sure the arguments are correct. - Make sure Bluetooth is turned on, on your client (host). -- If you are still facing issues, reproduce the issue on the default - example for the device and then raise an `issue `__. Make sure +- If you are still facing issues, reproduce it on the default + example for the device and then raise it `here `__. Make sure to share these: - The complete device logs. @@ -38,7 +37,7 @@ I cannot commission a new device through the chip-tool: Bluetooth/BLE does not work on by device: -- There are some known issues where BLE does not work on MacOS. +- There are some `known issues `__ where BLE does not work on MacOS. - In this case, the following can be done: - Run the device console command: @@ -46,8 +45,8 @@ Bluetooth/BLE does not work on by device: - Run the chip-tool command for commissioning over ip: ``chip-tool pairing onnetwork 1 20202021``. -- If you are still facing issues, reproduce the issue on the default - example for the device and then raise an `issue `__. Make sure +- If you are still facing issues, reproduce it on the default + example for the device and then raise it `here `__. Make sure to share these: - The complete device logs taken over UART. @@ -71,8 +70,8 @@ My device is crashing: is (are) exported. - Delete the build/ directory and also sdkconfig and sdkconfig.old and then build and flash again. -- If you are still facing issues, reproduce the issue on the default - example for the device and then raise an `issue `__. Make sure +- If you are still facing issues, reproduce it on the default + example for the device and then raise it `here `__. Make sure to share these: - The steps you followed to reproduce the issue. @@ -101,8 +100,8 @@ My device is not responding to commands: to the Wi-Fi. - Make sure the node_id and the endpoint_id are correct in the command from chip-tool. -- If you are still facing issues, reproduce the issue on the default - example for the device and then raise an `issue `__. Make sure +- If you are still facing issues, reproduce it on the default + example for the device and then raise it `here `__. Make sure to share these: - The steps you followed to reproduce the issue. @@ -133,8 +132,8 @@ The LED on my devkit is not working: - Check the version of your board, and if it has the LED connected to a different pin. If it is different, you can change the led_driver_config_t accordingly in the device.c file. -- If you are still facing issues, reproduce the issue on the default - example for the device and then raise an `issue `__. Make sure +- If you are still facing issues, reproduce it on the default + example for the device and then raise it `here `__. Make sure to share these: - The complete device logs taken over UART. @@ -147,7 +146,7 @@ The LED on my devkit is not working: :maxdepth: 1 Light + Light Switch RainMaker Light - Switch Zap Light ZigBee Bridge diff --git a/docs/en/introduction.rst b/docs/en/introduction.rst index ec5c1d10b..36106aecb 100644 --- a/docs/en/introduction.rst +++ b/docs/en/introduction.rst @@ -51,6 +51,11 @@ Espressif's AIoT cloud platform `ESP RainMaker matter device factoryreset diff --git a/examples/light/main/app_main.cpp b/examples/light/main/app_main.cpp index 48afe37b9..6ad35725d 100644 --- a/examples/light/main/app_main.cpp +++ b/examples/light/main/app_main.cpp @@ -27,13 +27,21 @@ using namespace esp_matter::endpoint; static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) { - if (event->Type == chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged) { + switch (event->Type) { + case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged: #if !CHIP_DEVICE_CONFIG_ENABLE_THREAD chip::app::DnssdServer::Instance().StartServer(); esp_route_hook_init(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF")); #endif + break; + + case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kCommissioningComplete: + ESP_LOGI(TAG, "Commissioning complete"); + break; + + default: + break; } - ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } static esp_err_t app_attribute_update_cb(callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id, @@ -58,7 +66,7 @@ extern "C" void app_main() /* Initialize the ESP NVS layer */ nvs_flash_init(); - /* Create matter device */ + /* Create a Matter node */ node::config_t node_config; node_t *node = node::create(&node_config, app_attribute_update_cb, NULL); @@ -68,12 +76,13 @@ extern "C" void app_main() light_config.color_control.hue_saturation.current_hue = DEFAULT_HUE; light_config.color_control.hue_saturation.current_saturation = DEFAULT_SATURATION; endpoint_t *endpoint = color_dimmable_light::create(node, &light_config, ENDPOINT_FLAG_NONE); - light_endpoint_id = endpoint::get_id(endpoint); /* These node and endpoint handles can be used to create/add other endpoints and clusters. */ if (!node || !endpoint) { - ESP_LOGE(TAG, "Matter device creation failed"); + ESP_LOGE(TAG, "Matter node creation failed"); } + + light_endpoint_id = endpoint::get_id(endpoint); ESP_LOGI(TAG, "Light created with endpoint_id %d", light_endpoint_id); /* Initialize driver */ diff --git a/examples/switch/CMakeLists.txt b/examples/light_switch/CMakeLists.txt similarity index 95% rename from examples/switch/CMakeLists.txt rename to examples/light_switch/CMakeLists.txt index da5743943..a8c929291 100644 --- a/examples/switch/CMakeLists.txt +++ b/examples/light_switch/CMakeLists.txt @@ -22,7 +22,7 @@ endif(NOT DEFINED ENV{ESP_MATTER_DEVICE_PATH}) set(ESP_MATTER_PATH $ENV{ESP_MATTER_PATH}) set(MATTER_SDK_PATH ${ESP_MATTER_PATH}/connectedhomeip/connectedhomeip) -set(ZAP_GENERATED_PATH ${ESP_MATTER_PATH}/examples/switch/main/zap-generated) +set(ZAP_GENERATED_PATH ${CMAKE_CURRENT_LIST_DIR}/main/zap-generated) # This should be done before using the IDF_TARGET variable. include($ENV{IDF_PATH}/tools/cmake/project.cmake) @@ -36,7 +36,7 @@ set(EXTRA_COMPONENT_DIRS "${ESP_MATTER_PATH}/device_hal/device" ${extra_components_dirs_append}) -project(switch) +project(light_switch) idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++14;-Os;-DLWIP_IPV6_SCOPES=0;-DCHIP_HAVE_CONFIG_H" APPEND) idf_build_set_property(C_COMPILE_OPTIONS "-Os;-DLWIP_IPV6_SCOPES=0" APPEND) diff --git a/examples/switch/README.md b/examples/light_switch/README.md similarity index 98% rename from examples/switch/README.md rename to examples/light_switch/README.md index cafc07de7..72bb36ba0 100644 --- a/examples/switch/README.md +++ b/examples/light_switch/README.md @@ -1,4 +1,4 @@ -# Switch Example +# Light Switch Example ## Building and Flashing the Firmware diff --git a/examples/switch/main/CMakeLists.txt b/examples/light_switch/main/CMakeLists.txt similarity index 100% rename from examples/switch/main/CMakeLists.txt rename to examples/light_switch/main/CMakeLists.txt diff --git a/examples/switch/main/app_driver.cpp b/examples/light_switch/main/app_driver.cpp similarity index 100% rename from examples/switch/main/app_driver.cpp rename to examples/light_switch/main/app_driver.cpp diff --git a/examples/switch/main/app_main.cpp b/examples/light_switch/main/app_main.cpp similarity index 86% rename from examples/switch/main/app_main.cpp rename to examples/light_switch/main/app_main.cpp index 96e01aafa..e31c11f42 100644 --- a/examples/switch/main/app_main.cpp +++ b/examples/light_switch/main/app_main.cpp @@ -27,13 +27,21 @@ using namespace esp_matter::endpoint; static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) { - if (event->Type == chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged) { + switch (event->Type) { + case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged: #if !CHIP_DEVICE_CONFIG_ENABLE_THREAD chip::app::DnssdServer::Instance().StartServer(); esp_route_hook_init(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF")); #endif + break; + + case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kCommissioningComplete: + ESP_LOGI(TAG, "Commissioning complete"); + break; + + default: + break; } - ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } static esp_err_t app_attribute_update_cb(callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id, @@ -58,18 +66,19 @@ extern "C" void app_main() /* Initialize the ESP NVS layer */ nvs_flash_init(); - /* Create matter device */ + /* Create a Matter node */ node::config_t node_config; node_t *node = node::create(&node_config, app_attribute_update_cb, NULL); on_off_switch::config_t switch_config; endpoint_t *endpoint = on_off_switch::create(node, &switch_config, ENDPOINT_FLAG_NONE); - switch_endpoint_id = endpoint::get_id(endpoint); /* These node and endpoint handles can be used to create/add other endpoints and clusters. */ if (!node || !endpoint) { - ESP_LOGE(TAG, "Matter device creation failed"); + ESP_LOGE(TAG, "Matter node creation failed"); } + + switch_endpoint_id = endpoint::get_id(endpoint); ESP_LOGI(TAG, "Switch created with endpoint_id %d", switch_endpoint_id); /* Initialize driver */ diff --git a/examples/switch/main/app_priv.h b/examples/light_switch/main/app_priv.h similarity index 100% rename from examples/switch/main/app_priv.h rename to examples/light_switch/main/app_priv.h diff --git a/examples/switch/main/zap-generated/PluginApplicationCallbacks.h b/examples/light_switch/main/zap-generated/PluginApplicationCallbacks.h similarity index 100% rename from examples/switch/main/zap-generated/PluginApplicationCallbacks.h rename to examples/light_switch/main/zap-generated/PluginApplicationCallbacks.h diff --git a/examples/switch/main/zap-generated/af-gen-event.h b/examples/light_switch/main/zap-generated/af-gen-event.h similarity index 100% rename from examples/switch/main/zap-generated/af-gen-event.h rename to examples/light_switch/main/zap-generated/af-gen-event.h diff --git a/examples/switch/main/zap-generated/empty_file.cpp b/examples/light_switch/main/zap-generated/empty_file.cpp similarity index 100% rename from examples/switch/main/zap-generated/empty_file.cpp rename to examples/light_switch/main/zap-generated/empty_file.cpp diff --git a/examples/switch/main/zap-generated/endpoint_config.h b/examples/light_switch/main/zap-generated/endpoint_config.h similarity index 100% rename from examples/switch/main/zap-generated/endpoint_config.h rename to examples/light_switch/main/zap-generated/endpoint_config.h diff --git a/examples/switch/partitions.csv b/examples/light_switch/partitions.csv similarity index 100% rename from examples/switch/partitions.csv rename to examples/light_switch/partitions.csv diff --git a/examples/switch/partitions_h2.csv b/examples/light_switch/partitions_h2.csv similarity index 100% rename from examples/switch/partitions_h2.csv rename to examples/light_switch/partitions_h2.csv diff --git a/examples/switch/sdkconfig.defaults b/examples/light_switch/sdkconfig.defaults similarity index 100% rename from examples/switch/sdkconfig.defaults rename to examples/light_switch/sdkconfig.defaults diff --git a/examples/switch/sdkconfig.defaults.esp32h2 b/examples/light_switch/sdkconfig.defaults.esp32h2 similarity index 100% rename from examples/switch/sdkconfig.defaults.esp32h2 rename to examples/light_switch/sdkconfig.defaults.esp32h2 diff --git a/examples/switch/sdkconfig.defaults.esp32s2 b/examples/light_switch/sdkconfig.defaults.esp32s2 similarity index 100% rename from examples/switch/sdkconfig.defaults.esp32s2 rename to examples/light_switch/sdkconfig.defaults.esp32s2 diff --git a/examples/rainmaker_light/main/app_main.cpp b/examples/rainmaker_light/main/app_main.cpp index 6d609eae0..76c964c60 100644 --- a/examples/rainmaker_light/main/app_main.cpp +++ b/examples/rainmaker_light/main/app_main.cpp @@ -27,13 +27,21 @@ using namespace esp_matter::endpoint; static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) { - if (event->Type == chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged) { + switch (event->Type) { + case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged: #if !CHIP_DEVICE_CONFIG_ENABLE_THREAD chip::app::DnssdServer::Instance().StartServer(); esp_route_hook_init(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF")); #endif + break; + + case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kCommissioningComplete: + ESP_LOGI(TAG, "Commissioning complete"); + break; + + default: + break; } - ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } static esp_err_t app_attribute_update_cb(callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id, @@ -59,7 +67,7 @@ extern "C" void app_main() /* Initialize the ESP NVS layer */ nvs_flash_init(); - /* Create matter device */ + /* Create a Matter node */ node::config_t node_config; node_t *node = node::create(&node_config, app_attribute_update_cb, NULL); @@ -69,12 +77,13 @@ extern "C" void app_main() light_config.color_control.hue_saturation.current_hue = DEFAULT_HUE; light_config.color_control.hue_saturation.current_saturation = DEFAULT_SATURATION; endpoint_t *endpoint = color_dimmable_light::create(node, &light_config, ENDPOINT_FLAG_NONE); - light_endpoint_id = endpoint::get_id(endpoint); /* These node and endpoint handles can be used to create/add other endpoints and clusters. */ if (!node || !endpoint) { - ESP_LOGE(TAG, "Matter device creation failed"); + ESP_LOGE(TAG, "Matter node creation failed"); } + + light_endpoint_id = endpoint::get_id(endpoint); ESP_LOGI(TAG, "Light created with endpoint_id %d", light_endpoint_id); /* Initialize driver */ diff --git a/examples/zap_light/README.md b/examples/zap_light/README.md index cd638aafa..f9071b204 100644 --- a/examples/zap_light/README.md +++ b/examples/zap_light/README.md @@ -47,7 +47,7 @@ Connect to Wi-Fi network. Dump the device static configuration -- Facotry reset +- Factory reset ``` > matter device factoryreset diff --git a/examples/zap_light/main/app_main.cpp b/examples/zap_light/main/app_main.cpp index b24a18c7f..961d6b07c 100644 --- a/examples/zap_light/main/app_main.cpp +++ b/examples/zap_light/main/app_main.cpp @@ -25,13 +25,21 @@ uint16_t light_endpoint_id = 0; static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) { - if (event->Type == chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged) { + switch (event->Type) { + case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged: #if !CHIP_DEVICE_CONFIG_ENABLE_THREAD chip::app::DnssdServer::Instance().StartServer(); esp_route_hook_init(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF")); #endif + break; + + case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kCommissioningComplete: + ESP_LOGI(TAG, "Commissioning complete"); + break; + + default: + break; } - ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } static esp_err_t app_attribute_update_cb(callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id, diff --git a/examples/zigbee_bridge/main/app_main.cpp b/examples/zigbee_bridge/main/app_main.cpp index 50e2f6d0f..31d5812b6 100644 --- a/examples/zigbee_bridge/main/app_main.cpp +++ b/examples/zigbee_bridge/main/app_main.cpp @@ -27,11 +27,21 @@ using namespace esp_matter::attribute; static void app_event_cb(const ChipDeviceEvent *event, intptr_t arg) { - if (event->Type == chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged) { + switch (event->Type) { + case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kInterfaceIpAddressChanged: +#if !CHIP_DEVICE_CONFIG_ENABLE_THREAD chip::app::DnssdServer::Instance().StartServer(); esp_route_hook_init(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF")); +#endif + break; + + case chip::DeviceLayer::DeviceEventType::PublicEventTypes::kCommissioningComplete: + ESP_LOGI(TAG, "Commissioning complete"); + break; + + default: + break; } - ESP_LOGI(TAG, "Current free heap: %zu", heap_caps_get_free_size(MALLOC_CAP_8BIT)); } static esp_err_t app_attribute_update_cb(callback_type_t type, uint16_t endpoint_id, uint32_t cluster_id, @@ -52,13 +62,13 @@ extern "C" void app_main() /* Initialize the ESP NVS layer */ nvs_flash_init(); - /* Create matter device */ + /* Create a Matter node */ node::config_t node_config; node_t *node = node::create(&node_config, app_attribute_update_cb, NULL); /* These node and endpoint handles can be used to create/add other endpoints and clusters. */ if (!node) { - ESP_LOGE(TAG, "Matter device creation failed"); + ESP_LOGE(TAG, "Matter node creation failed"); } /* Matter start */