Merge branch 'feature/add_led_config_for_ot_device' into 'master'

feat(openthread): support configuring indicator color of OpenThread device

See merge request espressif/esp-idf!29413
This commit is contained in:
Shu Chen 2024-03-14 19:17:23 +08:00
commit ee8fa6a205
2 changed files with 109 additions and 5 deletions

View File

@ -1,4 +1,4 @@
menu "OpenThread Device Role LED"
menu "OpenThread Device Role Indicator"
orsource "$IDF_PATH/examples/common_components/env_caps/$IDF_TARGET/Kconfig.env_caps"
@ -21,4 +21,108 @@ menu "OpenThread Device Role LED"
GPIO number (IOxx) to blink on and off the LED.
Some GPIOs are used for other purposes (flash connections, etc.) and cannot be used to blink.
menu "Indicator of Leader Device"
config LEADER_INDICATOR_RED
depends on OPENTHREAD_STATE_INDICATOR_ENABLE
int "red config"
range 0 255
default 40
help
Red config of LED for OpenThread leader device
config LEADER_INDICATOR_GREEN
depends on OPENTHREAD_STATE_INDICATOR_ENABLE
int "green config"
range 0 255
default 0
help
Red config of LED for OpenThread leader device
config LEADER_INDICATOR_BLUE
depends on OPENTHREAD_STATE_INDICATOR_ENABLE
int "blue config"
range 0 255
default 0
help
Blue config of LED for OpenThread leader device
endmenu
menu "Indicator of Router Device"
config ROUTER_INDICATOR_RED
depends on OPENTHREAD_STATE_INDICATOR_ENABLE
int "red config"
range 0 255
default 0
help
Red config of LED for OpenThread router device
config ROUTER_INDICATOR_GREEN
depends on OPENTHREAD_STATE_INDICATOR_ENABLE
int "green config"
range 0 255
default 0
help
Green config of LED for OpenThread router device
config ROUTER_INDICATOR_BLUE
depends on OPENTHREAD_STATE_INDICATOR_ENABLE
int "blue config"
range 0 255
default 40
help
Blue config of LED for OpenThread router device
endmenu
menu "Indicator of Child Device"
config CHILD_INDICATOR_RED
depends on OPENTHREAD_STATE_INDICATOR_ENABLE
int "red config"
range 0 255
default 0
help
Red config of LED for OpenThread child device
config CHILD_INDICATOR_GREEN
depends on OPENTHREAD_STATE_INDICATOR_ENABLE
int "green config"
range 0 255
default 40
help
Green config of LED for OpenThread child device
config CHILD_INDICATOR_BLUE
depends on OPENTHREAD_STATE_INDICATOR_ENABLE
int "blue config"
range 0 255
default 0
help
Blue config of LED for OpenThread child device
endmenu
menu "Indicator of Detached Device"
config DETACHED_INDICATOR_RED
depends on OPENTHREAD_STATE_INDICATOR_ENABLE
int "red config"
range 0 255
default 20
help
Red config of LED for OpenThread detached device
config DETACHED_INDICATOR_GREEN
depends on OPENTHREAD_STATE_INDICATOR_ENABLE
int "green config"
range 0 255
default 20
help
Green config of LED for OpenThread detached device
config DETACHED_INDICATOR_BLUE
depends on OPENTHREAD_STATE_INDICATOR_ENABLE
int "blue config"
range 0 255
default 20
help
Blue config of LED for OpenThread detached device
endmenu
endmenu

View File

@ -45,13 +45,13 @@ static void ot_indicator_change_callback(otChangedFlags changed_flags, void* ctx
if (role == OT_DEVICE_ROLE_DISABLED) {
esp_openthread_state_indicator_clear();
} else if (role == OT_DEVICE_ROLE_DETACHED) {
esp_openthread_state_indicator_set(0, 40, 0, 0);
esp_openthread_state_indicator_set(0, CONFIG_DETACHED_INDICATOR_RED, CONFIG_DETACHED_INDICATOR_GREEN, CONFIG_DETACHED_INDICATOR_BLUE);
} else if (role == OT_DEVICE_ROLE_LEADER) {
esp_openthread_state_indicator_set(0, 0, 40, 0);
esp_openthread_state_indicator_set(0, CONFIG_LEADER_INDICATOR_RED, CONFIG_LEADER_INDICATOR_GREEN, CONFIG_LEADER_INDICATOR_BLUE);
} else if (role == OT_DEVICE_ROLE_ROUTER) {
esp_openthread_state_indicator_set(0, 0, 0, 40);
esp_openthread_state_indicator_set(0, CONFIG_ROUTER_INDICATOR_RED, CONFIG_ROUTER_INDICATOR_GREEN, CONFIG_ROUTER_INDICATOR_BLUE);
} else if (role == OT_DEVICE_ROLE_CHILD) {
esp_openthread_state_indicator_set(0, 40, 8, 60);
esp_openthread_state_indicator_set(0, CONFIG_CHILD_INDICATOR_RED, CONFIG_CHILD_INDICATOR_GREEN, CONFIG_CHILD_INDICATOR_BLUE);
}
}