diff options
author | Neil Kolban <kolban1@kolban.com> | 2018-01-17 18:16:31 -0600 |
---|---|---|
committer | Neil Kolban <kolban1@kolban.com> | 2018-01-17 18:16:31 -0600 |
commit | 3f5005c383540d07dd16ac044c78d7be28d4aa8e (patch) | |
tree | c5236ddbe5c8dd99ad7083dd498110152ad0e9be /src/BLERemoteCharacteristic.cpp | |
parent | Removal of unneeded file (diff) | |
download | thermostat-3f5005c383540d07dd16ac044c78d7be28d4aa8e.tar.gz thermostat-3f5005c383540d07dd16ac044c78d7be28d4aa8e.tar.bz2 thermostat-3f5005c383540d07dd16ac044c78d7be28d4aa8e.zip |
0.4.8
Diffstat (limited to 'src/BLERemoteCharacteristic.cpp')
-rw-r--r-- | src/BLERemoteCharacteristic.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/BLERemoteCharacteristic.cpp b/src/BLERemoteCharacteristic.cpp index 64b0a92..d9c64c9 100644 --- a/src/BLERemoteCharacteristic.cpp +++ b/src/BLERemoteCharacteristic.cpp @@ -15,6 +15,7 @@ #include <esp_err.h> #include <sstream> +#include "BLEExceptions.h" #include "BLEUtils.h" #include "GeneralUtils.h" #include "BLERemoteDescriptor.h" @@ -432,6 +433,12 @@ uint8_t BLERemoteCharacteristic::readUInt8(void) { std::string BLERemoteCharacteristic::readValue() { ESP_LOGD(LOG_TAG, ">> readValue(): uuid: %s, handle: %d 0x%.2x", getUUID().toString().c_str(), getHandle(), getHandle()); + // Check to see that we are connected. + if (!getRemoteService()->getClient()->isConnected()) { + ESP_LOGE(LOG_TAG, "Disconnected"); + throw BLEDisconnectedException(); + } + m_semaphoreReadCharEvt.take("readValue"); // Ask the BLE subsystem to retrieve the value for the remote hosted characteristic. @@ -543,6 +550,12 @@ std::string BLERemoteCharacteristic::toString() { void BLERemoteCharacteristic::writeValue(std::string newValue, bool response) { ESP_LOGD(LOG_TAG, ">> writeValue(), length: %d", newValue.length()); + // Check to see that we are connected. + if (!getRemoteService()->getClient()->isConnected()) { + ESP_LOGE(LOG_TAG, "Disconnected"); + throw BLEDisconnectedException(); + } + m_semaphoreWriteCharEvt.take("writeValue"); // Invoke the ESP-IDF API to perform the write. |