Skip to content

Commit 3a0b62e

Browse files
committed
Merge branch 'fix/update_idf_6.0' into 'master'
fix(espnow): Fix commpile issue when update IDF to 6.0 See merge request ae_group/esp-now!151
2 parents c33383d + 8f37e5e commit 3a0b62e

38 files changed

+558
-146
lines changed

.gitlab-ci.yml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,33 +102,33 @@ deploy_docs_production:
102102
DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH"
103103
DOCS_DEPLOY_URL_BASE: "https://$DOCS_PROD_SERVER/projects/esp-now"
104104

105-
build_idf_v4.4:
105+
build_idf_v5.2:
106106
extends: .build_template
107-
image: espressif/idf:release-v4.4
107+
image: espressif/idf:release-v5.2
108108
variables:
109-
TARGETS: "esp32 esp32s2 esp32s3 esp32c3"
109+
TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6"
110110

111-
build_idf_v5.0:
111+
build_idf_v5.3:
112112
extends: .build_template
113-
image: espressif/idf:release-v5.0
113+
image: espressif/idf:release-v5.3
114114
variables:
115-
TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3"
115+
TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6"
116116

117-
build_idf_v5.1:
117+
build_idf_v5.4:
118118
extends: .build_template
119-
image: espressif/idf:release-v5.1
119+
image: espressif/idf:release-v5.4
120120
variables:
121-
TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6"
121+
TARGETS: "esp32 esp32s2 esp32s3 esp32c3"
122122

123-
build_idf_v5.2:
123+
build_idf_v5.5:
124124
extends: .build_template
125-
image: espressif/idf:release-v5.2
125+
image: espressif/idf:release-v5.5
126126
variables:
127-
TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6"
127+
TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3"
128128

129-
build_idf_v5.3:
129+
build_idf_v6.0:
130130
extends: .build_template
131-
image: espressif/idf:release-v5.3
131+
image: espressif/idf:v6.0-beta1
132132
variables:
133133
TARGETS: "esp32 esp32s2 esp32s3 esp32c2 esp32c3 esp32c6"
134134

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ list(APPEND srcs "src/utils/src/espnow_mem.c"
5151
list(APPEND include_dirs "src/utils/include")
5252

5353
list(APPEND requires "spi_flash" "nvs_flash" "esp_timer" "esp_wifi" "driver")
54+
if(IDF_VERSION_MAJOR GREATER_EQUAL 6)
55+
list(APPEND requires "esp_driver_uart" "esp_driver_usb_serial_jtag" "vfs")
56+
endif()
5457

5558
idf_component_register(SRCS "${srcs}"
5659
INCLUDE_DIRS "${include_dirs}"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
CONFIG_ESPNOW_CONTROL_AUTO_CHANNEL_SENDING=y
2+
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=y

examples/coin_cell_demo/switch/main/app_main.c

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "espnow_ctrl.h"
2323
#if !defined(CONFIG_EXAMPLE_USE_COIN_CELL_BUTTON) || !CONFIG_EXAMPLE_USE_COIN_CELL_BUTTON_V1
2424
#include "iot_button.h"
25+
#include "button_gpio.h"
26+
#include "button_adc.h"
2527
#endif
2628
#ifdef CONFIG_EXAMPLE_USE_COIN_CELL_BUTTON
2729
#include "switch_board.h"
@@ -359,51 +361,59 @@ static void app_driver_init(void)
359361
board_init();
360362

361363
#if !CONFIG_EXAMPLE_USE_COIN_CELL_BUTTON_V1
364+
/* Button 4.x API for ADC */
362365
button_config_t button_config = {
363-
.type = BUTTON_TYPE_ADC,
364-
.adc_button_config = {
365-
.adc_channel = BOARD_CHAN_ADC,
366-
.min = 2200,
367-
.max = 3400,
368-
.adc_handle = NULL,
369-
},
366+
.long_press_time = 2000,
367+
.short_press_time = 180,
370368
};
371-
button_handle_t button_handle = iot_button_create(&button_config);
372-
iot_button_register_cb(button_handle, BUTTON_PRESS_DOWN, app_switch_button_event_cb, NULL);
373-
iot_button_register_cb(button_handle, BUTTON_SINGLE_CLICK, app_switch_button_event_cb, NULL);
374-
iot_button_register_cb(button_handle, BUTTON_LONG_PRESS_HOLD, app_switch_button_event_cb, NULL);
375-
iot_button_register_cb(button_handle, BUTTON_PRESS_END, app_switch_button_event_cb, NULL);
376-
377-
button_event_config_t btn_event_cfg = {
378-
.event = BUTTON_LONG_PRESS_UP,
379-
.event_data = {
380-
.long_press.press_time = 2000,
381-
}
369+
370+
button_adc_config_t adc_config = {
371+
.adc_channel = BOARD_CHAN_ADC,
372+
.adc_handle = NULL,
373+
.unit_id = ADC_UNIT_1,
374+
.button_index = 0,
375+
.min = 2200,
376+
.max = 3400,
377+
};
378+
379+
button_handle_t button_handle = NULL;
380+
ESP_ERROR_CHECK(iot_button_new_adc_device(&button_config, &adc_config, &button_handle));
381+
382+
iot_button_register_cb(button_handle, BUTTON_PRESS_DOWN, NULL, app_switch_button_event_cb, NULL);
383+
iot_button_register_cb(button_handle, BUTTON_SINGLE_CLICK, NULL, app_switch_button_event_cb, NULL);
384+
iot_button_register_cb(button_handle, BUTTON_LONG_PRESS_HOLD, NULL, app_switch_button_event_cb, NULL);
385+
iot_button_register_cb(button_handle, BUTTON_PRESS_END, NULL, app_switch_button_event_cb, NULL);
386+
387+
button_event_args_t btn_event_args = {
388+
.long_press.press_time = 2000,
382389
};
383-
iot_button_register_event_cb(button_handle, btn_event_cfg, app_switch_button_event_cb, NULL);
390+
iot_button_register_cb(button_handle, BUTTON_LONG_PRESS_UP, &btn_event_args, app_switch_button_event_cb, NULL);
384391

385-
btn_event_cfg.event = BUTTON_LONG_PRESS_START;
386-
btn_event_cfg.event_data.long_press.press_time = 4000;
387-
iot_button_register_event_cb(button_handle, btn_event_cfg, app_switch_button_event_cb, NULL);
392+
btn_event_args.long_press.press_time = 4000;
393+
iot_button_register_cb(button_handle, BUTTON_LONG_PRESS_START, &btn_event_args, app_switch_button_event_cb, NULL);
388394
#endif
389395

390396
#else
397+
/* Button 4.x API */
391398
button_config_t button_config = {
392-
.type = BUTTON_TYPE_GPIO,
393-
.gpio_button_config = {
394-
.gpio_num = CONTROL_KEY_GPIO,
395-
.active_level = 0,
399+
.long_press_time = 2000,
400+
.short_press_time = 180,
401+
};
402+
403+
button_gpio_config_t gpio_config = {
404+
.gpio_num = CONTROL_KEY_GPIO,
405+
.active_level = 0,
396406
#if CONFIG_GPIO_BUTTON_SUPPORT_POWER_SAVE
397407
.enable_power_save = true,
398408
#endif
399-
},
400409
};
401410

402-
button_handle_t button_handle = iot_button_create(&button_config);
411+
button_handle_t button_handle = NULL;
412+
ESP_ERROR_CHECK(iot_button_new_gpio_device(&button_config, &gpio_config, &button_handle));
403413

404-
iot_button_register_cb(button_handle, BUTTON_SINGLE_CLICK, app_switch_button_event_cb, NULL);
405-
iot_button_register_cb(button_handle, BUTTON_DOUBLE_CLICK, app_switch_button_event_cb, NULL);
406-
iot_button_register_cb(button_handle, BUTTON_LONG_PRESS_START, app_switch_button_event_cb, NULL);
414+
iot_button_register_cb(button_handle, BUTTON_SINGLE_CLICK, NULL, app_switch_button_event_cb, NULL);
415+
iot_button_register_cb(button_handle, BUTTON_DOUBLE_CLICK, NULL, app_switch_button_event_cb, NULL);
416+
iot_button_register_cb(button_handle, BUTTON_LONG_PRESS_START, NULL, app_switch_button_event_cb, NULL);
407417
#endif
408418
}
409419

examples/coin_cell_demo/switch/main/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## IDF Component Manager Manifest File
22
dependencies:
3-
espressif/button: "==3.3.2"
3+
espressif/button: "^4.1.5"
44
## Required IDF version
55
idf:
66
version: ">=4.4"

examples/coin_cell_demo/switch/sdkconfig.defaults

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ CONFIG_ESPNOW_LIGHT_SLEEP=y
1414
CONFIG_ESPNOW_CONTROL_AUTO_CHANNEL_SENDING=y
1515
CONFIG_ESPNOW_CONTROL_RETRANSMISSION_TIMES=2
1616
CONFIG_ESPNOW_DATA_FAST_ACK=y
17+
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=y

examples/coin_cell_demo/switch/sdkconfig.defaults.v1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ CONFIG_ESPNOW_CONTROL_AUTO_CHANNEL_SENDING=y
2323
CONFIG_ESPNOW_CONTROL_WAIT_ACK_DURATION=20
2424
CONFIG_ESPNOW_CONTROL_RETRANSMISSION_TIMES=2
2525
CONFIG_ESPNOW_DATA_FAST_ACK=y
26+
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=y

examples/coin_cell_demo/switch/sdkconfig.defaults.v2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ CONFIG_ESPNOW_CONTROL_AUTO_CHANNEL_SENDING=y
2424
CONFIG_ESPNOW_CONTROL_WAIT_ACK_DURATION=20
2525
CONFIG_ESPNOW_CONTROL_RETRANSMISSION_TIMES=2
2626
CONFIG_ESPNOW_DATA_FAST_ACK=y
27+
CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_1=y

examples/control/main/app_main.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@
2222
#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
2323
#include "driver/rmt.h"
2424
#endif
25+
#include "driver/gpio.h"
2526
#include "led_strip.h"
2627

2728
#include "iot_button.h"
29+
#include "button_gpio.h"
30+
#include "esp_err.h"
2831

2932
// All the default GPIOs are based on ESP32 series DevKitC boards, for other boards, please modify them accordingly.
3033
#ifdef CONFIG_IDF_TARGET_ESP32C2
@@ -209,19 +212,23 @@ static void app_driver_init(void)
209212
{
210213
app_led_init();
211214

215+
/* Button 4.x API */
212216
button_config_t button_config = {
213-
.type = BUTTON_TYPE_GPIO,
214-
.gpio_button_config = {
215-
.gpio_num = CONTROL_KEY_GPIO,
216-
.active_level = 0,
217-
},
217+
.long_press_time = 2000,
218+
.short_press_time = 180,
218219
};
219220

220-
button_handle_t button_handle = iot_button_create(&button_config);
221+
button_gpio_config_t gpio_config = {
222+
.gpio_num = CONTROL_KEY_GPIO,
223+
.active_level = 0,
224+
};
225+
226+
button_handle_t button_handle = NULL;
227+
ESP_ERROR_CHECK(iot_button_new_gpio_device(&button_config, &gpio_config, &button_handle));
221228

222-
iot_button_register_cb(button_handle, BUTTON_SINGLE_CLICK, app_initiator_send_press_cb, NULL);
223-
iot_button_register_cb(button_handle, BUTTON_DOUBLE_CLICK, app_initiator_bind_press_cb, NULL);
224-
iot_button_register_cb(button_handle, BUTTON_LONG_PRESS_START, app_initiator_unbind_press_cb, NULL);
229+
iot_button_register_cb(button_handle, BUTTON_SINGLE_CLICK, NULL, app_initiator_send_press_cb, NULL);
230+
iot_button_register_cb(button_handle, BUTTON_DOUBLE_CLICK, NULL, app_initiator_bind_press_cb, NULL);
231+
iot_button_register_cb(button_handle, BUTTON_LONG_PRESS_START, NULL, app_initiator_unbind_press_cb, NULL);
225232
}
226233

227234
static void app_responder_ctrl_data_cb(espnow_attribute_t initiator_attribute,

examples/control/main/idf_component.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## IDF Component Manager Manifest File
22
dependencies:
3-
espressif/button: "==2.5.0"
3+
espressif/button: "^4.1.5"
44
espressif/led_strip:
55
version: "==1.1.0-alpha"
66
rules:

0 commit comments

Comments
 (0)