Skip to content

Conversation

h2zero
Copy link
Owner

@h2zero h2zero commented Aug 10, 2024

Refactor attributes to reduce code duplication and improve maintainability.

  • Add attribute base classes to provide common code.
  • Add const where possible to functions and parameters.
  • NimBLECharacteristic::notify no longer takes a bool is_notification parameter, instead indicate() should be called to send indications.
  • NimBLECharacteristic::indicate now takes the same parameters as notify.
  • NimBLECharacteristicCallbacks and NimBLEDescriptorCallbacks methods now take const NimBLEConnInfo& instead of non-const.
  • NimBLECharacteristic::onNotify callback removed as unnecessary, the library does not call notify without app input.
  • NimBLERemoteCharacteristic::getRemoteService now returns a const NimBLERemoteService* instead of non-const.
  • Add NimBLEUUID constructor that takes a reference to ble_uuid_any_t.
  • NimBLERemoteService::getCharacteristics now returns a const std::vector<NimBLERemoteCharacteristic*>& instead of non-const std::vector<NimBLERemoteCharacteristic*>*
  • NimBLERemoteService::getValue now returns NimBLEAttValue instead of std::string
  • NimBLEService::getCharacteristics now returns a const std::vector<NimBLECharacteristic*>& instead of a copy of std::vector<NimBLECharacteristic *>.
  • Remove const requirement for NimBLEConnInfo parameter in callbacks.
    Const is unnecessary as the data can't be changed by application code.
  • Change NimBLERemoteCharacteristic::getRemoteService to return const pointer.

@h2zero h2zero force-pushed the refactor-attributes branch 2 times, most recently from 1e04e4f to eb28997 Compare August 10, 2024 00:46
@h2zero h2zero force-pushed the refactor-attributes branch 3 times, most recently from d0136fb to 7d6c512 Compare September 24, 2024 14:21
Refactor attributes to reduce code duplication and improve maintainability.

* Add attribute base classes to provide common code.
* Add const where possible to functions and parameters.
* `NimBLECharacteristic::notify` no longer takes a `bool is_notification` parameter, instead `indicate()` should be called to send indications.
* `NimBLECharacteristic::indicate` now takes the same parameters as `notify`.
* `NimBLECharacteristicCallbacks` and `NimBLEDescriptorCallbacks` methods now take `const NimBLEConnInfo&` instead of non-const.
* `NimBLECharacteristic::onNotify` callback removed as unnecessary, the library does not call notify without app input.
* `NimBLERemoteCharacteristic::getRemoteService` now returns a `const NimBLERemoteService*` instead of non-const.
* Add NimBLEUUID constructor that takes a reference to `ble_uuid_any_t`.
* `NimBLERemoteService::getCharacteristics` now returns a `const std::vector<NimBLERemoteCharacteristic*>&` instead of non-const `std::vector<NimBLERemoteCharacteristic*>*`
* `NimBLERemoteService::getValue` now returns `NimBLEAttValue` instead of `std::string`
* `NimBLEService::getCharacteristics` now returns a `const std::vector<NimBLECharacteristic*>&` instead of a copy of std::vector<NimBLECharacteristic *>.
* Remove const requirement for NimBLEConnInfo parameter in callbacks.
  Const is unnecessary as the data can't be changed by application code.
* Change NimBLERemoteCharacteristic::getRemoteService to return const pointer.
@h2zero h2zero force-pushed the refactor-attributes branch from 7d6c512 to 6119b56 Compare September 24, 2024 16:18
@h2zero h2zero merged commit 853241b into master Sep 24, 2024
62 checks passed
@h2zero h2zero deleted the refactor-attributes branch September 24, 2024 20:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant