bluetooth: Fix the incompatibility made by https://github.com/apache/nuttx/pull/14224
that pr requires chip turn on CONFIG_DRIVERS_BLUETOOTH to use bluetooth, but not all defconig enable this option, so let's map bt_driver_register to bt_netdev_register in header file in this case, and revert the unnessary change in the related chip and board folders. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
parent
7aa7bf70c1
commit
24cb8c25ab
10 changed files with 12 additions and 32 deletions
|
|
@ -914,14 +914,12 @@ int nrf52_sdc_initialize(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register(&g_bt_driver);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_driver_register error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -907,14 +907,12 @@ int nrf53_sdc_initialize(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register(&g_bt_driver);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_driver_register error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -332,14 +332,12 @@ static int stm32wb_blehci_driverinitialize(void)
|
|||
{
|
||||
int ret = 0;
|
||||
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register(&g_blehci_driver);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_driver_register error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,7 +305,6 @@ int sim_bthcisock_register(int dev_id)
|
|||
return -ENOMEM;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register_with_id(&dev->drv, dev_id);
|
||||
if (ret < 0)
|
||||
{
|
||||
|
|
@ -313,9 +312,6 @@ int sim_bthcisock_register(int dev_id)
|
|||
bthcisock_free(dev);
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
# error "Please select CONFIG_DRIVERS_BLUETOOTH"
|
||||
#endif
|
||||
|
||||
return work_queue(HPWORK, &dev->worker, sim_bthcisock_work, dev, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -318,14 +318,12 @@ int esp32_ble_initialize(void)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register(&g_ble_priv.drv);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_driver_register error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -306,14 +306,12 @@ int esp32s3_ble_initialize(void)
|
|||
return ERROR;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
ret = bt_driver_register(&g_ble_priv.drv);
|
||||
if (ret < 0)
|
||||
{
|
||||
wlerr("bt_driver_register error: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
return OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ CONFIG_BTSAK=y
|
|||
CONFIG_BUILTIN=y
|
||||
CONFIG_DEFAULT_SMALL=y
|
||||
CONFIG_DISABLE_MQUEUE_SYSV=y
|
||||
CONFIG_DRIVERS_BLUETOOTH=y
|
||||
CONFIG_DRIVERS_WIRELESS=y
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
CONFIG_FAT_LCNAMES=y
|
||||
CONFIG_FAT_LFN=y
|
||||
|
|
|
|||
|
|
@ -34,8 +34,6 @@ CONFIG_BOARDCTL_MKRD=y
|
|||
CONFIG_BOARD_LOOPSPERMSEC=5500
|
||||
CONFIG_DEFAULT_SMALL=y
|
||||
CONFIG_DISABLE_MQUEUE_SYSV=y
|
||||
CONFIG_DRIVERS_BLUETOOTH=y
|
||||
CONFIG_DRIVERS_WIRELESS=y
|
||||
CONFIG_EXAMPLES_NIMBLE=y
|
||||
CONFIG_EXPERIMENTAL=y
|
||||
CONFIG_FILE_STREAM=y
|
||||
|
|
|
|||
|
|
@ -44,20 +44,12 @@
|
|||
****************************************************************************/
|
||||
|
||||
static int bt_driver_register_internal(FAR struct bt_driver_s *driver,
|
||||
int id, bool bt)
|
||||
FAR const char *prefix, int id)
|
||||
{
|
||||
#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);
|
||||
}
|
||||
|
||||
snprintf(name, sizeof(name), prefix, id);
|
||||
return uart_bth4_register(name, driver);
|
||||
#elif defined(CONFIG_NET_BLUETOOTH)
|
||||
return bt_netdev_register(driver);
|
||||
|
|
@ -109,20 +101,20 @@ int bt_driver_register_with_id(FAR struct bt_driver_s *driver, int id)
|
|||
return ret;
|
||||
}
|
||||
|
||||
ret = bt_driver_register_internal(btdrv, id, true);
|
||||
ret = bt_driver_register_internal(btdrv, "/dev/ttyBT%d", id);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = bt_driver_register_internal(bledrv, id, false);
|
||||
ret = bt_driver_register_internal(bledrv, "/dev/ttyBLE%d", id);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
ret = bt_driver_register_internal(driver, id, true);
|
||||
ret = bt_driver_register_internal(driver, "/dev/ttyHCI%d", id);
|
||||
if (ret < 0)
|
||||
{
|
||||
return ret;
|
||||
|
|
|
|||
|
|
@ -49,8 +49,12 @@
|
|||
#define bt_netdev_receive(btdev, type, data, len) \
|
||||
(btdev)->receive(btdev, type, data, len)
|
||||
|
||||
#define bt_driver_register(btdev) \
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
# define bt_driver_register(btdev) \
|
||||
bt_driver_register_with_id(btdev, CONFIG_BLUETOOTH_DEVICE_ID)
|
||||
#else
|
||||
# define bt_driver_register(btdev) bt_netdev_register(btdev)
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
|
|
@ -155,6 +159,8 @@ int bt_netdev_unregister(FAR struct bt_driver_s *btdev);
|
|||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DRIVERS_BLUETOOTH
|
||||
int bt_driver_register_with_id(FAR struct bt_driver_s *driver, int id);
|
||||
#endif
|
||||
|
||||
#endif /* __INCLUDE_NUTTX_WIRELESS_BLUETOOTH_BT_DRIVER_H */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue