While deleting the client attribute database, if a notification occurs there is a possibility of
concurrency causing an exception. This fixes that by setting a flag before calling disconnect in
the deleteClient function to prevent processing further notifications.
This change is needed to allow any tasks that were stopped during a host reset to finish
before resuming from the re-sync. This would occasionally result in a LoadStoreError exception
if not done.
If we client just connected and a notification comes before deleting services it could cause an exception
when accessing a vector that is being deleted. This will check the connection established flag before
processing of notifications.
If a connection event was sent but failed to establish then the disconnect
callback would be triggered when the application was not yet informed of the connection.
* Cleanup logs and add comments.
* Handle the return codes from ble_gap_connect to take proper actions for different codes.
* Improve client event handling to accomodate delayed PDU responses.
* Use connection ID as a replacement for the isConnected flag. Also check if a task is waiting for
results instead of the waitingToConnect flag.
* Adds a disconnect timer so that calling disconnect will start a timer for the connection
supervision timeout time + a small delay. When this expires it will reset the host if a disconnect event
does not occur in this time. This is added as a workaround for the occasional situation
when the controller does not send an event after the disconnect command.
The BLE_HS_EBUSY return code was causing the application to hang when starting scan as
occasionally the code would not change, resulting in an infinite loop.
This patch handles the return code more appopriately and removes the loop.
Additionally a race condition would sometimes allow the code to execute past the conditional checks
and clear the advertised device vector while a scan was active and writing to it causing an exception.
This has been hopefully corrected by only clearing the vector if the return code from starting the scan is 0.
* Some peripherals will advertise 16/32bit UUIDs but when queried for their handles
they do not convert the UUID to 128 bit locally and will return attribute not found.
This patch will query the peripheral a second time with a 128bit converted UUID.
- This changes NimBLERemoteCharacteristic::subscribe and NimBLERemoteCharacteristic::registerForNotify functionality
such that the notification callback will always be set.
Additionally these methods will always return true unless the descriptor write fails.
This allows for notifications to trigger the callback when a peer device sends them and does not have a CCCD.
Also it should not be flagged as a failure if the CCCD does not exist.
It should only be flagged when an acutal write operation fails.
* Fix for random notify crash in ISR context
Tested for stability over 30 minutes with a daisy chain of 3 esp32
Co-authored-by: h2zero <powellperalta@gmail.com>
* Adds functionality to advertise for a set duration, similar to NimBLEScan::start.
The first parameter being the duration (in seconds).
The second parameter is a pointer to a callback function that is invoked when advertising stops.
* NimBLEAdvertising::isAdvertising method added, returns true if advertising is currently active.
* These methods were noop's and are now removed due to lack of usefulness and advertisment space consumed if used.
Applications can still manually set these values if desired using NimBLEAdvertisementData::addData.