mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Component/bt: fix connection interval error in slave adv params
This commit is contained in:
parent
fda865b002
commit
fe7fd3bf4d
@ -296,8 +296,21 @@ typedef struct {
|
|||||||
bool set_scan_rsp; /*!< Set this advertising data as scan response or not*/
|
bool set_scan_rsp; /*!< Set this advertising data as scan response or not*/
|
||||||
bool include_name; /*!< Advertising data include device name or not */
|
bool include_name; /*!< Advertising data include device name or not */
|
||||||
bool include_txpower; /*!< Advertising data include TX power */
|
bool include_txpower; /*!< Advertising data include TX power */
|
||||||
int min_interval; /*!< Advertising data show advertising min interval */
|
int min_interval; /*!< Advertising data show slave preferred connection min interval.
|
||||||
int max_interval; /*!< Advertising data show advertising max interval */
|
The connection interval in the following manner:
|
||||||
|
connIntervalmin = Conn_Interval_Min * 1.25 ms
|
||||||
|
Conn_Interval_Min range: 0x0006 to 0x0C80
|
||||||
|
Value of 0xFFFF indicates no specific minimum.
|
||||||
|
Values not defined above are reserved for future use.*/
|
||||||
|
|
||||||
|
int max_interval; /*!< Advertising data show slave preferred connection max interval.
|
||||||
|
The connection interval in the following manner:
|
||||||
|
connIntervalmax = Conn_Interval_Max * 1.25 ms
|
||||||
|
Conn_Interval_Max range: 0x0006 to 0x0C80
|
||||||
|
Conn_Interval_Max shall be equal to or greater than the Conn_Interval_Min.
|
||||||
|
Value of 0xFFFF indicates no specific maximum.
|
||||||
|
Values not defined above are reserved for future use.*/
|
||||||
|
|
||||||
int appearance; /*!< External appearance of device */
|
int appearance; /*!< External appearance of device */
|
||||||
uint16_t manufacturer_len; /*!< Manufacturer data length */
|
uint16_t manufacturer_len; /*!< Manufacturer data length */
|
||||||
uint8_t *p_manufacturer_data; /*!< Manufacturer data point */
|
uint8_t *p_manufacturer_data; /*!< Manufacturer data point */
|
||||||
|
@ -74,8 +74,8 @@ static esp_ble_adv_data_t hidd_adv_data = {
|
|||||||
.set_scan_rsp = false,
|
.set_scan_rsp = false,
|
||||||
.include_name = true,
|
.include_name = true,
|
||||||
.include_txpower = true,
|
.include_txpower = true,
|
||||||
.min_interval = 0x20,
|
.min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
|
||||||
.max_interval = 0x30,
|
.max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec
|
||||||
.appearance = 0x03c0, //HID Generic,
|
.appearance = 0x03c0, //HID Generic,
|
||||||
.manufacturer_len = 0,
|
.manufacturer_len = 0,
|
||||||
.p_manufacturer_data = NULL,
|
.p_manufacturer_data = NULL,
|
||||||
|
@ -109,8 +109,8 @@ static esp_ble_adv_data_t adv_data = {
|
|||||||
.set_scan_rsp = false,
|
.set_scan_rsp = false,
|
||||||
.include_name = true,
|
.include_name = true,
|
||||||
.include_txpower = true,
|
.include_txpower = true,
|
||||||
.min_interval = 0x20,
|
.min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
|
||||||
.max_interval = 0x40,
|
.max_interval = 0x000C, //slave connection max interval, Time = max_interval * 1.25 msec
|
||||||
.appearance = 0x00,
|
.appearance = 0x00,
|
||||||
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
||||||
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
||||||
@ -125,8 +125,8 @@ static esp_ble_adv_data_t scan_rsp_data = {
|
|||||||
.set_scan_rsp = true,
|
.set_scan_rsp = true,
|
||||||
.include_name = true,
|
.include_name = true,
|
||||||
.include_txpower = true,
|
.include_txpower = true,
|
||||||
.min_interval = 0x20,
|
.min_interval = 0x0006,
|
||||||
.max_interval = 0x40,
|
.max_interval = 0x000C,
|
||||||
.appearance = 0x00,
|
.appearance = 0x00,
|
||||||
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
||||||
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
||||||
|
@ -48,8 +48,8 @@ static esp_ble_adv_data_t example_adv_data = {
|
|||||||
.set_scan_rsp = false,
|
.set_scan_rsp = false,
|
||||||
.include_name = true,
|
.include_name = true,
|
||||||
.include_txpower = true,
|
.include_txpower = true,
|
||||||
.min_interval = 0x100,
|
.min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
|
||||||
.max_interval = 0x100,
|
.max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec
|
||||||
.appearance = 0x00,
|
.appearance = 0x00,
|
||||||
.manufacturer_len = 0,
|
.manufacturer_len = 0,
|
||||||
.p_manufacturer_data = NULL,
|
.p_manufacturer_data = NULL,
|
||||||
|
@ -58,8 +58,8 @@ static uint8_t sec_service_uuid[16] = {
|
|||||||
static esp_ble_adv_data_t heart_rate_adv_config = {
|
static esp_ble_adv_data_t heart_rate_adv_config = {
|
||||||
.set_scan_rsp = false,
|
.set_scan_rsp = false,
|
||||||
.include_txpower = true,
|
.include_txpower = true,
|
||||||
.min_interval = 0x100,
|
.min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
|
||||||
.max_interval = 0x100,
|
.max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec
|
||||||
.appearance = 0x00,
|
.appearance = 0x00,
|
||||||
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
||||||
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
||||||
|
@ -100,8 +100,8 @@ static esp_ble_adv_data_t adv_data = {
|
|||||||
.set_scan_rsp = false,
|
.set_scan_rsp = false,
|
||||||
.include_name = true,
|
.include_name = true,
|
||||||
.include_txpower = true,
|
.include_txpower = true,
|
||||||
.min_interval = 0x20,
|
.min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
|
||||||
.max_interval = 0x40,
|
.max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec
|
||||||
.appearance = 0x00,
|
.appearance = 0x00,
|
||||||
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
||||||
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
||||||
@ -116,8 +116,8 @@ static esp_ble_adv_data_t scan_rsp_data = {
|
|||||||
.set_scan_rsp = true,
|
.set_scan_rsp = true,
|
||||||
.include_name = true,
|
.include_name = true,
|
||||||
.include_txpower = true,
|
.include_txpower = true,
|
||||||
.min_interval = 0x20,
|
.min_interval = 0x0006,
|
||||||
.max_interval = 0x40,
|
.max_interval = 0x0010,
|
||||||
.appearance = 0x00,
|
.appearance = 0x00,
|
||||||
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
||||||
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
||||||
|
@ -214,8 +214,8 @@ typedef struct {
|
|||||||
bool set_scan_rsp; /*!< Set this advertising data as scan response or not*/
|
bool set_scan_rsp; /*!< Set this advertising data as scan response or not*/
|
||||||
bool include_name; /*!< Advertising data include device name or not */
|
bool include_name; /*!< Advertising data include device name or not */
|
||||||
bool include_txpower; /*!< Advertising data include TX power */
|
bool include_txpower; /*!< Advertising data include TX power */
|
||||||
int min_interval; /*!< Advertising data show advertising min interval */
|
int min_interval; /*!< Advertising data show slave preferred connection min interval */
|
||||||
int max_interval; /*!< Advertising data show advertising max interval */
|
int max_interval; /*!< Advertising data show slave preferred connection max interval */
|
||||||
int appearance; /*!< External appearance of device */
|
int appearance; /*!< External appearance of device */
|
||||||
uint16_t manufacturer_len; /*!< Manufacturer data length */
|
uint16_t manufacturer_len; /*!< Manufacturer data length */
|
||||||
uint8_t *p_manufacturer_data; /*!< Manufacturer data point */
|
uint8_t *p_manufacturer_data; /*!< Manufacturer data point */
|
||||||
@ -233,8 +233,8 @@ static esp_ble_adv_data_t adv_data = {
|
|||||||
.set_scan_rsp = false,
|
.set_scan_rsp = false,
|
||||||
.include_name = true,
|
.include_name = true,
|
||||||
.include_txpower = true,
|
.include_txpower = true,
|
||||||
.min_interval = 0x20,
|
.min_interval = 0x0006,
|
||||||
.max_interval = 0x40,
|
.max_interval = 0x0010,
|
||||||
.appearance = 0x00,
|
.appearance = 0x00,
|
||||||
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
||||||
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
||||||
@ -245,7 +245,7 @@ static esp_ble_adv_data_t adv_data = {
|
|||||||
.flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
|
.flag = (ESP_BLE_ADV_FLAG_GEN_DISC | ESP_BLE_ADV_FLAG_BREDR_NOT_SPT),
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
The minimum and maximum advertisement intervals are set as multiples of 1.25 ms. In this example, the minimum advertisement interval is defined as 0x20 * 1.25 ms = 40 ms, and the maximum advertisement interval is initialized as 0x40 * 1.25 ms = 80 ms.
|
The minimum and maximum slave preferred connection intervals are set in units of 1.25 ms. In this example, the minimum slave preferred connection interval is defined as 0x0006 * 1.25 ms = 7.5 ms, and the maximum slave preferred connection interval is initialized as 0x0010 * 1.25 ms = 20 ms.
|
||||||
|
|
||||||
An advertising payload can be up to 31 bytes of data. It is possible the parameter data is large enough to surpass the 31-byte advertisement packet limit, which causes the stack to cut the advertisement packet and leave some of the parameters out. This behavior can be demonstrated in this example if the manufacturer length and data are uncommented, which makes the services to not be advertised after recompiling and testing.
|
An advertising payload can be up to 31 bytes of data. It is possible the parameter data is large enough to surpass the 31-byte advertisement packet limit, which causes the stack to cut the advertisement packet and leave some of the parameters out. This behavior can be demonstrated in this example if the manufacturer length and data are uncommented, which makes the services to not be advertised after recompiling and testing.
|
||||||
|
|
||||||
|
@ -92,8 +92,8 @@ static esp_ble_adv_data_t adv_data = {
|
|||||||
.set_scan_rsp = false,
|
.set_scan_rsp = false,
|
||||||
.include_name = true,
|
.include_name = true,
|
||||||
.include_txpower = true,
|
.include_txpower = true,
|
||||||
.min_interval = 0x20,
|
.min_interval = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
|
||||||
.max_interval = 0x40,
|
.max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec
|
||||||
.appearance = 0x00,
|
.appearance = 0x00,
|
||||||
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
||||||
.p_manufacturer_data = NULL, //test_manufacturer,
|
.p_manufacturer_data = NULL, //test_manufacturer,
|
||||||
@ -109,8 +109,8 @@ static esp_ble_adv_data_t scan_rsp_data = {
|
|||||||
.set_scan_rsp = true,
|
.set_scan_rsp = true,
|
||||||
.include_name = true,
|
.include_name = true,
|
||||||
.include_txpower = true,
|
.include_txpower = true,
|
||||||
.min_interval = 0x20,
|
.min_interval = 0x0006,
|
||||||
.max_interval = 0x40,
|
.max_interval = 0x0010,
|
||||||
.appearance = 0x00,
|
.appearance = 0x00,
|
||||||
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
||||||
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
||||||
|
@ -173,8 +173,8 @@ typedef struct {
|
|||||||
bool set_scan_rsp; /*!< Set this advertising data as scan response or not*/
|
bool set_scan_rsp; /*!< Set this advertising data as scan response or not*/
|
||||||
bool include_name; /*!< Advertising data include device name or not */
|
bool include_name; /*!< Advertising data include device name or not */
|
||||||
bool include_txpower; /*!< Advertising data include TX power */
|
bool include_txpower; /*!< Advertising data include TX power */
|
||||||
int min_interval; /*!< Advertising data show advertising min interval */
|
int min_interval; /*!< Advertising data show slave preferred connection min interval */
|
||||||
int max_interval; /*!< Advertising data show advertising max interval */
|
int max_interval; /*!< Advertising data show slave preferred connection max interval */
|
||||||
int appearance; /*!< External appearance of device */
|
int appearance; /*!< External appearance of device */
|
||||||
uint16_t manufacturer_len; /*!< Manufacturer data length */
|
uint16_t manufacturer_len; /*!< Manufacturer data length */
|
||||||
uint8_t *p_manufacturer_data; /*!< Manufacturer data point */
|
uint8_t *p_manufacturer_data; /*!< Manufacturer data point */
|
||||||
@ -193,8 +193,8 @@ static esp_ble_adv_data_t heart_rate_adv_config = {
|
|||||||
.set_scan_rsp = false,
|
.set_scan_rsp = false,
|
||||||
.include_name = true,
|
.include_name = true,
|
||||||
.include_txpower = true,
|
.include_txpower = true,
|
||||||
.min_interval = 0x20,
|
.min_interval = 0x0006,
|
||||||
.max_interval = 0x40,
|
.max_interval = 0x0010,
|
||||||
.appearance = 0x00,
|
.appearance = 0x00,
|
||||||
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
.manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
|
||||||
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
.p_manufacturer_data = NULL, //&test_manufacturer[0],
|
||||||
@ -206,7 +206,7 @@ static esp_ble_adv_data_t heart_rate_adv_config = {
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
The minimum and maximum advertisement intervals are set in units of 0.625 ms. In this example, the minimum advertisement interval is defined as 0x20 * 0.625 ms = 20 ms and the maximum advertisement interval is initialized as 0x40 * 0.625 ms = 40 ms.
|
The minimum and maximum slave preferred connection intervals are set in units of 1.25 ms. In this example, the minimum slave preferred connection interval is defined as 0x0006 * 1.25 ms = 7.5 ms and the maximum slave preferred connection interval is initialized as 0x0010 * 1.25 ms = 20 ms.
|
||||||
|
|
||||||
An advertising payload can be up to 31 bytes of data. It is possible that some of the parameters surpass the 31-byte advertisement packet limit which causes the stack to cut the message and leave some of the parameters out. To solve this, usually the longer parameters are stored in the scan response, which can be configured using the same ``esp_ble_gap_config_adv_data()`` function and an additional esp_ble_adv_data_t type structure with the .set_scan_rsp parameter is set to true. Finally, to set the device name the ``esp_ble_gap_set_device_name()`` function is used. The registering event handler is shown as follows:
|
An advertising payload can be up to 31 bytes of data. It is possible that some of the parameters surpass the 31-byte advertisement packet limit which causes the stack to cut the message and leave some of the parameters out. To solve this, usually the longer parameters are stored in the scan response, which can be configured using the same ``esp_ble_gap_config_adv_data()`` function and an additional esp_ble_adv_data_t type structure with the .set_scan_rsp parameter is set to true. Finally, to set the device name the ``esp_ble_gap_set_device_name()`` function is used. The registering event handler is shown as follows:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user