void ble_hs_test_util_rx_ack(uint16_t opcode, uint8_t status) { uint8_t buf[BLE_HCI_EVENT_CMD_STATUS_LEN]; int rc; ble_hs_test_util_build_cmd_status(buf, sizeof buf, status, 1, opcode); rc = host_hci_event_rx(buf); TEST_ASSERT(rc == 0); }
void ble_hs_test_util_rx_ack_param(uint16_t opcode, uint8_t status, void *param, int param_len) { uint8_t buf[256]; int rc; ble_hs_test_util_build_cmd_complete(buf, sizeof buf, param_len + 1, 1, opcode); buf[BLE_HCI_EVENT_CMD_COMPLETE_HDR_LEN] = status; memcpy(buf + BLE_HCI_EVENT_CMD_COMPLETE_HDR_LEN + 1, param, param_len); rc = host_hci_event_rx(buf); TEST_ASSERT(rc == 0); }
int host_hci_os_event_proc(struct os_event *ev) { os_error_t err; int rc; rc = host_hci_event_rx(ev->ev_arg); /* Free the command buffer */ err = os_memblock_put(&g_hci_cmd_pool, ev->ev_arg); assert(err == OS_OK); /* Free the event */ err = os_memblock_put(&g_hci_os_event_pool, ev); assert(err == OS_OK); return rc; }
void ble_hs_test_util_rx_hci_buf_size_ack(uint16_t buf_size) { uint8_t buf[BLE_HCI_EVENT_CMD_COMPLETE_HDR_LEN + BLE_HCI_RD_BUF_SIZE_RSPLEN + 1]; int rc; ble_hs_test_util_build_cmd_complete(buf, sizeof buf, BLE_HCI_RD_BUF_SIZE_RSPLEN + 1, 1, (BLE_HCI_OGF_LE << 10) | BLE_HCI_OCF_LE_RD_BUF_SIZE); buf[BLE_HCI_EVENT_CMD_COMPLETE_HDR_LEN + 0] = 0; htole16(buf + BLE_HCI_EVENT_CMD_COMPLETE_HDR_LEN + 1, buf_size); buf[BLE_HCI_EVENT_CMD_COMPLETE_HDR_LEN + 3] = 1; rc = host_hci_event_rx(buf); TEST_ASSERT(rc == 0); }
void ble_hs_test_util_rx_num_completed_pkts_event( struct ble_hs_test_util_num_completed_pkts_entry *entries) { struct ble_hs_test_util_num_completed_pkts_entry *entry; uint8_t buf[1024]; int num_entries; int off; int rc; int i; /* Count number of entries. */ num_entries = 0; for (entry = entries; entry->handle_id != 0; entry++) { num_entries++; } assert(num_entries <= UINT8_MAX); buf[0] = BLE_HCI_EVCODE_NUM_COMP_PKTS; buf[2] = num_entries; off = 3; for (i = 0; i < num_entries; i++) { htole16(buf + off, entries[i].handle_id); off += 2; } for (i = 0; i < num_entries; i++) { htole16(buf + off, entries[i].num_pkts); off += 2; } buf[1] = off - 2; rc = host_hci_event_rx(buf); TEST_ASSERT(rc == 0); }