mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-16 16:54:38 +08:00
emulator: Add special Virtual HCI setup command
This commit is contained in:
parent
38c5dcc9a8
commit
57a43ed48e
@ -33,6 +33,9 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
#include <bluetooth/hci.h>
|
||||
|
||||
#include "monitor/mainloop.h"
|
||||
#include "monitor/bt.h"
|
||||
#include "btdev.h"
|
||||
@ -93,20 +96,27 @@ struct vhci *vhci_open(enum vhci_type type)
|
||||
{
|
||||
struct vhci *vhci;
|
||||
enum btdev_type uninitialized_var(btdev_type);
|
||||
unsigned char uninitialized_var(ctrl_type);
|
||||
unsigned char setup_cmd[2];
|
||||
static uint8_t id = 0x23;
|
||||
|
||||
switch (type) {
|
||||
case VHCI_TYPE_BREDRLE:
|
||||
btdev_type = BTDEV_TYPE_BREDRLE;
|
||||
ctrl_type = HCI_BREDR;
|
||||
break;
|
||||
case VHCI_TYPE_BREDR:
|
||||
btdev_type = BTDEV_TYPE_BREDR;
|
||||
ctrl_type = HCI_BREDR;
|
||||
break;
|
||||
case VHCI_TYPE_LE:
|
||||
btdev_type = BTDEV_TYPE_LE;
|
||||
ctrl_type = HCI_BREDR;
|
||||
break;
|
||||
case VHCI_TYPE_AMP:
|
||||
return NULL;
|
||||
btdev_type = BTDEV_TYPE_AMP;
|
||||
ctrl_type = HCI_AMP;
|
||||
break;
|
||||
}
|
||||
|
||||
vhci = malloc(sizeof(*vhci));
|
||||
@ -122,6 +132,15 @@ struct vhci *vhci_open(enum vhci_type type)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
setup_cmd[0] = HCI_VENDOR_PKT;
|
||||
setup_cmd[1] = ctrl_type;
|
||||
|
||||
if (write(vhci->fd, setup_cmd, sizeof(setup_cmd)) < 0) {
|
||||
close(vhci->fd);
|
||||
free(vhci);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vhci->btdev = btdev_create(btdev_type, id++);
|
||||
if (!vhci->btdev) {
|
||||
close(vhci->fd);
|
||||
|
Loading…
Reference in New Issue
Block a user