arch/sim: Extend hcitty_register to accept device name

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-01-18 02:31:16 +08:00 committed by Alan Carvalho de Assis
parent 8c8c30b9d7
commit aa37399c89
3 changed files with 5 additions and 9 deletions

View File

@ -28,7 +28,6 @@
#include <nuttx/nuttx.h>
#include <string.h>
#include <stdio.h>
#include <poll.h>
#include <queue.h>
@ -411,14 +410,11 @@ void bthcitty_loop(void)
}
}
int bthcitty_register(int dev_id)
int bthcitty_register(const char *name, int id)
{
FAR struct bthcitty_s *dev;
unsigned char name[16];
int ret;
snprintf(name, sizeof(name), "/dev/ttyHCI%d", dev_id);
dev = (FAR struct bthcitty_s *)kmm_zalloc(sizeof(struct bthcitty_s));
if (dev == NULL)
{
@ -426,7 +422,7 @@ int bthcitty_register(int dev_id)
}
dev->fd = -1;
dev->id = dev_id;
dev->id = id;
nxsem_init(&dev->recvlock, 0, 1);
nxsem_init(&dev->sendlock, 0, 1);

View File

@ -400,7 +400,7 @@ int bthcisock_loop(void);
/* up_hcitty.c **************************************************************/
#ifdef CONFIG_SIM_HCITTY
int bthcitty_register(int dev_id);
int bthcitty_register(const char *name, int id);
void bthcitty_loop(void);
#endif

View File

@ -349,9 +349,9 @@ int sim_bringup(void)
#endif
#ifdef CONFIG_SIM_HCITTY
/* Register the Host Bluetooth network device via HCI socket */
/* Register the HCI TTY device via HCI socket */
ret = bthcitty_register(0); /* Use HCI0 */
ret = bthcitty_register("/dev/ttyHCI", 0); /* Use HCI0 */
if (ret < 0)
{
syslog(LOG_ERR, "ERROR: bthcitty_register() failed: %d\n", ret);