diff options
author | kolban <kolban1@kolban.com> | 2017-10-13 10:52:17 -0500 |
---|---|---|
committer | kolban <kolban1@kolban.com> | 2017-10-13 10:52:17 -0500 |
commit | 34902f4e7fc6926a005a5ccfd4e530d6a6321613 (patch) | |
tree | 512593068ed656012ee31fced9526bff80ecad55 /src/BLECharacteristicMap.cpp | |
parent | Merge pull request #5 from sebastiankliem/master (diff) | |
download | thermostat-34902f4e7fc6926a005a5ccfd4e530d6a6321613.tar.gz thermostat-34902f4e7fc6926a005a5ccfd4e530d6a6321613.tar.bz2 thermostat-34902f4e7fc6926a005a5ccfd4e530d6a6321613.zip |
Sync update for 0.4.3 take 2
Diffstat (limited to 'src/BLECharacteristicMap.cpp')
-rw-r--r-- | src/BLECharacteristicMap.cpp | 122 |
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 */ |