Commit graph

37 commits

Author SHA1 Message Date
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
gluhovsky
e868f37135
Add conn_handle to NimBLECharacteristic::notify to send notification/indication to a specific client (#97)
Adds the ability to send notifications/indications to specific clients individually.
2022-09-11 20:18:55 -06:00
h2zero
ba79a1bf72 [Breaking] Update callbacks to use NimBLEConnInfo.
Change the callback functions that receive a ble_gap_conn_desc pointer to instead receive a NimBLEConnInfo reference.

* Add a reason parameter to the server disconnect callback.

* Remove connect and disconnect callback that do not receive info parameters.

* Remove onRead and onWrite Characteristic callbacks that do not receive info parameters.

* Add info parameter to Descriptor onWrite and onRead callbacks.

* Add details to migration guide.
2022-08-27 13:02:29 -06:00
h2zero
ca8a7c56ac
[Breaking] Remove extra notification status from onStatus callback. (#80)
Removes the unnecessary NimBLECharacteristicCallbacks::Status enum and callback parameter from NimBLECharacteristic::onStatus.

This was maintained for compatibility with the Arduino BLE library and is not necessary as the return code from the stack is also provided.

* Update examples/docs.
2022-08-26 20:40:21 -06:00
h2zero
efa48c0d57 Release 1.4.0
* Fix typos

* Update docs
2022-07-31 11:34:56 -06:00
h2zero
93de7ab8ed Bugfix/onRead callback not called for non-long read commands. 2022-06-26 17:03:21 -06:00
h2zero
e3ee082dd7
Add NimBLEAttValue class. (#67)
This is a specialized container class to hold BLE attribute values.

- Removes the use of std::string previously used to store the values.
- Allows for setting/getting/notifying values from std::string, std::vector<uint8_t>, Arduino String, const char*, and uint8_t buffers.
- Has operators retrieve the value as std::string, Arduino String, std::vector<uint8_t>, uint8_t* or char pointers.
- Includes iterators and subscript/random access operator.
- Introduces a max length parameter to the creation of server characteristics/descriptors to limit the size of the memory footprint.
- Nearly Seamless integration with existing code.
- Adds a config option to enable/disable timestamp storage when the value is updated.
- Adds a config option to specify the initial size of the value container if not specified in the constructor.
2022-01-16 20:11:18 -07:00
h2zero
be9cdc1ab6 Update docs 2022-01-15 15:21:41 -07:00
h2zero
ea02eb9452 Add config option for log verbosity. 2022-01-14 19:47:44 -07:00
h2zero
9824bdfe73 Update log level macro name 2022-01-14 10:02:47 -07:00
h2zero
9debfcd226 Use NimBLE calls for critical sections 2021-12-29 08:10:57 -07:00
h2zero
8620092c90 Cleanup and add support for non-esp devices. 2021-12-29 08:08:25 -07:00
David Robertson
f841f030ae
Add method to send notifications/indications with custom values (#63) 2021-12-28 20:11:37 -07:00
h2zero
ccea428b9e Refactor include directives to use different paths for arduino/idf.
* Sets macros to allow compiling when Central role is enabled and Observer disabled, or Peripheral enabled and Broadcaster disabled.

* Adds a macro definition for CONFIG_NIMBLE_CPP_IDF to enable different include paths/functionality for IDF / Arduino.
2021-09-12 18:43:31 -06:00
h2zero
6be6a111d0
[Server] Implement remove Characteristics/Descriptors. (#54)
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.
2021-07-30 20:56:52 -06:00
h2zero
d9d794ae40 [Server] Add ability to create static attributes.
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.
2021-05-23 13:07:00 -06:00
Bascy
7815d89dbf Call onSubscribe() after adding connection to subscribedVector
This allows for sending BLE messages in the onSubscribe() handler
2021-05-19 22:28:30 -06:00
Ketan Padegaonkar
9fa9531e50 Add method to get the callbacks from a characteristic.
This is useul to be able to unit/integration test the behavior of a
characteristic.
2021-05-19 22:23:40 -06:00
h2zero
b62358a520 Remove task notification for server indications.
This resolves an issue when sending an indication from a callback that can cause the server to hang.
2021-05-17 14:08:02 -06:00
h2zero
7bec9c240a Release 1.2.0 2021-02-08 11:46:11 -07:00
David Robertson
7dd4d68806
[NimBLEServer] Support duplicate characteristics (#36)
* 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
2021-02-08 08:28:32 -07:00
Anthony Doud
7ed962d963 Fix crashing caused by calling time() in a critical section (#159)
* 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>
2020-12-19 21:58:37 -07:00
Roland Szabo
5823703670 incorrect buffer index used when processing longer writes 2020-08-20 09:24:04 +02:00
h2zero
4723b1cc53
Server: Add onSubscribe() callback for characteristics. (#21)
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.
2020-07-27 21:11:38 -06:00
h2zero
2b4c1cd4f1 Add alternative characteristic read/write callbacks
Added alternative characteristic read/write callbacks that carry the connection description information.
Fixes h2zero/NimBLE-Arduino#83

Author: lknop <lknop@users.noreply.github.com>
2020-07-14 15:14:29 -06:00
h2zero
2a5df0c905
Add feature: remove service (#17)
* 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.
2020-07-13 21:24:07 -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
8d2821a429 Use templates for attribute values.
* Add timestamps for NimBLECharacteristic.
2020-07-01 17:32:41 -06:00
h2zero
c25e48872f NimBLECharacteristic: add setValue(uint8_t single_byte) 2020-06-21 20:38:38 -06:00
h2zero
0712f606f1
Don't send notifications to un-paired peers when READ_ENC set (#14)
* start security when peer subscribes to secured characteristic

* Don't send notifications to non-secure clients
2020-06-21 20:26:16 -06:00
h2zero
74f48f5d5e Remove semaphores, use task notifications instead. 2020-06-11 08:06:16 -06:00
h2zero
e987ad58b2 Refactor server code to use vectors instead of maps.
* 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.
2020-06-07 18:42:28 -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
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