diff --git a/examples/bluetooth/esp_ble_mesh/common_components/button/Kconfig b/examples/bluetooth/esp_ble_mesh/common_components/button/Kconfig index 76062fcf00e..2e06529cb99 100644 --- a/examples/bluetooth/esp_ble_mesh/common_components/button/Kconfig +++ b/examples/bluetooth/esp_ble_mesh/common_components/button/Kconfig @@ -18,4 +18,14 @@ menu "Button" range 10 100 default 50 + config BUTTON_IO_NUM + int "Default Boot Button IO" + default 0 if IDF_TARGET_ESP32 + default 9 if IDF_TARGET_ESP32C3 + default 0 if IDF_TARGET_ESP32S3 + default 8 if IDF_TARGET_ESP32C6 + default 9 if IDF_TARGET_ESP32H2 + default 9 if IDF_TARGET_ESP32C61 + default 28 if IDF_TARGET_ESP32C5 + endmenu diff --git a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/board.c b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/board.c index 30f7b6be5a5..c236a0b19ea 100644 --- a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/board.c @@ -2,20 +2,17 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include -#include "driver/gpio.h" #include "esp_log.h" #include "iot_button.h" #include "board.h" -#include "esp_timer.h" -#include "lightbulb.h" #define TAG "BOARD" @@ -24,59 +21,6 @@ extern void example_ble_mesh_start_example_configuration(void); extern void example_ble_mesh_send_gen_onoff_set(bool by_df); extern uint8_t in_configuration_phase; -esp_timer_handle_t led_timer_hdl; - -void board_led_operation(uint8_t r, uint8_t g, uint8_t b) -{ - ws2812_set_rgb_channel(r, g, b); -} - -static void led_timer_callback(void* arg) -{ - board_led_operation(0,0,0); -} - -static void esp_led_timer_init(void) -{ - const esp_timer_create_args_t led_timer_args = { - .callback = &led_timer_callback, - .arg = NULL, - .name = "led timer", - }; - - ESP_ERROR_CHECK(esp_timer_create(&led_timer_args, &led_timer_hdl)); -} - -void board_led_operation_auto_close(uint8_t r, uint8_t g, uint8_t b, uint32_t ms) -{ - esp_timer_stop(led_timer_hdl); - board_led_operation(r,g,b); - esp_timer_start_once(led_timer_hdl, ms * 1000); -} - - -static void board_led_init(void) -{ - lightbulb_config_t config = { - .type = DRIVER_WS2812, - .driver_conf.ws2812.led_num = 3, - .driver_conf.ws2812.ctrl_io = 8, - .capability.enable_fades = true, - .capability.fades_ms = 800, - .capability.enable_status_storage = false, - .capability.mode_mask = COLOR_MODE, - .capability.storage_cb = NULL, - .external_limit = NULL, - .gamma_conf = NULL, - .init_status.mode = WORK_COLOR, - .init_status.on = false, - .init_status.hue = 0, - .init_status.saturation = 100, - .init_status.value = 100, - }; - lightbulb_init(&config); - esp_led_timer_init(); -} static void button_tap_cb(void* arg) { @@ -100,6 +44,5 @@ static void board_button_init(void) void board_init(void) { - board_led_init(); board_button_init(); } diff --git a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/board.h b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/board.h index 3f7a9b37870..31ac3999ecb 100644 --- a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/board.h @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -15,49 +15,8 @@ extern "C" { #endif /**< __cplusplus */ #include "driver/gpio.h" -#include "esp_ble_mesh_defs.h" -#if defined(CONFIG_BLE_MESH_ESP_WROOM_32) -#define LED_R GPIO_NUM_25 -#define LED_G GPIO_NUM_26 -#define LED_B GPIO_NUM_27 -#elif defined(CONFIG_BLE_MESH_ESP_WROVER) -#define LED_R GPIO_NUM_0 -#define LED_G GPIO_NUM_2 -#define LED_B GPIO_NUM_4 -#elif defined(CONFIG_BLE_MESH_ESP32C3_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32S3_DEV) -#define LED_R GPIO_NUM_47 -#define LED_G GPIO_NUM_47 -#define LED_B GPIO_NUM_47 -#elif defined(CONFIG_BLE_MESH_ESP32C6_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C61_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32H2_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C5_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#endif - -#define LED_ON 1 -#define LED_OFF 0 - -#define BUTTON_IO_NUM GPIO_NUM_9 - -struct _led_state { - uint8_t current; - uint8_t previous; - uint8_t pin; - char *name; -}; - -void board_led_operation(uint8_t r, uint8_t g, uint8_t b); +#define BUTTON_IO_NUM CONFIG_BUTTON_IO_NUM void board_init(void); diff --git a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/main.c b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/main.c index ba64989164b..1e5f47bb837 100644 --- a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_client/main/main.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -338,7 +338,7 @@ void example_ble_mesh_send_gen_onoff_set(bool by_df) } node->onoff = !node->onoff; - board_led_operation(0, 100, 0); + ESP_LOGI(TAG, "GenOnOff Set sent to node 0x%04x", node->unicast); } void example_ble_mesh_start_example_configuration(void) @@ -388,7 +388,7 @@ static esp_err_t prov_complete(int node_idx, const esp_ble_mesh_octet16_t uuid, return ESP_FAIL; } - err = example_ble_mesh_store_node_info(uuid, unicast, elem_num, LED_OFF); + err = example_ble_mesh_store_node_info(uuid, unicast, elem_num, 0); if (err) { ESP_LOGE(TAG, "%s: Store node info failed", __func__); return ESP_FAIL; @@ -438,7 +438,7 @@ static void recv_unprov_adv_pkt(uint8_t dev_uuid[16], uint8_t addr[BD_ADDR_LEN], ESP_LOGE(TAG, "%s: Add unprovisioned device into queue failed", __func__); } - board_led_operation(100, 100, 100); + ESP_LOGI(TAG, "Unprovisioned device added to queue, starting provisioning"); return; } @@ -468,7 +468,6 @@ static void example_ble_mesh_provisioning_cb(esp_ble_mesh_prov_cb_event_t event, prov_complete(param->provisioner_prov_complete.node_idx, param->provisioner_prov_complete.device_uuid, param->provisioner_prov_complete.unicast_addr, param->provisioner_prov_complete.element_num, param->provisioner_prov_complete.netkey_idx); - board_led_operation(0, 0, 0); break; case ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT: ESP_LOGI(TAG, "ESP_BLE_MESH_PROVISIONER_ADD_UNPROV_DEV_COMP_EVT, err_code %d", param->provisioner_add_unprov_dev_comp.err_code); @@ -694,7 +693,6 @@ static void example_ble_mesh_generic_client_cb(esp_ble_mesh_generic_client_cb_ev node->onoff = param->status_cb.onoff_status.present_onoff; ESP_LOGI(TAG, "ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET onoff: 0x%02x", node->onoff); node->onoff = !node->onoff; - board_led_operation(0,0,0); break; default: break; @@ -876,7 +874,6 @@ static esp_err_t ble_mesh_init(void) example_ble_mesh_store_node_info(dev_uuid, 0x01, 1, 0); ESP_LOGI(TAG, "BLE Mesh Provisioner initialized"); - board_led_operation(0,0,0); return err; } diff --git a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/board.c b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/board.c index 6134c50f90a..23ea05da46b 100644 --- a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/board.c @@ -2,79 +2,20 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include -#include -#include "driver/gpio.h" #include "esp_log.h" -#include "board.h" -#include "esp_timer.h" -#include "lightbulb.h" #include "iot_button.h" - -#include "mesh/adapter.h" +#include "board.h" #define TAG "BOARD" #define BUTTON_ACTIVE_LEVEL 0 -esp_timer_handle_t led_timer_hdl; - -void board_led_operation(uint8_t r, uint8_t g, uint8_t b) -{ - ws2812_set_rgb_channel(r, g, b); -} - -static void led_timer_callback(void* arg) -{ - board_led_operation(0,0,0); -} - -static void esp_led_timer_init(void) -{ - const esp_timer_create_args_t led_timer_args = { - .callback = &led_timer_callback, - .arg = NULL, - .name = "led timer", - }; - - ESP_ERROR_CHECK(esp_timer_create(&led_timer_args, &led_timer_hdl)); -} - -void board_led_operation_auto_close(uint8_t r, uint8_t g, uint8_t b, uint32_t ms) -{ - esp_timer_stop(led_timer_hdl); - board_led_operation(r,g,b); - esp_timer_start_once(led_timer_hdl, ms * 1000); -} - -static void board_led_init(void) -{ - lightbulb_config_t config = { - .type = DRIVER_WS2812, - .driver_conf.ws2812.led_num = 3, - .driver_conf.ws2812.ctrl_io = 8, - .capability.enable_fades = true, - .capability.fades_ms = 800, - .capability.enable_status_storage = false, - .capability.mode_mask = COLOR_MODE, - .capability.storage_cb = NULL, - .external_limit = NULL, - .gamma_conf = NULL, - .init_status.mode = WORK_COLOR, - .init_status.on = false, - .init_status.hue = 0, - .init_status.saturation = 100, - .init_status.value = 100, - }; - lightbulb_init(&config); - esp_led_timer_init(); -} - static void button_tap_cb(void* arg) { ESP_LOGI(TAG, "tap cb (%s)", (char *)arg); @@ -90,6 +31,5 @@ static void board_button_init(void) void board_init(void) { - board_led_init(); board_button_init(); } diff --git a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/board.h b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/board.h index 975543b9f9f..31ac3999ecb 100644 --- a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/board.h @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,40 +16,8 @@ extern "C" { #include "driver/gpio.h" -#if defined(CONFIG_BLE_MESH_ESP_WROOM_32) -#define LED_R GPIO_NUM_25 -#define LED_G GPIO_NUM_26 -#define LED_B GPIO_NUM_27 -#elif defined(CONFIG_BLE_MESH_ESP_WROVER) -#define LED_R GPIO_NUM_0 -#define LED_G GPIO_NUM_2 -#define LED_B GPIO_NUM_4 -#elif defined(CONFIG_BLE_MESH_ESP32C3_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32S3_DEV) -#define LED_R GPIO_NUM_47 -#define LED_G GPIO_NUM_47 -#define LED_B GPIO_NUM_47 -#elif defined(CONFIG_BLE_MESH_ESP32C6_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C61_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32H2_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C5_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#endif +#define BUTTON_IO_NUM CONFIG_BUTTON_IO_NUM -#define LED_ON 1 -#define LED_OFF 0 -#define BUTTON_IO_NUM GPIO_NUM_9 - -void board_led_operation(uint8_t r, uint8_t g, uint8_t b); -void board_led_operation_auto_close(uint8_t r, uint8_t g, uint8_t b, uint32_t ms); void board_init(void); #ifdef __cplusplus diff --git a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/main.c b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/main.c index dcf8d8eddca..63f8038cdc6 100644 --- a/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/directed_forwarding/df_server/main/main.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -149,7 +149,6 @@ static void prov_complete(uint16_t net_idx, uint16_t addr, uint8_t flags, uint32 ESP_LOGI(TAG, "net_idx: 0x%04x, addr: 0x%04x", net_idx, addr); ESP_LOGI(TAG, "flags: 0x%02x, iv_index: 0x%08" PRIx32, flags, iv_index); esp_ble_mesh_node_add_local_app_key(app_key, net_idx, APP_KEY_IDX); - board_led_operation(0, 0,0); } static void example_change_led_state(esp_ble_mesh_model_t *model, @@ -164,11 +163,9 @@ static void example_change_led_state(esp_ble_mesh_model_t *model, if (ctx->recv_dst == (primary_addr + i)) { if (ctx->recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET) { if (ctx->recv_cred == ESP_BLE_MESH_DIRECTED_CRED) { - // Receive a message send by directed forwarding. - board_led_operation_auto_close(0,0,100,2000); + ESP_LOGI(TAG, "Recv OnOff %s via directed forwarding", onoff ? "ON" : "OFF"); } else { - // Receive a message send by flooding. - board_led_operation_auto_close(100,0,0,2000); + ESP_LOGI(TAG, "Recv OnOff %s via flooding", onoff ? "ON" : "OFF"); } } } @@ -177,22 +174,18 @@ static void example_change_led_state(esp_ble_mesh_model_t *model, if (esp_ble_mesh_is_model_subscribed_to_group(model, ctx->recv_dst)) { if (ctx->recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET) { if (ctx->recv_cred == ESP_BLE_MESH_DIRECTED_CRED) { - /* Receive a message send by directed forwarding. */ - board_led_operation_auto_close(0,0,100,2000); + ESP_LOGI(TAG, "Recv OnOff %s via directed forwarding", onoff ? "ON" : "OFF"); } else { - /* Receive a message send by flooding. */ - board_led_operation_auto_close(100,0,0,2000); + ESP_LOGI(TAG, "Recv OnOff %s via flooding", onoff ? "ON" : "OFF"); } } } } else if (ctx->recv_dst == 0xFFFF) { if (ctx->recv_op == ESP_BLE_MESH_MODEL_OP_GEN_ONOFF_SET) { if (ctx->recv_cred == ESP_BLE_MESH_DIRECTED_CRED) { - /* Receive a message send by directed forwarding. */ - board_led_operation_auto_close(0,0,100,2000); + ESP_LOGI(TAG, "Recv OnOff %s via directed forwarding", onoff ? "ON" : "OFF"); } else { - /* Receive a message send by flooding. */ - board_led_operation_auto_close(100,0,0,2000); + ESP_LOGI(TAG, "Recv OnOff %s via flooding", onoff ? "ON" : "OFF"); } } } @@ -279,7 +272,7 @@ static void example_ble_mesh_provisioning_cb(esp_ble_mesh_prov_cb_event_t event, } } } - board_led_operation_auto_close(50,50,50, 1000); + ESP_LOGI(TAG, "AppKey bound to local model successfully"); break; } @@ -380,7 +373,6 @@ static void example_ble_mesh_directed_forwarding_server_cb(esp_ble_mesh_df_serve memcpy(&path_origin, &change.df_table_info.df_table_entry_add_remove.path_origin, sizeof(path_origin)); memcpy(&path_target, &change.df_table_info.df_table_entry_add_remove.path_target, sizeof(path_target)); ESP_LOGI(TAG, "Established a path from 0x%04x to 0x%04x", path_origin.range_start, path_target.range_start); - // board_led_operation(0, 0, 100); } break; @@ -388,7 +380,6 @@ static void example_ble_mesh_directed_forwarding_server_cb(esp_ble_mesh_df_serve memcpy(&path_origin, &change.df_table_info.df_table_entry_add_remove.path_origin, sizeof(path_origin)); memcpy(&path_target, &change.df_table_info.df_table_entry_add_remove.path_target, sizeof(path_target)); ESP_LOGI(TAG, "Remove a path from 0x%04x to 0x%04x", path_origin.range_start, path_target.range_start); - board_led_operation(0, 0, 0); } break; default: @@ -467,8 +458,6 @@ static esp_err_t ble_mesh_init(void) ESP_LOGI(TAG, "BLE Mesh Node initialized"); - board_led_operation(0, 0, 0); - return err; } diff --git a/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_client/main/main.c b/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_client/main/main.c index f59d40d9713..181fe71a5d1 100644 --- a/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_client/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_client/main/main.c @@ -149,7 +149,7 @@ static void provisioner_prov_complete(int node_index, const uint8_t uuid[16], ui /* Sets node info */ err = example_store_node_info(uuid, unicast_addr, elem_num, prov_info.net_idx, - prov_info.app_idx, LED_OFF); + prov_info.app_idx, 0); if (err != ESP_OK) { ESP_LOGE(TAG, "%s: Failed to set node info", __func__); return; diff --git a/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_server/main/board.c b/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_server/main/board.c index 353f0c1166d..a6c6b5c2374 100644 --- a/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_server/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_server/main/board.c @@ -1,66 +1,18 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include -#include -#include "driver/gpio.h" +#include "esp_log.h" #include "board.h" -#include "ble_mesh_fast_prov_common.h" #define TAG "BOARD" -struct _led_state led_state[3] = { - { LED_OFF, LED_OFF, LED_R, "red" }, - { LED_OFF, LED_OFF, LED_G, "green" }, - { LED_OFF, LED_OFF, LED_B, "blue" }, -}; - -void board_output_number(esp_ble_mesh_output_action_t action, uint32_t number) -{ - ESP_LOGI(TAG, "Board output number %" PRIu32, number); -} - -void board_prov_complete(void) -{ - board_led_operation(LED_B, LED_OFF); -} - -void board_led_operation(uint8_t pin, uint8_t onoff) -{ - for (int i = 0; i < 3; i++) { - if (led_state[i].pin != pin) { - continue; - } - if (onoff == led_state[i].previous) { - ESP_LOGW(TAG, "led %s is already %s", - led_state[i].name, (onoff ? "on" : "off")); - return; - } - gpio_set_level(pin, onoff); - led_state[i].previous = onoff; - return; - } - - ESP_LOGE(TAG, "LED is not found!"); -} - -static void board_led_init(void) -{ - for (int i = 0; i < 3; i++) { - gpio_reset_pin(led_state[i].pin); - gpio_set_direction(led_state[i].pin, GPIO_MODE_OUTPUT); - gpio_set_level(led_state[i].pin, LED_OFF); - led_state[i].previous = LED_OFF; - } -} - esp_err_t board_init(void) { - board_led_init(); return ESP_OK; } diff --git a/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_server/main/board.h b/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_server/main/board.h index a58820dd613..646b24cdd37 100644 --- a/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_server/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_server/main/board.h @@ -1,6 +1,6 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,56 +12,7 @@ extern "C" { #endif /**< __cplusplus */ -#include "sdkconfig.h" -#include "driver/gpio.h" -#include "esp_ble_mesh_defs.h" - -#ifdef CONFIG_BLE_MESH_ESP_WROOM_32 -#define LED_R GPIO_NUM_25 -#define LED_G GPIO_NUM_26 -#define LED_B GPIO_NUM_27 -#elif defined(CONFIG_BLE_MESH_ESP_WROVER) -#define LED_R GPIO_NUM_0 -#define LED_G GPIO_NUM_2 -#define LED_B GPIO_NUM_4 -#elif defined(CONFIG_BLE_MESH_ESP32C3_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32S3_DEV) -#define LED_R GPIO_NUM_47 -#define LED_G GPIO_NUM_47 -#define LED_B GPIO_NUM_47 -#elif defined(CONFIG_BLE_MESH_ESP32C6_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C61_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32H2_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C5_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#endif - -struct _led_state { - uint8_t current; - uint8_t previous; - uint8_t pin; - char *name; -}; - -void board_output_number(esp_ble_mesh_output_action_t action, uint32_t number); - -void board_prov_complete(void); - -void board_led_operation(uint8_t pin, uint8_t onoff); +#include "esp_err.h" esp_err_t board_init(void); diff --git a/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_server/main/main.c b/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_server/main/main.c index a09b611a8aa..cb1c717371a 100644 --- a/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/fast_provisioning/fast_prov_server/main/main.c @@ -1,6 +1,6 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -28,7 +28,6 @@ #define TAG "EXAMPLE" -extern struct _led_state led_state[3]; extern struct k_delayed_work send_self_prov_node_addr_timer; extern bt_mesh_atomic_t fast_prov_cli_flags; @@ -155,9 +154,7 @@ static esp_ble_mesh_prov_t prov = { static void example_change_led_state(uint8_t onoff) { - struct _led_state *led = &led_state[1]; - - board_led_operation(led->pin, onoff); + ESP_LOGI(TAG, "Recv GenOnOff message, state: %s", onoff ? "ON" : "OFF"); /* When the node receives the first Generic OnOff Get/Set/Set Unack message, it will * start the timer used to disable fast provisioning functionality. @@ -177,7 +174,7 @@ static void node_prov_complete(uint16_t net_idx, uint16_t addr, uint8_t flags, u { ESP_LOGI(TAG, "net_idx: 0x%04x, unicast_addr: 0x%04x", net_idx, addr); ESP_LOGI(TAG, "flags: 0x%02x, iv_index: 0x%08" PRIx32, flags, iv_index); - board_prov_complete(); + ESP_LOGI(TAG, "Provisioning complete"); /* Updates the net_idx used by Fast Prov Server model, and it can also * be updated if the Fast Prov Info Set message contains a valid one. */ @@ -213,7 +210,7 @@ static void provisioner_prov_complete(int node_idx, const uint8_t uuid[16], uint /* Sets node info */ err = example_store_node_info(uuid, unicast_addr, element_num, net_idx, - fast_prov_server.app_idx, LED_OFF); + fast_prov_server.app_idx, 0); if (err != ESP_OK) { ESP_LOGE(TAG, "%s: Failed to set node info", __func__); return; @@ -522,7 +519,7 @@ static void example_ble_mesh_custom_model_cb(esp_ble_mesh_model_cb_event_t event param->client_send_timeout.model, param->client_send_timeout.ctx); if (err != ESP_OK) { - ESP_LOGE(TAG, "%s: Faield to resend fast prov client message", __func__); + ESP_LOGE(TAG, "%s: Failed to resend fast prov client message", __func__); return; } break; @@ -743,8 +740,6 @@ static esp_err_t ble_mesh_init(void) ESP_LOGI(TAG, "BLE Mesh Fast Prov Node initialized"); - board_led_operation(LED_B, LED_ON); - return ESP_OK; } diff --git a/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_client/main/board.c b/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_client/main/board.c index 325bbd96adf..f9e30ff9fd5 100644 --- a/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_client/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_client/main/board.c @@ -2,14 +2,14 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include +#include -#include "driver/gpio.h" #include "esp_log.h" #include "iot_button.h" @@ -17,45 +17,11 @@ #define TAG "BOARD" -#define BUTTON_IO_NUM 0 +#define BUTTON_IO_NUM CONFIG_BUTTON_IO_NUM #define BUTTON_ACTIVE_LEVEL 0 extern void example_ble_mesh_send_gen_onoff_set(void); -struct _led_state led_state[3] = { - { LED_OFF, LED_OFF, LED_R, "red" }, - { LED_OFF, LED_OFF, LED_G, "green" }, - { LED_OFF, LED_OFF, LED_B, "blue" }, -}; - -void board_led_operation(uint8_t pin, uint8_t onoff) -{ - for (int i = 0; i < ARRAY_SIZE(led_state); i++) { - if (led_state[i].pin != pin) { - continue; - } - if (onoff == led_state[i].previous) { - ESP_LOGW(TAG, "led %s is already %s", - led_state[i].name, (onoff ? "on" : "off")); - return; - } - gpio_set_level(pin, onoff); - led_state[i].previous = onoff; - return; - } - ESP_LOGE(TAG, "LED is not found!"); -} - -static void board_led_init(void) -{ - for (int i = 0; i < ARRAY_SIZE(led_state); i++) { - gpio_reset_pin(led_state[i].pin); - gpio_set_direction(led_state[i].pin, GPIO_MODE_OUTPUT); - gpio_set_level(led_state[i].pin, LED_OFF); - led_state[i].previous = LED_OFF; - } -} - static void button_tap_cb(void* arg) { ESP_LOGI(TAG, "tap cb (%s)", (char *)arg); @@ -73,6 +39,5 @@ static void board_button_init(void) void board_init(void) { - board_led_init(); board_button_init(); } diff --git a/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_client/main/board.h b/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_client/main/board.h index ee604c5cf5e..c752d6fb63f 100644 --- a/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_client/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_client/main/board.h @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -14,55 +14,6 @@ extern "C" { #endif /**< __cplusplus */ -#include "driver/gpio.h" -#include "esp_ble_mesh_defs.h" - -#if defined(CONFIG_BLE_MESH_ESP_WROOM_32) -#define LED_R GPIO_NUM_25 -#define LED_G GPIO_NUM_26 -#define LED_B GPIO_NUM_27 -#elif defined(CONFIG_BLE_MESH_ESP_WROVER) -#define LED_R GPIO_NUM_0 -#define LED_G GPIO_NUM_2 -#define LED_B GPIO_NUM_4 -#elif defined(CONFIG_BLE_MESH_ESP32C3_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32S3_DEV) -#define LED_R GPIO_NUM_47 -#define LED_G GPIO_NUM_47 -#define LED_B GPIO_NUM_47 -#elif defined(CONFIG_BLE_MESH_ESP32C6_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C61_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32H2_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C5_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#endif - -#define LED_ON 1 -#define LED_OFF 0 - -struct _led_state { - uint8_t current; - uint8_t previous; - uint8_t pin; - char *name; -}; - -void board_led_operation(uint8_t pin, uint8_t onoff); - void board_init(void); #ifdef __cplusplus diff --git a/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_client/main/main.c b/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_client/main/main.c index c3e55ccd4f6..a22580d4a84 100644 --- a/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_client/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_client/main/main.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -38,7 +38,7 @@ static struct example_info_store { } __attribute__((packed)) store = { .net_idx = ESP_BLE_MESH_KEY_UNUSED, .app_idx = ESP_BLE_MESH_KEY_UNUSED, - .onoff = LED_OFF, + .onoff = 0, .tid = 0x0, }; @@ -122,7 +122,6 @@ static void prov_complete(uint16_t net_idx, uint16_t addr, uint8_t flags, uint32 { ESP_LOGI(TAG, "net_idx: 0x%04x, addr: 0x%04x", net_idx, addr); ESP_LOGI(TAG, "flags: 0x%02x, iv_index: 0x%08" PRIx32, flags, iv_index); - board_led_operation(LED_G, LED_OFF); store.net_idx = net_idx; /* mesh_example_info_store() shall not be invoked here, because if the device * is restarted and goes into a provisioned state, then the following events @@ -287,8 +286,6 @@ static esp_err_t ble_mesh_init(void) ESP_LOGI(TAG, "BLE Mesh Node initialized"); - board_led_operation(LED_G, LED_ON); - return err; } diff --git a/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_server/main/board.c b/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_server/main/board.c index 1a2bbbb7897..c073da4aac4 100644 --- a/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_server/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_server/main/board.c @@ -2,55 +2,17 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include - -#include "driver/gpio.h" #include "esp_log.h" #include "board.h" #define TAG "BOARD" -struct _led_state led_state[3] = { - { LED_OFF, LED_OFF, LED_R, "red" }, - { LED_OFF, LED_OFF, LED_G, "green" }, - { LED_OFF, LED_OFF, LED_B, "blue" }, -}; - -void board_led_operation(uint8_t pin, uint8_t onoff) -{ - for (int i = 0; i < 3; i++) { - if (led_state[i].pin != pin) { - continue; - } - if (onoff == led_state[i].previous) { - ESP_LOGW(TAG, "led %s is already %s", - led_state[i].name, (onoff ? "on" : "off")); - return; - } - gpio_set_level(pin, onoff); - led_state[i].previous = onoff; - return; - } - - ESP_LOGE(TAG, "LED is not found!"); -} - -static void board_led_init(void) -{ - for (int i = 0; i < 3; i++) { - gpio_reset_pin(led_state[i].pin); - gpio_set_direction(led_state[i].pin, GPIO_MODE_OUTPUT); - gpio_set_level(led_state[i].pin, LED_OFF); - led_state[i].previous = LED_OFF; - } -} - void board_init(void) { - board_led_init(); } diff --git a/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_server/main/board.h b/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_server/main/board.h index 2be1b508af7..90e2d788aba 100644 --- a/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_server/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_server/main/board.h @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,60 +12,16 @@ #ifdef __cplusplus extern "C" { -#endif /**< __cplusplus */ +#endif #include "driver/gpio.h" -#if defined(CONFIG_BLE_MESH_ESP_WROOM_32) -#define LED_R GPIO_NUM_25 -#define LED_G GPIO_NUM_26 -#define LED_B GPIO_NUM_27 -#elif defined(CONFIG_BLE_MESH_ESP_WROVER) -#define LED_R GPIO_NUM_0 -#define LED_G GPIO_NUM_2 -#define LED_B GPIO_NUM_4 -#elif defined(CONFIG_BLE_MESH_ESP32C3_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32S3_DEV) -#define LED_R GPIO_NUM_47 -#define LED_G GPIO_NUM_47 -#define LED_B GPIO_NUM_47 -#elif defined(CONFIG_BLE_MESH_ESP32C6_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C61_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32H2_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C5_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#endif - -#define LED_ON 1 -#define LED_OFF 0 - -struct _led_state { - uint8_t current; - uint8_t previous; - uint8_t pin; - char *name; -}; - -void board_led_operation(uint8_t pin, uint8_t onoff); +#define BUTTON_IO_NUM CONFIG_BUTTON_IO_NUM void board_init(void); #ifdef __cplusplus } -#endif /**< __cplusplus */ +#endif #endif /* _BOARD_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_server/main/main.c b/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_server/main/main.c index 8e115b43e60..fadce4fe8fa 100644 --- a/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/onoff_models/onoff_server/main/main.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -29,8 +29,6 @@ #define CID_ESP 0x02E5 -extern struct _led_state led_state[3]; - static uint8_t dev_uuid[16] = { 0xdd, 0xdd }; static esp_ble_mesh_cfg_srv_t config_server = { @@ -119,7 +117,6 @@ static void prov_complete(uint16_t net_idx, uint16_t addr, uint8_t flags, uint32 { ESP_LOGI(TAG, "net_idx: 0x%04x, addr: 0x%04x", net_idx, addr); ESP_LOGI(TAG, "flags: 0x%02x, iv_index: 0x%08" PRIx32, flags, iv_index); - board_led_operation(LED_G, LED_OFF); } static void example_change_led_state(esp_ble_mesh_model_t *model, @@ -127,24 +124,23 @@ static void example_change_led_state(esp_ble_mesh_model_t *model, { uint16_t primary_addr = esp_ble_mesh_get_primary_element_address(); uint8_t elem_count = esp_ble_mesh_get_element_count(); - struct _led_state *led = NULL; uint8_t i; if (ESP_BLE_MESH_ADDR_IS_UNICAST(ctx->recv_dst)) { for (i = 0; i < elem_count; i++) { if (ctx->recv_dst == (primary_addr + i)) { - led = &led_state[i]; - board_led_operation(led->pin, onoff); + ESP_LOGI(TAG, "Recv onoff message (unicast 0x%04x), element index %d, onoff %s", + ctx->recv_dst, i, onoff ? "ON" : "OFF"); } } } else if (ESP_BLE_MESH_ADDR_IS_GROUP(ctx->recv_dst)) { if (esp_ble_mesh_is_model_subscribed_to_group(model, ctx->recv_dst)) { - led = &led_state[model->element->element_addr - primary_addr]; - board_led_operation(led->pin, onoff); + ESP_LOGI(TAG, "Recv onoff message (group 0x%04x), element index %d, onoff %s", + ctx->recv_dst, (int)(model->element->element_addr - primary_addr), onoff ? "ON" : "OFF"); } } else if (ctx->recv_dst == 0xFFFF) { - led = &led_state[model->element->element_addr - primary_addr]; - board_led_operation(led->pin, onoff); + ESP_LOGI(TAG, "Recv onoff message (broadcast), element index %d, onoff %s", + (int)(model->element->element_addr - primary_addr), onoff ? "ON" : "OFF"); } } @@ -312,8 +308,6 @@ static esp_err_t ble_mesh_init(void) ESP_LOGI(TAG, "BLE Mesh Node initialized"); - board_led_operation(LED_G, LED_ON); - return err; } diff --git a/examples/bluetooth/esp_ble_mesh/provisioner/main/main.c b/examples/bluetooth/esp_ble_mesh/provisioner/main/main.c index 9df82355c74..18f3c80c98b 100644 --- a/examples/bluetooth/esp_ble_mesh/provisioner/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/provisioner/main/main.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -25,9 +25,6 @@ #define TAG "EXAMPLE" -#define LED_OFF 0x0 -#define LED_ON 0x1 - #define CID_ESP 0x02E5 #define PROV_OWN_ADDR 0x0001 @@ -202,7 +199,7 @@ static esp_err_t prov_complete(int node_idx, const esp_ble_mesh_octet16_t uuid, return ESP_FAIL; } - err = example_ble_mesh_store_node_info(uuid, unicast, elem_num, LED_OFF); + err = example_ble_mesh_store_node_info(uuid, unicast, elem_num, 0); if (err) { ESP_LOGE(TAG, "%s: Store node info failed", __func__); return ESP_FAIL; diff --git a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/board.c b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/board.c index db6da9b7ceb..71545421c34 100644 --- a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/board.c @@ -2,67 +2,25 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include - #include "iot_button.h" -#include "driver/gpio.h" -#include "lightbulb.h" #include "esp_log.h" #include "board.h" #define TAG "BOARD" +#define BUTTON_IO_NUM CONFIG_BUTTON_IO_NUM #define BUTTON_ACTIVE_LEVEL 0 extern uint8_t click_to_send_onoff_set; extern void example_ble_mesh_send_gen_onoff_set(uint8_t onoff); extern void example_ble_mesh_send_remote_provisioning_scan_start(void); -void board_led_operation(uint8_t r, uint8_t g, uint8_t b) -{ -#ifdef BLE_MESH_LED_STRIP_IO - ws2812_set_rgb_channel(r, g, b); -#else - gpio_set_level(LED_R, r); - gpio_set_level(LED_G, g); - gpio_set_level(LED_B, b); -#endif -} - -static void board_led_init(void) -{ -#ifdef BLE_MESH_LED_STRIP_IO - lightbulb_config_t config = { - .type = DRIVER_WS2812, - .driver_conf.ws2812.led_num = 3, - .driver_conf.ws2812.ctrl_io = 8, - .capability.enable_fades = true, - .capability.fades_ms = 800, - .capability.enable_status_storage = false, - .capability.mode_mask = COLOR_MODE, - .capability.storage_cb = NULL, - .external_limit = NULL, - .gamma_conf = NULL, - .init_status.mode = WORK_COLOR, - .init_status.on = false, - .init_status.hue = 0, - .init_status.saturation = 100, - .init_status.value = 100, - }; - lightbulb_init(&config); - ws2812_set_rgb_channel(LED_OFF, LED_OFF, LED_OFF); -#else - gpio_set_level(LED_R, LED_OFF); - gpio_set_level(LED_G, LED_OFF); - gpio_set_level(LED_B, LED_OFF); -#endif -} - static void button_tap_cb(void* arg) { static uint8_t onoff = 1; @@ -75,7 +33,6 @@ static void button_tap_cb(void* arg) } } - static void board_button_init(void) { button_handle_t btn_handle = iot_button_create(BUTTON_IO_NUM, BUTTON_ACTIVE_LEVEL); @@ -86,6 +43,5 @@ static void board_button_init(void) void board_init(void) { - board_led_init(); board_button_init(); } diff --git a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/board.h b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/board.h index 3b04417b5b0..c752d6fb63f 100644 --- a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/board.h @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -14,45 +14,6 @@ extern "C" { #endif /**< __cplusplus */ -#include "driver/gpio.h" - -#if defined(CONFIG_BLE_MESH_ESP_WROOM_32) -#define LED_R GPIO_NUM_25 -#define LED_G GPIO_NUM_26 -#define LED_B GPIO_NUM_27 -#elif defined(CONFIG_BLE_MESH_ESP_WROVER) -#define LED_R GPIO_NUM_0 -#define LED_G GPIO_NUM_2 -#define LED_B GPIO_NUM_4 -#elif defined(CONFIG_BLE_MESH_ESP32C3_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32S3_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_47 -#elif defined(CONFIG_BLE_MESH_ESP32C6_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C61_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32H2_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C5_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#endif - -#define BUTTON_IO_NUM GPIO_NUM_9 - -#ifndef BLE_MESH_LED_STRIP_IO -#define LED_ON 1 -#else -#define LED_R 0 -#define LED_G 1 -#define LED_B 2 -#define LED_ON 100 -#endif - -#define LED_OFF 0 - -void board_led_operation(uint8_t r, uint8_t g, uint8_t b); - void board_init(void); #ifdef __cplusplus diff --git a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/main.c b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/main.c index dcfdab25ae2..8955131e89a 100644 --- a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_client/main/main.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -220,7 +220,7 @@ static esp_err_t prov_complete(int node_idx, const esp_ble_mesh_octet16_t uuid, return ESP_FAIL; } - err = example_ble_mesh_store_node_info(uuid, unicast, elem_num, LED_OFF); + err = example_ble_mesh_store_node_info(uuid, unicast, elem_num, 0); if (err) { ESP_LOGE(TAG, "%s: Store node info failed", __func__); return ESP_FAIL; @@ -249,7 +249,6 @@ static esp_err_t prov_complete(int node_idx, const esp_ble_mesh_octet16_t uuid, static void prov_link_open(esp_ble_mesh_prov_bearer_t bearer) { ESP_LOGI(TAG, "%s link open", bearer == ESP_BLE_MESH_PROV_ADV ? "PB-ADV" : "PB-GATT"); - board_led_operation(LED_OFF, LED_ON, LED_OFF); } static void prov_link_close(esp_ble_mesh_prov_bearer_t bearer, uint8_t reason) @@ -634,7 +633,6 @@ static void example_ble_mesh_config_client_cb(esp_ble_mesh_cfg_client_cb_event_t ESP_LOGI(TAG, "The Remote Provisioning Server have been provisioned, You could click button to start remote provisioning"); remote_rpr_srv_addr = addr; } - board_led_operation(LED_OFF, LED_OFF, LED_OFF); break; } default: @@ -997,7 +995,6 @@ static void example_ble_mesh_remote_prov_client_callback(esp_ble_mesh_rpr_client if (err) { ESP_LOGE(TAG, "Failed to perform Remote Provisioning Client action: Start Prov"); } - board_led_operation(LED_OFF, LED_ON, LED_OFF); break; } default: diff --git a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/board.c b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/board.c index d2f8a4d2959..2b4b570653c 100644 --- a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/board.c @@ -2,61 +2,18 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include -#include "driver/gpio.h" -#include "lightbulb.h" #include "esp_log.h" #include "board.h" #define TAG "BOARD" -void board_led_operation(uint8_t r, uint8_t g, uint8_t b) -{ -#ifdef BLE_MESH_LED_STRIP_IO - ws2812_set_rgb_channel(r, g, b); -#else - gpio_set_level(LED_R, r); - gpio_set_level(LED_G, g); - gpio_set_level(LED_B, b); -#endif -} - -static void board_led_init(void) -{ -#ifdef BLE_MESH_LED_STRIP_IO - lightbulb_config_t config = { - .type = DRIVER_WS2812, - .driver_conf.ws2812.led_num = 3, - .driver_conf.ws2812.ctrl_io = 8, - .capability.enable_fades = true, - .capability.fades_ms = 800, - .capability.enable_status_storage = false, - .capability.mode_mask = COLOR_MODE, - .capability.storage_cb = NULL, - .external_limit = NULL, - .gamma_conf = NULL, - .init_status.mode = WORK_COLOR, - .init_status.on = false, - .init_status.hue = 0, - .init_status.saturation = 100, - .init_status.value = 100, - }; - lightbulb_init(&config); - ws2812_set_rgb_channel(LED_OFF, LED_OFF, LED_OFF); -#else - gpio_set_level(LED_R, LED_OFF); - gpio_set_level(LED_G, LED_OFF); - gpio_set_level(LED_B, LED_OFF); -#endif -} - void board_init(void) { - board_led_init(); } diff --git a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/board.h b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/board.h index 3b04417b5b0..ddfb8db911b 100644 --- a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/board.h @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,51 +12,12 @@ #ifdef __cplusplus extern "C" { -#endif /**< __cplusplus */ - -#include "driver/gpio.h" - -#if defined(CONFIG_BLE_MESH_ESP_WROOM_32) -#define LED_R GPIO_NUM_25 -#define LED_G GPIO_NUM_26 -#define LED_B GPIO_NUM_27 -#elif defined(CONFIG_BLE_MESH_ESP_WROVER) -#define LED_R GPIO_NUM_0 -#define LED_G GPIO_NUM_2 -#define LED_B GPIO_NUM_4 -#elif defined(CONFIG_BLE_MESH_ESP32C3_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32S3_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_47 -#elif defined(CONFIG_BLE_MESH_ESP32C6_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C61_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32H2_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C5_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 #endif -#define BUTTON_IO_NUM GPIO_NUM_9 - -#ifndef BLE_MESH_LED_STRIP_IO -#define LED_ON 1 -#else -#define LED_R 0 -#define LED_G 1 -#define LED_B 2 -#define LED_ON 100 -#endif - -#define LED_OFF 0 - -void board_led_operation(uint8_t r, uint8_t g, uint8_t b); - void board_init(void); #ifdef __cplusplus } -#endif /**< __cplusplus */ +#endif #endif /* _BOARD_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/main.c b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/main.c index 0373e038f6e..d5b0d407b7c 100644 --- a/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/remote_provisioning/rpr_server/main/main.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -128,28 +128,8 @@ static void prov_complete(uint16_t net_idx, uint16_t addr, uint8_t flags, uint32 static void example_change_led_state(esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx, uint8_t onoff) { - uint16_t primary_addr = esp_ble_mesh_get_primary_element_address(); - uint8_t elem_count = esp_ble_mesh_get_element_count(); - uint8_t rgb[3] = {0}; - uint8_t i; - - if (ESP_BLE_MESH_ADDR_IS_UNICAST(ctx->recv_dst)) { - for (i = 0; i < elem_count; i++) { - if (ctx->recv_dst == (primary_addr + i)) { - rgb[i] = onoff ? LED_ON : LED_OFF; - } - } - } else if (ESP_BLE_MESH_ADDR_IS_GROUP(ctx->recv_dst)) { - if (esp_ble_mesh_is_model_subscribed_to_group(model, ctx->recv_dst)) { - rgb[model->element->element_addr - primary_addr] = onoff ? LED_ON : LED_OFF; - } - } else if (ctx->recv_dst == 0xFFFF) { - rgb[0] = onoff ? LED_ON : LED_OFF; - rgb[1] = onoff ? LED_ON : LED_OFF; - rgb[2] = onoff ? LED_ON : LED_OFF; - } - - board_led_operation(rgb[0], rgb[1], rgb[2]); + ESP_LOGI(TAG, "Recv onoff message, element addr 0x%04x, onoff %s", + ctx->recv_dst, onoff ? "ON" : "OFF"); } static void example_handle_gen_onoff_msg(esp_ble_mesh_model_t *model, @@ -197,7 +177,6 @@ static void example_ble_mesh_provisioning_cb(esp_ble_mesh_prov_cb_event_t event, case ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT: ESP_LOGI(TAG, "ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT, bearer %s", param->node_prov_link_open.bearer == ESP_BLE_MESH_PROV_ADV ? "PB-ADV" : "PB-GATT"); - board_led_operation(LED_OFF, LED_ON, LED_OFF); break; case ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT: ESP_LOGI(TAG, "ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT, bearer %s", @@ -280,7 +259,6 @@ static void example_ble_mesh_config_server_cb(esp_ble_mesh_cfg_server_cb_event_t param->value.state_change.mod_app_bind.app_idx, param->value.state_change.mod_app_bind.company_id, param->value.state_change.mod_app_bind.model_id); - board_led_operation(LED_OFF, LED_OFF, LED_OFF); break; case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD: ESP_LOGI(TAG, "ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD"); @@ -400,11 +378,9 @@ static void example_remote_prov_server_callback(esp_ble_mesh_rpr_server_cb_event case ESP_BLE_MESH_RPR_SERVER_LINK_OPEN_EVT: ESP_LOGW(TAG, "ESP_BLE_MESH_RPR_SERVER_LINK_OPEN_EVT"); print_link_open_evt(param); - board_led_operation(LED_OFF, LED_OFF, LED_ON); break; case ESP_BLE_MESH_RPR_SERVER_LINK_CLOSE_EVT: ESP_LOGW(TAG, "ESP_BLE_MESH_RPR_SERVER_LINK_CLOSE_EVT"); - board_led_operation(LED_OFF, LED_OFF, LED_OFF); print_link_close_evt(param); break; case ESP_BLE_MESH_RPR_SERVER_PROV_COMP_EVT: @@ -439,8 +415,6 @@ static esp_err_t ble_mesh_init(void) ESP_LOGI(TAG, "BLE Mesh Node initialized"); - board_led_operation(LED_ON, LED_OFF, LED_OFF); - return err; } diff --git a/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/board.c b/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/board.c index d2f8a4d2959..c073da4aac4 100644 --- a/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/board.c @@ -2,61 +2,17 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include - -#include "driver/gpio.h" -#include "lightbulb.h" #include "esp_log.h" #include "board.h" #define TAG "BOARD" -void board_led_operation(uint8_t r, uint8_t g, uint8_t b) -{ -#ifdef BLE_MESH_LED_STRIP_IO - ws2812_set_rgb_channel(r, g, b); -#else - gpio_set_level(LED_R, r); - gpio_set_level(LED_G, g); - gpio_set_level(LED_B, b); -#endif -} - -static void board_led_init(void) -{ -#ifdef BLE_MESH_LED_STRIP_IO - lightbulb_config_t config = { - .type = DRIVER_WS2812, - .driver_conf.ws2812.led_num = 3, - .driver_conf.ws2812.ctrl_io = 8, - .capability.enable_fades = true, - .capability.fades_ms = 800, - .capability.enable_status_storage = false, - .capability.mode_mask = COLOR_MODE, - .capability.storage_cb = NULL, - .external_limit = NULL, - .gamma_conf = NULL, - .init_status.mode = WORK_COLOR, - .init_status.on = false, - .init_status.hue = 0, - .init_status.saturation = 100, - .init_status.value = 100, - }; - lightbulb_init(&config); - ws2812_set_rgb_channel(LED_OFF, LED_OFF, LED_OFF); -#else - gpio_set_level(LED_R, LED_OFF); - gpio_set_level(LED_G, LED_OFF); - gpio_set_level(LED_B, LED_OFF); -#endif -} - void board_init(void) { - board_led_init(); } diff --git a/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/board.h b/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/board.h index 3b04417b5b0..ddfb8db911b 100644 --- a/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/board.h @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,51 +12,12 @@ #ifdef __cplusplus extern "C" { -#endif /**< __cplusplus */ - -#include "driver/gpio.h" - -#if defined(CONFIG_BLE_MESH_ESP_WROOM_32) -#define LED_R GPIO_NUM_25 -#define LED_G GPIO_NUM_26 -#define LED_B GPIO_NUM_27 -#elif defined(CONFIG_BLE_MESH_ESP_WROVER) -#define LED_R GPIO_NUM_0 -#define LED_G GPIO_NUM_2 -#define LED_B GPIO_NUM_4 -#elif defined(CONFIG_BLE_MESH_ESP32C3_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32S3_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_47 -#elif defined(CONFIG_BLE_MESH_ESP32C6_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C61_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32H2_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C5_DEV) -#define BLE_MESH_LED_STRIP_IO GPIO_NUM_8 #endif -#define BUTTON_IO_NUM GPIO_NUM_9 - -#ifndef BLE_MESH_LED_STRIP_IO -#define LED_ON 1 -#else -#define LED_R 0 -#define LED_G 1 -#define LED_B 2 -#define LED_ON 100 -#endif - -#define LED_OFF 0 - -void board_led_operation(uint8_t r, uint8_t g, uint8_t b); - void board_init(void); #ifdef __cplusplus } -#endif /**< __cplusplus */ +#endif #endif /* _BOARD_H_ */ diff --git a/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/main.c b/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/main.c index bb27579245d..df0e56675c9 100644 --- a/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/remote_provisioning/unprov_dev/main/main.c @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -122,28 +122,8 @@ static void prov_complete(uint16_t net_idx, uint16_t addr, uint8_t flags, uint32 static void example_change_led_state(esp_ble_mesh_model_t *model, esp_ble_mesh_msg_ctx_t *ctx, uint8_t onoff) { - uint16_t primary_addr = esp_ble_mesh_get_primary_element_address(); - uint8_t elem_count = esp_ble_mesh_get_element_count(); - uint8_t rgb[3] = {0}; - uint8_t i; - - if (ESP_BLE_MESH_ADDR_IS_UNICAST(ctx->recv_dst)) { - for (i = 0; i < elem_count; i++) { - if (ctx->recv_dst == (primary_addr + i)) { - rgb[i] = onoff ? LED_ON : LED_OFF; - } - } - } else if (ESP_BLE_MESH_ADDR_IS_GROUP(ctx->recv_dst)) { - if (esp_ble_mesh_is_model_subscribed_to_group(model, ctx->recv_dst)) { - rgb[model->element->element_addr - primary_addr] = onoff ? LED_ON : LED_OFF; - } - } else if (ctx->recv_dst == 0xFFFF) { - rgb[0] = onoff ? LED_ON : LED_OFF; - rgb[1] = onoff ? LED_ON : LED_OFF; - rgb[2] = onoff ? LED_ON : LED_OFF; - } - - board_led_operation(rgb[0], rgb[1], rgb[2]); + ESP_LOGI(TAG, "Recv onoff message, element addr 0x%04x, onoff %s", + ctx->recv_dst, onoff ? "ON" : "OFF"); } static void example_handle_gen_onoff_msg(esp_ble_mesh_model_t *model, @@ -191,7 +171,6 @@ static void example_ble_mesh_provisioning_cb(esp_ble_mesh_prov_cb_event_t event, case ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT: ESP_LOGI(TAG, "ESP_BLE_MESH_NODE_PROV_LINK_OPEN_EVT, bearer %s", param->node_prov_link_open.bearer == ESP_BLE_MESH_PROV_ADV ? "PB-ADV" : "PB-GATT"); - board_led_operation(LED_OFF, LED_ON, LED_OFF); break; case ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT: ESP_LOGI(TAG, "ESP_BLE_MESH_NODE_PROV_LINK_CLOSE_EVT, bearer %s", @@ -275,7 +254,6 @@ static void example_ble_mesh_config_server_cb(esp_ble_mesh_cfg_server_cb_event_t param->value.state_change.mod_app_bind.company_id, param->value.state_change.mod_app_bind.model_id); - board_led_operation(LED_OFF, LED_OFF, LED_OFF); break; case ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD: ESP_LOGI(TAG, "ESP_BLE_MESH_MODEL_OP_MODEL_SUB_ADD"); @@ -313,8 +291,6 @@ static esp_err_t ble_mesh_init(void) ESP_LOGI(TAG, "BLE Mesh Node initialized"); - board_led_operation(LED_ON, LED_OFF, LED_OFF); - return err; } diff --git a/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_client/main/board.c b/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_client/main/board.c index b7734f55575..84da028cf68 100644 --- a/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_client/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_client/main/board.c @@ -14,7 +14,7 @@ #define TAG "BOARD" -#define BUTTON_IO_NUM 0 +#define BUTTON_IO_NUM CONFIG_BUTTON_IO_NUM #define BUTTON_ACTIVE_LEVEL 0 extern void example_ble_mesh_send_sensor_message(uint32_t opcode); diff --git a/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_server/main/board.c b/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_server/main/board.c index 6fc4d672751..c073da4aac4 100644 --- a/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_server/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_server/main/board.c @@ -2,54 +2,17 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include -#include "driver/gpio.h" #include "esp_log.h" #include "board.h" #define TAG "BOARD" -struct _led_state led_state[3] = { - { LED_OFF, LED_OFF, LED_R, "red" }, - { LED_OFF, LED_OFF, LED_G, "green" }, - { LED_OFF, LED_OFF, LED_B, "blue" }, -}; - -void board_led_operation(uint8_t pin, uint8_t onoff) -{ - for (int i = 0; i < 3; i++) { - if (led_state[i].pin != pin) { - continue; - } - if (onoff == led_state[i].previous) { - ESP_LOGW(TAG, "led %s is already %s", - led_state[i].name, (onoff ? "on" : "off")); - return; - } - gpio_set_level(pin, onoff); - led_state[i].previous = onoff; - return; - } - - ESP_LOGE(TAG, "LED is not found!"); -} - -static void board_led_init(void) -{ - for (int i = 0; i < 3; i++) { - gpio_reset_pin(led_state[i].pin); - gpio_set_direction(led_state[i].pin, GPIO_MODE_OUTPUT); - gpio_set_level(led_state[i].pin, LED_OFF); - led_state[i].previous = LED_OFF; - } -} - void board_init(void) { - board_led_init(); } diff --git a/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_server/main/board.h b/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_server/main/board.h index 2be1b508af7..c752d6fb63f 100644 --- a/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_server/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_server/main/board.h @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -14,54 +14,6 @@ extern "C" { #endif /**< __cplusplus */ -#include "driver/gpio.h" - -#if defined(CONFIG_BLE_MESH_ESP_WROOM_32) -#define LED_R GPIO_NUM_25 -#define LED_G GPIO_NUM_26 -#define LED_B GPIO_NUM_27 -#elif defined(CONFIG_BLE_MESH_ESP_WROVER) -#define LED_R GPIO_NUM_0 -#define LED_G GPIO_NUM_2 -#define LED_B GPIO_NUM_4 -#elif defined(CONFIG_BLE_MESH_ESP32C3_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32S3_DEV) -#define LED_R GPIO_NUM_47 -#define LED_G GPIO_NUM_47 -#define LED_B GPIO_NUM_47 -#elif defined(CONFIG_BLE_MESH_ESP32C6_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C61_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32H2_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C5_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#endif - -#define LED_ON 1 -#define LED_OFF 0 - -struct _led_state { - uint8_t current; - uint8_t previous; - uint8_t pin; - char *name; -}; - -void board_led_operation(uint8_t pin, uint8_t onoff); - void board_init(void); #ifdef __cplusplus diff --git a/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_server/main/main.c b/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_server/main/main.c index 70b30136e29..1c99e40eea5 100644 --- a/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/sensor_models/sensor_server/main/main.c @@ -164,8 +164,6 @@ static void prov_complete(uint16_t net_idx, uint16_t addr, uint8_t flags, uint32 { ESP_LOGI(TAG, "net_idx 0x%03x, addr 0x%04x", net_idx, addr); ESP_LOGI(TAG, "flags 0x%02x, iv_index 0x%08" PRIx32, flags, iv_index); - board_led_operation(LED_G, LED_OFF); - /* Initialize the indoor and outdoor temperatures for each sensor. */ net_buf_simple_add_u8(&sensor_data_0, indoor_temp); net_buf_simple_add_u8(&sensor_data_1, outdoor_temp); @@ -617,8 +615,6 @@ static esp_err_t ble_mesh_init(void) return err; } - board_led_operation(LED_G, LED_ON); - ESP_LOGI(TAG, "BLE Mesh sensor server initialized"); return ESP_OK; diff --git a/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_client/main/board.c b/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_client/main/board.c index 83518c76c21..4a60f8f3600 100644 --- a/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_client/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_client/main/board.c @@ -13,7 +13,7 @@ #define TAG "BOARD" -#define BUTTON_IO_NUM 0 +#define BUTTON_IO_NUM CONFIG_BUTTON_IO_NUM #define BUTTON_ACTIVE_LEVEL 0 extern void example_ble_mesh_send_vendor_message(bool resend); diff --git a/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_server/main/board.c b/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_server/main/board.c index 6fc4d672751..c073da4aac4 100644 --- a/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_server/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_server/main/board.c @@ -2,54 +2,17 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include -#include "driver/gpio.h" #include "esp_log.h" #include "board.h" #define TAG "BOARD" -struct _led_state led_state[3] = { - { LED_OFF, LED_OFF, LED_R, "red" }, - { LED_OFF, LED_OFF, LED_G, "green" }, - { LED_OFF, LED_OFF, LED_B, "blue" }, -}; - -void board_led_operation(uint8_t pin, uint8_t onoff) -{ - for (int i = 0; i < 3; i++) { - if (led_state[i].pin != pin) { - continue; - } - if (onoff == led_state[i].previous) { - ESP_LOGW(TAG, "led %s is already %s", - led_state[i].name, (onoff ? "on" : "off")); - return; - } - gpio_set_level(pin, onoff); - led_state[i].previous = onoff; - return; - } - - ESP_LOGE(TAG, "LED is not found!"); -} - -static void board_led_init(void) -{ - for (int i = 0; i < 3; i++) { - gpio_reset_pin(led_state[i].pin); - gpio_set_direction(led_state[i].pin, GPIO_MODE_OUTPUT); - gpio_set_level(led_state[i].pin, LED_OFF); - led_state[i].previous = LED_OFF; - } -} - void board_init(void) { - board_led_init(); } diff --git a/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_server/main/board.h b/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_server/main/board.h index 2be1b508af7..c752d6fb63f 100644 --- a/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_server/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_server/main/board.h @@ -2,7 +2,7 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -14,54 +14,6 @@ extern "C" { #endif /**< __cplusplus */ -#include "driver/gpio.h" - -#if defined(CONFIG_BLE_MESH_ESP_WROOM_32) -#define LED_R GPIO_NUM_25 -#define LED_G GPIO_NUM_26 -#define LED_B GPIO_NUM_27 -#elif defined(CONFIG_BLE_MESH_ESP_WROVER) -#define LED_R GPIO_NUM_0 -#define LED_G GPIO_NUM_2 -#define LED_B GPIO_NUM_4 -#elif defined(CONFIG_BLE_MESH_ESP32C3_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32S3_DEV) -#define LED_R GPIO_NUM_47 -#define LED_G GPIO_NUM_47 -#define LED_B GPIO_NUM_47 -#elif defined(CONFIG_BLE_MESH_ESP32C6_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C61_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32H2_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C5_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#endif - -#define LED_ON 1 -#define LED_OFF 0 - -struct _led_state { - uint8_t current; - uint8_t previous; - uint8_t pin; - char *name; -}; - -void board_led_operation(uint8_t pin, uint8_t onoff); - void board_init(void); #ifdef __cplusplus diff --git a/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_server/main/main.c b/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_server/main/main.c index 3dde20b0ed0..245f0636552 100644 --- a/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_server/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/vendor_models/vendor_server/main/main.c @@ -88,7 +88,6 @@ static void prov_complete(uint16_t net_idx, uint16_t addr, uint8_t flags, uint32 { ESP_LOGI(TAG, "net_idx 0x%03x, addr 0x%04x", net_idx, addr); ESP_LOGI(TAG, "flags 0x%02x, iv_index 0x%08" PRIx32, flags, iv_index); - board_led_operation(LED_G, LED_OFF); } static void example_ble_mesh_provisioning_cb(esp_ble_mesh_prov_cb_event_t event, @@ -199,8 +198,6 @@ static esp_err_t ble_mesh_init(void) return err; } - board_led_operation(LED_G, LED_ON); - ESP_LOGI(TAG, "BLE Mesh Node initialized"); return ESP_OK; diff --git a/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/board.c b/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/board.c index 353f0c1166d..1b41c679f7a 100644 --- a/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/board.c +++ b/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/board.c @@ -1,66 +1,17 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include -#include - -#include "driver/gpio.h" +#include "esp_log.h" #include "board.h" -#include "ble_mesh_fast_prov_common.h" #define TAG "BOARD" -struct _led_state led_state[3] = { - { LED_OFF, LED_OFF, LED_R, "red" }, - { LED_OFF, LED_OFF, LED_G, "green" }, - { LED_OFF, LED_OFF, LED_B, "blue" }, -}; - -void board_output_number(esp_ble_mesh_output_action_t action, uint32_t number) -{ - ESP_LOGI(TAG, "Board output number %" PRIu32, number); -} - -void board_prov_complete(void) -{ - board_led_operation(LED_B, LED_OFF); -} - -void board_led_operation(uint8_t pin, uint8_t onoff) -{ - for (int i = 0; i < 3; i++) { - if (led_state[i].pin != pin) { - continue; - } - if (onoff == led_state[i].previous) { - ESP_LOGW(TAG, "led %s is already %s", - led_state[i].name, (onoff ? "on" : "off")); - return; - } - gpio_set_level(pin, onoff); - led_state[i].previous = onoff; - return; - } - - ESP_LOGE(TAG, "LED is not found!"); -} - -static void board_led_init(void) -{ - for (int i = 0; i < 3; i++) { - gpio_reset_pin(led_state[i].pin); - gpio_set_direction(led_state[i].pin, GPIO_MODE_OUTPUT); - gpio_set_level(led_state[i].pin, LED_OFF); - led_state[i].previous = LED_OFF; - } -} - esp_err_t board_init(void) { - board_led_init(); return ESP_OK; } diff --git a/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/board.h b/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/board.h index 7eca5b0f11f..8c95b7bf65c 100644 --- a/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/board.h +++ b/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/board.h @@ -1,6 +1,6 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -8,52 +8,7 @@ #ifndef _BOARD_H_ #define _BOARD_H_ -#include "sdkconfig.h" -#include "driver/gpio.h" -#include "esp_ble_mesh_defs.h" - -#ifdef CONFIG_BLE_MESH_ESP_WROOM_32 -#define LED_R GPIO_NUM_25 -#define LED_G GPIO_NUM_26 -#define LED_B GPIO_NUM_27 -#elif defined(CONFIG_BLE_MESH_ESP_WROVER) -#define LED_R GPIO_NUM_0 -#define LED_G GPIO_NUM_2 -#define LED_B GPIO_NUM_4 -#elif defined(CONFIG_BLE_MESH_ESP32C3_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32S3_DEV) -#define LED_R GPIO_NUM_47 -#define LED_G GPIO_NUM_47 -#define LED_B GPIO_NUM_47 -#elif defined(CONFIG_BLE_MESH_ESP32C6_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C61_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#elif defined(CONFIG_BLE_MESH_ESP32C5_DEV) -#define LED_R GPIO_NUM_8 -#define LED_G GPIO_NUM_8 -#define LED_B GPIO_NUM_8 -#endif - -struct _led_state { - uint8_t current; - uint8_t previous; - uint8_t pin; - char *name; -}; - -void board_output_number(esp_ble_mesh_output_action_t action, uint32_t number); - -void board_prov_complete(void); - -void board_led_operation(uint8_t pin, uint8_t onoff); +#include "esp_err.h" esp_err_t board_init(void); diff --git a/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/main.c b/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/main.c index e4d4da0bf4d..8b9771dcdac 100644 --- a/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/main.c +++ b/examples/bluetooth/esp_ble_mesh/wifi_coexist/main/main.c @@ -1,6 +1,6 @@ /* * SPDX-FileCopyrightText: 2017 Intel Corporation - * SPDX-FileContributor: 2018-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -41,7 +41,6 @@ #define TAG "EXAMPLE" -extern struct _led_state led_state[3]; extern struct k_delayed_work send_self_prov_node_addr_timer; extern bt_mesh_atomic_t fast_prov_cli_flags; @@ -166,9 +165,7 @@ static esp_ble_mesh_prov_t prov = { static void example_change_led_state(uint8_t onoff) { - struct _led_state *led = &led_state[1]; - - board_led_operation(led->pin, onoff); + ESP_LOGI(TAG, "Recv GenOnOff message, state: %s", onoff ? "ON" : "OFF"); /* When the node receives the first Generic OnOff Get/Set/Set Unack message, it will * start the timer used to disable fast provisioning functionality. @@ -187,7 +184,7 @@ static void node_prov_complete(uint16_t net_idx, uint16_t addr, uint8_t flags, u { ESP_LOGI(TAG, "net_idx: 0x%04x, unicast_addr: 0x%04x", net_idx, addr); ESP_LOGI(TAG, "flags: 0x%02x, iv_index: 0x%08" PRIx32, flags, iv_index); - board_prov_complete(); + ESP_LOGI(TAG, "Provisioning complete"); /* Updates the net_idx used by Fast Prov Server model, and it can also * be updated if the Fast Prov Info Set message contains a valid one. */ @@ -223,7 +220,7 @@ static void provisioner_prov_complete(int node_idx, const uint8_t uuid[16], uint /* Sets node info */ err = example_store_node_info(uuid, unicast_addr, element_num, net_idx, - fast_prov_server.app_idx, LED_OFF); + fast_prov_server.app_idx, 0); if (err != ESP_OK) { ESP_LOGE(TAG, "%s: Failed to set node info", __func__); return; @@ -753,8 +750,6 @@ static esp_err_t ble_mesh_init(void) ESP_LOGI(TAG, "BLE Mesh Wi-Fi Coexist Node initialized"); - board_led_operation(LED_B, LED_ON); - return ESP_OK; }