* 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>
* 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.
* Add support for getting multiple services data from advertisments.
* Adds new methods for getting advertised service data and UUIDS.
- getServiceData(index), gets the service data by index value.
- getServiceData(NimBLEUUID), gets the service data by UUID.
- getServiceDataCount(), gets the number of services with data advertised.
* Templates added for getServiceData(index) and getServiceData(NimBLEUUID)
to be able to specify the data type returned by these methods
Example:
getServiceData<uint32_t>(NimBLEUUID("ABCD");
* Also added:
- getServiceUUID(index), gets the advertised service UUID by index value.
- getServiceUUIDCount(), gets the number of advertised services.
Server: Add onSubscribe() callback for characteristics.
Adds a new method to NimBLECharacteristicCallbacks that gets called when a client
changes it's subscription status.
* Remove NimBLE2902 class.
As the NimBLE2902 class usefulness was only related to callback functions that were replaced
by the NimBLECharacteristicCallbacks:onSubscribe() method this removes the NimBLE2902 class and
moves all subscription handling to NimBLECharacteristic.
* Update documents and examples to reflect this change.
* Add getSubscribedCount() to get the number of subscribed clients.
Added alternative characteristic read/write callbacks that carry the connection description information.
Fixesh2zero/NimBLE-Arduino#83
Author: lknop <lknop@users.noreply.github.com>
* Get service handles on server start
* remove service + indicate service changed
* Reset gatt services when no connections active and services changed.
* NimBLEServer::createService can now be used any time and will send service changed
indication if server was already active.
* Add ability to remove advertised serviceUUIDS
* Adds addService() method to server to be allow user to re-add a service previously removed
* Add destructior to NimBLEServer, NimBLEService and NimBLECharacteristic to release allocated resources.
Also adds:
* NimBLEScan::setDuplicateFilter() to tell the controller to filter duplicates
before sending the result to the host.
* NimBLEScan::setLimitedOnly() to tell the controller only report scan results
from devices advertising in limited discovery mode, i.e. directed advertising.
* NimBLEScan::setFilterPolicy() to set the filter policy i.e whitelist only devices.
* Replace all semaphores with task notifications.
* use critical sections to prevent concurrent data access.
* Ensure scan stop has been called before connecting.
* Optimize and cleanup
* Add template casting to NimBLERemoteDescriptor::readValue()
* Removed storage of the descriptor value read as it did not serve any purpose.
* Add subscribe() and unsubscribe() methods to replace registerForNotify() in NimBLERemoteCharacteristic.
* registerForNotify() remains as a (depreciated) method.
* Use critical sections to access characteristic/descriptor value data.
* Remove unnecessary code
* Create characteristic semaphore only if needed for indications.
* Fix advertising when not broadcasting a service.
* 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.
* Make remote attribute delete functions public.
* Rename clear...() functions to delete...(), with ... equals Service(-s), Characteristic(-s) or Descriptor(-s), depending on what the function actually deletes
Previously getRawData() made an unnecessary copy of the remote characteristic value data in order to return a uint8_t*. The resources used for this was unjustified by the value it provided as templates to retrieve such data have been added. Also the application writer could cast the std::string result of readValue() and/or getValue() however they choose using the data() method on the container if desired.
getDataLength() is also an unnecessary function as the length can be retrieved by the returned std::string from readValue() and/or getValue() with the length() method.
The value returned by reading a remote characteristic or by getting a notification for it is kept in the class instance of the NimBLERemoteCharacteristic. This value can be accessed as a std::string type using the getValue() function.
This adds templates to read the value in the type used by the peripheral. The same functionality is implemented for getting the manufacturer data or the service data of an advertised device.
* 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
Instead of discovering the peripheral database on connection and consuming
the associated resources this will give the user more control over the
discovery operation.
* Adds void NimBLEClient::discoverAtrributes() for the user to discover all
the peripheral attributes as a replacement for the former functionality.
* getServices(), getCharacteristics(), getDescriptors() now take an
optional bool parameter (default false).
If true it will clear the respective vector and retrieve all the respective
attributes from the peripheral. If false it will retrieve the attributes
only if the vector is empty, otherwise the vector is returned with the
currently stored attributes.
* getService(NimBLEUUID), getCharacteristic(NimBLEUUID), getDescriptor(NimBLEUUID)
will now check the respective vectors for the attribute object and, if not
found, will retrieve (only) the specified attribute from the peripheral.
Add iterators for NimBLEScan: NimBLEadvertisedDevice, NimBLEClient: NimBLERemoteService, NimBLERemoteService: NimBLERemoteCharacteristic and NimBLERemoteCharacteristic: NimBLERemoteDescriptor
This is handy e.g. for showing every address of the advertised devices from a scan. To do so, first get a new scan and next:
```
for(auto pAdvertisedDevice: pBLEScan->getResults()) {
Serial.printf("Address is %s\n", std::string(pAdvertisedDevice->getAddress()).c_str());
}
```
Of course any other property of the advertised device can be shown (or looked up, if that is your use case)
Also this is handy e.g. for showing every UUID in a peripheral. To do so, first connect to a peripheral and next:
```
for(auto pService: *pClient) {
Serial.printf("Service UUID is %s\n", std::string(pService->getUUID()).c_str());
for(auto pCharacteristic: *pService) {
Serial.printf("Characteristic UUID is %s\n", std::string(pCharacteristic->getUUID()).c_str());
for(auto pDescriptor: *pCharacteristic) {
Serial.printf("Descriptor UUID is %s\n", std::string(pDescriptor->getUUID()).c_str());
}
}
}
```
Again of course any other property can be shown, or looked up.
* Exchange map for vector, saving 1,076 bytes of program memory and 5,024 bytes of heap for a small device (LYWSD03MMC)
* Removing m_characteristicMapByHandle (using the handles form m_characteristicVector instead) saving in total (compared to the current master) 1,508 bytes of program memory and 6,500 bytes of heap for a small device (LYWSD03MMC)
* Change NimBLEScan container from std::map to std::vector
* Add function to get advertised device by address
* Update documentation
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.
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.