]> granicus.if.org Git - esp-idf/commitdiff
Component/bt: fix connection interval error in slave adv params
authorzhiweijian <zhiweijian@espressif.com>
Sat, 29 Sep 2018 08:22:24 +0000 (16:22 +0800)
committerbot <bot@espressif.com>
Sun, 30 Sep 2018 11:14:27 +0000 (11:14 +0000)
components/bt/bluedroid/api/include/api/esp_gap_ble_api.h
examples/bluetooth/ble_hid_device_demo/main/ble_hidd_demo_main.c
examples/bluetooth/ble_throughput/throughput_server/main/example_ble_server_throughput.c
examples/bluetooth/blufi/main/blufi_example_main.c
examples/bluetooth/gatt_security_server/main/example_ble_sec_gatts_demo.c
examples/bluetooth/gatt_server/main/gatts_demo.c
examples/bluetooth/gatt_server/tutorial/Gatt_Server_Example_Walkthrough.md
examples/bluetooth/gatt_server_service_table/main/gatts_table_creat_demo.c
examples/bluetooth/gatt_server_service_table/tutorial/Gatt_Server_Service_Table_Example_Walkthrough.md

index 2ca5d2f790a20a478f5f27c3f8936f131776f1bc..b624365cb9310fcf257a8d71824b501cb0f0b949 100644 (file)
@@ -296,8 +296,21 @@ typedef struct {
     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_txpower;        /*!< Advertising data include TX power */
-    int                     min_interval;           /*!< Advertising data show advertising min interval */
-    int                     max_interval;           /*!< Advertising data show advertising max interval */
+    int                     min_interval;           /*!< Advertising data show slave preferred connection min 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 */
     uint16_t                manufacturer_len;       /*!< Manufacturer data length */
     uint8_t                 *p_manufacturer_data;   /*!< Manufacturer data point */
index 2aaa7472607aa5517bf05c4d109779bddd1a7fef..c37b5d4416f7742c2bc4523e0f53b345f89f8457 100644 (file)
@@ -74,8 +74,8 @@ static esp_ble_adv_data_t hidd_adv_data = {
     .set_scan_rsp = false,
     .include_name = true,
     .include_txpower = true,
-    .min_interval = 0x20,
-    .max_interval = 0x30,
+    .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
     .appearance = 0x03c0,       //HID Generic,
     .manufacturer_len = 0,
     .p_manufacturer_data =  NULL,
index 0b245ac676bf24faf1b20e22692575dbc8e06745..51643c178e30e603fe28d3963967e6f564120209 100644 (file)
@@ -109,8 +109,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 = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
+    .max_interval = 0x000C, //slave connection max interval, Time = max_interval * 1.25 msec
     .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 = {
     .set_scan_rsp = true,
     .include_name = true,
     .include_txpower = true,
-    .min_interval = 0x20,
-    .max_interval = 0x40,
+    .min_interval = 0x0006,
+    .max_interval = 0x000C,
     .appearance = 0x00,
     .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
     .p_manufacturer_data =  NULL, //&test_manufacturer[0],
index bb046306e836ab4cb474d1be5867f7123d792937..4106dd24ebca0754bcacddffe9f6d0b34e475e74 100644 (file)
@@ -48,8 +48,8 @@ static esp_ble_adv_data_t example_adv_data = {
     .set_scan_rsp = false,
     .include_name = true,
     .include_txpower = true,
-    .min_interval = 0x100,
-    .max_interval = 0x100,
+    .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
     .appearance = 0x00,
     .manufacturer_len = 0,
     .p_manufacturer_data =  NULL,
index 06be1a72e64f5d64d4ab2bc8658a9d136f37f665..ac06e85e0b4ebba3d38b4ede044d965c650e7d4b 100644 (file)
@@ -58,8 +58,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 = 0x100,
-    .max_interval = 0x100,
+    .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
     .appearance = 0x00,
     .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
     .p_manufacturer_data =  NULL, //&test_manufacturer[0],
index 1cb7afb9e92c7f498b0a9796b53abe5d3a7054e9..8c1d529823480887776bfea06cbc141317f6eae8 100644 (file)
@@ -100,8 +100,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 = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
+    .max_interval = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec
     .appearance = 0x00,
     .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
     .p_manufacturer_data =  NULL, //&test_manufacturer[0],
@@ -116,8 +116,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 = 0x0006,
+    .max_interval = 0x0010,
     .appearance = 0x00,
     .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
     .p_manufacturer_data =  NULL, //&test_manufacturer[0],
index 495a2bde8f06868c536bb7ffbe72b40e1602a3f5..89dea52147728424cf0c0daf9f981ea4df85d0fe 100644 (file)
@@ -214,8 +214,8 @@ typedef struct {
     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_txpower;         /*!< Advertising data include TX power */
-    int min_interval;             /*!< Advertising data show advertising min interval */
-    int max_interval;             /*!< Advertising data show advertising max interval */
+    int min_interval;             /*!< Advertising data show slave preferred connection min interval */
+    int max_interval;             /*!< Advertising data show slave preferred connection max interval */
     int appearance;               /*!< External appearance of device */
     uint16_t manufacturer_len;    /*!< Manufacturer data length */
     uint8_t *p_manufacturer_data; /*!< Manufacturer data point */
@@ -233,8 +233,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 = 0x0006,
+    .max_interval = 0x0010,
     .appearance = 0x00,
     .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
     .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),
 };
 ```
-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.
 
index 92b1c06301177efabdab798415d63c07fef7ba5b..530530c4968346b695e884224463fef35cd9cc92 100644 (file)
@@ -92,8 +92,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        = 0x0006, //slave connection min interval, Time = min_interval * 1.25 msec
+    .max_interval        = 0x0010, //slave connection max interval, Time = max_interval * 1.25 msec
     .appearance          = 0x00,
     .manufacturer_len    = 0,    //TEST_MANUFACTURER_DATA_LEN,
     .p_manufacturer_data = NULL, //test_manufacturer,
@@ -109,8 +109,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        = 0x0006,
+    .max_interval        = 0x0010,
     .appearance          = 0x00,
     .manufacturer_len    = 0, //TEST_MANUFACTURER_DATA_LEN,
     .p_manufacturer_data = NULL, //&test_manufacturer[0],
index c86d82cc2c9fb11a05608e4989cf45be8f06a5ec..6c47d918673833f97a4274b227e7d4fc5192db13 100644 (file)
@@ -173,8 +173,8 @@ typedef struct {
     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_txpower; /*!< Advertising data include TX power */
-    int min_interval;     /*!< Advertising data show advertising min interval */
-    int max_interval;     /*!< Advertising data show advertising max interval */
+    int min_interval;     /*!< Advertising data show slave preferred connection min interval */
+    int max_interval;     /*!< Advertising data show slave preferred connection max interval */
     int appearance;       /*!< External appearance of device */
     uint16_t manufacturer_len; /*!< Manufacturer data length */
     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,
     .include_name = true,
     .include_txpower = true,
-    .min_interval = 0x20,
-    .max_interval = 0x40,
+    .min_interval = 0x0006,
+    .max_interval = 0x0010,
     .appearance = 0x00,
     .manufacturer_len = 0, //TEST_MANUFACTURER_DATA_LEN,
     .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: