summaryrefslogtreecommitdiff
path: root/src/BLECharacteristicMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/BLECharacteristicMap.cpp')
-rw-r--r--src/BLECharacteristicMap.cpp122
1 files changed, 63 insertions, 59 deletions
diff --git a/src/BLECharacteristicMap.cpp b/src/BLECharacteristicMap.cpp
index f475e83..6ded0a6 100644
--- a/src/BLECharacteristicMap.cpp
+++ b/src/BLECharacteristicMap.cpp
@@ -10,6 +10,17 @@
#include <iomanip>
#include "BLEService.h"
+
+/**
+ * @brief Return the characteristic by handle.
+ * @param [in] handle The handle to look up the characteristic.
+ * @return The characteristic.
+ */
+BLECharacteristic* BLECharacteristicMap::getByHandle(uint16_t handle) {
+ return m_handleMap.at(handle);
+} // getByHandle
+
+
/**
* @brief Return the characteristic by UUID.
* @param [in] UUID The UUID to look up the characteristic.
@@ -19,6 +30,7 @@ BLECharacteristic* BLECharacteristicMap::getByUUID(const char* uuid) {
return getByUUID(BLEUUID(uuid));
}
+
/**
* @brief Return the characteristic by UUID.
* @param [in] UUID The UUID to look up the characteristic.
@@ -36,26 +48,49 @@ BLECharacteristic* BLECharacteristicMap::getByUUID(BLEUUID uuid) {
/**
- * @brief Return the characteristic by handle.
- * @param [in] handle The handle to look up the characteristic.
- * @return The characteristic.
+ * @brief Get the first characteristic in the map.
+ * @return The first characteristic in the map.
*/
-BLECharacteristic* BLECharacteristicMap::getByHandle(uint16_t handle) {
- return m_handleMap.at(handle);
-} // getByHandle
+BLECharacteristic* BLECharacteristicMap::getFirst() {
+ m_iterator = m_uuidMap.begin();
+ if (m_iterator == m_uuidMap.end()) {
+ return nullptr;
+ }
+ BLECharacteristic* pRet = m_iterator->second;
+ m_iterator++;
+ return pRet;
+} // getFirst
/**
- * @brief Set the characteristic by UUID.
- * @param [in] uuid The uuid of the characteristic.
- * @param [in] characteristic The characteristic to cache.
- * @return N/A.
+ * @brief Get the next characteristic in the map.
+ * @return The next characteristic in the map.
*/
-void BLECharacteristicMap::setByUUID(
- BLEUUID uuid,
- BLECharacteristic *pCharacteristic) {
- m_uuidMap.insert(std::pair<std::string, BLECharacteristic *>(uuid.toString(), pCharacteristic));
-} // setByUUID
+BLECharacteristic* BLECharacteristicMap::getNext() {
+ if (m_iterator == m_uuidMap.end()) {
+ return nullptr;
+ }
+ BLECharacteristic* pRet = m_iterator->second;
+ m_iterator++;
+ return pRet;
+} // getNext
+
+
+/**
+ * @brief Pass the GATT server event onwards to each of the characteristics found in the mapping
+ * @param [in] event
+ * @param [in] gatts_if
+ * @param [in] param
+ */
+void BLECharacteristicMap::handleGATTServerEvent(
+ esp_gatts_cb_event_t event,
+ esp_gatt_if_t gatts_if,
+ esp_ble_gatts_cb_param_t* param) {
+ // Invoke the handler for every Service we have.
+ for (auto &myPair : m_uuidMap) {
+ myPair.second->handleGATTServerEvent(event, gatts_if, param);
+ }
+} // handleGATTServerEvent
/**
@@ -71,6 +106,19 @@ void BLECharacteristicMap::setByHandle(uint16_t handle,
/**
+ * @brief Set the characteristic by UUID.
+ * @param [in] uuid The uuid of the characteristic.
+ * @param [in] characteristic The characteristic to cache.
+ * @return N/A.
+ */
+void BLECharacteristicMap::setByUUID(
+ BLEUUID uuid,
+ BLECharacteristic *pCharacteristic) {
+ m_uuidMap.insert(std::pair<std::string, BLECharacteristic *>(uuid.toString(), pCharacteristic));
+} // setByUUID
+
+
+/**
* @brief Return a string representation of the characteristic map.
* @return A string representation of the characteristic map.
*/
@@ -89,48 +137,4 @@ std::string BLECharacteristicMap::toString() {
} // toString
-/**
- * @breif Pass the GATT server event onwards to each of the characteristics found in the mapping
- * @param [in] event
- * @param [in] gatts_if
- * @param [in] param
- */
-void BLECharacteristicMap::handleGATTServerEvent(
- esp_gatts_cb_event_t event,
- esp_gatt_if_t gatts_if,
- esp_ble_gatts_cb_param_t *param) {
- // Invoke the handler for every Service we have.
- for (auto &myPair : m_uuidMap) {
- myPair.second->handleGATTServerEvent(event, gatts_if, param);
- }
-} // handleGATTServerEvent
-
-
-/**
- * @brief Get the first characteristic in the map.
- * @return The first characteristic in the map.
- */
-BLECharacteristic* BLECharacteristicMap::getFirst() {
- m_iterator = m_uuidMap.begin();
- if (m_iterator == m_uuidMap.end()) {
- return nullptr;
- }
- BLECharacteristic *pRet = m_iterator->second;
- m_iterator++;
- return pRet;
-} // getFirst
-
-
-/**
- * @brief Get the next characteristic in the map.
- * @return The next characteristic in the map.
- */
-BLECharacteristic* BLECharacteristicMap::getNext() {
- if (m_iterator == m_uuidMap.end()) {
- return nullptr;
- }
- BLECharacteristic *pRet = m_iterator->second;
- m_iterator++;
- return pRet;
-} // getNext
#endif /* CONFIG_BT_ENABLED */