mirror of
https://github.com/espressif/esp-nimble.git
synced 2026-09-13 12:40:01 +00:00
babblesim/edtt: Workaround EDTT not consuming cs/cc
It seems that sometimes EDTT can send a command before cs/cc is consumed by get_event and this triggers an error since cmd buffer is reused for cs/cc and thus it will be queued as an event on edtt_q_event. Not sure if this is an EDTT issue/feature or smth on our side, for now we can workaround this by simply creating a copy of cs/cc which can be safely enqueued on edtt_q_event waiting to be consumed and freed by get_event while original cmd buffer is freed as soon as cs/cc is processed.
This commit is contained in:
@@ -330,10 +330,12 @@ ble_hci_trans_buf_free(uint8_t *buf)
|
|||||||
} else if (os_memblock_from(&ble_hci_edtt_evt_lo_pool, buf)) {
|
} else if (os_memblock_from(&ble_hci_edtt_evt_lo_pool, buf)) {
|
||||||
rc = os_memblock_put(&ble_hci_edtt_evt_lo_pool, buf);
|
rc = os_memblock_put(&ble_hci_edtt_evt_lo_pool, buf);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
} else {
|
} else if (os_memblock_from(&ble_hci_edtt_cmd_pool, buf)) {
|
||||||
assert(os_memblock_from(&ble_hci_edtt_cmd_pool, buf));
|
assert(os_memblock_from(&ble_hci_edtt_cmd_pool, buf));
|
||||||
rc = os_memblock_put(&ble_hci_edtt_cmd_pool, buf);
|
rc = os_memblock_put(&ble_hci_edtt_cmd_pool, buf);
|
||||||
assert(rc == 0);
|
assert(rc == 0);
|
||||||
|
} else {
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -545,6 +547,19 @@ queue_data(struct os_mbuf *om)
|
|||||||
return pkt;
|
return pkt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void *
|
||||||
|
dup_complete_evt(void *evt)
|
||||||
|
{
|
||||||
|
struct ble_hci_ev *evt_copy;
|
||||||
|
|
||||||
|
evt_copy = calloc(1, BLE_HCI_TRANS_CMD_SZ);
|
||||||
|
memcpy(evt_copy, evt, BLE_HCI_TRANS_CMD_SZ);
|
||||||
|
ble_hci_trans_buf_free((void *)evt);
|
||||||
|
|
||||||
|
return evt_copy;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Thread to service events and ACL data packets from the HCI input queue
|
* @brief Thread to service events and ACL data packets from the HCI input queue
|
||||||
*/
|
*/
|
||||||
@@ -568,10 +583,12 @@ service_events(void *arg)
|
|||||||
/* Prepare and send EDTT events */
|
/* Prepare and send EDTT events */
|
||||||
switch (evt->opcode) {
|
switch (evt->opcode) {
|
||||||
case BLE_HCI_EVCODE_COMMAND_COMPLETE:
|
case BLE_HCI_EVCODE_COMMAND_COMPLETE:
|
||||||
|
evt = dup_complete_evt(evt);
|
||||||
queue_event(evt);
|
queue_event(evt);
|
||||||
command_complete(evt);
|
command_complete(evt);
|
||||||
break;
|
break;
|
||||||
case BLE_HCI_EVCODE_COMMAND_STATUS:
|
case BLE_HCI_EVCODE_COMMAND_STATUS:
|
||||||
|
evt = dup_complete_evt(evt);
|
||||||
queue_event(evt);
|
queue_event(evt);
|
||||||
command_status(evt);
|
command_status(evt);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user