Skip to content

Commit f68fbd6

Browse files
sylvioalvescarlescufi
authored andcommitted
driver: ble: esp32: implement deinit function
Current ESP32 BLE interface does not allow disabling BLE. This PR adds proper deinit call. Signed-off-by: Sylvio Alves <[email protected]>
1 parent 82bace6 commit f68fbd6

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

drivers/bluetooth/hci/hci_esp32.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,25 @@ static int bt_esp32_ble_init(void)
303303
return 0;
304304
}
305305

306+
static int bt_esp32_ble_deinit(void)
307+
{
308+
int ret;
309+
310+
ret = esp_bt_controller_disable();
311+
if (ret) {
312+
LOG_ERR("Bluetooth controller disable failed %d", ret);
313+
return ret;
314+
}
315+
316+
ret = esp_bt_controller_deinit();
317+
if (ret) {
318+
LOG_ERR("Bluetooth controller deinit failed %d", ret);
319+
return ret;
320+
}
321+
322+
return 0;
323+
}
324+
306325
static int bt_esp32_open(void)
307326
{
308327
int err;
@@ -317,10 +336,25 @@ static int bt_esp32_open(void)
317336
return 0;
318337
}
319338

339+
static int bt_esp32_close(void)
340+
{
341+
int err;
342+
343+
err = bt_esp32_ble_deinit();
344+
if (err) {
345+
return err;
346+
}
347+
348+
LOG_DBG("ESP32 BT stopped");
349+
350+
return 0;
351+
}
352+
320353
static const struct bt_hci_driver drv = {
321354
.name = "BT ESP32",
322355
.open = bt_esp32_open,
323356
.send = bt_esp32_send,
357+
.close = bt_esp32_close,
324358
.bus = BT_HCI_DRIVER_BUS_IPM,
325359
#if defined(CONFIG_BT_DRIVER_QUIRK_NO_AUTO_DLE)
326360
.quirks = BT_QUIRK_NO_AUTO_DLE,
@@ -329,7 +363,6 @@ static const struct bt_hci_driver drv = {
329363

330364
static int bt_esp32_init(void)
331365
{
332-
333366
bt_hci_driver_register(&drv);
334367

335368
return 0;

west.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ manifest:
152152
groups:
153153
- hal
154154
- name: hal_espressif
155-
revision: 754be4745295a45c26d42c916a8600cdcefddd4e
155+
revision: e98ce93e916eebdc4a0c5bceef864289447e3d63
156156
path: modules/hal/espressif
157157
west-commands: west/west-commands.yml
158158
groups:

0 commit comments

Comments
 (0)