mirror of
https://github.com/apache/nuttx.git
synced 2025-01-13 08:38:38 +08:00
bluetooth: call bt_driver_register common interface
Signed-off-by: chengkai <chengkai@xiaomi.com>
This commit is contained in:
parent
772807c50f
commit
31605b6335
14 changed files with 35 additions and 200 deletions
|
@ -899,11 +899,6 @@ config NRF52_SDC_DLE
|
|||
bool "Support Data Length Extension (DLE)"
|
||||
default y
|
||||
|
||||
config NRF52_BLE_TTY_NAME
|
||||
string "BLE TTY device name"
|
||||
default "/dev/ttyHCI0"
|
||||
depends on UART_BTH4
|
||||
|
||||
config NRF52_SDC_FICR_STATIC_ADDR
|
||||
bool "Configure factory generated static random address"
|
||||
default n
|
||||
|
|
|
@ -38,10 +38,6 @@
|
|||
#include <arch/nrf52/nrf52_irq.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
|
||||
#if defined(CONFIG_UART_BTH4)
|
||||
# include <nuttx/serial/uart_bth4.h>
|
||||
#endif
|
||||
|
||||
#include "arm_internal.h"
|
||||
#include "ram_vectors.h"
|
||||
|
||||
|
@ -918,26 +914,13 @@ int nrf52_sdc_initialize(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_UART_BTH4
|
||||
/* Register UART BT H4 device */
|
||||
|
||||
ret = uart_bth4_register(CONFIG_NRF52_BLE_TTY_NAME, &g_bt_driver);
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register(&g_bt_driver);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_bth4_register error: %d\n", ret);
|
||||
wlerr("bt_driver_register error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#elif defined(CONFIG_NET_BLUETOOTH)
|
||||
/* Register network device */
|
||||
|
||||
ret = bt_netdev_register(&g_bt_driver);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_netdev_register error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
# error
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -792,11 +792,6 @@ config NRF53_SDC_DLE
|
|||
bool "Support Data Length Extension (DLE)"
|
||||
default y
|
||||
|
||||
config NRF53_BLE_TTY_NAME
|
||||
string "BLE TTY device name"
|
||||
default "/dev/ttyHCI0"
|
||||
depends on UART_BTH4
|
||||
|
||||
config NRF53_SDC_FICR_STATIC_ADDR
|
||||
bool "Configure factory generated static random address"
|
||||
default n
|
||||
|
|
|
@ -38,9 +38,6 @@
|
|||
#include <arch/nrf53/nrf5340_irq_cpunet.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
|
||||
#if defined(CONFIG_UART_BTH4)
|
||||
# include <nuttx/serial/uart_bth4.h>
|
||||
#endif
|
||||
#ifdef CONFIG_BLUETOOTH_RPMSG_SERVER
|
||||
# include <nuttx/wireless/bluetooth/bt_rpmsghci.h>
|
||||
#endif
|
||||
|
@ -910,28 +907,13 @@ int nrf53_sdc_initialize(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_UART_BTH4
|
||||
/* Register UART BT H4 device */
|
||||
|
||||
ret = uart_bth4_register(CONFIG_NRF53_BLE_TTY_NAME, &g_bt_driver);
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register(&g_bt_driver);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_bth4_register error: %d\n", ret);
|
||||
wlerr("bt_driver_register error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#elif defined(CONFIG_NET_BLUETOOTH)
|
||||
/* Register network device */
|
||||
|
||||
ret = bt_netdev_register(&g_bt_driver);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_netdev_register error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#elif defined(CONFIG_BLUETOOTH_RPMSG_SERVER)
|
||||
/* Do nothing here */
|
||||
#else
|
||||
# error
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
|
|
|
@ -1182,11 +1182,6 @@ config STM32WB_BLE_LE_CODED_PHY
|
|||
default STM32WB_STM32WB15 || STM32WB_STM32WB35 || STM32WB_STM32WB55
|
||||
depends on STM32WB_STM32WB15 || STM32WB_STM32WB35 || STM32WB_STM32WB55
|
||||
|
||||
config STM32WB_BLE_TTY_NAME
|
||||
string "BLE TTY device name"
|
||||
default "/dev/ttyHCI0"
|
||||
depends on UART_BTH4
|
||||
|
||||
config STM32WB_BLE_FICR_STATIC_ADDR
|
||||
bool "Configure factory generated static random address"
|
||||
default n
|
||||
|
|
|
@ -33,10 +33,6 @@
|
|||
#include <nuttx/mutex.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
|
||||
#if defined(CONFIG_UART_BTH4)
|
||||
# include <nuttx/serial/uart_bth4.h>
|
||||
#endif
|
||||
|
||||
#include "stm32wb_ipcc.h"
|
||||
#include "stm32wb_mbox.h"
|
||||
#include "stm32wb_mbox_shci.h"
|
||||
|
@ -336,22 +332,11 @@ static int stm32wb_blehci_driverinitialize(void)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
#ifdef CONFIG_UART_BTH4
|
||||
/* Register UART BT H4 device */
|
||||
|
||||
ret = uart_bth4_register(CONFIG_STM32WB_BLE_TTY_NAME, &g_blehci_driver);
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register(&g_blehci_driver);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_bth4_register error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#elif defined(CONFIG_NET_BLUETOOTH)
|
||||
/* Register network device */
|
||||
|
||||
ret = bt_netdev_register(&g_blehci_driver);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_netdev_register error: %d\n", ret);
|
||||
wlerr("bt_driver_register error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -40,8 +40,6 @@
|
|||
#include <nuttx/net/bluetooth.h>
|
||||
#include <nuttx/wireless/bluetooth/bt_driver.h>
|
||||
#include <nuttx/wireless/bluetooth/bt_uart.h>
|
||||
#include <nuttx/wireless/bluetooth/bt_bridge.h>
|
||||
#include <nuttx/serial/uart_bth4.h>
|
||||
|
||||
#include "sim_internal.h"
|
||||
#include "sim_hosthcisocket.h"
|
||||
|
@ -256,27 +254,6 @@ static void bthcisock_free(struct bthcisock_s *dev)
|
|||
kmm_free(dev);
|
||||
}
|
||||
|
||||
static int bthcisock_driver_register(struct bt_driver_s *drv, int id,
|
||||
bool bt)
|
||||
{
|
||||
#ifdef CONFIG_UART_BTH4
|
||||
char name[32];
|
||||
|
||||
if (bt)
|
||||
{
|
||||
snprintf(name, sizeof(name), "/dev/ttyBT%d", id);
|
||||
}
|
||||
else
|
||||
{
|
||||
snprintf(name, sizeof(name), "/dev/ttyBLE%d", id);
|
||||
}
|
||||
|
||||
return uart_bth4_register(name, drv);
|
||||
#else
|
||||
return bt_netdev_register(drv);
|
||||
#endif
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sim_bthcisock_work
|
||||
*
|
||||
|
@ -320,10 +297,6 @@ static void sim_bthcisock_work(void *arg)
|
|||
int sim_bthcisock_register(int dev_id)
|
||||
{
|
||||
struct bthcisock_s *dev;
|
||||
#if defined(CONFIG_BLUETOOTH_BRIDGE)
|
||||
struct bt_driver_s *btdrv;
|
||||
struct bt_driver_s *bledrv;
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
dev = bthcisock_alloc(dev_id);
|
||||
|
@ -332,35 +305,17 @@ int sim_bthcisock_register(int dev_id)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_BLUETOOTH_BRIDGE)
|
||||
ret = bt_bridge_register(&dev->drv, &btdrv, &bledrv);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = bthcisock_driver_register(btdrv, dev_id, true);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
ret = bthcisock_driver_register(bledrv, dev_id, false);
|
||||
if (ret < 0)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
end:
|
||||
#else
|
||||
ret = bthcisock_driver_register(&dev->drv, dev_id, true);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register_with_id(&dev->drv, dev_id);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_driver_register error: %d\n", ret);
|
||||
bthcisock_free(dev);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
# error "Please select CONFIG_DRIVERS_BLUETOOTH"
|
||||
#endif
|
||||
|
||||
return work_queue(HPWORK, &dev->worker, sim_bthcisock_work, dev, 0);
|
||||
}
|
||||
|
|
|
@ -2175,11 +2175,6 @@ config ESP32_BLE_PKTBUF_NUM
|
|||
int "BLE netcard packet buffer number per netcard"
|
||||
default 16
|
||||
|
||||
config ESP32_BLE_TTY_NAME
|
||||
string "BLE TTY device name"
|
||||
default "/dev/ttyHCI0"
|
||||
depends on UART_BTH4
|
||||
|
||||
config ESP32_BLE_TASK_STACK_SIZE
|
||||
int "Controller task stack size"
|
||||
default 4096
|
||||
|
|
|
@ -40,10 +40,6 @@
|
|||
#include <nuttx/wireless/bluetooth/bt_driver.h>
|
||||
#include <nuttx/wireless/bluetooth/bt_uart.h>
|
||||
|
||||
#if defined(CONFIG_UART_BTH4)
|
||||
# include <nuttx/serial/uart_bth4.h>
|
||||
#endif
|
||||
|
||||
#include "esp32_ble_adapter.h"
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -322,16 +318,14 @@ int esp32_ble_initialize(void)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_UART_BTH4)
|
||||
ret = uart_bth4_register(CONFIG_BT_UART_ON_DEV_NAME, &g_ble_priv.drv);
|
||||
#else
|
||||
ret = bt_netdev_register(&g_ble_priv.drv);
|
||||
#endif
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register(&g_ble_priv.drv);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_netdev_register or uart_bth4_register error: %d\n", ret);
|
||||
wlerr("bt_driver_register error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
@ -1682,11 +1682,6 @@ endif # ESP32S3_OPENETH
|
|||
menu "BLE Configuration"
|
||||
depends on ESP32S3_BLE
|
||||
|
||||
config ESP32S3_BLE_TTY_NAME
|
||||
string "BLE TTY device name"
|
||||
default "/dev/ttyHCI0"
|
||||
depends on UART_BTH4
|
||||
|
||||
config ESP32S3_BLE_TASK_STACK_SIZE
|
||||
int "Controller task stack size"
|
||||
default 4096
|
||||
|
|
|
@ -40,10 +40,6 @@
|
|||
#include <nuttx/wireless/bluetooth/bt_driver.h>
|
||||
#include <nuttx/wireless/bluetooth/bt_uart.h>
|
||||
|
||||
#if defined(CONFIG_UART_BTH4)
|
||||
# include <nuttx/serial/uart_bth4.h>
|
||||
#endif
|
||||
|
||||
#include "esp32s3_ble_adapter.h"
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -310,16 +306,14 @@ int esp32s3_ble_initialize(void)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_UART_BTH4)
|
||||
ret = uart_bth4_register(CONFIG_ESP32S3_BLE_TTY_NAME, &g_ble_priv.drv);
|
||||
#else
|
||||
ret = bt_netdev_register(&g_ble_priv.drv);
|
||||
#endif
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register(&g_ble_priv.drv);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_netdev_register or uart_bth4_register error: %d\n", ret);
|
||||
wlerr("bt_driver_register error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
@ -55,10 +55,7 @@
|
|||
|
||||
#ifdef CONFIG_RPTUN
|
||||
# include <nuttx/wireless/bluetooth/bt_rpmsghci.h>
|
||||
# ifdef CONFIG_UART_BTH4
|
||||
# include <nuttx/serial/uart_bth4.h>
|
||||
# endif
|
||||
# ifdef CONFIG_NET_BLUETOOTH
|
||||
# ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
# include <nuttx/wireless/bluetooth/bt_driver.h>
|
||||
# endif
|
||||
# include "nrf53_rptun.h"
|
||||
|
@ -104,21 +101,11 @@ static int nrf53_appcore_bleinit(void)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
# ifdef CONFIG_UART_BTH4
|
||||
/* Register UART BT H4 device */
|
||||
|
||||
ret = uart_bth4_register("/dev/ttyHCI", bt_dev);
|
||||
# ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register(bt_dev);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "bt_bth4_register error: %d\n", ret);
|
||||
}
|
||||
# elif defined(CONFIG_NET_BLUETOOTH)
|
||||
/* Register network device */
|
||||
|
||||
ret = bt_netdev_register(bt_dev);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "bt_netdev_register error: %d\n", ret);
|
||||
syslog(LOG_ERR, "bt_driver_register error: %d\n", ret);
|
||||
}
|
||||
# else
|
||||
# error
|
||||
|
|
|
@ -52,10 +52,7 @@
|
|||
|
||||
#ifdef CONFIG_RPTUN
|
||||
# include <nuttx/wireless/bluetooth/bt_rpmsghci.h>
|
||||
# ifdef CONFIG_UART_BTH4
|
||||
# include <nuttx/serial/uart_bth4.h>
|
||||
# endif
|
||||
# ifdef CONFIG_NET_BLUETOOTH
|
||||
# ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
# include <nuttx/wireless/bluetooth/bt_driver.h>
|
||||
# endif
|
||||
# include "nrf53_rptun.h"
|
||||
|
@ -91,21 +88,11 @@ static int nrf53_appcore_bleinit(void)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
# ifdef CONFIG_UART_BTH4
|
||||
/* Register UART BT H4 device */
|
||||
|
||||
ret = uart_bth4_register("/dev/ttyHCI", bt_dev);
|
||||
# ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register(bt_dev);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "bt_bth4_register error: %d\n", ret);
|
||||
}
|
||||
# elif defined(CONFIG_NET_BLUETOOTH)
|
||||
/* Register network device */
|
||||
|
||||
ret = bt_netdev_register(bt_dev);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR, "bt_netdev_register error: %d\n", ret);
|
||||
syslog(LOG_ERR, "bt_driver_register error: %d\n", ret);
|
||||
}
|
||||
# else
|
||||
# error
|
||||
|
|
|
@ -59,9 +59,6 @@
|
|||
#include <nuttx/wireless/bluetooth/bt_driver.h>
|
||||
#include <nuttx/wireless/bluetooth/bt_uart.h>
|
||||
#include <nuttx/circbuf.h>
|
||||
#if defined(CONFIG_UART_BTH4)
|
||||
#include <nuttx/serial/uart_bth4.h>
|
||||
#endif
|
||||
#endif /* CONFIG_BL602_BLE_CONTROLLER */
|
||||
|
||||
#ifdef CONFIG_FS_ROMFS
|
||||
|
@ -320,18 +317,14 @@ int bthci_register(void)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_UART_BTH4)
|
||||
ret = uart_bth4_register("/dev/ttyHCI0", &hci_dev->drv);
|
||||
#elif defined(CONFIG_NET_BLUETOOTH)
|
||||
ret = bt_netdev_register(&hci_dev->drv);
|
||||
#elif defined(CONFIG_BL602_BLE_CONTROLLER)
|
||||
#error "Must select CONFIG_UART_BTH4 or CONFIG_NET_BLUETOOTH"
|
||||
#endif
|
||||
# ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register(&hci_dev->drv);
|
||||
if (ret < 0)
|
||||
{
|
||||
printf("register faile[%d] errno %d\n", ret, errno);
|
||||
printf("bt_driver_register failed[%d] errno %d\n", ret, errno);
|
||||
kmm_free(hci_dev);
|
||||
}
|
||||
# endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue