Commit graph

24 commits

Author SHA1 Message Date
h2zero
ae2ff3a638 Fix Documentation. 2021-02-06 11:12:40 -07:00
h2zero
af24cd7720 Add controller scan filter options and refactor nimconfig.h
* Add the option to change the scan filter mode through NimBLEDevice::setScanFilterMode

* Add the option to change the scan filter cache size through NimBLEDevice::setScanDuplicateCacheSize

* Refactor nimconfig to make it for doxygen use only.
2021-01-31 21:15:31 -07:00
h2zero
559a6e6970 Update documentation. 2021-01-15 21:51:49 -07:00
Asuki Kono
f61bd5c2df Add option to use resolvable and non-resolvable private address.
Adds the possibility to configure a resolvable or non-resolvable address (BLE privacy).
2021-01-13 18:01:41 -07:00
h2zero
372c79a6b8 Only start scan/advertise when host re-synced if duration was indefinite.
Previously when the host reset while scanning (if active prior) it would be restarted automatically.
This caused errors for some applications and has been removed since the event invokes the scan
ended callback for the app to take action. Instead scanning will now only be restarted if the duration
was indefinite and a callback was set for the advertisment events, this use case is less likely to have
a scan ended callback.

Advertising (if active prior) would be started without regard to it's previous state.
This has been corrected to only start advertising again if it was advertising for an idefinite time.
2021-01-12 20:42:19 -07:00
h2zero
28573f5abe Fix crash in NimBLEDevice::deleteClient when notification arrives.
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.
2021-01-12 14:01:44 -07:00
h2zero
b807321d1b NimBLEDevice::onSync should call taskYIELD() before returning.
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.
2021-01-12 13:59:49 -07:00
h2zero
09ff0c3472 Remove client delay calls and check if task is valid before notifying. 2021-01-12 13:54:53 -07:00
h2zero
28717c300a Fix client connect return code handling, add disconnect timer.
* 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.
2021-01-12 13:50:08 -07:00
h2zero
97832d4d95 Initialize peerAddress in client constructor.
Co-authored-by: wakwak-koba <wakwak-koba@users.noreply.github.com>
2020-08-03 22:13:57 -06:00
h2zero
73cec7a92a Remove type parameter from NimBLEClient::connect()
* The type is available in the NimBLEAddress parameter, no longer needed separately.

Co-authored-by: wakwak-koba <wakwak-koba@users.noreply.github.com>
2020-08-03 22:13:57 -06:00
h2zero
b901eeb1e5 Connect address type default to public.
* Cleanup logs.

Co-authored-by: wakwak-koba <wakwak-koba@users.noreply.github.com>
2020-08-03 22:13:57 -06:00
h2zero
33d0a732a6 Set peer address of client when creating the instance.
* Adds new client connect method that will connect to the address already set.

Co-authored-by: wakwak-koba <wakwak-koba@users.noreply.github.com>
2020-08-03 22:13:57 -06:00
h2zero
abdf6cda35
Add clearAll parameter to deinit() (#22)
* Add clearAll parameter to deinit()

Adds the ability to clear all resources consumed during BLE operation when deinitializing and shutting down BLE.
Useful when BLE is used intermittently or in a task that initializes, performs operations then deinitializes.

By setting the clearAll parameter to true all created BLE objects will be deleted, freeing the memory for other tasks.

Warning: This will invalidate any pointers that may be referencing the deleted objects.

* Add bool deleteCallbacks parameter to NimBLEServer::setCallbacks, if true (default) will delete the callback class when server is destructed.

* Delete scan results when scan is destructed.
2020-07-28 20:57:33 -06:00
h2zero
aae2a8f1e3
Fix comments for doxygen (#16)
* Fix comments for doxygen

* Add documentation and update readme.
2020-07-08 19:27:26 -06:00
h2zero
44f16e6ee2 Correct client connection status signalling.
* NimBLEClient::disconnect() was setting the connected flag to false before the disconnection occured.

* NimBLEDevice::deleteClient() was not waiting for disconnection if it was already in progress.

* Client gap event handler was releasing the connection event semaphore when it should not.
2020-05-30 09:01:42 -06:00
h2zero
10f544f80a Update remote characteristic value from a notification
* Add NimBLERemoteCharacteristic::getValue(time_t *timestamp = nullptr) to get the latest remote characteristic and (optionally) it's timestamp.

* Added a timestamp to NimBLEAdvertisedDevice for the moment a device was scanned
2020-05-29 18:26:41 -06:00
h2zero
fc1022a46d Add new getServer() method.
Previously we used createServer() to get a reference to the server instance.
This was problematic when using advertising only as it would create a server
when starting advertising. This prevents that and provides better semantics.
2020-05-14 12:59:35 -06:00
h2zero
03cb7b21d9 Conditionally compile code for specific roles.
This allows NimBLE options in menuconfig to reduce code size based on
the roles selected (scan/advertising/central/peripheral).

Significant code space can be saved by removing unnecessary roles for the application.
2020-05-13 22:03:56 -06:00
h2zero
f0191eb1e6 Add ==,!= operators to NimBLEAddress, pass parameters by const reference. 2020-05-10 07:21:46 -06:00
h2zero
1779a3f723 Bugfixes + add new NimBLEUUID constructor. 2020-05-03 13:50:49 -06:00
h2zero
725807b619 Resync to arduino master 2020-04-23 15:17:09 -06:00
h2zero
3327a32341 Merge bugfix branch into master 2020-04-13 19:13:51 -06:00
h2zero
5d4332e945 Initial commit. 2020-03-29 17:44:20 -06:00