]> granicus.if.org Git - esp-idf/commitdiff
Unified Provisioning: Miscellaneous fixes in BLE
authorHrishikesh Dhayagude <hrishi@espressif.com>
Wed, 3 Apr 2019 10:15:34 +0000 (15:45 +0530)
committerHrishikesh Dhayagude <hrishi@espressif.com>
Tue, 9 Apr 2019 05:55:42 +0000 (11:25 +0530)
1. Pass the correct conn_id to protocomm_req_handle
In transport_simple_ble_write(), passing param->exec_write.conn_id would
be invalid. Instead param->write.conn_id should be passed
Similar change in transport_simple_ble_exec_write() to use
param->exec_write.conn_id

2. simple_ble_start() assumes that the mode is BLE only and enables
Bluetooth controller accordingly. For, cases having BT + BLE like Alexa
(Provisioning over BLE + Audio over classic BT), this assumption should
be removed.

components/protocomm/src/simple_ble/simple_ble.c
components/protocomm/src/transports/protocomm_ble.c

index f29f1a34801689e1044cdaff4c05629b89672622..61f65021bb844381ecb32df1b5ba1493c05c9f2f 100644 (file)
@@ -189,7 +189,14 @@ esp_err_t simple_ble_start(simple_ble_cfg_t *cfg)
         return ret;
     }
 
+#ifdef CONFIG_BTDM_CONTROLLER_MODE_BTDM
+    ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
+#elif defined CONFIG_BTDM_CONTROLLER_MODE_BLE_ONLY
     ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
+#else
+    ESP_LOGE(TAG, "Configuration mismatch. Select BLE Only or BTDM mode from menuconfig");
+    return ESP_FAIL;
+#endif
     if (ret) {
         ESP_LOGE(TAG, "%s enable controller failed %d", __func__, ret);
         return ret;
index 3a1f11287d6bd43c4976591895706a3482e8a4d8..5e65aa95d4a7013a0429d5fdd447fc8fd0532b85 100644 (file)
@@ -201,7 +201,7 @@ static void transport_simple_ble_write(esp_gatts_cb_event_t event, esp_gatt_if_t
 
     ret = protocomm_req_handle(protoble_internal->pc_ble,
                                handle_to_handler(param->write.handle),
-                               param->exec_write.conn_id,
+                               param->write.conn_id,
                                param->write.value,
                                param->write.len,
                                &outbuf, &outlen);
@@ -246,7 +246,7 @@ static void transport_simple_ble_exec_write(esp_gatts_cb_event_t event, esp_gatt
 
         if (err != ESP_OK) {
             ESP_LOGE(TAG, "Invalid content received, killing connection");
-            esp_ble_gatts_close(gatts_if, param->write.conn_id);
+            esp_ble_gatts_close(gatts_if, param->exec_write.conn_id);
         } else {
             hexdump("Response from exec write", outbuf, outlen);
             esp_ble_gatts_set_attr_value(prepare_write_env.handle, outlen, outbuf);