This reverts a previous change @2e1d78ff that caused compiling/linking errors due to the redefinition of btInUse() when another linked library uses the Arduino bluetooth code.
This allows for adding and removing of characteristics and descriptors after initial setup of the server.
When used it will send a service changed notification to all clients.
The changes will not take effect until all clients have disconnected and advertising restarted.
This allows creating instances of services/characteristics and decriptors without
needing to call the parent createX() methods. This allows creation of the attibutes
within a class or other structure and the attributes can be linked to the parent by
calling the parent addX() method.
Additonally this increases the backward compatibility with the original bluedroid library
to further support user migration.
Previously we used the service end handle or, if available, the handle of the next characteristic in the service
as the end handle when retrieving the descriptors of a characteristic. This process would fail when connecting to some
devices if the characteristics were retrieved individually instead of all together. The cause of failure was requesting
a handle range that is out of characteristic scope which is also out of line with BLE
specifications.
The fix included in this is to set the end handles of the characteristics either after retrieving all the characteristics
in a service by using the next charactertistic definition handle or, if the characteristic was retrieved separately,
we retrieve the next characteristic just before retrieving the descriptors.
This allows for clearing the duplicate filter cache when required and will also clear it
automatically when starting a scan.
This is useful when unexpectedly disconnected from a device and attempting to reconnect.
Previously the scan filter would not report advertisements from a device if it was multi-connectable
and advertising while connected. The result was long delays until the device would be scanned again.
This resolves it by clearing the filter cache on each scan start/clearResults call
and adding a method to NimBLEScan for manually clearing the cache on demand.
* Add method to get all characteristics of a service
* Added method on NimBLEDescriptor to get the value out as a std::string
* Added methods to get things by handle where UUID could be used already.
* Added helper methods for getting a list of characteristics with a given UUID and service
* Demote the warning log for adding duplicate characteristics to a debug level log.
* Add methods to get services and characteristics using UUID + index
This prevents an exception when initializing a NimBLEAdvertising instance before calling NimBLEDevice::init().
The constructor calls reset() which calls stop(), if the stack was not yet initialized it will cause an exception.
Previous to this NimBLEAdvertising did not have some functionality that was in NimBLEAdvertisementData.
Also NimBLEAdvertisementData was missing functionality that exists in NimBLEAdvertising.
This resolves that by adding the missing functions to both classes.
Changed:
NimBLEAdvertising: Transmission power is no longer advertised by default and can be added to the advertisement by calling ::addTxPower()
Added:
- NimBLEAdvertising::setName
- NimBLEAdvertising::setManufacturerData
- NimBLEAdvertising::setURI
- NimBLEAdvertising::setServiceData
- NimBLEAdvertising::addTxPower
- NimBLEAdvertising::reset
- NimBLEAdvertisementData::addTxPower
- NimBLEAdvertisementData::setPreferredParams
- NimBLEAdvertisementData::setURI
Adds:
- setPartialServices16
- setPartialServices32
- setCompleteServices16
- setCompleteServices32
Each takes an input parameter of std::vector<NimBLEUUID> to allow for advertising multiple services with a simple interface.
* 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.
* Adds setMaxResults to NimBLEScan to limit the number of advertised devices stored.
If set to 0 no devices will be stored in memory and only the callback will be invoked.
If set to 0xFF (default) stored devices will be unlimited. Any other value will be the limit.
* Uses the controller to filter duplicate devices from the scan results when wantDuplicates == false.
* Stores complete advertisement payload and only performs parsing on demand. The advertised data is no longer parsed automatically as it is discovered, instead it will be parsed to find only the data requested by the user application when it makes a call to do so. This saves processing time and approximately 2.4k in flash size, with the new methods listed below included.
Add more advertised device field methods:
* Adds haveAdvInterval/getAdvInterval - checks if the interval is advertised / gets the advertisement interval value.
* Adds haveConnParams/getMinInterval/getMaxInterval - checks if the parameters are advertised / get min value / get max value.
* Adds haveURI/getURI - checks if a URI is advertised / gets the URI data.
* Adds haveTargetAddress/getTargetAddressCount/getTargetAddress(index) - checks if a target address is present / gets a count of the addresses targeted / gets the address of the target at index.