]> granicus.if.org Git - esp-idf/commitdiff
component/bt: Fix exception when there is no device name
authorbaohongde <baohongde@espressif.com>
Tue, 10 Apr 2018 09:55:33 +0000 (17:55 +0800)
committerbaohongde <baohongde@espressif.com>
Tue, 10 Apr 2018 09:55:33 +0000 (17:55 +0800)
components/bt/bluedroid/api/include/esp_bt_device.h
components/bt/bluedroid/btc/core/btc_dm.c
components/bt/lib

index d3c3f79c55cb2169a0352fb8225d51bba197531e..0dca4499786cb8169d785c6979ed0bf442fc18c0 100644 (file)
@@ -27,15 +27,17 @@ extern "C" {
 /**
  *
  * @brief      Get bluetooth device address.  Must use after "esp_bluedroid_enable".
- * 
+ *
  * @return     bluetooth device address (six bytes), or NULL if bluetooth stack is not enabled
  */
 const uint8_t *esp_bt_dev_get_address(void);
 
 
 /**
- * @brief           Set bluetooth device name. This function should be called after esp_bluedroid_enable() 
- *                  completes successfully
+ * @brief           Set bluetooth device name. This function should be called after esp_bluedroid_enable()
+ *                  completes successfully.
+ *                  A BR/EDR/LE device type shall have a single Bluetooth device name which shall be
+ *                  identical irrespective of the physical channel used to perform the name discovery procedure.
  *
  * @param[in]       name : device name to be set
  *
index 1f6322b86fb39add800f422de5202d7bd2c2338b..e073889723612dc0eb04cf6da5571357c59be99c 100644 (file)
@@ -434,6 +434,12 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
         //load the bonding device to the btm layer
         btc_storage_load_bonded_ble_devices();
 #endif  ///SMP_INCLUDED == TRUE
+
+        /* Set initial device name, it can be overwritten later */
+        if (p_data->enable.status == BTA_SUCCESS) {
+            char *initial_device_name = "ESP32";
+            BTA_DmSetDeviceName(initial_device_name);
+        }
         btc_enable_bluetooth_evt(p_data->enable.status);
         break;
     }
@@ -465,7 +471,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
         memcpy(bd_addr.address, p_data->link_down.bd_addr, sizeof(BD_ADDR));
         btm_set_bond_type_dev(p_data->link_down.bd_addr, BOND_TYPE_UNKNOWN);
         param.remove_bond_dev_cmpl.status = ESP_BT_STATUS_FAIL;
-        
+
         if (p_data->link_down.status == HCI_SUCCESS) {
             //remove the bonded key in the config and nvs flash.
             btc_storage_remove_ble_dev_type(&bd_addr, false);
index 9a93239bc8f54bc5434e8a3dec98e2a8b6b9454a..74a772d0b88271d6161d0e61e4c358030a001ab5 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 9a93239bc8f54bc5434e8a3dec98e2a8b6b9454a
+Subproject commit 74a772d0b88271d6161d0e61e4c358030a001ab5