Beispiel #1
0
static void BTTasks() {
    switch (state) {
    case STATE_DETACHED:
        if (USBHostBluetoothIsDeviceAttached()) {
            BTAttached();
            state = STATE_ATTACHED;
        }
        break;

    case STATE_ATTACHED:
        if (USBHostBluetoothIsDeviceAttached()) {
            hci_transport_mchpusb_tasks();

            if (rfcomm_channel_id && rfcomm_send_credit) {
                rfcomm_grant_credits(rfcomm_channel_id, 1);
                rfcomm_send_credit = 0;
            }
        } else {
            // Detached. We don't care about the state of btstack, since we're not
            // going to give it any context, and we'll reset it the next time a
            // dongle is attached. Just close the channel if it is open.
            log_printf("Bluetooth detached.");
            client_callback(NULL, 1, client_callback_arg);
            client_callback = DummyCallback;
            rfcomm_channel_id = 0;
            state = STATE_DETACHED;
        }
    }
}
Beispiel #2
0
void BTTasks() {
  hci_transport_mchpusb_tasks();

  if (rfcomm_channel_id && rfcomm_send_credit) {
    rfcomm_grant_credits(rfcomm_channel_id, 1);
    rfcomm_send_credit = 0;
  }
}