@@ -57,8 +57,8 @@ BLERemoteCharacteristic::BLERemoteCharacteristic(
57
57
*@brief Destructor.
58
58
*/
59
59
BLERemoteCharacteristic::~BLERemoteCharacteristic () {
60
- if (m_rawData != nullptr ) free (m_rawData);
61
60
removeDescriptors (); // Release resources for any descriptor information we may have allocated.
61
+ if (m_rawData != nullptr ) free (m_rawData);
62
62
} // ~BLERemoteCharacteristic
63
63
64
64
@@ -523,10 +523,10 @@ std::string BLERemoteCharacteristic::toString() {
523
523
* @brief Write the new value for the characteristic.
524
524
* @param [in] newValue The new value to write.
525
525
* @param [in] response Do we expect a response?
526
- * @return N/A .
526
+ * @return false if not connected or cant perform write for some reason .
527
527
*/
528
- void BLERemoteCharacteristic::writeValue (std::string newValue, bool response) {
529
- writeValue ((uint8_t *)newValue.c_str (), strlen (newValue.c_str ()), response);
528
+ bool BLERemoteCharacteristic::writeValue (std::string newValue, bool response) {
529
+ return writeValue ((uint8_t *)newValue.c_str (), strlen (newValue.c_str ()), response);
530
530
} // writeValue
531
531
532
532
@@ -536,10 +536,10 @@ void BLERemoteCharacteristic::writeValue(std::string newValue, bool response) {
536
536
* This is a convenience function. Many BLE characteristics are a single byte of data.
537
537
* @param [in] newValue The new byte value to write.
538
538
* @param [in] response Whether we require a response from the write.
539
- * @return N/A .
539
+ * @return false if not connected or cant perform write for some reason .
540
540
*/
541
- void BLERemoteCharacteristic::writeValue (uint8_t newValue, bool response) {
542
- writeValue (&newValue, 1 , response);
541
+ bool BLERemoteCharacteristic::writeValue (uint8_t newValue, bool response) {
542
+ return writeValue (&newValue, 1 , response);
543
543
} // writeValue
544
544
545
545
@@ -548,15 +548,16 @@ void BLERemoteCharacteristic::writeValue(uint8_t newValue, bool response) {
548
548
* @param [in] data A pointer to a data buffer.
549
549
* @param [in] length The length of the data in the data buffer.
550
550
* @param [in] response Whether we require a response from the write.
551
+ * @return false if not connected or cant perform write for some reason.
551
552
*/
552
- void BLERemoteCharacteristic::writeValue (uint8_t * data, size_t length, bool response) {
553
+ bool BLERemoteCharacteristic::writeValue (uint8_t * data, size_t length, bool response) {
553
554
// writeValue(std::string((char*)data, length), response);
554
555
ESP_LOGD (LOG_TAG, " >> writeValue(), length: %d" , length);
555
556
556
557
// Check to see that we are connected.
557
558
if (!getRemoteService ()->getClient ()->isConnected ()) {
558
559
ESP_LOGE (LOG_TAG, " Disconnected" );
559
- throw BLEDisconnectedException () ;
560
+ return false ;
560
561
}
561
562
562
563
m_semaphoreWriteCharEvt.take (" writeValue" );
@@ -573,12 +574,13 @@ void BLERemoteCharacteristic::writeValue(uint8_t* data, size_t length, bool resp
573
574
574
575
if (errRc != ESP_OK) {
575
576
ESP_LOGE (LOG_TAG, " esp_ble_gattc_write_char: rc=%d %s" , errRc, GeneralUtils::errorToString (errRc));
576
- return ;
577
+ return false ;
577
578
}
578
579
579
580
m_semaphoreWriteCharEvt.wait (" writeValue" );
580
581
581
582
ESP_LOGD (LOG_TAG, " << writeValue" );
583
+ return true ;
582
584
} // writeValue
583
585
584
586
/* *
0 commit comments