pico-sdk
pico-sdk copied to clipboard
Deadlock problem when connecting to Bluetooth devices with high frequency output
My test setup is using single core, reading data from Bluetooth and write to USB When connecting to Bluetooth devices with high frequency output, the HCI layer always has data to read. The Pico driver has a while loop to read data, it causes the loop will never end. So that other data processing functions will never be called. My solution is, killing the while loop, it may generate delay for reading but it works OK. Is there any other possible solution?
Here are my changes btstack_hci_transport_cyw43.c
static void hci_transport_cyw43_process(void) {
CYW43_THREAD_LOCK_CHECK
uint32_t len = 0;
//bool has_work;
//do {
int err = cyw43_bluetooth_hci_read(hci_packet_with_pre_buffer, sizeof(hci_packet_with_pre_buffer), &len);
BT_DEBUG("bt in len=%lu err=%d\n", len, err);
if (err == 0 && len > 0) {
hci_transport_cyw43_packet_handler(hci_packet_with_pre_buffer[3], hci_packet_with_pre_buffer + 4, len - 4);
//has_work = true;
} else {
//has_work = false;
}
//} while (has_work);
}