Commit graph

249 commits

Author SHA1 Message Date
h2zero
c2ab790e1d [BREAKING] Refactor NimBLEAdvertised device.
* Construct the device with the parameters from the advertisement in the initialization list.
* Removed no longer needed methods; setAddress, setAdvType, setRSSI, setSetId, setPrimaryPhy, setSecondaryPhy, setPeriodicInterval.
* Removed `hasRSSI()` method, the RSSI is always reported so this is redundant.
* Replace setPayload with new method; `update` which will update the device info when new advertisement data is received.
* getPayload now returns `const std::vector<uint8_t>` instead of a pointer to internal memory.
* Added `begin` and `end` read-only iterators for convienience and use in range loops.
* Timestamp removed, if needed then the app should track the time in the callback.
* Consolidate some functions to use getPayloadByType.
* Add optional index parameter to getPayloadByType.
* Change payload indexing to use 0 as the first item.
* Code cleanup and apply const correctness.
2024-07-17 20:44:49 -06:00
h2zero
6279817143 [BREAKING] Refactor NimBLEAddress - use NimBLE core representation.
This simplifies the NimBLEAddress code by directly using the NimBLE core `ble_addr_t` type to hold the address
and allows using NimBLE core functions and macros to replace code in some methods.

* `getNative()` replaced with `getBase()` and now returns a pointer to `const ble_addr_t` instead of a pointer to the address value.
* Adds `isNrpa()` method to test if an address is random non-resolvable.
* Adds `isStatic()` method to test if an address is random static.
* Adds `isPublic()` method to test if an address is a public address.
* Adds `isNull()` methods to test if an address is NULL.
* Adds `getValue()` method which returns a read-only pointer to the address value.
* Adds `reverseByteOrder()` method which will reverse the byte order of the address value.
* `equals()` method and == operator will now also test if the address types are the same.
* Code cleanup.
2024-07-17 19:38:35 -06:00
h2zero
21e1217e4c [BREAKING] Use an array to manage created client instances.
* Replaces the use of std::list with a fixed array to track and manage created client instances.
* Removes: NimBLEDevice::getClientList
* Replaces: NimBLEDevice::getClientListSize with NimBLEDevice::getCreatedClientCount
2024-07-10 07:05:47 -06:00
h2zero
a92149ac74 [BREAKING] Change NIMBLE_LOGC macro to use printf.
Replaces all use of NIMBLE_LOGC with NIMBLE_LOGE and redefines NIMBLE_LOGC to use printf.
This allows NIMBLE_CPP_DEBUG_ASSERT messages to print event when log level filtering is set to none.
2024-07-04 19:05:35 -06:00
h2zero
d9f5794b57 Replace NimBLEAttValue asserts with user defineable action.
* Adds the NIMBLE_CPP_DEBUG_ASSERT macro that calls a weak function to allow user defined action, defaults to critical error message and aborts.
* Adds a config option to disable asserts using the NIMBLE_CPP_DEBUG_ASSERT macro.
2024-07-04 18:47:28 -06:00
h2zero
44977cdcce Remove NimBLEUtils::checkConnParams.
This function is not required as the stack will return an error code in the case of invalid params.
2024-07-03 15:01:44 -06:00
h2zero
a5dd84b2f9 Remove descriptor asserts when the connection info is not found.
* Trigger onRead callbacks when the connection handle is NONE (internal).
2024-07-03 15:01:28 -06:00
h2zero
b8d6e3d87f Remove assert for 0x2902, make a dummy descriptor instead.
Rather than asserting for a harmless situation, this will just create a dummy descriptor
object, marked as removed, and print a warning.
2024-07-03 15:01:14 -06:00
h2zero
fae53b8d7f Remove asserts from NimBLEDevice. 2024-07-03 15:01:00 -06:00
h2zero
358170847d Remove aborts in NimBLEAdvertising::start. 2024-07-03 14:27:59 -06:00
h2zero
a1bd817875 Remove NimBLEServer::start abort. 2024-07-03 14:27:31 -06:00
h2zero
fd698b0212 [NimBLEServer] Add getPeerName and get peer name on connect.
* Adds a new method, getPeerName to NimBLEServer to read the name from the peers device name characteristic.
* Adds a setting to automatically get the name of the peer when connected and provide it as an additional parameter in the onConnect callback.
* Adds callback with client name after authentication as it may change.
2024-06-30 16:44:49 -06:00
h2zero
cabd48aef3 Add documentation to NimBLEService::isStarted 2024-06-15 09:55:40 -06:00
h2zero
8acea66c10 Reset advertisment vectors when changing their data.
* Add method to erase all service UUIDS.
2024-06-14 22:02:29 -06:00
h2zero
bd29e738bd Add service isStarted method, remove abort in NimBLEServer::start. 2024-06-14 18:26:42 -06:00
h2zero
792359b510 Remove asserts in NimBLECharacteristic read/write. 2024-06-14 10:01:50 -06:00
h2zero
bc7bfe8278 Add clearData method to NimBLEAdvertisementData. 2024-06-14 10:01:41 -06:00
h2zero
20349c64a4 Add conditional checks in NimBLEDevice init/deinit. 2024-06-14 10:01:34 -06:00
h2zero
70c2d83b3b Remove broken links from docs. 2024-06-14 09:57:23 -06:00
h2zero
63a3301696 Add missing const in NimBLEConnInfo. 2024-06-12 21:12:09 -06:00
h2zero
c156b0202c Add isRpa method to NimBLEAddress.
This provides and easy way to check if the peer address is a Resolvable Private Address.
2024-06-12 21:12:09 -06:00
h2zero
ef90a8aa95 Remove address from whitelist if the procedure fails.
This prevents a situation where the whitelist contains the address but the procedure errors and the address cannot be added again.
2024-06-12 21:12:09 -06:00
h2zero
aeb4334e98 Add server and client onIdentity callback.
Adds a callback that is called when the identity address of the peer is resolved, this is useful for adding it to a whitelist.
2024-06-12 21:12:09 -06:00
h2zero
44daa3c687 Fix failure to reconnect to device when bonded.
iOS devices specifically expect to receive the ID key of the bonded device even when RPA is not used.
This sets the default value of the key distribution config to provide the ID key as well as the encryption key.
2024-06-12 21:12:09 -06:00
cmorganBE
f36929963d
Add disconnect overload to take NimBLEConnInfo reference. (#162)
* NimBLEConnInfo - Note that the connection handle is the same as the connection id in the comment for getConnHandle()

* NimBLEServer - int disconnect(const NimBLEConnInfo&) helper method
2024-06-08 10:06:57 -06:00
Max93
2447af6a4d Fix Error in converting EddystoneTLM negative temperatures to float | resolves h2zero/NimBLE-Arduino#675 2024-06-08 10:02:47 -06:00
h2zero
9c1f1adf7a
[BREAKING] Asynchronous pin injections for Numeric Comparison and PassKey Input (#165)
* Make NimBLEConnInfo functions const.

* Update callback functions and update client to use new functions.

* Update examples.

* Update migration guide.

---------

Co-authored-by: Casey Smith <csmith@morningstarcorp.com>
2024-06-06 19:36:14 -06:00
William Emfinger
6ca61bbd9c
feat(NimBLEDevice): deleteAllBonds() Add return value (#158)
Add return value to `deleteAllBonds`.
2024-06-04 16:52:55 -06:00
William Emfinger
32c213a8a3
feat(NimBLEClient): allow connection id / established flag to be set via public API. (#156)
* Adds NimBLEClient::setConnection  to allow servers to read the name of connected clients by passing their connection info to the Client class.
* Adds NimBLEClient::clearConnection to be able to reuse the client without deleting and recreating.
2024-06-04 10:37:24 -06:00
William Emfinger
51bf1f3c7c
feat(NimBLEAdvertising): support std::function for advertising complete callback (#157)
Updates the interface to use a typedef'd std::function for the advertise callback, which is backwards compatible but also allows std::bind and lambda functions.
2024-06-04 07:12:20 -06:00
h2zero
7c0300c34e Change NimBLEHIDDevice formatting for consistency. 2024-06-02 17:02:02 -06:00
afpineda
6fa3783206 Bug fix on PNP info
Fixed issue #492
2024-06-02 17:02:00 -06:00
Sebastian Holder
226c67f729
Initialize ble_gatt_chr_def[]. Fixes #148 (#150)
IDF 5.2 introduced a new member, cpfd, to the
ble_gatt_chr_def struct. It needs to be initialized
to nullptr in order to avoid accessing uninitialized
memory. By initializing the whole struct, we get
everything initialized in a backward-compatible way.
2024-04-20 09:14:55 -06:00
kiss81
bf4b5d4ffa
ESP IDF 5.2 include fix (#144) 2024-03-01 12:29:18 -07:00
psitto
58f86cb7bd
Fix inconsistent use of time units (#143)
Seconds to milliseconds
2024-02-29 17:34:53 -07:00
Julio Contreras Fuica
22fb1ab801 Add generic advertisement 'type' functions (#575) 2023-11-25 08:10:30 -07:00
h2zero
2ea0f26de0 Add support for esp32c6 2023-08-13 10:40:00 -06:00
h2zero
1786d0ede3
Fix compilation when CONFIG_BTDM_BLE_SCAN_DUPL is not enabled.
*  fix warning: variable 'pkey' set but not used [-Wunused-but-set-variable]
---------

Co-authored-by: Franz Höpfinger <f.hoepfinger@hr-agrartechnik.de>
2023-05-29 09:08:14 -06:00
JPZV
4ff9baf68a
Fixed unhandled exception on handleGapEvent (#112)
Somehow, the conn_handle can have the value of `0xffff`. Not sure why or how, but anyway it should be managed before moving forward on NimBLECharacteristic::handleGapEvent. Otherwise, an unhandled exception will occur on `assert(rc == 0);`
2023-05-29 07:56:31 -06:00
eighty2fifty1
c1e7a521b7 Add overloaded setManufacturerData to allow vector of uint8_t 2023-05-28 16:23:34 -06:00
h2zero
091c1c014c Update doxygen config 2023-05-25 10:29:53 -06:00
h2zero
d0eaf6c1e0 Set service handle in getHandle function if not set already.
If a service has been created and started but not yet added to the gatt server then the call to getHandle will result in an invalid handle. This adds a call to set the handle value in the getHandle function.
2023-05-24 15:37:53 -06:00
h2zero
46e7bb9302 Add onDiscovered scan callback.
This adds a callback that is called when a device is initially discovered.
It is always called wether scanning in passive or active mode. This allows
for active scanning to receive device detection information in the case where
the scan response is not sent/received.

This callback is optional, the application may decide to implement it or not.
2023-05-24 15:37:46 -06:00
h2zero
559a26b74b Add index parameter for multiple manufacturer data sets.
Adds an index parameter to NimBLEAdvertisedDevice::getManufacturerData to allow for selecting from multiple instances in the advertisements.
Adds NimBLEAdvertisedDevice::getManufacturerDataCount to get the number of manufacturer data sets present in the advertised data.
2023-05-24 15:37:38 -06:00
Luca Niccoli
4423e5fbb6 Expose advertisement flags in NimBLEAdvertisedDevice 2023-05-24 15:37:30 -06:00
h2zero
0aa7e9510d Add directed peer address parameter to advertising start.
Adds a parameter to NimBLEAdvertising::start to take the peer address for use with directed advertising.
2023-05-24 15:37:22 -06:00
h2zero
d83cd94d5b Revert 03b22e5 sub/unsub changes, app should specify response. 2023-05-24 15:37:17 -06:00
h2zero
7d2d73d8fc Fix pairing when already in progress.
If pairing is requested before performing an action on a protected attribute pairing could fail due to already being in progress.
This fix will wait for the result of the pairing process before proceeding with the action.
2023-05-24 15:37:03 -06:00
Armandas Jarušauskas
05ac9deaea
Remove deprecated API in case of ESP-IDF V5. (#102)
* Remove deprecated API in case of ESP-IDF V5.

0a93ee1337/docs/en/migration-guides/release-5.x/bluetooth-low-energy.rst (id17)

* Fix initialization in case of ESP-IDF V5
2022-11-03 20:47:04 -06:00
Johanna Amann
cad022650a Fix getPower return value
Power level -3 returned the wrong value.
2022-09-11 20:34:33 -06:00