From 7cd2f7b34d925f6b4ebcbecf320c2d5a1b2e7036 Mon Sep 17 00:00:00 2001 From: zhanghaipeng Date: Fri, 26 Dec 2025 12:01:12 +0800 Subject: [PATCH] feat(examples/bluedroid): Add BLE time interval conversion macros for better readability Add macros to convert time values from milliseconds to BLE interval units: - ESP_BLE_GAP_ADV_ITVL_MS: Convert advertising interval (0.625ms unit) - ESP_BLE_GAP_SCAN_ITVL_MS: Convert scan interval (0.625ms unit) - ESP_BLE_GAP_SCAN_WIN_MS: Convert scan window (0.625ms unit) - ESP_BLE_GAP_CONN_ITVL_MS: Convert connection interval (1.25ms unit) - ESP_BLE_GAP_PERIODIC_ADV_ITVL_MS: Convert periodic adv interval (1.25ms unit) - ESP_BLE_GAP_SUPERVISION_TIMEOUT_MS: Convert supervision timeout (10ms unit) --- .../api/include/api/esp_gap_ble_api.h | 21 +++++++++++++++++++ .../ble/ble_ancs/main/ble_ancs_demo.c | 8 +++---- .../main/ble_compatibility_test.c | 14 ++++++------- .../main/esp_eddystone_demo.c | 4 ++-- .../main/esp_eddystone_demo.c | 4 ++-- .../main/ble_hidd_demo_main.c | 8 +++---- .../ble/ble_ibeacon/main/ibeacon_demo.c | 10 ++++----- .../main/ble_multiconn_cent_demo.c | 14 ++++++------- .../main/ble_multiconn_prph_demo.c | 8 +++---- .../ble/ble_spp_client/main/spp_client_demo.c | 6 +++--- .../ble_spp_server/main/ble_spp_server_demo.c | 4 ++-- .../main/example_ble_client_throughput.c | 8 +++---- .../main/example_ble_server_throughput.c | 14 ++++++------- .../ble/gatt_client/main/gattc_demo.c | 4 ++-- .../main/example_ble_sec_gattc_demo.c | 4 ++-- .../main/example_ble_sec_gatts_demo.c | 10 ++++----- .../ble/gatt_server/main/gatts_demo.c | 8 +++---- .../main/gatts_table_creat_demo.c | 14 ++++++------- .../main/gattc_multi_connect.c | 4 ++-- .../main/ble50_sec_gattc_demo.c | 20 +++++++++--------- .../main/ble50_sec_gatts_demo.c | 4 ++-- .../main/example_ble_client_throughput.c | 20 +++++++++--------- .../main/example_ble_server_throughput.c | 4 ++-- .../ble_50/multi-adv/main/multi_adv_demo.c | 16 +++++++------- .../periodic_adv/main/periodic_adv_demo.c | 10 ++++----- .../coex/a2dp_gatts_coex/main/main.c | 4 ++-- .../gattc_gatts_coex/main/gattc_gatts_coex.c | 18 ++++++++-------- 27 files changed, 142 insertions(+), 121 deletions(-) diff --git a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h index 102fdfd66b..ba0f524c68 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h @@ -283,6 +283,27 @@ typedef uint8_t esp_gap_ble_channels[ESP_GAP_BLE_CHANNELS_LEN]; #define VENDOR_HCI_CMD_MASK (0x3F << 10) /**!< 0xFC00 */ +/** + * @brief BLE time interval conversion macros + * + * These macros convert time values in milliseconds to BLE interval units. + * + * - Advertising interval: unit is 0.625ms (range: 20ms to 10240ms) + * - Connection interval: unit is 1.25ms (range: 7.5ms to 4000ms) + * - Scan interval/window: unit is 0.625ms + * - Periodic advertising interval: unit is 1.25ms + * - Supervision timeout: unit is 10ms (range: 100ms to 32000ms) + * + * @note If the input value is not an exact multiple of the unit, the result will be rounded to the nearest value. + * For example, ESP_BLE_GAP_ADV_ITVL_MS(25) = 40 (25ms / 0.625ms = 40), but ESP_BLE_GAP_ADV_ITVL_MS(25.5) = 40 (rounded). + */ +#define ESP_BLE_GAP_ADV_ITVL_MS(t) ((uint16_t)((t) * 1000 / 625)) /*!< Convert advertising interval from ms to 0.625ms units. If input is not a multiple of 0.625ms, it will be rounded to the nearest value. */ +#define ESP_BLE_GAP_SCAN_ITVL_MS(t) ((uint16_t)((t) * 1000 / 625)) /*!< Convert scan interval from ms to 0.625ms units. If input is not a multiple of 0.625ms, it will be rounded to the nearest value. */ +#define ESP_BLE_GAP_SCAN_WIN_MS(t) ((uint16_t)((t) * 1000 / 625)) /*!< Convert scan window from ms to 0.625ms units. If input is not a multiple of 0.625ms, it will be rounded to the nearest value. */ +#define ESP_BLE_GAP_CONN_ITVL_MS(t) ((uint16_t)((t) * 1000 / 1250)) /*!< Convert connection interval from ms to 1.25ms units. If input is not a multiple of 1.25ms, it will be rounded to the nearest value. */ +#define ESP_BLE_GAP_PERIODIC_ADV_ITVL_MS(t) ((uint16_t)((t) * 1000 / 1250)) /*!< Convert periodic advertising interval from ms to 1.25ms units. If input is not a multiple of 1.25ms, it will be rounded to the nearest value. */ +#define ESP_BLE_GAP_SUPERVISION_TIMEOUT_MS(t) ((uint16_t)((t) / 10)) /*!< Convert supervision timeout from ms to 10ms units. If input is not a multiple of 10ms, it will be rounded to the nearest value. */ + /* relate to BTM_BLE_AD_TYPE_xxx in stack/btm_ble_api.h */ /// The type of advertising data(not adv_type) typedef enum { diff --git a/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c b/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c index d5f6992f92..0f97ea23fe 100644 --- a/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_ancs/main/ble_ancs_demo.c @@ -83,8 +83,8 @@ static uint8_t hidd_service_uuid128[] = { static esp_ble_adv_data_t adv_config = { .set_scan_rsp = false, .include_txpower = false, - .min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec - .max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec + .min_interval = ESP_BLE_GAP_CONN_ITVL_MS(7.5), //slave connection min interval + .max_interval = ESP_BLE_GAP_CONN_ITVL_MS(20), //slave connection max interval .appearance = ESP_BLE_APPEARANCE_GENERIC_HID, .service_uuid_len = sizeof(hidd_service_uuid128), .p_service_uuid = hidd_service_uuid128, @@ -99,8 +99,8 @@ static esp_ble_adv_data_t scan_rsp_config = { }; static esp_ble_adv_params_t adv_params = { - .adv_int_min = 0x100, - .adv_int_max = 0x100, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(160), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(160), .adv_type = ADV_TYPE_IND, .own_addr_type = BLE_ADDR_TYPE_RPA_PUBLIC, .channel_map = ADV_CHNL_ALL, diff --git a/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c b/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c index 4ff18b6bd3..66c009ab04 100644 --- a/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c +++ b/examples/bluetooth/bluedroid/ble/ble_compatibility_test/main/ble_compatibility_test.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -101,8 +101,8 @@ static esp_ble_adv_data_t adv_data = { .set_scan_rsp = false, .include_name = true, .include_txpower = true, - .min_interval = 0x20, - .max_interval = 0x40, + .min_interval = ESP_BLE_GAP_CONN_ITVL_MS(40), + .max_interval = ESP_BLE_GAP_CONN_ITVL_MS(80), .appearance = 0x00, .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN, .p_manufacturer_data = NULL, //test_manufacturer, @@ -118,8 +118,8 @@ static esp_ble_adv_data_t scan_rsp_data = { .set_scan_rsp = true, .include_name = true, .include_txpower = true, - .min_interval = 0x20, - .max_interval = 0x40, + .min_interval = ESP_BLE_GAP_CONN_ITVL_MS(40), + .max_interval = ESP_BLE_GAP_CONN_ITVL_MS(80), .appearance = 0x00, .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN, .p_manufacturer_data = NULL, //&test_manufacturer[0], @@ -132,8 +132,8 @@ static esp_ble_adv_data_t scan_rsp_data = { #endif /* CONFIG_SET_RAW_ADV_DATA */ static esp_ble_adv_params_t adv_params = { - .adv_int_min = 0x40, - .adv_int_max = 0x40, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(40), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(40), .adv_type = ADV_TYPE_IND, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .channel_map = ADV_CHNL_ALL, diff --git a/examples/bluetooth/bluedroid/ble/ble_eddystone_receiver/main/esp_eddystone_demo.c b/examples/bluetooth/bluedroid/ble/ble_eddystone_receiver/main/esp_eddystone_demo.c index bca42f31a9..d7d705d022 100644 --- a/examples/bluetooth/bluedroid/ble/ble_eddystone_receiver/main/esp_eddystone_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_eddystone_receiver/main/esp_eddystone_demo.c @@ -39,8 +39,8 @@ static esp_ble_scan_params_t ble_scan_params = { .scan_type = BLE_SCAN_TYPE_ACTIVE, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, - .scan_interval = 0x50, - .scan_window = 0x30, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(50), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(30), .scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE }; diff --git a/examples/bluetooth/bluedroid/ble/ble_eddystone_sender/main/esp_eddystone_demo.c b/examples/bluetooth/bluedroid/ble/ble_eddystone_sender/main/esp_eddystone_demo.c index ffb6ec83b5..973dbe36d7 100644 --- a/examples/bluetooth/bluedroid/ble/ble_eddystone_sender/main/esp_eddystone_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_eddystone_sender/main/esp_eddystone_demo.c @@ -36,8 +36,8 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t* par static void eddystone_send_raw(const esp_eddystone_result_t *res); static esp_ble_adv_params_t adv_params = { - .adv_int_min = 0x20, - .adv_int_max = 0x40, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(40), .adv_type = ADV_TYPE_IND, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .channel_map = ADV_CHNL_ALL, diff --git a/examples/bluetooth/bluedroid/ble/ble_hid_device_demo/main/ble_hidd_demo_main.c b/examples/bluetooth/bluedroid/ble/ble_hid_device_demo/main/ble_hidd_demo_main.c index becac7e405..375aa58446 100644 --- a/examples/bluetooth/bluedroid/ble/ble_hid_device_demo/main/ble_hidd_demo_main.c +++ b/examples/bluetooth/bluedroid/ble/ble_hid_device_demo/main/ble_hidd_demo_main.c @@ -67,8 +67,8 @@ static esp_ble_adv_data_t hidd_adv_data = { .set_scan_rsp = false, .include_name = true, .include_txpower = true, - .min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec - .max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec + .min_interval = ESP_BLE_GAP_CONN_ITVL_MS(7.5), //slave connection min interval + .max_interval = ESP_BLE_GAP_CONN_ITVL_MS(20), //slave connection max interval .appearance = 0x03c0, //HID Generic, .manufacturer_len = 0, .p_manufacturer_data = NULL, @@ -80,8 +80,8 @@ static esp_ble_adv_data_t hidd_adv_data = { }; static esp_ble_adv_params_t hidd_adv_params = { - .adv_int_min = 0x20, - .adv_int_max = 0x30, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(30), .adv_type = ADV_TYPE_IND, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, //.peer_addr = diff --git a/examples/bluetooth/bluedroid/ble/ble_ibeacon/main/ibeacon_demo.c b/examples/bluetooth/bluedroid/ble/ble_ibeacon/main/ibeacon_demo.c index ae5c672bcd..101302fdc0 100644 --- a/examples/bluetooth/bluedroid/ble/ble_ibeacon/main/ibeacon_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_ibeacon/main/ibeacon_demo.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -43,15 +43,15 @@ static esp_ble_scan_params_t ble_scan_params = { .scan_type = BLE_SCAN_TYPE_ACTIVE, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, - .scan_interval = 0x50, - .scan_window = 0x30, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(50), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(30), .scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE }; #elif (IBEACON_MODE == IBEACON_SENDER) static esp_ble_adv_params_t ble_adv_params = { - .adv_int_min = 0x20, - .adv_int_max = 0x40, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(40), .adv_type = ADV_TYPE_NONCONN_IND, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .channel_map = ADV_CHNL_ALL, diff --git a/examples/bluetooth/bluedroid/ble/ble_multi_conn/ble_multi_conn_cent/main/ble_multiconn_cent_demo.c b/examples/bluetooth/bluedroid/ble/ble_multi_conn/ble_multi_conn_cent/main/ble_multiconn_cent_demo.c index 6c669108c5..28d67e64b5 100644 --- a/examples/bluetooth/bluedroid/ble/ble_multi_conn/ble_multi_conn_cent/main/ble_multiconn_cent_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_multi_conn/ble_multi_conn_cent/main/ble_multiconn_cent_demo.c @@ -101,7 +101,7 @@ const static esp_ble_conn_params_t phy_1m_conn_params = { .interval_min = BLE_PREF_CONN_ITVL_MS * 1000 / 1250, .interval_max = BLE_PREF_CONN_ITVL_MS * 1000 / 1250, .latency = 0, - .supervision_timeout = 600, + .supervision_timeout = ESP_BLE_GAP_SUPERVISION_TIMEOUT_MS(6000), .min_ce_len = BLE_PREF_CE_LEN, .max_ce_len = BLE_PREF_CE_LEN, }; @@ -113,7 +113,7 @@ const static esp_ble_conn_params_t phy_2m_conn_params = { .interval_min = BLE_PREF_CONN_ITVL_MS * 1000 / 1250, .interval_max = BLE_PREF_CONN_ITVL_MS * 1000 / 1250, .latency = 0, - .supervision_timeout = 600, + .supervision_timeout = ESP_BLE_GAP_SUPERVISION_TIMEOUT_MS(6000), .min_ce_len = BLE_PREF_CE_LEN, .max_ce_len = BLE_PREF_CE_LEN, }; @@ -124,7 +124,7 @@ const static esp_ble_conn_params_t phy_coded_conn_params = { .interval_min = BLE_PREF_CONN_ITVL_MS * 1000 / 1250, .interval_max = BLE_PREF_CONN_ITVL_MS * 1000 / 1250, .latency = 0, - .supervision_timeout = 600, + .supervision_timeout = ESP_BLE_GAP_SUPERVISION_TIMEOUT_MS(6000), .min_ce_len = BLE_PREF_CE_LEN, .max_ce_len = BLE_PREF_CE_LEN, }; @@ -160,8 +160,8 @@ struct gatts_profile_inst #if (BLE50_SUPPORTED == 0) esp_ble_adv_params_t legacy_adv_params = { - .adv_int_min = 0x20, - .adv_int_max = 0x20, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(20), .adv_type = ADV_TYPE_IND, .own_addr_type = BLE_ADDR_TYPE_RANDOM, .channel_map = ADV_CHNL_ALL, @@ -171,8 +171,8 @@ esp_ble_adv_params_t legacy_adv_params = { #else esp_ble_gap_ext_adv_params_t ext_adv_params = { .type = ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE, - .interval_min = 0x20, - .interval_max = 0x20, + .interval_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .interval_max = ESP_BLE_GAP_ADV_ITVL_MS(20), .channel_map = ADV_CHNL_ALL, .filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, .primary_phy = ESP_BLE_GAP_PHY_1M, diff --git a/examples/bluetooth/bluedroid/ble/ble_multi_conn/ble_multi_conn_prph/main/ble_multiconn_prph_demo.c b/examples/bluetooth/bluedroid/ble/ble_multi_conn/ble_multi_conn_prph/main/ble_multiconn_prph_demo.c index 8f2b2c0ede..b1131432bf 100644 --- a/examples/bluetooth/bluedroid/ble/ble_multi_conn/ble_multi_conn_prph/main/ble_multiconn_prph_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_multi_conn/ble_multi_conn_prph/main/ble_multiconn_prph_demo.c @@ -68,8 +68,8 @@ static esp_ble_gap_ext_adv_t ext_adv[1] = { esp_ble_gap_ext_adv_params_t ext_adv_params = { .type = ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE, - .interval_min = 0x20, - .interval_max = 0x20, + .interval_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .interval_max = ESP_BLE_GAP_ADV_ITVL_MS(20), .channel_map = ADV_CHNL_ALL, .filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, .primary_phy = ESP_BLE_GAP_PHY_1M, @@ -82,8 +82,8 @@ esp_ble_gap_ext_adv_params_t ext_adv_params = { }; #else static esp_ble_adv_params_t legacy_adv_params = { - .adv_int_min = 0x20, - .adv_int_max = 0x40, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(40), .adv_type = ADV_TYPE_IND, .own_addr_type = BLE_ADDR_TYPE_RANDOM, .channel_map = ADV_CHNL_ALL, diff --git a/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c b/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c index 8b14b35e1d..a7c3917d09 100644 --- a/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_spp_client/main/spp_client_demo.c @@ -89,8 +89,8 @@ static esp_ble_scan_params_t ble_scan_params = { .scan_type = BLE_SCAN_TYPE_ACTIVE, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, - .scan_interval = 0x50, - .scan_window = 0x30, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(50), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(30), .scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE }; @@ -255,7 +255,7 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par phy_1m_conn_params.interval_max = 32; phy_1m_conn_params.interval_min = 32; phy_1m_conn_params.latency = 0; - phy_1m_conn_params.supervision_timeout = 600; + phy_1m_conn_params.supervision_timeout = ESP_BLE_GAP_SUPERVISION_TIMEOUT_MS(6000); esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(&creat_conn_params.remote_bda, scan_result->scan_rst.bda,ESP_BD_ADDR_LEN); creat_conn_params.remote_addr_type = scan_result->scan_rst.ble_addr_type; diff --git a/examples/bluetooth/bluedroid/ble/ble_spp_server/main/ble_spp_server_demo.c b/examples/bluetooth/bluedroid/ble/ble_spp_server/main/ble_spp_server_demo.c index ebbe1d52a2..054148d6a1 100644 --- a/examples/bluetooth/bluedroid/ble/ble_spp_server/main/ble_spp_server_demo.c +++ b/examples/bluetooth/bluedroid/ble/ble_spp_server/main/ble_spp_server_demo.c @@ -79,8 +79,8 @@ static esp_bd_addr_t spp_remote_bda = {0x0,}; static uint16_t spp_handle_table[SPP_IDX_NB]; static esp_ble_adv_params_t spp_adv_params = { - .adv_int_min = 0x20, - .adv_int_max = 0x40, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(40), .adv_type = ADV_TYPE_IND, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .channel_map = ADV_CHNL_ALL, diff --git a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c index c367969fc2..05f4ba02e7 100644 --- a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c +++ b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_client/main/example_ble_client_throughput.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -95,8 +95,8 @@ static esp_ble_scan_params_t ble_scan_params = { .scan_type = BLE_SCAN_TYPE_ACTIVE, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, - .scan_interval = 0x50, - .scan_window = 0x30, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(50), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(30), .scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE }; @@ -412,7 +412,7 @@ static void esp_gap_cb(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *par phy_1m_conn_params.interval_min = 32; #endif phy_1m_conn_params.latency = 0; - phy_1m_conn_params.supervision_timeout = 600; + phy_1m_conn_params.supervision_timeout = ESP_BLE_GAP_SUPERVISION_TIMEOUT_MS(6000); esp_ble_gatt_creat_conn_params_t creat_conn_params = {0}; memcpy(&creat_conn_params.remote_bda, scan_result->scan_rst.bda, ESP_BD_ADDR_LEN); diff --git a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c index 391feb4f29..0f945ad372 100644 --- a/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c +++ b/examples/bluetooth/bluedroid/ble/ble_throughput/throughput_server/main/example_ble_server_throughput.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -127,8 +127,8 @@ static esp_ble_adv_data_t adv_data = { .set_scan_rsp = false, .include_name = true, .include_txpower = true, - .min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec - .max_interval = 0x000C, //slave connection max interval, Time = max_interval * 1.25 msec + .min_interval = ESP_BLE_GAP_CONN_ITVL_MS(7.5), //slave connection min interval + .max_interval = ESP_BLE_GAP_CONN_ITVL_MS(15), //slave connection max interval .appearance = 0x00, .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN, .p_manufacturer_data = NULL, //&test_manufacturer[0], @@ -143,8 +143,8 @@ static esp_ble_adv_data_t scan_rsp_data = { .set_scan_rsp = true, .include_name = true, .include_txpower = true, - .min_interval = 0x0006, - .max_interval = 0x000C, + .min_interval = ESP_BLE_GAP_CONN_ITVL_MS(7.5), + .max_interval = ESP_BLE_GAP_CONN_ITVL_MS(15), .appearance = 0x00, .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN, .p_manufacturer_data = NULL, //&test_manufacturer[0], @@ -158,8 +158,8 @@ static esp_ble_adv_data_t scan_rsp_data = { #endif /* CONFIG_EXAMPLE_SET_RAW_ADV_DATA */ static esp_ble_adv_params_t adv_params = { - .adv_int_min = 0x20, - .adv_int_max = 0x40, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(40), .adv_type = ADV_TYPE_IND, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, //.peer_addr = diff --git a/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c b/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c index 50c9df5cd2..66c93787fe 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_client/main/gattc_demo.c @@ -72,8 +72,8 @@ static esp_ble_scan_params_t ble_scan_params = { .scan_type = BLE_SCAN_TYPE_ACTIVE, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, - .scan_interval = 0x50, - .scan_window = 0x30, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(50), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(30), .scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE }; diff --git a/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c b/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c index 28e6774c53..0c6954d7fc 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_security_client/main/example_ble_sec_gattc_demo.c @@ -57,8 +57,8 @@ static esp_ble_scan_params_t ble_scan_params = { .scan_type = BLE_SCAN_TYPE_ACTIVE, .own_addr_type = BLE_ADDR_TYPE_RPA_PUBLIC, .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, - .scan_interval = 0x50, - .scan_window = 0x30, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(50), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(30), .scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE }; diff --git a/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c b/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c index 8d259d9a52..ff7e262b27 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_security_server/main/example_ble_sec_gatts_demo.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -49,8 +49,8 @@ static uint8_t sec_service_uuid[16] = { static esp_ble_adv_data_t heart_rate_adv_config = { .set_scan_rsp = false, .include_txpower = true, - .min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec - .max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec + .min_interval = ESP_BLE_GAP_CONN_ITVL_MS(7.5), //slave connection min interval + .max_interval = ESP_BLE_GAP_CONN_ITVL_MS(20), //slave connection max interval .appearance = 0x00, .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN, .p_manufacturer_data = NULL, //&test_manufacturer[0], @@ -69,8 +69,8 @@ static esp_ble_adv_data_t heart_rate_scan_rsp_config = { }; static esp_ble_adv_params_t heart_rate_adv_params = { - .adv_int_min = 0x100, - .adv_int_max = 0x100, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(160), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(160), .adv_type = ADV_TYPE_IND, .own_addr_type = BLE_ADDR_TYPE_RPA_PUBLIC, .channel_map = ADV_CHNL_ALL, diff --git a/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c b/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c index 60fc5a94de..0d6acead7b 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_server/main/gatts_demo.c @@ -118,8 +118,8 @@ static esp_ble_adv_data_t adv_data = { .set_scan_rsp = false, .include_name = true, .include_txpower = false, - .min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec - .max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec + .min_interval = ESP_BLE_GAP_CONN_ITVL_MS(7.5), //slave connection min interval + .max_interval = ESP_BLE_GAP_CONN_ITVL_MS(20), //slave connection max interval .appearance = 0x00, .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN, .p_manufacturer_data = NULL, //&test_manufacturer[0], @@ -149,8 +149,8 @@ static esp_ble_adv_data_t scan_rsp_data = { #endif /* CONFIG_SET_RAW_ADV_DATA */ static esp_ble_adv_params_t adv_params = { - .adv_int_min = 0x20, - .adv_int_max = 0x40, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(40), .adv_type = ADV_TYPE_IND, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, //.peer_addr = diff --git a/examples/bluetooth/bluedroid/ble/gatt_server_service_table/main/gatts_table_creat_demo.c b/examples/bluetooth/bluedroid/ble/gatt_server_service_table/main/gatts_table_creat_demo.c index 650d716cdf..7dfc803ae3 100644 --- a/examples/bluetooth/bluedroid/ble/gatt_server_service_table/main/gatts_table_creat_demo.c +++ b/examples/bluetooth/bluedroid/ble/gatt_server_service_table/main/gatts_table_creat_demo.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -94,8 +94,8 @@ static esp_ble_adv_data_t adv_data = { .set_scan_rsp = false, .include_name = true, .include_txpower = true, - .min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec - .max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec + .min_interval = ESP_BLE_GAP_CONN_ITVL_MS(7.5), //slave connection min interval + .max_interval = ESP_BLE_GAP_CONN_ITVL_MS(20), //slave connection max interval .appearance = 0x00, .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN, .p_manufacturer_data = NULL, //test_manufacturer, @@ -111,8 +111,8 @@ static esp_ble_adv_data_t scan_rsp_data = { .set_scan_rsp = true, .include_name = true, .include_txpower = true, - .min_interval = 0x0006, - .max_interval = 0x0010, + .min_interval = ESP_BLE_GAP_CONN_ITVL_MS(7.5), + .max_interval = ESP_BLE_GAP_CONN_ITVL_MS(20), .appearance = 0x00, .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN, .p_manufacturer_data = NULL, //&test_manufacturer[0], @@ -125,8 +125,8 @@ static esp_ble_adv_data_t scan_rsp_data = { #endif /* CONFIG_SET_RAW_ADV_DATA */ static esp_ble_adv_params_t adv_params = { - .adv_int_min = 0x20, - .adv_int_max = 0x40, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(40), .adv_type = ADV_TYPE_IND, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .channel_map = ADV_CHNL_ALL, diff --git a/examples/bluetooth/bluedroid/ble/gattc_multi_connect/main/gattc_multi_connect.c b/examples/bluetooth/bluedroid/ble/gattc_multi_connect/main/gattc_multi_connect.c index 28920bd988..f747e25e94 100644 --- a/examples/bluetooth/bluedroid/ble/gattc_multi_connect/main/gattc_multi_connect.c +++ b/examples/bluetooth/bluedroid/ble/gattc_multi_connect/main/gattc_multi_connect.c @@ -92,8 +92,8 @@ static esp_ble_scan_params_t ble_scan_params = { .scan_type = BLE_SCAN_TYPE_ACTIVE, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, - .scan_interval = 0x50, - .scan_window = 0x30, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(50), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(30), .scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE }; diff --git a/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/ble50_sec_gattc_demo.c b/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/ble50_sec_gattc_demo.c index 286286138f..2dbcecf529 100644 --- a/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/ble50_sec_gattc_demo.c +++ b/examples/bluetooth/bluedroid/ble_50/ble50_security_client/main/ble50_sec_gattc_demo.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -66,32 +66,32 @@ static esp_ble_ext_scan_params_t ext_scan_params = { }; const esp_ble_conn_params_t phy_1m_conn_params = { - .scan_interval = 0x40, - .scan_window = 0x40, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(40), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(40), .interval_min = 320, .interval_max = 320, .latency = 0, - .supervision_timeout = 600, + .supervision_timeout = ESP_BLE_GAP_SUPERVISION_TIMEOUT_MS(6000), .min_ce_len = 0, .max_ce_len = 0, }; const esp_ble_conn_params_t phy_2m_conn_params = { - .scan_interval = 0x40, - .scan_window = 0x40, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(40), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(40), .interval_min = 320, .interval_max = 320, .latency = 0, - .supervision_timeout = 600, + .supervision_timeout = ESP_BLE_GAP_SUPERVISION_TIMEOUT_MS(6000), .min_ce_len = 0, .max_ce_len = 0, }; const esp_ble_conn_params_t phy_coded_conn_params = { - .scan_interval = 0x40, - .scan_window = 0x40, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(40), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(40), .interval_min = 320, // 306-> 362Kbps .interval_max = 320, .latency = 0, - .supervision_timeout = 600, + .supervision_timeout = ESP_BLE_GAP_SUPERVISION_TIMEOUT_MS(6000), .min_ce_len = 0, .max_ce_len = 0, }; diff --git a/examples/bluetooth/bluedroid/ble_50/ble50_security_server/main/ble50_sec_gatts_demo.c b/examples/bluetooth/bluedroid/ble_50/ble50_security_server/main/ble50_sec_gatts_demo.c index 3e7a3a452f..07d32df681 100644 --- a/examples/bluetooth/bluedroid/ble_50/ble50_security_server/main/ble50_sec_gatts_demo.c +++ b/examples/bluetooth/bluedroid/ble_50/ble50_security_server/main/ble50_sec_gatts_demo.c @@ -52,8 +52,8 @@ static esp_ble_gap_ext_adv_t ext_adv[1] = { esp_ble_gap_ext_adv_params_t ext_adv_params_2M = { .type = ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE, - .interval_min = 0x20, - .interval_max = 0x20, + .interval_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .interval_max = ESP_BLE_GAP_ADV_ITVL_MS(20), .channel_map = ADV_CHNL_ALL, .filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, .primary_phy = ESP_BLE_GAP_PHY_1M, diff --git a/examples/bluetooth/bluedroid/ble_50/ble50_throughput/throughput_client/main/example_ble_client_throughput.c b/examples/bluetooth/bluedroid/ble_50/ble50_throughput/throughput_client/main/example_ble_client_throughput.c index c0d7ae3a08..d316ba59a0 100644 --- a/examples/bluetooth/bluedroid/ble_50/ble50_throughput/throughput_client/main/example_ble_client_throughput.c +++ b/examples/bluetooth/bluedroid/ble_50/ble50_throughput/throughput_client/main/example_ble_client_throughput.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -110,9 +110,9 @@ const esp_ble_conn_params_t phy_1m_conn_params = { .latency = 0, .max_ce_len = 0, .min_ce_len = 0, - .scan_interval = 0x40, - .scan_window = 0x40, - .supervision_timeout = 600, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(40), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(40), + .supervision_timeout = ESP_BLE_GAP_SUPERVISION_TIMEOUT_MS(6000), }; const esp_ble_conn_params_t phy_2m_conn_params = { @@ -121,9 +121,9 @@ const esp_ble_conn_params_t phy_2m_conn_params = { .latency = 0, .max_ce_len = 0, .min_ce_len = 0, - .scan_interval = 0x40, - .scan_window = 0x40, - .supervision_timeout = 600, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(40), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(40), + .supervision_timeout = ESP_BLE_GAP_SUPERVISION_TIMEOUT_MS(6000), }; const esp_ble_conn_params_t phy_coded_conn_params = { @@ -132,9 +132,9 @@ const esp_ble_conn_params_t phy_coded_conn_params = { .latency = 0, .max_ce_len = 0, .min_ce_len = 0, - .scan_interval = 0x40, - .scan_window = 0x40, - .supervision_timeout = 600, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(40), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(40), + .supervision_timeout = ESP_BLE_GAP_SUPERVISION_TIMEOUT_MS(6000), }; struct gattc_profile_inst { diff --git a/examples/bluetooth/bluedroid/ble_50/ble50_throughput/throughput_server/main/example_ble_server_throughput.c b/examples/bluetooth/bluedroid/ble_50/ble50_throughput/throughput_server/main/example_ble_server_throughput.c index 057229fffb..4cbca419f0 100644 --- a/examples/bluetooth/bluedroid/ble_50/ble50_throughput/throughput_server/main/example_ble_server_throughput.c +++ b/examples/bluetooth/bluedroid/ble_50/ble50_throughput/throughput_server/main/example_ble_server_throughput.c @@ -112,8 +112,8 @@ static esp_ble_gap_ext_adv_t ext_adv[1] = { esp_ble_gap_ext_adv_params_t ext_adv_params = { .type = ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE, - .interval_min = 0x20, - .interval_max = 0x20, + .interval_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .interval_max = ESP_BLE_GAP_ADV_ITVL_MS(20), .channel_map = ADV_CHNL_ALL, .filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, .primary_phy = ESP_BLE_GAP_PHY_1M, diff --git a/examples/bluetooth/bluedroid/ble_50/multi-adv/main/multi_adv_demo.c b/examples/bluetooth/bluedroid/ble_50/multi-adv/main/multi_adv_demo.c index f3413a8232..f8bfc012db 100644 --- a/examples/bluetooth/bluedroid/ble_50/multi-adv/main/multi_adv_demo.c +++ b/examples/bluetooth/bluedroid/ble_50/multi-adv/main/multi_adv_demo.c @@ -49,8 +49,8 @@ static SemaphoreHandle_t test_sem = NULL; esp_ble_gap_ext_adv_params_t ext_adv_params_1M = { .type = ESP_BLE_GAP_SET_EXT_ADV_PROP_CONNECTABLE, - .interval_min = 0x30, - .interval_max = 0x30, + .interval_min = ESP_BLE_GAP_ADV_ITVL_MS(30), + .interval_max = ESP_BLE_GAP_ADV_ITVL_MS(30), .channel_map = ADV_CHNL_ALL, .filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, .primary_phy = ESP_BLE_GAP_PHY_1M, @@ -64,8 +64,8 @@ esp_ble_gap_ext_adv_params_t ext_adv_params_1M = { esp_ble_gap_ext_adv_params_t ext_adv_params_2M = { .type = ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE, - .interval_min = 0x40, - .interval_max = 0x40, + .interval_min = ESP_BLE_GAP_ADV_ITVL_MS(40), + .interval_max = ESP_BLE_GAP_ADV_ITVL_MS(40), .channel_map = ADV_CHNL_ALL, .filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, .primary_phy = ESP_BLE_GAP_PHY_1M, @@ -79,8 +79,8 @@ esp_ble_gap_ext_adv_params_t ext_adv_params_2M = { esp_ble_gap_ext_adv_params_t legacy_adv_params = { .type = ESP_BLE_GAP_SET_EXT_ADV_PROP_LEGACY_IND, - .interval_min = 0x45, - .interval_max = 0x45, + .interval_min = ESP_BLE_GAP_ADV_ITVL_MS(43), + .interval_max = ESP_BLE_GAP_ADV_ITVL_MS(43), .channel_map = ADV_CHNL_ALL, .filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, .primary_phy = ESP_BLE_GAP_PHY_1M, @@ -94,8 +94,8 @@ esp_ble_gap_ext_adv_params_t legacy_adv_params = { esp_ble_gap_ext_adv_params_t ext_adv_params_coded = { .type = ESP_BLE_GAP_SET_EXT_ADV_PROP_SCANNABLE, - .interval_min = 0x50, - .interval_max = 0x50, + .interval_min = ESP_BLE_GAP_ADV_ITVL_MS(50), + .interval_max = ESP_BLE_GAP_ADV_ITVL_MS(50), .channel_map = ADV_CHNL_ALL, .filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, .primary_phy = ESP_BLE_GAP_PHY_1M, diff --git a/examples/bluetooth/bluedroid/ble_50/periodic_adv/main/periodic_adv_demo.c b/examples/bluetooth/bluedroid/ble_50/periodic_adv/main/periodic_adv_demo.c index abaeb219d8..9c9cffb8ca 100644 --- a/examples/bluetooth/bluedroid/ble_50/periodic_adv/main/periodic_adv_demo.c +++ b/examples/bluetooth/bluedroid/ble_50/periodic_adv/main/periodic_adv_demo.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -58,8 +58,8 @@ static SemaphoreHandle_t test_sem = NULL; esp_ble_gap_ext_adv_params_t ext_adv_params_2M = { .type = ESP_BLE_GAP_SET_EXT_ADV_PROP_NONCONN_NONSCANNABLE_UNDIRECTED, - .interval_min = 0x30, - .interval_max = 0x30, + .interval_min = ESP_BLE_GAP_ADV_ITVL_MS(30), + .interval_max = ESP_BLE_GAP_ADV_ITVL_MS(30), .channel_map = ADV_CHNL_ALL, .filter_policy = ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY, .primary_phy = ESP_BLE_GAP_PHY_1M, @@ -72,8 +72,8 @@ esp_ble_gap_ext_adv_params_t ext_adv_params_2M = { }; static esp_ble_gap_periodic_adv_params_t periodic_adv_params = { - .interval_min = 0x40, // 80 ms interval - .interval_max = 0x40, + .interval_min = ESP_BLE_GAP_PERIODIC_ADV_ITVL_MS(80), + .interval_max = ESP_BLE_GAP_PERIODIC_ADV_ITVL_MS(80), .properties = 0, // Do not include TX power }; diff --git a/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/main.c b/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/main.c index 348f429af8..4b9288eedb 100644 --- a/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/main.c +++ b/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/main.c @@ -98,8 +98,8 @@ esp_attr_value_t gatts_initial_char_val = { }; static esp_ble_adv_params_t adv_params = { - .adv_int_min = 0x060, - .adv_int_max = 0x060, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(60), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(60), .adv_type = ADV_TYPE_IND, .own_addr_type = BLE_ADDR_TYPE_RPA_PUBLIC, .channel_map = ADV_CHNL_ALL, diff --git a/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c b/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c index 269069f4a3..1b4d3cfe4c 100644 --- a/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c +++ b/examples/bluetooth/bluedroid/coex/gattc_gatts_coex/main/gattc_gatts_coex.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -145,8 +145,8 @@ static esp_ble_adv_data_t adv_data = { .set_scan_rsp = false, .include_name = true, .include_txpower = true, - .min_interval = 0x20, - .max_interval = 0x40, + .min_interval = ESP_BLE_GAP_CONN_ITVL_MS(40), + .max_interval = ESP_BLE_GAP_CONN_ITVL_MS(80), .appearance = 0x00, .manufacturer_len = 0, .p_manufacturer_data = NULL, @@ -162,8 +162,8 @@ static esp_ble_adv_data_t scan_rsp_data = { .set_scan_rsp = true, .include_name = true, .include_txpower = true, - .min_interval = 0x0006, - .max_interval = 0x0010, + .min_interval = ESP_BLE_GAP_CONN_ITVL_MS(7.5), + .max_interval = ESP_BLE_GAP_CONN_ITVL_MS(20), .appearance = 0x00, .manufacturer_len = 0, .p_manufacturer_data = NULL, @@ -176,8 +176,8 @@ static esp_ble_adv_data_t scan_rsp_data = { #endif /* CONFIG_SET_RAW_ADV_DATA */ static esp_ble_adv_params_t adv_params = { - .adv_int_min = 0x20, - .adv_int_max = 0x40, + .adv_int_min = ESP_BLE_GAP_ADV_ITVL_MS(20), + .adv_int_max = ESP_BLE_GAP_ADV_ITVL_MS(40), .adv_type = ADV_TYPE_IND, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .channel_map = ADV_CHNL_ALL, @@ -215,8 +215,8 @@ static esp_ble_scan_params_t ble_scan_params = { .scan_type = BLE_SCAN_TYPE_ACTIVE, .own_addr_type = BLE_ADDR_TYPE_PUBLIC, .scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL, - .scan_interval = 0x50, - .scan_window = 0x30, + .scan_interval = ESP_BLE_GAP_SCAN_ITVL_MS(50), + .scan_window = ESP_BLE_GAP_SCAN_WIN_MS(30), .scan_duplicate = BLE_SCAN_DUPLICATE_DISABLE };