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.
* The type is available in the NimBLEAddress parameter, no longer needed separately.
Co-authored-by: wakwak-koba <wakwak-koba@users.noreply.github.com>