@@ -40,6 +40,7 @@ BLERemoteCharacteristic::BLERemoteCharacteristic(
40
40
m_pRemoteService = pRemoteService;
41
41
m_notifyCallback = nullptr ;
42
42
m_rawData = nullptr ;
43
+ m_auth = ESP_GATT_AUTH_REQ_NONE;
43
44
44
45
retrieveDescriptors (); // Get the descriptors for this characteristic
45
46
log_v (" << BLERemoteCharacteristic" );
@@ -355,8 +356,8 @@ BLEUUID BLERemoteCharacteristic::getUUID() {
355
356
* @brief Read an unsigned 16 bit value
356
357
* @return The unsigned 16 bit value.
357
358
*/
358
- uint16_t BLERemoteCharacteristic::readUInt16 (esp_gatt_auth_req_t auth ) {
359
- std::string value = readValue (auth );
359
+ uint16_t BLERemoteCharacteristic::readUInt16 () {
360
+ std::string value = readValue ();
360
361
if (value.length () >= 2 ) {
361
362
return *(uint16_t *)(value.data ());
362
363
}
@@ -368,8 +369,8 @@ uint16_t BLERemoteCharacteristic::readUInt16(esp_gatt_auth_req_t auth) {
368
369
* @brief Read an unsigned 32 bit value.
369
370
* @return the unsigned 32 bit value.
370
371
*/
371
- uint32_t BLERemoteCharacteristic::readUInt32 (esp_gatt_auth_req_t auth ) {
372
- std::string value = readValue (auth );
372
+ uint32_t BLERemoteCharacteristic::readUInt32 () {
373
+ std::string value = readValue ();
373
374
if (value.length () >= 4 ) {
374
375
return *(uint32_t *)(value.data ());
375
376
}
@@ -381,8 +382,8 @@ uint32_t BLERemoteCharacteristic::readUInt32(esp_gatt_auth_req_t auth) {
381
382
* @brief Read a byte value
382
383
* @return The value as a byte
383
384
*/
384
- uint8_t BLERemoteCharacteristic::readUInt8 (esp_gatt_auth_req_t auth ) {
385
- std::string value = readValue (auth );
385
+ uint8_t BLERemoteCharacteristic::readUInt8 () {
386
+ std::string value = readValue ();
386
387
if (value.length () >= 1 ) {
387
388
return (uint8_t )value[0 ];
388
389
}
@@ -393,8 +394,8 @@ uint8_t BLERemoteCharacteristic::readUInt8(esp_gatt_auth_req_t auth) {
393
394
* @brief Read a float value.
394
395
* @return the float value.
395
396
*/
396
- float BLERemoteCharacteristic::readFloat (esp_gatt_auth_req_t auth ) {
397
- std::string value = readValue (auth );
397
+ float BLERemoteCharacteristic::readFloat () {
398
+ std::string value = readValue ();
398
399
if (value.length () >= 4 ) {
399
400
return *(float *)(value.data ());
400
401
}
@@ -405,7 +406,7 @@ float BLERemoteCharacteristic::readFloat(esp_gatt_auth_req_t auth) {
405
406
* @brief Read the value of the remote characteristic.
406
407
* @return The value of the remote characteristic.
407
408
*/
408
- std::string BLERemoteCharacteristic::readValue (esp_gatt_auth_req_t auth ) {
409
+ std::string BLERemoteCharacteristic::readValue () {
409
410
log_v (" >> readValue(): uuid: %s, handle: %d 0x%.2x" , getUUID ().toString ().c_str (), getHandle (), getHandle ());
410
411
411
412
// Check to see that we are connected.
E864
button>@@ -423,7 +424,7 @@ std::string BLERemoteCharacteristic::readValue(esp_gatt_auth_req_t auth) {
423
424
m_pRemoteService->getClient ()->getGattcIf (),
424
425
m_pRemoteService->getClient ()->getConnId (), // The connection ID to the BLE server
425
426
getHandle (), // The handle of this characteristic
426
- auth ); // Security
427
+ m_auth ); // Security
427
428
428
429
if (errRc != ESP_OK) {
429
430
log_e (" esp_ble_gattc_read_char: rc=%d %s" , errRc, GeneralUtils::errorToString (errRc));
@@ -531,8 +532,8 @@ std::string BLERemoteCharacteristic::toString() {
531
532
* @param [in] response Do we expect a response?
532
533
* @return N/A.
533
534
*/
534
- void BLERemoteCharacteristic::writeValue (std::string newValue, bool response, esp_gatt_auth_req_t auth ) {
535
- writeValue ((uint8_t *)newValue.c_str (), strlen (newValue.c_str ()), response, auth );
535
+ void BLERemoteCharacteristic::writeValue (std::string newValue, bool response) {
536
+ writeValue ((uint8_t *)newValue.c_str (), strlen (newValue.c_str ()), response);
536
537
} // writeValue
537
538
538
539
@@ -544,8 +545,8 @@ void BLERemoteCharacteristic::writeValue(std::string newValue, bool response, es
544
545
* @param [in] response Whether we require a response from the write.
545
546
* @return N/A.
546
547
*/
547
- void BLERemoteCharacteristic::writeValue (uint8_t newValue, bool response, esp_gatt_auth_req_t auth ) {
548
- writeValue (&newValue, 1 , response, auth );
548
+ void BLERemoteCharacteristic::writeValue (uint8_t newValue, bool response) {
549
+ writeValue (&newValue, 1 , response);
549
550
} // writeValue
550
551
551
552
@@ -555,7 +556,7 @@ void BLERemoteCharacteristic::writeValue(uint8_t newValue, bool response, esp_ga
555
556
* @param [in] length The length of the data in the data buffer.
556
557
* @param [in] response Whether we require a response from the write.
557
558
*/
558
- void BLERemoteCharacteristic::writeValue (uint8_t * data, size_t length, bool response, esp_gatt_auth_req_t auth ) {
559
+ void BLERemoteCharacteristic::writeValue (uint8_t * data, size_t length, bool response) {
559
560
// writeValue(std::string((char*)data, length), response);
560
561
log_v (" >> writeValue(), length: %d" , length);
561
562
@@ -574,7 +575,7 @@ void BLERemoteCharacteristic::writeValue(uint8_t* data, size_t length, bool resp
574
575
length,
575
576
data,
576
577
response?ESP_GATT_WRITE_TYPE_RSP:ESP_GATT_WRITE_TYPE_NO_RSP,
577
- auth
578
+ m_auth
578
579
);
579
580
580
581
if (errRc != ESP_OK) {
@@ -595,4 +596,12 @@ uint8_t* BLERemoteCharacteristic::readRawData() {
595
596
return m_rawData;
596
597
}
597
598
599
+ /* *
600
+ * @brief Set authentication request type for characteristic
601
+ * @param [in] auth Authentication request type.
602
+ */
603
+ void BLERemoteCharacteristic::setAuth (esp_gatt_auth_req_t auth) {
604
+ m_auth = auth;
605
+ }
606
+
598
607
#endif /* CONFIG_BT_ENABLED */
0 commit comments