Skip to content

Commit 31605b6

Browse files
chengkai15xiaoxiang781216
authored andcommitted
bluetooth: call bt_driver_register common interface
Signed-off-by: chengkai <[email protected]>
1 parent 772807c commit 31605b6

File tree

14 files changed

+35
-200
lines changed

14 files changed

+35
-200
lines changed

arch/arm/src/nrf52/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -899,11 +899,6 @@ config NRF52_SDC_DLE
899899
bool "Support Data Length Extension (DLE)"
900900
default y
901901

902-
config NRF52_BLE_TTY_NAME
903-
string "BLE TTY device name"
904-
default "/dev/ttyHCI0"
905-
depends on UART_BTH4
906-
907902
config NRF52_SDC_FICR_STATIC_ADDR
908903
bool "Configure factory generated static random address"
909904
default n

arch/arm/src/nrf52/nrf52_sdc.c

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@
3838
#include <arch/nrf52/nrf52_irq.h>
3939
#include <nuttx/wqueue.h>
4040

41-
#if defined(CONFIG_UART_BTH4)
42-
# include <nuttx/serial/uart_bth4.h>
43-
#endif
44-
4541
#include "arm_internal.h"
4642
#include "ram_vectors.h"
4743

@@ -918,26 +914,13 @@ int nrf52_sdc_initialize(void)
918914
return ret;
919915
}
920916

921-
#ifdef CONFIG_UART_BTH4
922-
/* Register UART BT H4 device */
923-
924-
ret = uart_bth4_register(CONFIG_NRF52_BLE_TTY_NAME, &g_bt_driver);
917+
#ifdef CONFIG_DRIVERS_BLUETOOTH
918+
ret = bt_driver_register(&g_bt_driver);
925919
if (ret < 0)
926920
{
927-
wlerr("bt_bth4_register error: %d\n", ret);
921+
wlerr("bt_driver_register error: %d\n", ret);
928922
return ret;
929923
}
930-
#elif defined(CONFIG_NET_BLUETOOTH)
931-
/* Register network device */
932-
933-
ret = bt_netdev_register(&g_bt_driver);
934-
if (ret < 0)
935-
{
936-
wlerr("bt_netdev_register error: %d\n", ret);
937-
return ret;
938-
}
939-
#else
940-
# error
941924
#endif
942925

943926
return ret;

arch/arm/src/nrf53/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -792,11 +792,6 @@ config NRF53_SDC_DLE
792792
bool "Support Data Length Extension (DLE)"
793793
default y
794794

795-
config NRF53_BLE_TTY_NAME
796-
string "BLE TTY device name"
797-
default "/dev/ttyHCI0"
798-
depends on UART_BTH4
799-
800795
config NRF53_SDC_FICR_STATIC_ADDR
801796
bool "Configure factory generated static random address"
802797
default n

arch/arm/src/nrf53/nrf53_sdc.c

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@
3838
#include <arch/nrf53/nrf5340_irq_cpunet.h>
3939
#include <nuttx/wqueue.h>
4040

41-
#if defined(CONFIG_UART_BTH4)
42-
# include <nuttx/serial/uart_bth4.h>
43-
#endif
4441
#ifdef CONFIG_BLUETOOTH_RPMSG_SERVER
4542
# include <nuttx/wireless/bluetooth/bt_rpmsghci.h>
4643
#endif
@@ -910,28 +907,13 @@ int nrf53_sdc_initialize(void)
910907
return ret;
911908
}
912909

913-
#ifdef CONFIG_UART_BTH4
914-
/* Register UART BT H4 device */
915-
916-
ret = uart_bth4_register(CONFIG_NRF53_BLE_TTY_NAME, &g_bt_driver);
917-
if (ret < 0)
918-
{
919-
wlerr("bt_bth4_register error: %d\n", ret);
920-
return ret;
921-
}
922-
#elif defined(CONFIG_NET_BLUETOOTH)
923-
/* Register network device */
924-
925-
ret = bt_netdev_register(&g_bt_driver);
910+
#ifdef CONFIG_DRIVERS_BLUETOOTH
911+
ret = bt_driver_register(&g_bt_driver);
926912
if (ret < 0)
927913
{
928-
wlerr("bt_netdev_register error: %d\n", ret);
914+
wlerr("bt_driver_register error: %d\n", ret);
929915
return ret;
930916
}
931-
#elif defined(CONFIG_BLUETOOTH_RPMSG_SERVER)
932-
/* Do nothing here */
933-
#else
934-
# error
935917
#endif
936918

937919
return ret;

arch/arm/src/stm32wb/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,11 +1182,6 @@ config STM32WB_BLE_LE_CODED_PHY
11821182
default STM32WB_STM32WB15 || STM32WB_STM32WB35 || STM32WB_STM32WB55
11831183
depends on STM32WB_STM32WB15 || STM32WB_STM32WB35 || STM32WB_STM32WB55
11841184

1185-
config STM32WB_BLE_TTY_NAME
1186-
string "BLE TTY device name"
1187-
default "/dev/ttyHCI0"
1188-
depends on UART_BTH4
1189-
11901185
config STM32WB_BLE_FICR_STATIC_ADDR
11911186
bool "Configure factory generated static random address"
11921187
default n

arch/arm/src/stm32wb/stm32wb_blehci.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@
3333
#include <nuttx/mutex.h>
3434
#include <nuttx/wqueue.h>
3535

36-
#if defined(CONFIG_UART_BTH4)
37-
# include <nuttx/serial/uart_bth4.h>
38-
#endif
39-
4036
#include "stm32wb_ipcc.h"
4137
#include "stm32wb_mbox.h"
4238
#include "stm32wb_mbox_shci.h"
@@ -336,22 +332,11 @@ static int stm32wb_blehci_driverinitialize(void)
336332
{
337333
int ret = 0;
338334

339-
#ifdef CONFIG_UART_BTH4
340-
/* Register UART BT H4 device */
341-
342-
ret = uart_bth4_register(CONFIG_STM32WB_BLE_TTY_NAME, &g_blehci_driver);
343-
if (ret < 0)
344-
{
345-
wlerr("bt_bth4_register error: %d\n", ret);
346-
return ret;
347-
}
348-
#elif defined(CONFIG_NET_BLUETOOTH)
349-
/* Register network device */
350-
351-
ret = bt_netdev_register(&g_blehci_driver);
335+
#ifdef CONFIG_DRIVERS_BLUETOOTH
336+
ret = bt_driver_register(&g_blehci_driver);
352337
if (ret < 0)
353338
{
354-
wlerr("bt_netdev_register error: %d\n", ret);
339+
wlerr("bt_driver_register error: %d\n", ret);
355340
return ret;
356341
}
357342
#endif

arch/sim/src/sim/sim_hcisocket.c

Lines changed: 6 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@
4040
#include <nuttx/net/bluetooth.h>
4141
#include <nuttx/wireless/bluetooth/bt_driver.h>
4242
#include <nuttx/wireless/bluetooth/bt_uart.h>
43-
#include <nuttx/wireless/bluetooth/bt_bridge.h>
44-
#include <nuttx/serial/uart_bth4.h>
4543

4644
#include "sim_internal.h"
4745
#include "sim_hosthcisocket.h"
@@ -256,27 +254,6 @@ static void bthcisock_free(struct bthcisock_s *dev)
256254
kmm_free(dev);
257255
}
258256

259-
static int bthcisock_driver_register(struct bt_driver_s *drv, int id,
260-
bool bt)
261-
{
262-
#ifdef CONFIG_UART_BTH4
263-
char name[32];
264-
265-
if (bt)
266-
{
267-
snprintf(name, sizeof(name), "/dev/ttyBT%d", id);
268-
}
269-
else
270-
{
271-
snprintf(name, sizeof(name), "/dev/ttyBLE%d", id);
272-
}
273-
274-
return uart_bth4_register(name, drv);
275-
#else
276-
return bt_netdev_register(drv);
277-
#endif
278-
}
279-
280257
/****************************************************************************
281258
* Name: sim_bthcisock_work
282259
*
@@ -320,10 +297,6 @@ static void sim_bthcisock_work(void *arg)
320297
int sim_bthcisock_register(int dev_id)
321298
{
322299
struct bthcisock_s *dev;
323-
#if defined(CONFIG_BLUETOOTH_BRIDGE)
324-
struct bt_driver_s *btdrv;
325-
struct bt_driver_s *bledrv;
326-
#endif
327300
int ret;
328301

329302
dev = bthcisock_alloc(dev_id);
@@ -332,35 +305,17 @@ int sim_bthcisock_register(int dev_id)
332305
return -ENOMEM;
333306
}
334307

335-
#if defined(CONFIG_BLUETOOTH_BRIDGE)
336-
ret = bt_bridge_register(&dev->drv, &btdrv, &bledrv);
337-
if (ret < 0)
338-
{
339-
goto end;
340-
}
341-
342-
ret = bthcisock_driver_register(btdrv, dev_id, true);
343-
if (ret < 0)
344-
{
345-
goto end;
346-
}
347-
348-
ret = bthcisock_driver_register(bledrv, dev_id, false);
349-
if (ret < 0)
350-
{
351-
goto end;
352-
}
353-
354-
end:
355-
#else
356-
ret = bthcisock_driver_register(&dev->drv, dev_id, true);
357-
#endif
358-
308+
#ifdef CONFIG_DRIVERS_BLUETOOTH
309+
ret = bt_driver_register_with_id(&dev->drv, dev_id);
359310
if (ret < 0)
360311
{
312+
wlerr("bt_driver_register error: %d\n", ret);
361313
bthcisock_free(dev);
362314
return ret;
363315
}
316+
#else
317+
# error "Please select CONFIG_DRIVERS_BLUETOOTH"
318+
#endif
364319

365320
return work_queue(HPWORK, &dev->worker, sim_bthcisock_work, dev, 0);
366321
}

arch/xtensa/src/esp32/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,11 +2175,6 @@ config ESP32_BLE_PKTBUF_NUM
21752175
int "BLE netcard packet buffer number per netcard"
21762176
default 16
21772177

2178-
config ESP32_BLE_TTY_NAME
2179-
string "BLE TTY device name"
2180-
default "/dev/ttyHCI0"
2181-
depends on UART_BTH4
2182-
21832178
config ESP32_BLE_TASK_STACK_SIZE
21842179
int "Controller task stack size"
21852180
default 4096

arch/xtensa/src/esp32/esp32_ble.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@
4040
#include <nuttx/wireless/bluetooth/bt_driver.h>
4141
#include <nuttx/wireless/bluetooth/bt_uart.h>
4242

43-
#if defined(CONFIG_UART_BTH4)
44-
# include <nuttx/serial/uart_bth4.h>
45-
#endif
46-
4743
#include "esp32_ble_adapter.h"
4844

4945
/****************************************************************************
@@ -322,16 +318,14 @@ int esp32_ble_initialize(void)
322318
return ERROR;
323319
}
324320

325-
#if defined(CONFIG_UART_BTH4)
326-
ret = uart_bth4_register(CONFIG_BT_UART_ON_DEV_NAME, &g_ble_priv.drv);
327-
#else
328-
ret = bt_netdev_register(&g_ble_priv.drv);
329-
#endif
321+
#ifdef CONFIG_DRIVERS_BLUETOOTH
322+
ret = bt_driver_register(&g_ble_priv.drv);
330323
if (ret < 0)
331324
{
332-
wlerr("bt_netdev_register or uart_bth4_register error: %d\n", ret);
325+
wlerr("bt_driver_register error: %d\n", ret);
333326
return ret;
334327
}
328+
#endif
335329

336330
return OK;
337331
}

arch/xtensa/src/esp32s3/Kconfig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,11 +1682,6 @@ endif # ESP32S3_OPENETH
16821682
menu "BLE Configuration"
16831683
depends on ESP32S3_BLE
16841684

1685-
config ESP32S3_BLE_TTY_NAME
1686-
string "BLE TTY device name"
1687-
default "/dev/ttyHCI0"
1688-
depends on UART_BTH4
1689-
16901685
config ESP32S3_BLE_TASK_STACK_SIZE
16911686
int "Controller task stack size"
16921687
default 4096

0 commit comments

Comments
 (0)