Skip to content

Commit

Permalink
esp32: support ICMPv6 RIO handling (#11412)
Browse files Browse the repository at this point in the history
* esp32: support ICMPv6 RIO handling

* Add support for ICMPv6 RIO handling
* Update ESP-IDF release to v4.4 for route hook support.

* esp32: better rio message parsing

* esp32: update v4.4 release branch README

* fix review comments
  • Loading branch information
gjc13 authored and pull[bot] committed Nov 15, 2021
1 parent 836d897 commit 1046764
Show file tree
Hide file tree
Showing 25 changed files with 556 additions and 18 deletions.
4 changes: 2 additions & 2 deletions examples/all-clusters-app/esp32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ The VSCode devcontainer has these components pre-installed, so you can skip this
step. To install these components manually, follow these steps:

- Clone the Espressif ESP-IDF and checkout
[v4.3 tag](https://github.com/espressif/esp-idf/releases/v4.3)
[v4.4 tag](https://github.com/espressif/esp-idf/releases/v4.4)

$ mkdir ${HOME}/tools
$ cd ${HOME}/tools
$ git clone https://github.com/espressif/esp-idf.git
$ cd esp-idf
$ git checkout v4.3
$ git checkout release/v4.4
$ git submodule update --init
$ ./install.sh

Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/all-clusters-app/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/route_hook"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
Expand Down
7 changes: 7 additions & 0 deletions examples/all-clusters-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@
#include "Globals.h"
#include "LEDWidget.h"
#include "WiFiWidget.h"
#include "esp_check.h"
#include "esp_err.h"
#include "esp_heap_caps.h"
#include "esp_log.h"
#include "route_hook/esp_route_hook.h"
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app/Command.h>
Expand Down Expand Up @@ -83,6 +86,10 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_
// newly selected address.
chip::app::DnssdServer::Instance().StartServer();
}
if (event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned)
{
ESP_ERROR_CHECK(esp_route_hook_init(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF")));
}
break;
}

Expand Down
4 changes: 4 additions & 0 deletions examples/all-clusters-app/esp32/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,7 @@ CONFIG_DEVICE_PRODUCT_ID=0x4541

#enable debug shell
CONFIG_ENABLE_CHIP_SHELL=y

#enable lwIP route hooks
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
3 changes: 3 additions & 0 deletions examples/all-clusters-app/esp32/sdkconfig_c3devkit.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ CONFIG_LWIP_IPV6_AUTOCONFIG=y
CONFIG_PARTITION_TABLE_CUSTOM=y
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
4 changes: 4 additions & 0 deletions examples/all-clusters-app/esp32/sdkconfig_m5stack.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@ CONFIG_ESP_MAIN_TASK_STACK_SIZE=5120

#enable debug shell
CONFIG_ENABLE_CHIP_SHELL=y

#enable lwIP route hooks
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
4 changes: 2 additions & 2 deletions examples/bridge-app/esp32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ The VSCode devcontainer has these components pre-installed, so you can skip this
step. To install these components manually, follow these steps:

- Clone the Espressif ESP-IDF and checkout
[v4.3 tag](https://github.com/espressif/esp-idf/releases/v4.3)
[v4.4 tag](https://github.com/espressif/esp-idf/releases/v4.4)

$ mkdir ${HOME}/tools
$ cd ${HOME}/tools
$ git clone https://github.com/espressif/esp-idf.git
$ cd esp-idf
$ git checkout v4.3
$ git checkout release/v4.4
$ git submodule update --init
$ ./install.sh

Expand Down
5 changes: 3 additions & 2 deletions examples/bridge-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ 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/wifi_network_diagnostics_server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/software_diagnostics_server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general_diagnostics_server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general_diagnostics_server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/on-off-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/route_hook"
PRIV_REQUIRES chip QRCode bt)

set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 14)
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 14)
target_compile_options(${COMPONENT_LIB} PRIVATE "-DLWIP_IPV6_SCOPES=0" "-DCHIP_HAVE_CONFIG_H")
4 changes: 4 additions & 0 deletions examples/bridge-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@
*/

#include "DeviceCallbacks.h"
#include "esp_check.h"
#include "esp_err.h"
#include "esp_heap_caps.h"
#include "esp_log.h"
#include "route_hook/esp_route_hook.h"
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app/server/Dnssd.h>
Expand Down Expand Up @@ -81,6 +84,7 @@ void DeviceCallbacks::OnInternetConnectivityChange(const ChipDeviceEvent * event
{
ESP_LOGI(TAG, "IPv6 Server ready...");
chip::app::DnssdServer::Instance().StartServer();
ESP_ERROR_CHECK(esp_route_hook_init(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF")));
}
else if (event->InternetConnectivityChange.IPv6 == kConnectivity_Lost)
{
Expand Down
3 changes: 3 additions & 0 deletions examples/bridge-app/esp32/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ CONFIG_LWIP_IPV6_AUTOCONFIG=y
# Use a custom partition table
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"

CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
2 changes: 1 addition & 1 deletion examples/ipv6only-app/esp32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ step. To install these components manually, follow these steps:
$ cd ${HOME}/tools
$ git clone https://github.com/espressif/esp-idf.git
$ cd esp-idf
$ git checkout release/v4.3
$ git checkout release/v4.4
$ git submodule update --init
$ ./install.sh

Expand Down
4 changes: 2 additions & 2 deletions examples/lock-app/esp32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ The VSCode devcontainer has these components pre-installed, so you can skip this
step. To install these components manually, follow these steps:

- Clone the Espressif ESP-IDF and checkout
[v4.3 tag](https://github.com/espressif/esp-idf/releases/v4.3)
[v4.4 tag](https://github.com/espressif/esp-idf/releases/v4.4)

$ mkdir ${HOME}/tools
$ cd ${HOME}/tools
$ git clone https://github.com/espressif/esp-idf.git
$ cd esp-idf
$ git checkout v4.3
$ git checkout release/v4.4
$ git submodule update --init
$ ./install.sh

Expand Down
1 change: 1 addition & 0 deletions examples/lock-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ idf_component_register(PRIV_INCLUDE_DIRS
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated/attributes"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/app-common/app-common/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/zzz_generated/lock-app/zap-generated"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/route_hook"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/shell_extension"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/util"
Expand Down
8 changes: 8 additions & 0 deletions examples/lock-app/esp32/main/DeviceCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
#include "AppConfig.h"
#include "BoltLockManager.h"

#include "esp_check.h"
#include "esp_err.h"
#include "esp_heap_caps.h"
#include "esp_log.h"
#include "route_hook/esp_route_hook.h"
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app/server/Dnssd.h>
Expand Down Expand Up @@ -63,11 +66,16 @@ void DeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, intptr_
// newly selected address.
chip::app::DnssdServer::Instance().StartServer();
}
if (event->InterfaceIpAddressChanged.Type == InterfaceIpChangeType::kIpV6_Assigned)
{
ESP_ERROR_CHECK(esp_route_hook_init(esp_netif_get_handle_from_ifkey("WIFI_STA_DEF")));
}
break;
}

ESP_LOGI(TAG, "Current free heap: %d\n", heap_caps_get_free_size(MALLOC_CAP_8BIT));
}

void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, ClusterId clusterId, AttributeId attributeId, uint8_t mask,
uint8_t type, uint16_t size, uint8_t * value)
{
Expand Down
4 changes: 4 additions & 0 deletions examples/lock-app/esp32/sdkconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ CONFIG_LWIP_IPV6_AUTOCONFIG=y
# Use a custom partition table
CONFIG_PARTITION_TABLE_CUSTOM=y
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
4 changes: 2 additions & 2 deletions examples/persistent-storage/esp32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ The VSCode devcontainer has these components pre-installed, so you can skip this
step. To install these components manually, follow these steps:

- Clone the Espressif ESP-IDF and checkout
[v4.3 tag](https://github.com/espressif/esp-idf/releases/v4.3)
[v4.4 tag](https://github.com/espressif/esp-idf/releases/v4.4)

$ mkdir ${HOME}/tools
$ cd ${HOME}/tools
$ git clone https://github.com/espressif/esp-idf.git
$ cd esp-idf
$ git checkout v4.3
$ git checkout release/v4.4
$ git submodule update --init
$ ./install.sh

Expand Down
4 changes: 2 additions & 2 deletions examples/pigweed-app/esp32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ The VSCode devcontainer has these components pre-installed, so you can skip this
step. To install these components manually, follow these steps:

- Clone the Espressif ESP-IDF and checkout
[v4.3 tag](https://github.com/espressif/esp-idf/releases/v4.3)
[v4.4 tag](https://github.com/espressif/esp-idf/releases/v4.4)

$ mkdir ${HOME}/tools
$ cd ${HOME}/tools
$ git clone https://github.com/espressif/esp-idf.git
$ cd esp-idf
$ git checkout v4.3
$ git checkout release/v4.4
$ git submodule update --init
$ ./install.sh

Expand Down
Loading

0 comments on commit 1046764

Please sign in to comment.