Closed tonton81 closed 3 years ago
looks like I figured out the lockup issue. I wrote a multiple connection utility which connects X amount of devices (i set 4) where each slot is a MAC address. So if the non-blocking scan picks up the MAC it auto connects to the proper array index. There were 2 issues, the semaphore needs to be commented out in above I posted to prevent writeValue from locking up during reconnections, and that if the MAC address was picked up in the scan BEFORE it had a chance to disconnect, the code would process a:
new BLEAdvertisedDevice(device);
in this case, it was a simple ONE line fix: `
if ( _client[j]->isConnected() ) return; // (prevents lockup by not reconnecting until the disconnection occurs)
_controller[j] = new BLEAdvertisedDevice(device);
`
now it is surviving disconnects and preventing reconnects until an actual disconnection occurs :)
I am writing using writeValue in my loop. I test killing power on my BT device and re-applying it. The disconnect callback works but the loop freezes up. I checked into the BLERemoteCharacteristic.cpp file and commented out one line:
`void BLERemoteCharacteristic::writeValue(uint8_t data, size_t length, bool response) { // writeValue(std::string((char)data, length), response); log_v(">> writeValue(), length: %d", length);
} // writeValue `
Is there any reprocussions or side effects by disabling this? Now the code never freezes up and continues working despite me unplugging and plugging in the BT device's power source! :)
EDIT: while killing the device power and waiting for disconnected callback, loop never stops working, great! However, if i cut power and re-apply before the disconnected callback fires, then the loop() locks up again :(