mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 13:20:39 +00:00
hci_transport: send HCI_EVENT_TRANSPORT_PACKET_SENT when buffer can be re-used, send HCI_EVENT_SCO_CAN_SEND_NOW if that's separate
This commit is contained in:
parent
827b1c43e5
commit
63fa3374ea
@ -165,7 +165,7 @@ static void packet_handler(uint8_t * event, uint16_t event_size){
|
||||
printf("Working!\n");
|
||||
break;
|
||||
case HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS:
|
||||
case DAEMON_EVENT_HCI_PACKET_SENT:
|
||||
case HCI_EVENT_TRANSPORT_PACKET_SENT:
|
||||
// printf("DAEMON_EVENT_HCI_PACKET_SENT\n");
|
||||
// try_send_sco();
|
||||
break;
|
||||
|
@ -407,7 +407,7 @@ static int h4_process(struct btstack_data_source *ds) {
|
||||
}
|
||||
|
||||
tx_send_packet_sent = 0;
|
||||
uint8_t event[] = { DAEMON_EVENT_HCI_PACKET_SENT, 0 };
|
||||
uint8_t event[] = { HCI_EVENT_TRANSPORT_PACKET_SENT, 0 };
|
||||
packet_handler(HCI_EVENT_PACKET, &event[0], sizeof(event));
|
||||
}
|
||||
|
||||
|
@ -252,7 +252,7 @@ static int h4_process(struct btstack_data_source *ds) {
|
||||
if (tx_state == TX_DONE){
|
||||
// reset state
|
||||
tx_state = TX_IDLE;
|
||||
uint8_t event[] = { DAEMON_EVENT_HCI_PACKET_SENT, 0 };
|
||||
uint8_t event[] = { HCI_EVENT_TRANSPORT_PACKET_SENT, 0 };
|
||||
packet_handler(HCI_EVENT_PACKET, &event[0], sizeof(event));
|
||||
}
|
||||
|
||||
|
@ -278,11 +278,9 @@ static int usb_send_sco_packet(uint8_t *packet, int size){
|
||||
|
||||
// log_info("H2: queued packet at index %u, num active %u", tranfer_index, sco_ring_transfers_active);
|
||||
|
||||
// notify upper stack that packet processed and that it might be possible to send again
|
||||
if (sco_ring_have_space()){
|
||||
uint8_t event[] = { DAEMON_EVENT_HCI_PACKET_SENT, 0};
|
||||
packet_handler(HCI_EVENT_PACKET, &event[0], sizeof(event));
|
||||
}
|
||||
// notify upper stack that provided buffer can be used again
|
||||
uint8_t event[] = { HCI_EVENT_TRANSPORT_PACKET_SENT, 0};
|
||||
packet_handler(HCI_EVENT_PACKET, &event[0], sizeof(event));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -365,9 +363,10 @@ static void handle_completed_transfer(struct libusb_transfer *transfer){
|
||||
transfer->iso_packet_desc[0].actual_length, transfer->iso_packet_desc[0].length, transfer->iso_packet_desc[0].status,
|
||||
transfer->iso_packet_desc[1].actual_length, transfer->iso_packet_desc[1].length, transfer->iso_packet_desc[1].status,
|
||||
transfer->iso_packet_desc[2].actual_length, transfer->iso_packet_desc[2].length, transfer->iso_packet_desc[2].status);
|
||||
if (!sco_ring_have_space()) {
|
||||
// if there isn't space, the last SCO send didn't emit a packet sent event
|
||||
signal_done = 1;
|
||||
// notify upper layer if there's space for new SCO packets
|
||||
if (sco_ring_have_space()) {
|
||||
uint8_t event[] = { HCI_EVENT_SCO_CAN_SEND_NOW, 0};
|
||||
packet_handler(HCI_EVENT_PACKET, &event[0], sizeof(event));
|
||||
}
|
||||
// decrease tab
|
||||
sco_ring_transfers_active--;
|
||||
@ -378,8 +377,8 @@ static void handle_completed_transfer(struct libusb_transfer *transfer){
|
||||
}
|
||||
|
||||
if (signal_done){
|
||||
// notify upper stack that iit might be possible to send again
|
||||
uint8_t event[] = { DAEMON_EVENT_HCI_PACKET_SENT, 0};
|
||||
// notify upper stack that provided buffer can be used again
|
||||
uint8_t event[] = { HCI_EVENT_TRANSPORT_PACKET_SENT, 0};
|
||||
packet_handler(HCI_EVENT_PACKET, &event[0], sizeof(event));
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ static wiced_result_t h4_main_notify_packet_send(void *arg){
|
||||
// prepare for next packet
|
||||
tx_worker_data_size = 0;
|
||||
// notify upper stack that it might be possible to send again
|
||||
uint8_t event[] = { DAEMON_EVENT_HCI_PACKET_SENT, 0};
|
||||
uint8_t event[] = { HCI_EVENT_TRANSPORT_PACKET_SENT, 0};
|
||||
packet_handler(HCI_EVENT_PACKET, &event[0], sizeof(event));
|
||||
return WICED_SUCCESS;
|
||||
}
|
||||
|
@ -302,11 +302,14 @@ typedef uint8_t sm_key_t[16];
|
||||
// data: event(8)
|
||||
#define DAEMON_EVENT_NEW_RFCOMM_CREDITS 0x6B
|
||||
|
||||
// data: event(8)
|
||||
#define DAEMON_EVENT_HCI_PACKET_SENT 0x6C
|
||||
|
||||
|
||||
// additional HCI events
|
||||
|
||||
/**
|
||||
* @brief Outgoing packet
|
||||
*/
|
||||
#define HCI_EVENT_TRANSPORT_PACKET_SENT 0x6E
|
||||
|
||||
/**
|
||||
* @format B
|
||||
* @param handle
|
||||
|
22
src/hci.c
22
src/hci.c
@ -527,8 +527,8 @@ static int hci_send_acl_packet_fragments(hci_connection_t *connection){
|
||||
// release buffer now for synchronous transport
|
||||
if (hci_transport_synchronous()){
|
||||
hci_release_packet_buffer();
|
||||
// notify upper stack that iit might be possible to send again
|
||||
uint8_t event[] = { DAEMON_EVENT_HCI_PACKET_SENT, 0};
|
||||
// notify upper stack that it might be possible to send again
|
||||
uint8_t event[] = { HCI_EVENT_TRANSPORT_PACKET_SENT, 0};
|
||||
hci_emit_event(&event[0], sizeof(event), 0); // don't dump
|
||||
}
|
||||
|
||||
@ -610,8 +610,8 @@ int hci_send_sco_packet_buffer(int size){
|
||||
|
||||
if (hci_transport_synchronous()){
|
||||
hci_release_packet_buffer();
|
||||
// notify upper stack that iit might be possible to send again
|
||||
uint8_t event[] = { DAEMON_EVENT_HCI_PACKET_SENT, 0};
|
||||
// notify upper stack that it might be possible to send again
|
||||
uint8_t event[] = { HCI_EVENT_TRANSPORT_PACKET_SENT, 0};
|
||||
hci_emit_event(&event[0], sizeof(event), 0); // don't dump
|
||||
}
|
||||
|
||||
@ -1683,20 +1683,26 @@ static void event_handler(uint8_t *packet, int size){
|
||||
conn->role = packet[9];
|
||||
break;
|
||||
|
||||
case DAEMON_EVENT_HCI_PACKET_SENT:
|
||||
case HCI_EVENT_TRANSPORT_PACKET_SENT:
|
||||
// release packet buffer only for asynchronous transport and if there are not further fragements
|
||||
if (hci_transport_synchronous()) {
|
||||
log_error("Synchronous HCI Transport shouldn't send DAEMON_EVENT_HCI_PACKET_SENT");
|
||||
log_error("Synchronous HCI Transport shouldn't send HCI_EVENT_TRANSPORT_PACKET_SENT");
|
||||
return; // instead of break: to avoid re-entering hci_run()
|
||||
}
|
||||
if (hci_stack->acl_fragmentation_total_size) break;
|
||||
hci_release_packet_buffer();
|
||||
|
||||
// L2CAP receives this event via the hci_add_event_handler
|
||||
// For SCO, we do the can send now check here
|
||||
// L2CAP receives this event via the hci_emit_event below
|
||||
|
||||
// For SCO, we do the can_send_now_check here
|
||||
hci_notify_if_sco_can_send_now();
|
||||
break;
|
||||
|
||||
case HCI_EVENT_SCO_CAN_SEND_NOW:
|
||||
// For SCO, we do the can_send_now_check here
|
||||
hci_notify_if_sco_can_send_now();
|
||||
return;
|
||||
|
||||
#ifdef ENABLE_BLE
|
||||
case HCI_EVENT_LE_META:
|
||||
switch (packet[2]){
|
||||
|
@ -964,7 +964,7 @@ static void l2cap_hci_event_handler(uint8_t packet_type, uint16_t cid, uint8_t *
|
||||
break;
|
||||
|
||||
// Notify channel packet handler if they can send now
|
||||
case DAEMON_EVENT_HCI_PACKET_SENT:
|
||||
case HCI_EVENT_TRANSPORT_PACKET_SENT:
|
||||
case HCI_EVENT_NUMBER_OF_COMPLETED_PACKETS:
|
||||
l2cap_run(); // try sending signaling packets first
|
||||
l2cap_notify_channel_can_send();
|
||||
|
Loading…
x
Reference in New Issue
Block a user