Hello;
I'm having trouble with the following code.
The Scancallback is completing, and a connection request is being sent to the device. If the connection cannot be established at this point, the connection remains pending. And the device cannot establish a connection again. Despite all my research, I couldn't find a timeout option. How can I add a feature to try to establish a connection and give up after x milliseconds?
Currently, as a temporary solution, I'm resetting module if the connection remains pending. But this is not the best solution.
Can you help? Thank you.
void config()
{
Bluefruit.begin(0, 1);
Bluefruit.setTxPower(4);
for (uint8_t idx = 0; idx < BLE_MAX_CONNECTION; idx++) {
prphs[idx].conn_handle = BLE_CONN_HANDLE_INVALID;
prphs[idx].bleuart.begin();
prphs[idx].bleuart.setRxCallback(bleuart_rx_callback);
}
Bluefruit.Central.setConnectCallback(connect_callback);
Bluefruit.Central.setDisconnectCallback(disconnect_callback);
Bluefruit.Scanner.setRxCallback(scan_callback);
Bluefruit.Scanner.restartOnDisconnect(true);
Bluefruit.Scanner.setInterval(160, 80); // in units of 0.625 ms
Bluefruit.Scanner.filterUuid(BLEUART_UUID_SERVICE);
Bluefruit.Scanner.useActiveScan(true); // Don't request scan response data
Bluefruit.Scanner.start(0); // 0 = Don't stop scanning after n seconds
}
void scan_callback(ble_gap_evt_adv_report_t* report) {
Bluefruit.Central.connect(report);
Serial.println(F("Connecting..."));
}