mirror of
https://git.kernel.org/pub/scm/bluetooth/bluez.git
synced 2024-11-16 16:54:38 +08:00
emulator: cmd_status() using send_packet() for run hooks easily
Now like cmd_command(), cmd_status() directly uses send_packet() instead of send_event(), consequently cmd_status() must build the hci packet without help of send_event(). With this change the events sent by default_cmd() no more use send_event(), who is a good place to run hooks for BTDEV_HOOK_POST_EVT. And the functions cmd_command() and cmd_status() can run hooks for BTDEV_HOOK_POST_CMD.
This commit is contained in:
parent
6eef674964
commit
0714d4ee67
@ -571,13 +571,31 @@ static void cmd_complete(struct btdev *btdev, uint16_t opcode,
|
||||
|
||||
static void cmd_status(struct btdev *btdev, uint8_t status, uint16_t opcode)
|
||||
{
|
||||
struct bt_hci_evt_cmd_status cs;
|
||||
struct bt_hci_evt_hdr *hdr;
|
||||
struct bt_hci_evt_cmd_status *cs;
|
||||
uint16_t pkt_len;
|
||||
void *pkt_data;
|
||||
|
||||
cs.status = status;
|
||||
cs.ncmd = 0x01;
|
||||
cs.opcode = cpu_to_le16(opcode);
|
||||
pkt_len = 1 + sizeof(*hdr) + sizeof(*cs);
|
||||
|
||||
send_event(btdev, BT_HCI_EVT_CMD_STATUS, &cs, sizeof(cs));
|
||||
pkt_data = malloc(pkt_len);
|
||||
if (!pkt_data)
|
||||
return;
|
||||
|
||||
((uint8_t *) pkt_data)[0] = BT_H4_EVT_PKT;
|
||||
|
||||
hdr = pkt_data + 1;
|
||||
hdr->evt = BT_HCI_EVT_CMD_STATUS;
|
||||
hdr->plen = sizeof(*cs);
|
||||
|
||||
cs = pkt_data + 1 + sizeof(*hdr);
|
||||
cs->status = status;
|
||||
cs->ncmd = 0x01;
|
||||
cs->opcode = cpu_to_le16(opcode);
|
||||
|
||||
send_packet(btdev, pkt_data, pkt_len);
|
||||
|
||||
free(pkt_data);
|
||||
}
|
||||
|
||||
static void num_completed_packets(struct btdev *btdev)
|
||||
|
Loading…
Reference in New Issue
Block a user