-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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. * 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 *>.
- Loading branch information
Showing
29 changed files
with
1,664 additions
and
2,460 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* NimBLEAttribute.h | ||
* | ||
* Created: on July 28 2024 | ||
* Author H2zero | ||
*/ | ||
|
||
#ifndef NIMBLE_CPP_ATTRIBUTE_H_ | ||
#define NIMBLE_CPP_ATTRIBUTE_H_ | ||
|
||
#include "nimconfig.h" | ||
#if defined(CONFIG_BT_ENABLED) && (defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL) || defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)) | ||
|
||
# include "NimBLEUUID.h" | ||
|
||
/** | ||
* @brief A base class for BLE attributes. | ||
*/ | ||
class NimBLEAttribute { | ||
public: | ||
/** | ||
* @brief Get the UUID of the attribute. | ||
* @return The UUID. | ||
*/ | ||
const NimBLEUUID& getUUID() const { return m_uuid; } | ||
|
||
/** | ||
* @brief Get the handle of the attribute. | ||
*/ | ||
uint16_t getHandle() const { return m_handle; }; | ||
|
||
protected: | ||
/** | ||
* @brief Construct a new NimBLEAttribute object. | ||
* @param [in] handle The handle of the attribute. | ||
* @param [in] uuid The UUID of the attribute. | ||
*/ | ||
NimBLEAttribute(const NimBLEUUID& uuid, uint16_t handle) : m_uuid{uuid}, m_handle{handle} {} | ||
|
||
/** | ||
* @brief Destroy the NimBLEAttribute object. | ||
*/ | ||
~NimBLEAttribute() = default; | ||
|
||
const NimBLEUUID m_uuid{}; | ||
uint16_t m_handle{0}; | ||
}; | ||
|
||
#endif // CONFIG_BT_ENABLED && (CONFIG_BT_NIMBLE_ROLE_PERIPHERAL || CONFIG_BT_NIMBLE_ROLE_CENTRAL) | ||
#endif // NIMBLE_CPP_ATTRIBUTE_H_ |
Oops, something went wrong.