mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2026-01-26 17:12:31 +01:00
[BREAKING] Refactor attributes
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.
This commit is contained in:
@@ -25,6 +25,12 @@ static const char* LOG_TAG = "NimBLEUUID";
|
||||
static const uint8_t ble_base_uuid[] = {
|
||||
0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
/**
|
||||
* @brief Create a UUID from the native UUID.
|
||||
* @param [in] uuid The native UUID.
|
||||
*/
|
||||
NimBLEUUID::NimBLEUUID(const ble_uuid_any_t& uuid) : m_uuid{uuid} {}
|
||||
|
||||
/**
|
||||
* @brief Create a UUID from a string.
|
||||
*
|
||||
@@ -323,4 +329,4 @@ NimBLEUUID::operator std::string() const {
|
||||
return ble_uuid_to_str(&m_uuid.u, buf);
|
||||
} // operator std::string
|
||||
|
||||
#endif /* CONFIG_BT_ENABLED */
|
||||
# endif /* CONFIG_BT_ENABLED */
|
||||
|
||||
Reference in New Issue
Block a user