** Returns void
**
*******************************************************************************/
- void bta_alarm_cb(void *data) {
- assert(data != NULL);
- TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
+ void bta_alarm_cb(void *data)
+ {
+ assert(data != NULL);
+ TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
- fixed_queue_enqueue(btu_bta_alarm_queue, p_tle);
+ fixed_queue_enqueue(btu_bta_alarm_queue, p_tle);
}
- void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms) {
- assert(p_tle != NULL);
-
- // Get the alarm for this p_tle.
- pthread_mutex_lock(&bta_alarm_lock);
- if (!hash_map_has_key(bta_alarm_hash_map, p_tle)) {
- hash_map_set(bta_alarm_hash_map, p_tle, osi_alarm_new("bta_sys", bta_alarm_cb, p_tle, 0, false));
- }
- pthread_mutex_unlock(&bta_alarm_lock);
-
- osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
- if (alarm == NULL) {
- LOG_ERROR("%s unable to create alarm.", __func__);
- return;
- }
-
- p_tle->event = type;
- p_tle->ticks = timeout_ms;
- //osi_alarm_set(alarm, (period_ms_t)timeout_ms, bta_alarm_cb, p_tle);
- osi_alarm_set(alarm, (period_ms_t)timeout_ms);
+ void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms)
+ {
+ assert(p_tle != NULL);
+
+ // Get the alarm for this p_tle.
+ pthread_mutex_lock(&bta_alarm_lock);
+ if (!hash_map_has_key(bta_alarm_hash_map, p_tle)) {
- hash_map_set(bta_alarm_hash_map, p_tle, osi_alarm_new("bta_sys", bta_alarm_cb, p_tle, 0));
++ hash_map_set(bta_alarm_hash_map, p_tle, osi_alarm_new("bta_sys", bta_alarm_cb, p_tle, 0, false));
+ }
+ pthread_mutex_unlock(&bta_alarm_lock);
+
+ osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
+ if (alarm == NULL) {
+ LOG_ERROR("%s unable to create alarm.", __func__);
+ return;
+ }
+
+ p_tle->event = type;
+ p_tle->ticks = timeout_ms;
+ //osi_alarm_set(alarm, (period_ms_t)timeout_ms, bta_alarm_cb, p_tle);
+ osi_alarm_set(alarm, (period_ms_t)timeout_ms);
}
bool hash_iter_ro_cb(hash_map_entry_t *hash_map_entry, void *context)
*******************************************************************************/
void *GKI_getbuf (UINT16 size)
{
- BUFFER_HDR_T *header = osi_malloc(size + BUFFER_HDR_SIZE);
- assert(header != NULL);
- if (header != NULL) {
- header->status = BUF_STATUS_UNLINKED;
- header->p_next = NULL;
- header->Type = 0;
- header->size = size;
-
- return header + 1;
- } else {
- return NULL;
- }
+ BUFFER_HDR_T *header = osi_malloc(size + BUFFER_HDR_SIZE);
- header->status = BUF_STATUS_UNLINKED;
- header->p_next = NULL;
- header->Type = 0;
- header->size = size;
-
- return header + 1;
++ assert(header != NULL);
++ if (header != NULL) {
++ header->status = BUF_STATUS_UNLINKED;
++ header->p_next = NULL;
++ header->Type = 0;
++ header->size = size;
++
++ return header + 1;
++ } else {
++ return NULL;
++ }
}
static bool hal_open(const hci_hal_callbacks_t *upper_callbacks)
{
- assert(upper_callbacks != NULL);
- callbacks = upper_callbacks;
+ assert(upper_callbacks != NULL);
+ callbacks = upper_callbacks;
- hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, SIZE_MAX);
-
- xHciH4Queue = xQueueCreate(60, sizeof(BtTaskEvt_t));
- xTaskCreate(hci_hal_h4_rx_handler, "HciH4T", 2048+1024, NULL, configMAX_PRIORITIES - 3, &xHciH4TaskHandle);
+ hci_hal_env_init(HCI_HAL_SERIAL_BUFFER_SIZE, SIZE_MAX);
- //register vhci host cb
- API_vhci_host_register_callback(&vhci_host_cb);
+ xHciH4Queue = xQueueCreate(60, sizeof(BtTaskEvt_t));
- xTaskCreate(hci_hal_h4_rx_handler, "HciH4T", 4096 + 2048, NULL, configMAX_PRIORITIES - 3, &xHciH4TaskHandle);
++ xTaskCreate(hci_hal_h4_rx_handler, "HciH4T", 2048 + 1024, NULL, configMAX_PRIORITIES - 3, &xHciH4TaskHandle);
+ //register vhci host cb
+ API_vhci_host_register_callback(&vhci_host_cb);
- return true;
-
+ return true;
}
- static void hal_close() {
- hci_hal_env_deinit();
-
- /* delete task and queue */
- vTaskDelete(xHciH4TaskHandle);
- vQueueDelete(xHciH4Queue);
+ static void hal_close()
+ {
+ hci_hal_env_deinit();
+
+ /* delete task and queue */
+ vTaskDelete(xHciH4TaskHandle);
+ vQueueDelete(xHciH4Queue);
}
/**
}
}
- static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet) {
- uint8_t type, hdr_size;
- uint16_t length;
- uint8_t *stream = packet->data + packet->offset;
+ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
+ {
+ uint8_t type, hdr_size;
+ uint16_t length;
+ uint8_t *stream = packet->data + packet->offset;
- if (!packet)
- return;
- STREAM_TO_UINT8(type, stream);
- packet->offset++;
- packet->len--;
- if (type == HCI_BLE_EVENT) {
- uint8_t len;
- STREAM_TO_UINT8(len, stream);
- LOG_ERROR("Workround stream corrupted during LE SCAN: pkt_len=%d ble_event_len=%d",
- packet->len, len);
- hci_hal_env.allocator->free(packet);
- return;
- }
- if (type < DATA_TYPE_ACL || type > DATA_TYPE_EVENT) {
- LOG_ERROR("%d Unknown HCI message type. Dropping this byte 0x%x,"
- " min %x, max %x", __func__, type,
- DATA_TYPE_ACL, DATA_TYPE_EVENT);
- hci_hal_env.allocator->free(packet);
- return;
- }
- hdr_size = preamble_sizes[type - 1];
- if (packet->len < hdr_size) {
- LOG_ERROR("Wrong packet length type=%s pkt_len=%d hdr_len=%d",
- type, packet->len, hdr_size);
- hci_hal_env.allocator->free(packet);
- return;
- }
- if (type == DATA_TYPE_ACL) {
- stream += hdr_size - 2;
- STREAM_TO_UINT16(length, stream);
- } else {
- stream += hdr_size - 1;
- STREAM_TO_UINT8(length, stream);
- }
-
- if ((length + hdr_size) != packet->len) {
- LOG_ERROR("Wrong packet length type=%d hdr_len=%d pd_len=%d "
- "pkt_len=%d", type, hdr_size, length, packet->len);
- hci_hal_env.allocator->free(packet);
- return;
- }
+ if (!packet) {
+ return;
+ }
+ STREAM_TO_UINT8(type, stream);
+ packet->offset++;
+ packet->len--;
+ if (type == HCI_BLE_EVENT) {
+ uint8_t len;
+ STREAM_TO_UINT8(len, stream);
+ LOG_ERROR("Workround stream corrupted during LE SCAN: pkt_len=%d ble_event_len=%d\n",
+ packet->len, len);
+ hci_hal_env.allocator->free(packet);
+ return;
+ }
+ if (type < DATA_TYPE_ACL || type > DATA_TYPE_EVENT) {
+ LOG_ERROR("%s Unknown HCI message type. Dropping this byte 0x%x,"
+ " min %x, max %x\n", __func__, type,
+ DATA_TYPE_ACL, DATA_TYPE_EVENT);
+ hci_hal_env.allocator->free(packet);
+ return;
+ }
+ hdr_size = preamble_sizes[type - 1];
+ if (packet->len < hdr_size) {
+ LOG_ERROR("Wrong packet length type=%d pkt_len=%d hdr_len=%d",
+ type, packet->len, hdr_size);
+ hci_hal_env.allocator->free(packet);
+ return;
+ }
+ if (type == DATA_TYPE_ACL) {
- packet->offset--;
+ stream += hdr_size - 2;
+ STREAM_TO_UINT16(length, stream);
- stream = packet->data + 1;
- memcpy(packet->data, stream, packet->len);
+ } else {
+ stream += hdr_size - 1;
+ STREAM_TO_UINT8(length, stream);
+ }
- packet->event = outbound_event_types[PACKET_TYPE_TO_INDEX(type)];
- callbacks->packet_ready(packet);
+ if ((length + hdr_size) != packet->len) {
+ LOG_ERROR("Wrong packet length type=%d hdr_len=%d pd_len=%d "
+ "pkt_len=%d", type, hdr_size, length, packet->len);
+ hci_hal_env.allocator->free(packet);
+ return;
+ }
+
+ packet->event = outbound_event_types[PACKET_TYPE_TO_INDEX(type)];
+ callbacks->packet_ready(packet);
}
- static void event_uart_has_bytes(fixed_queue_t *queue) {
- BT_HDR *packet;
- while (!fixed_queue_is_empty(queue)) {
- packet = fixed_queue_dequeue(queue);
- hci_hal_h4_hdl_rx_packet(packet);
- }
+ static void event_uart_has_bytes(fixed_queue_t *queue)
+ {
+ BT_HDR *packet;
+ while (!fixed_queue_is_empty(queue)) {
+ packet = fixed_queue_dequeue(queue);
+ hci_hal_h4_hdl_rx_packet(packet);
+ }
}
- static void host_send_pkt_available_cb(void) {
- //Controller rx cache buffer is ready for receiving new host packet
- //Just Call Host main thread task to process pending packets.
- hci_host_task_post();
+ static void host_send_pkt_available_cb(void)
+ {
+ //Controller rx cache buffer is ready for receiving new host packet
+ //Just Call Host main thread task to process pending packets.
+ hci_host_task_post();
}
- static int host_recv_pkt_cb(uint8_t *data, uint16_t len) {
- //Target has packet to host, malloc new buffer for packet
- BT_HDR *pkt;
- size_t pkt_size;
-
- pkt_size = BT_HDR_SIZE + len;
- pkt = (BT_HDR *)hci_hal_env.allocator->alloc(pkt_size);
- if (!pkt) {
- LOG_ERROR("%s couldn't aquire memory for inbound data buffer.", __func__);
- return -1;
- }
- pkt->offset = 0;
- pkt->len = len;
- pkt->layer_specific = 0;
- memcpy(pkt->data, data, len);
- fixed_queue_enqueue(hci_hal_env.rx_q, pkt);
- hci_hal_h4_task_post();
-
- BTTRC_DUMP_BUFFER("Recv Pkt", pkt->data, len);
-
- return 0;
+ static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
+ {
+ //Target has packet to host, malloc new buffer for packet
+ BT_HDR *pkt;
+ size_t pkt_size;
+
+ pkt_size = BT_HDR_SIZE + len;
+ pkt = (BT_HDR *)hci_hal_env.allocator->alloc(pkt_size);
+ if (!pkt) {
+ LOG_ERROR("%s couldn't aquire memory for inbound data buffer.\n", __func__);
+ return -1;
+ }
+ pkt->offset = 0;
+ pkt->len = len;
+ pkt->layer_specific = 0;
+ memcpy(pkt->data, data, len);
+ fixed_queue_enqueue(hci_hal_env.rx_q, pkt);
+ hci_hal_h4_task_post();
+
+ BTTRC_DUMP_BUFFER("Recv Pkt", pkt->data, len);
+
+ return 0;
}
static const vhci_host_callback_t vhci_host_cb = {
static void dispatch_reassembled(BT_HDR *packet);
// Module lifecycle functions
- int hci_start_up(void) {
- if (hci_layer_init_env())
- goto error;
-
- xHciHostQueue = xQueueCreate(60, sizeof(BtTaskEvt_t));
- xTaskCreate(hci_host_thread_handler, "HciHostT", (1024+2048), NULL, configMAX_PRIORITIES - 3, &xHciHostTaskHandle);
-
- packet_fragmenter->init(&packet_fragmenter_callbacks);
- hal->open(&hal_callbacks);
-
- hci_host_startup_flag = true;
- return 0;
+ int hci_start_up(void)
+ {
+ if (hci_layer_init_env()) {
+ goto error;
+ }
+
+ xHciHostQueue = xQueueCreate(60, sizeof(BtTaskEvt_t));
- xTaskCreate(hci_host_thread_handler, "HciHostT", (4096 + 2048), NULL, configMAX_PRIORITIES - 3, &xHciHostTaskHandle);
++ xTaskCreate(hci_host_thread_handler, "HciHostT", (2048 + 1024), NULL, configMAX_PRIORITIES - 3, &xHciHostTaskHandle);
+
+ packet_fragmenter->init(&packet_fragmenter_callbacks);
+ hal->open(&hal_callbacks);
+
+ hci_host_startup_flag = true;
+ return 0;
error:
- hci_shut_down();
- return -1;
+ hci_shut_down();
+ return -1;
}
- void hci_shut_down(void) {
- hci_host_startup_flag = false;
- hci_layer_deinit_env();
+ void hci_shut_down(void)
+ {
+ hci_host_startup_flag = false;
+ hci_layer_deinit_env();
- packet_fragmenter->cleanup();
+ packet_fragmenter->cleanup();
- //low_power_manager->cleanup();
- hal->close();
- vTaskDelete(xHciHostTaskHandle);
- vQueueDelete(xHciHostQueue);
+ //low_power_manager->cleanup();
+ hal->close();
+ vTaskDelete(xHciHostTaskHandle);
+ vQueueDelete(xHciHostQueue);
}
static int hci_layer_init_env(void)
{
- command_waiting_response_t *cmd_wait_q;
-
- // The host is only allowed to send at most one command initially,
- // as per the Bluetooth spec, Volume 2, Part E, 4.4 (Command Flow Control)
- // This value can change when you get a command complete or command status event.
- hci_host_env.command_credits = 1;
- hci_host_env.command_queue = fixed_queue_new(SIZE_MAX);
- if (hci_host_env.command_queue)
- fixed_queue_register_dequeue(hci_host_env.command_queue, event_command_ready);
- else {
- LOG_ERROR("%s unable to create pending command queue.", __func__);
- return -1;
- }
+ command_waiting_response_t *cmd_wait_q;
+
+ // The host is only allowed to send at most one command initially,
+ // as per the Bluetooth spec, Volume 2, Part E, 4.4 (Command Flow Control)
+ // This value can change when you get a command complete or command status event.
+ hci_host_env.command_credits = 1;
+ hci_host_env.command_queue = fixed_queue_new(SIZE_MAX);
+ if (hci_host_env.command_queue) {
+ fixed_queue_register_dequeue(hci_host_env.command_queue, event_command_ready);
+ } else {
+ LOG_ERROR("%s unable to create pending command queue.", __func__);
+ return -1;
+ }
- hci_host_env.packet_queue = fixed_queue_new(SIZE_MAX);
- if (hci_host_env.packet_queue)
- fixed_queue_register_dequeue(hci_host_env.packet_queue, event_packet_ready);
- else {
- LOG_ERROR("%s unable to create pending packet queue.", __func__);
- return -1;
- }
-
- // Init Commands waiting response list and timer
- cmd_wait_q = &hci_host_env.cmd_waiting_q;
- cmd_wait_q->timer_is_set = false;
- cmd_wait_q->commands_pending_response = list_new(NULL);
- if (!cmd_wait_q->commands_pending_response) {
- LOG_ERROR("%s unable to create list for commands pending response.", __func__);
- return -1;
- }
- pthread_mutex_init(&cmd_wait_q->commands_pending_response_lock, NULL);
- cmd_wait_q->command_response_timer = osi_alarm_new("cmd_rsp_to", command_timed_out, cmd_wait_q, COMMAND_PENDING_TIMEOUT, false);
- if (!cmd_wait_q->command_response_timer) {
- LOG_ERROR("%s unable to create command response timer.", __func__);
- return -1;
- }
+ hci_host_env.packet_queue = fixed_queue_new(SIZE_MAX);
+ if (hci_host_env.packet_queue) {
+ fixed_queue_register_dequeue(hci_host_env.packet_queue, event_packet_ready);
+ } else {
+ LOG_ERROR("%s unable to create pending packet queue.", __func__);
+ return -1;
+ }
- return 0;
+ // Init Commands waiting response list and timer
+ cmd_wait_q = &hci_host_env.cmd_waiting_q;
+ cmd_wait_q->timer_is_set = false;
+ cmd_wait_q->commands_pending_response = list_new(NULL);
+ if (!cmd_wait_q->commands_pending_response) {
+ LOG_ERROR("%s unable to create list for commands pending response.", __func__);
+ return -1;
+ }
+ pthread_mutex_init(&cmd_wait_q->commands_pending_response_lock, NULL);
- cmd_wait_q->command_response_timer = osi_alarm_new("cmd_rsp_to", command_timed_out, cmd_wait_q, COMMAND_PENDING_TIMEOUT);
++ cmd_wait_q->command_response_timer = osi_alarm_new("cmd_rsp_to", command_timed_out, cmd_wait_q, COMMAND_PENDING_TIMEOUT, false);
+ if (!cmd_wait_q->command_response_timer) {
+ LOG_ERROR("%s unable to create command response timer.", __func__);
+ return -1;
+ }
+
+ return 0;
}
static void hci_layer_deinit_env(void)
}
// Callback for the fragmenter to send a fragment
- static void transmit_fragment(BT_HDR *packet, bool send_transmit_finished) {
- uint16_t event = packet->event & MSG_EVT_MASK;
- serial_data_type_t type = event_to_data_type(event);
+ static void transmit_fragment(BT_HDR *packet, bool send_transmit_finished)
+ {
+ uint16_t event = packet->event & MSG_EVT_MASK;
+ serial_data_type_t type = event_to_data_type(event);
- hal->transmit_data(type, packet->data + packet->offset, packet->len);
+ hal->transmit_data(type, packet->data + packet->offset, packet->len);
- if (event != MSG_STACK_TO_HC_HCI_CMD && send_transmit_finished)
- buffer_allocator->free(packet);
+ if (event != MSG_STACK_TO_HC_HCI_CMD && send_transmit_finished) {
+ buffer_allocator->free(packet);
+ }
}
- static void fragmenter_transmit_finished(BT_HDR *packet, bool all_fragments_sent) {
- if (all_fragments_sent) {
- buffer_allocator->free(packet);
- } else {
- // This is kind of a weird case, since we're dispatching a partially sent packet
- // up to a higher layer.
- // TODO(zachoverflow): rework upper layer so this isn't necessary.
- dispatch_reassembled(packet);
- //data_dispatcher_dispatch(interface.event_dispatcher, packet->event & MSG_EVT_MASK, packet);
- }
+ static void fragmenter_transmit_finished(BT_HDR *packet, bool all_fragments_sent)
+ {
+ if (all_fragments_sent) {
+ buffer_allocator->free(packet);
+ } else {
+ // This is kind of a weird case, since we're dispatching a partially sent packet
+ // up to a higher layer.
+ // TODO(zachoverflow): rework upper layer so this isn't necessary.
- buffer_allocator->free(packet);
- //dispatch_reassembled(packet);
++ dispatch_reassembled(packet);
+ //data_dispatcher_dispatch(interface.event_dispatcher, packet->event & MSG_EVT_MASK, packet);
+ }
}
static void restart_comamnd_waiting_response_timer(
static hash_map_t *partial_packets;
static BT_HDR *current_fragment_packet;
- static void init(const packet_fragmenter_callbacks_t *result_callbacks) {
- current_fragment_packet = NULL;
- callbacks = result_callbacks;
- partial_packets = hash_map_new(NUMBER_OF_BUCKETS, hash_function_naive, NULL, NULL, NULL);
+ static void init(const packet_fragmenter_callbacks_t *result_callbacks)
+ {
+ current_fragment_packet = NULL;
+ callbacks = result_callbacks;
+ partial_packets = hash_map_new(NUMBER_OF_BUCKETS, hash_function_naive, NULL, NULL, NULL);
}
- static void cleanup() {
- if (partial_packets)
- hash_map_free(partial_packets);
+ static void cleanup()
+ {
+ if (partial_packets) {
+ hash_map_free(partial_packets);
+ }
}
- static BT_HDR *fragment_get_current_packet() {
- return current_fragment_packet;
+ static BT_HDR *fragment_get_current_packet()
+ {
+ return current_fragment_packet;
}
- static void fragment_and_dispatch(BT_HDR *packet) {
- uint16_t continuation_handle;
- uint16_t max_data_size, max_packet_size, remaining_length;
- uint16_t event = packet->event & MSG_EVT_MASK;
- uint8_t *stream = packet->data + packet->offset;
-
- assert(packet != NULL);
-
- // We only fragment ACL packets
- if (event != MSG_STACK_TO_HC_HCI_ACL) {
- callbacks->fragmented(packet, true);
- return;
- }
-
- max_data_size =
- SUB_EVENT(packet->event) == LOCAL_BR_EDR_CONTROLLER_ID ?
- controller->get_acl_data_size_classic() :
- controller->get_acl_data_size_ble();
-
- max_packet_size = max_data_size + HCI_ACL_PREAMBLE_SIZE;
- remaining_length = packet->len;
-
- STREAM_TO_UINT16(continuation_handle, stream);
- continuation_handle = APPLY_CONTINUATION_FLAG(continuation_handle);
- if (remaining_length > max_packet_size) {
- current_fragment_packet = packet;
- UINT16_TO_STREAM(stream, max_packet_size);
- packet->len = max_packet_size;
- callbacks->fragmented(packet, false);
- packet->offset += max_data_size;
- remaining_length -= max_data_size;
- packet->len = remaining_length;
-
- // Write the ACL header for the next fragment
- stream = packet->data + packet->offset;
- UINT16_TO_STREAM(stream, continuation_handle);
- UINT16_TO_STREAM(stream, remaining_length - HCI_ACL_PREAMBLE_SIZE);
-
- // Apparently L2CAP can set layer_specific to a max number of segments to transmit
- if (packet->layer_specific) {
- packet->layer_specific--;
- if (packet->layer_specific == 0) {
- packet->event = MSG_HC_TO_STACK_L2C_SEG_XMIT;
- callbacks->transmit_finished(packet, false);
+ static void fragment_and_dispatch(BT_HDR *packet)
+ {
+ uint16_t continuation_handle;
+ uint16_t max_data_size, max_packet_size, remaining_length;
+ uint16_t event = packet->event & MSG_EVT_MASK;
+ uint8_t *stream = packet->data + packet->offset;
+
+ assert(packet != NULL);
+
+ // We only fragment ACL packets
+ if (event != MSG_STACK_TO_HC_HCI_ACL) {
+ callbacks->fragmented(packet, true);
return;
- }
}
- } else {
- current_fragment_packet = NULL;
- callbacks->fragmented(packet, true);
- }
+
+ max_data_size =
+ SUB_EVENT(packet->event) == LOCAL_BR_EDR_CONTROLLER_ID ?
+ controller->get_acl_data_size_classic() :
+ controller->get_acl_data_size_ble();
+
+ max_packet_size = max_data_size + HCI_ACL_PREAMBLE_SIZE;
+ remaining_length = packet->len;
+
+ STREAM_TO_UINT16(continuation_handle, stream);
+ continuation_handle = APPLY_CONTINUATION_FLAG(continuation_handle);
+ if (remaining_length > max_packet_size) {
+ current_fragment_packet = packet;
+ UINT16_TO_STREAM(stream, max_packet_size);
+ packet->len = max_packet_size;
+ callbacks->fragmented(packet, false);
+ packet->offset += max_data_size;
+ remaining_length -= max_data_size;
+ packet->len = remaining_length;
+
+ // Write the ACL header for the next fragment
+ stream = packet->data + packet->offset;
+ UINT16_TO_STREAM(stream, continuation_handle);
+ UINT16_TO_STREAM(stream, remaining_length - HCI_ACL_PREAMBLE_SIZE);
+
+ // Apparently L2CAP can set layer_specific to a max number of segments to transmit
+ if (packet->layer_specific) {
+ packet->layer_specific--;
+ if (packet->layer_specific == 0) {
+ packet->event = MSG_HC_TO_STACK_L2C_SEG_XMIT;
+ callbacks->transmit_finished(packet, false);
+ return;
+ }
+ }
+ } else {
+ current_fragment_packet = NULL;
+ callbacks->fragmented(packet, true);
+ }
}
- static void reassemble_and_dispatch(BT_HDR *packet) {
- if ((packet->event & MSG_EVT_MASK) == MSG_HC_TO_STACK_HCI_ACL) {
- uint8_t *stream = packet->data + packet->offset;
- uint16_t handle;
- uint16_t l2cap_length;
- uint16_t acl_length;
- uint8_t boundary_flag;
- BT_HDR *partial_packet;
-
- STREAM_TO_UINT16(handle, stream);
- STREAM_TO_UINT16(acl_length, stream);
- STREAM_TO_UINT16(l2cap_length, stream);
-
- assert(acl_length == packet->len - HCI_ACL_PREAMBLE_SIZE);
-
- boundary_flag = GET_BOUNDARY_FLAG(handle);
- handle = handle & HANDLE_MASK;
-
- partial_packet = (BT_HDR *)hash_map_get(partial_packets, (void *)(uintptr_t)handle);
-
- if (boundary_flag == START_PACKET_BOUNDARY) {
- uint16_t full_length;
- if (partial_packet) {
- LOG_WARN("%s found unfinished packet for handle with start packet. Dropping old.", __func__);
- hash_map_erase(partial_packets, (void *)(uintptr_t)handle);
- buffer_allocator->free(partial_packet);
- }
-
- full_length = l2cap_length + L2CAP_HEADER_SIZE + HCI_ACL_PREAMBLE_SIZE;
- if (full_length <= packet->len) {
- if (full_length < packet->len)
- LOG_WARN("%s found l2cap full length %d less than the hci length %d.", __func__, l2cap_length, packet->len);
-
- callbacks->reassembled(packet);
- return;
- }
-
- partial_packet = (BT_HDR *)buffer_allocator->alloc(full_length + sizeof(BT_HDR));
- partial_packet->event = packet->event;
- partial_packet->len = full_length;
- partial_packet->offset = packet->len;
-
- memcpy(partial_packet->data, packet->data+packet->offset, packet->len);
-
- // Update the ACL data size to indicate the full expected length
- stream = partial_packet->data;
- STREAM_SKIP_UINT16(stream); // skip the handle
- UINT16_TO_STREAM(stream, full_length - HCI_ACL_PREAMBLE_SIZE);
-
- hash_map_set(partial_packets, (void *)(uintptr_t)handle, partial_packet);
- // Free the old packet buffer, since we don't need it anymore
- buffer_allocator->free(packet);
+ static void reassemble_and_dispatch(BT_HDR *packet)
+ {
- LOG_DEBUG("reassemble_and_dispatch\n");
-
+ if ((packet->event & MSG_EVT_MASK) == MSG_HC_TO_STACK_HCI_ACL) {
- uint8_t *stream = packet->data;
++ uint8_t *stream = packet->data + packet->offset;
+ uint16_t handle;
+ uint16_t l2cap_length;
+ uint16_t acl_length;
++ uint8_t boundary_flag;
++ BT_HDR *partial_packet;
+
+ STREAM_TO_UINT16(handle, stream);
+ STREAM_TO_UINT16(acl_length, stream);
+ STREAM_TO_UINT16(l2cap_length, stream);
+
+ assert(acl_length == packet->len - HCI_ACL_PREAMBLE_SIZE);
+
- uint8_t boundary_flag = GET_BOUNDARY_FLAG(handle);
++ boundary_flag = GET_BOUNDARY_FLAG(handle);
+ handle = handle & HANDLE_MASK;
+
- BT_HDR *partial_packet = (BT_HDR *)hash_map_get(partial_packets, (void *)(uintptr_t)handle);
++ partial_packet = (BT_HDR *)hash_map_get(partial_packets, (void *)(uintptr_t)handle);
+
+ if (boundary_flag == START_PACKET_BOUNDARY) {
++ uint16_t full_length;
+ if (partial_packet) {
- LOG_ERROR("%s found unfinished packet for handle with start packet. Dropping old.\n", __func__);
- LOG_ERROR("partial_packet->len = %x, offset = %x\n", partial_packet->len, partial_packet->len);
-
- for (int i = 0; i < partial_packet->len; i++) {
- LOG_ERROR("%x", partial_packet->data[i]);
- }
- LOG_ERROR("\n");
++ LOG_WARN("%s found unfinished packet for handle with start packet. Dropping old.", __func__);
+ hash_map_erase(partial_packets, (void *)(uintptr_t)handle);
- //buffer_allocator->free(partial_packet);
- LOG_ERROR("+++++++++++++++++++\n");
++ buffer_allocator->free(partial_packet);
+ }
+
- uint16_t full_length = l2cap_length + L2CAP_HEADER_SIZE + HCI_ACL_PREAMBLE_SIZE;
++ full_length = l2cap_length + L2CAP_HEADER_SIZE + HCI_ACL_PREAMBLE_SIZE;
+ if (full_length <= packet->len) {
+ if (full_length < packet->len) {
- LOG_WARN("%s found l2cap full length %d less than the hci length %d.\n", __func__, l2cap_length, packet->len);
++ LOG_WARN("%s found l2cap full length %d less than the hci length %d.", __func__, l2cap_length, packet->len);
+ }
+
+ callbacks->reassembled(packet);
+ return;
+ }
+
+ partial_packet = (BT_HDR *)buffer_allocator->alloc(full_length + sizeof(BT_HDR));
+ partial_packet->event = packet->event;
+ partial_packet->len = full_length;
+ partial_packet->offset = packet->len;
+
- memcpy(partial_packet->data, packet->data, packet->len);
++ memcpy(partial_packet->data, packet->data + packet->offset, packet->len);
+
+ // Update the ACL data size to indicate the full expected length
+ stream = partial_packet->data;
+ STREAM_SKIP_UINT16(stream); // skip the handle
+ UINT16_TO_STREAM(stream, full_length - HCI_ACL_PREAMBLE_SIZE);
+
+ hash_map_set(partial_packets, (void *)(uintptr_t)handle, partial_packet);
+ // Free the old packet buffer, since we don't need it anymore
+ buffer_allocator->free(packet);
+ } else {
++ uint16_t projected_offset;
+ if (!partial_packet) {
- LOG_ERROR("%s got continuation for unknown packet. Dropping it.\n", __func__);
++ LOG_WARN("%s got continuation for unknown packet. Dropping it.", __func__);
+ buffer_allocator->free(packet);
+ return;
+ }
+
- packet->offset = HCI_ACL_PREAMBLE_SIZE;
- uint16_t projected_offset = partial_packet->offset + (packet->len - HCI_ACL_PREAMBLE_SIZE);
++ packet->offset += HCI_ACL_PREAMBLE_SIZE; // skip ACL preamble
++ packet->len -= HCI_ACL_PREAMBLE_SIZE;
++
++ projected_offset = partial_packet->offset + packet->len;
+ if (projected_offset > partial_packet->len) { // len stores the expected length
- LOG_ERROR("%s got packet which would exceed expected length of %d. Truncating.\n", __func__, partial_packet->len);
++ LOG_WARN("%s got packet which would exceed expected length of %d. Truncating.", __func__, partial_packet->len);
+ packet->len = partial_packet->len - partial_packet->offset;
+ projected_offset = partial_packet->len;
+ }
+
+ memcpy(
+ partial_packet->data + partial_packet->offset,
+ packet->data + packet->offset,
- packet->len - packet->offset
++ packet->len
+ );
-
+ // Free the old packet buffer, since we don't need it anymore
+ buffer_allocator->free(packet);
+ partial_packet->offset = projected_offset;
+
+ if (partial_packet->offset == partial_packet->len) {
- stream = partial_packet->data;
- STREAM_TO_UINT16(handle, stream);
- STREAM_TO_UINT16(acl_length, stream);
- STREAM_TO_UINT16(l2cap_length, stream);
- LOG_ERROR("partial_packet->offset = %x\n", partial_packet->offset);
+ hash_map_erase(partial_packets, (void *)(uintptr_t)handle);
+ partial_packet->offset = 0;
-
-
+ callbacks->reassembled(partial_packet);
+ }
+ }
} else {
- uint16_t projected_offset;
- if (!partial_packet) {
- LOG_WARN("%s got continuation for unknown packet. Dropping it.", __func__);
- buffer_allocator->free(packet);
- return;
- }
-
- packet->offset += HCI_ACL_PREAMBLE_SIZE; // skip ACL preamble
- packet->len -= HCI_ACL_PREAMBLE_SIZE;
-
- projected_offset = partial_packet->offset + packet->len;
- if (projected_offset > partial_packet->len) { // len stores the expected length
- LOG_WARN("%s got packet which would exceed expected length of %d. Truncating.", __func__, partial_packet->len);
- packet->len = partial_packet->len - partial_packet->offset;
- projected_offset = partial_packet->len;
- }
-
- memcpy(
- partial_packet->data + partial_packet->offset,
- packet->data + packet->offset,
- packet->len
- );
- // Free the old packet buffer, since we don't need it anymore
- buffer_allocator->free(packet);
- partial_packet->offset = projected_offset;
-
- if (partial_packet->offset == partial_packet->len) {
- hash_map_erase(partial_packets, (void *)(uintptr_t)handle);
- partial_packet->offset = 0;
- callbacks->reassembled(partial_packet);
- }
+ callbacks->reassembled(packet);
}
- } else {
- callbacks->reassembled(packet);
- }
}
static const packet_fragmenter_t interface = {
static void alarm_cb_handler(TimerHandle_t xTimer)
{
- struct alarm_t *alarm;
-
- if (!xTimer) {
- LOG_DEBUG("TimerName: NULL\n");
- return;
- }
-
- alarm = pvTimerGetTimerID(xTimer);
- LOG_DEBUG("TimerID %08x, Name %s\n", alarm, pcTimerGetTimerName(xTimer));
- if (alarm->cb) {
- alarm->cb(alarm->cb_data);
- }
+ struct alarm_t *alarm;
+
+ if (!xTimer) {
+ LOG_DEBUG("TimerName: NULL\n");
+ return;
+ }
+
+ alarm = pvTimerGetTimerID(xTimer);
+ LOG_DEBUG("TimerID %08x, Name %s\n", alarm, pcTimerGetTimerName(xTimer));
+ if (alarm->cb) {
+ alarm->cb(alarm->cb_data);
+ }
}
-osi_alarm_t *osi_alarm_new(char *alarm_name, osi_alarm_callback_t callback, void *data, period_ms_t timer_expire)
+osi_alarm_t *osi_alarm_new(char *alarm_name, osi_alarm_callback_t callback, void *data, period_ms_t timer_expire, bool is_periodic)
{
- struct alarm_t *timer_id;
- TimerHandle_t t;
-
- if (timer_expire == 0)
- timer_expire = 1000;
-
- /* TODO mutex lock */
- timer_id = alarm_cbs_lookfor_available();
- if (!timer_id) {
- LOG_ERROR("%s full\n", __func__);
- return NULL;
- }
-
- portBASE_TYPE auto_reload = is_periodic ? pdTRUE : pdFALSE;
- t = xTimerCreate(alarm_name, timer_expire / portTICK_PERIOD_MS, auto_reload, timer_id, alarm_cb_handler);
- if (!t) {
- LOG_ERROR("%s error\n", __func__);
- return NULL;
- }
-
- timer_id->alarm_hdl = t;
- timer_id->cb = callback;
- timer_id->cb_data = data;
- /* TODO mutex unlock */
-
- return timer_id;
+ struct alarm_t *timer_id;
+ TimerHandle_t t;
+
+ if (timer_expire == 0) {
+ timer_expire = 1000;
+ }
+
+ /* TODO mutex lock */
+ timer_id = alarm_cbs_lookfor_available();
+ if (!timer_id) {
+ LOG_ERROR("%s full\n", __func__);
+ return NULL;
+ }
+
- t = xTimerCreate(alarm_name, timer_expire / portTICK_PERIOD_MS, pdFALSE, timer_id, alarm_cb_handler);
++ portBASE_TYPE auto_reload = is_periodic ? pdTRUE : pdFALSE;
++ t = xTimerCreate(alarm_name, timer_expire / portTICK_PERIOD_MS, auto_reload, timer_id, alarm_cb_handler);
+ if (!t) {
+ LOG_ERROR("%s error\n", __func__);
+ return NULL;
+ }
+
+ timer_id->alarm_hdl = t;
+ timer_id->cb = callback;
+ timer_id->cb_data = data;
+ /* TODO mutex unlock */
+
+ return timer_id;
}
int osi_alarm_free(osi_alarm_t *alarm)
pthread_mutex_init(&btu_l2cap_alarm_lock, NULL);
btu_l2cap_alarm_queue = fixed_queue_new(SIZE_MAX);
- if (btu_l2cap_alarm_queue == NULL)
- goto error_exit;
+ if (btu_l2cap_alarm_queue == NULL) {
+ goto error_exit;
+ }
xBtuQueue = xQueueCreate(60, sizeof(BtTaskEvt_t));
- xTaskCreate(btu_task_thread_handler, "BtuT", 8192, NULL, configMAX_PRIORITIES - 1, &xBtuTaskHandle);
+ xTaskCreate(btu_task_thread_handler, "BtuT", 4096, NULL, configMAX_PRIORITIES - 1, &xBtuTaskHandle);
btu_task_post(SIG_BTU_START_UP);
- /*
- // Continue startup on bt workqueue thread.
- thread_post(bt_workqueue_thread, btu_task_start_up, NULL);
- */
+ /*
+ // Continue startup on bt workqueue thread.
+ thread_post(bt_workqueue_thread, btu_task_start_up, NULL);
+ */
return;
- error_exit:;
+ error_exit:;
LOG_ERROR("%s Unable to allocate resources for bt_workqueue", __func__);
BTU_ShutDown();
}
}
}
- void btu_general_alarm_cb(void *data) {
- assert(data != NULL);
- TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
+ void btu_general_alarm_cb(void *data)
+ {
+ assert(data != NULL);
+ TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
- fixed_queue_enqueue(btu_general_alarm_queue, p_tle);
- //ke_event_set(KE_EVENT_BTU_TASK_THREAD);
- btu_task_post(SIG_BTU_WORK);
+ fixed_queue_enqueue(btu_general_alarm_queue, p_tle);
+ //ke_event_set(KE_EVENT_BTU_TASK_THREAD);
+ btu_task_post(SIG_BTU_WORK);
}
- void btu_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec) {
- osi_alarm_t *alarm = NULL;
-
- assert(p_tle != NULL);
-
- // Get the alarm for the timer list entry.
- pthread_mutex_lock(&btu_general_alarm_lock);
- if (!hash_map_has_key(btu_general_alarm_hash_map, p_tle)) {
- alarm = osi_alarm_new("btu_gen", btu_general_alarm_cb, (void *)p_tle, 0, false);
- hash_map_set(btu_general_alarm_hash_map, p_tle, alarm);
- }
- pthread_mutex_unlock(&btu_general_alarm_lock);
-
- alarm = hash_map_get(btu_general_alarm_hash_map, p_tle);
- if (alarm == NULL) {
- LOG_ERROR("%s Unable to create alarm", __func__);
- return;
- }
- osi_alarm_cancel(alarm);
-
- p_tle->event = type;
- // NOTE: This value is in seconds but stored in a ticks field.
- p_tle->ticks = timeout_sec;
- p_tle->in_use = TRUE;
- osi_alarm_set(alarm, (period_ms_t)(timeout_sec * 1000));
+ void btu_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec)
+ {
+ osi_alarm_t *alarm = NULL;
+
+ assert(p_tle != NULL);
+
+ // Get the alarm for the timer list entry.
+ pthread_mutex_lock(&btu_general_alarm_lock);
+ if (!hash_map_has_key(btu_general_alarm_hash_map, p_tle)) {
- alarm = osi_alarm_new("btu_gen", btu_general_alarm_cb, (void *)p_tle, 0);
++ alarm = osi_alarm_new("btu_gen", btu_general_alarm_cb, (void *)p_tle, 0, false);
+ hash_map_set(btu_general_alarm_hash_map, p_tle, alarm);
+ }
+ pthread_mutex_unlock(&btu_general_alarm_lock);
+
+ alarm = hash_map_get(btu_general_alarm_hash_map, p_tle);
+ if (alarm == NULL) {
+ LOG_ERROR("%s Unable to create alarm", __func__);
+ return;
+ }
+ osi_alarm_cancel(alarm);
+
+ p_tle->event = type;
+ // NOTE: This value is in seconds but stored in a ticks field.
+ p_tle->ticks = timeout_sec;
+ p_tle->in_use = TRUE;
+ osi_alarm_set(alarm, (period_ms_t)(timeout_sec * 1000));
}
/*******************************************************************************
** Returns void
**
*******************************************************************************/
- static void btu_l2cap_alarm_process(TIMER_LIST_ENT *p_tle) {
- assert(p_tle != NULL);
+ static void btu_l2cap_alarm_process(TIMER_LIST_ENT *p_tle)
+ {
+ assert(p_tle != NULL);
- switch (p_tle->event) {
+ switch (p_tle->event) {
case BTU_TTYPE_L2CAP_CHNL: /* monitor or retransmission timer */
case BTU_TTYPE_L2CAP_FCR_ACK: /* ack timer */
- l2c_process_timeout (p_tle);
- break;
+ l2c_process_timeout (p_tle);
+ break;
default:
- break;
- }
+ break;
+ }
}
- static void btu_l2cap_alarm_cb(void *data) {
- assert(data != NULL);
- TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
+ static void btu_l2cap_alarm_cb(void *data)
+ {
+ assert(data != NULL);
+ TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
- fixed_queue_enqueue(btu_l2cap_alarm_queue, p_tle);
- //ke_event_set(KE_EVENT_BTU_TASK_THREAD);
- btu_task_post(SIG_BTU_WORK);
+ fixed_queue_enqueue(btu_l2cap_alarm_queue, p_tle);
+ //ke_event_set(KE_EVENT_BTU_TASK_THREAD);
+ btu_task_post(SIG_BTU_WORK);
}
- void btu_start_quick_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_ticks) {
- osi_alarm_t *alarm = NULL;
-
- assert(p_tle != NULL);
-
- // Get the alarm for the timer list entry.
- pthread_mutex_lock(&btu_l2cap_alarm_lock);
- if (!hash_map_has_key(btu_l2cap_alarm_hash_map, p_tle)) {
- alarm = osi_alarm_new("btu_l2cap", btu_l2cap_alarm_cb, (void *)p_tle, 0, false);
- hash_map_set(btu_l2cap_alarm_hash_map, p_tle, (void *)alarm);
- }
- pthread_mutex_unlock(&btu_l2cap_alarm_lock);
-
- alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_tle);
- if (alarm == NULL) {
- LOG_ERROR("%s Unable to create alarm", __func__);
- return;
- }
- osi_alarm_cancel(alarm);
-
- p_tle->event = type;
- p_tle->ticks = timeout_ticks;
- p_tle->in_use = TRUE;
- // The quick timer ticks are 100ms long.
- osi_alarm_set(alarm, (period_ms_t)(timeout_ticks * 100));
+ void btu_start_quick_timer(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_ticks)
+ {
+ osi_alarm_t *alarm = NULL;
+
+ assert(p_tle != NULL);
+
+ // Get the alarm for the timer list entry.
+ pthread_mutex_lock(&btu_l2cap_alarm_lock);
+ if (!hash_map_has_key(btu_l2cap_alarm_hash_map, p_tle)) {
- alarm = osi_alarm_new("btu_l2cap", btu_l2cap_alarm_cb, (void *)p_tle, 0);
++ alarm = osi_alarm_new("btu_l2cap", btu_l2cap_alarm_cb, (void *)p_tle, 0, false);
+ hash_map_set(btu_l2cap_alarm_hash_map, p_tle, (void *)alarm);
+ }
+ pthread_mutex_unlock(&btu_l2cap_alarm_lock);
+
+ alarm = hash_map_get(btu_l2cap_alarm_hash_map, p_tle);
+ if (alarm == NULL) {
+ LOG_ERROR("%s Unable to create alarm", __func__);
+ return;
+ }
+ osi_alarm_cancel(alarm);
+
+ p_tle->event = type;
+ p_tle->ticks = timeout_ticks;
+ p_tle->in_use = TRUE;
+ // The quick timer ticks are 100ms long.
+ osi_alarm_set(alarm, (period_ms_t)(timeout_ticks * 100));
}
/*******************************************************************************
/*
* Starts a oneshot timer with a timeout in seconds.
*/
- void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec) {
- osi_alarm_t *alarm = NULL;
-
- assert(p_tle != NULL);
-
- // Get the alarm for the timer list entry.
- pthread_mutex_lock(&btu_oneshot_alarm_lock);
- if (!hash_map_has_key(btu_oneshot_alarm_hash_map, p_tle)) {
- alarm = osi_alarm_new("btu_oneshot", btu_oneshot_alarm_cb, (void *)p_tle, 0, false);
- hash_map_set(btu_oneshot_alarm_hash_map, p_tle, alarm);
- }
- pthread_mutex_unlock(&btu_oneshot_alarm_lock);
-
- alarm = hash_map_get(btu_oneshot_alarm_hash_map, p_tle);
- if (alarm == NULL) {
- LOG_ERROR("%s Unable to create alarm", __func__);
- return;
- }
- osi_alarm_cancel(alarm);
-
- p_tle->event = type;
- p_tle->in_use = TRUE;
- // NOTE: This value is in seconds but stored in a ticks field.
- p_tle->ticks = timeout_sec;
- osi_alarm_set(alarm, (period_ms_t)(timeout_sec * 1000));
+ void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout_sec)
+ {
+ osi_alarm_t *alarm = NULL;
+
+ assert(p_tle != NULL);
+
+ // Get the alarm for the timer list entry.
+ pthread_mutex_lock(&btu_oneshot_alarm_lock);
+ if (!hash_map_has_key(btu_oneshot_alarm_hash_map, p_tle)) {
- alarm = osi_alarm_new("btu_oneshot", btu_oneshot_alarm_cb, (void *)p_tle, 0);
++ alarm = osi_alarm_new("btu_oneshot", btu_oneshot_alarm_cb, (void *)p_tle, 0, false);
+ hash_map_set(btu_oneshot_alarm_hash_map, p_tle, alarm);
+ }
+ pthread_mutex_unlock(&btu_oneshot_alarm_lock);
+
+ alarm = hash_map_get(btu_oneshot_alarm_hash_map, p_tle);
+ if (alarm == NULL) {
+ LOG_ERROR("%s Unable to create alarm", __func__);
+ return;
+ }
+ osi_alarm_cancel(alarm);
+
+ p_tle->event = type;
+ p_tle->in_use = TRUE;
+ // NOTE: This value is in seconds but stored in a ticks field.
+ p_tle->ticks = timeout_sec;
+ osi_alarm_set(alarm, (period_ms_t)(timeout_sec * 1000));
}
- void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle) {
- assert(p_tle != NULL);
+ void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle)
+ {
+ assert(p_tle != NULL);
- if (p_tle->in_use == FALSE)
- return;
- p_tle->in_use = FALSE;
+ if (p_tle->in_use == FALSE) {
+ return;
+ }
+ p_tle->in_use = FALSE;
- // Get the alarm for the timer list entry.
- osi_alarm_t *alarm = hash_map_get(btu_oneshot_alarm_hash_map, p_tle);
- if (alarm == NULL) {
- LOG_WARN("%s Unable to find expected alarm in hashmap", __func__);
- return;
- }
- osi_alarm_cancel(alarm);
+ // Get the alarm for the timer list entry.
+ osi_alarm_t *alarm = hash_map_get(btu_oneshot_alarm_hash_map, p_tle);
+ if (alarm == NULL) {
+ LOG_WARN("%s Unable to find expected alarm in hashmap", __func__);
+ return;
+ }
+ osi_alarm_cancel(alarm);
}
#if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
TIMER_LIST_ENT raddr_timer_ent;
} tBTM_LE_RANDOM_CB;
-#define BTM_BLE_MAX_BG_CONN_DEV_NUM 10
+#define BTM_BLE_MAX_BG_CONN_DEV_NUM 2
- typedef struct
- {
+ typedef struct {
UINT16 min_conn_int;
UINT16 max_conn_int;
UINT16 slave_latency;
bluedroid/gki/include \
bluedroid/hci/include \
bluedroid/osi/include \
- bluedroid/profiles/core/include \
- bluedroid/profiles/esp/blufi/include \
- bluedroid/profiles/esp/include \
- bluedroid/profiles/std/battery/include \
- bluedroid/profiles/std/dis/include \
- bluedroid/profiles/std/hid/include \
- bluedroid/profiles/std/rfcomm/include \
- bluedroid/profiles/std/include \
+ bluedroid/utils/include \
+ bluedroid/btc/core/include \
+ bluedroid/btc/profile/esp/blufi/include \
+ bluedroid/btc/profile/esp/include \
+ bluedroid/btc/profile/std/gatt/include \
+ bluedroid/btc/profile/std/gap/include \
+ bluedroid/btc/profile/std/sdp/include \
+ bluedroid/btc/profile/std/include \
+ bluedroid/btc/include \
bluedroid/stack/btm/include \
bluedroid/stack/btu/include \
bluedroid/stack/gap/include \