@@ -72,7 +72,7 @@ uint16_t BLEAdvertisedDevice::getAppearance() {
72
72
* @brief Get the manufacturer data.
73
73
* @return The manufacturer data of the advertised device.
74
74
*/
75
- std::string BLEAdvertisedDevice::getManufacturerData () {
75
+ String BLEAdvertisedDevice::getManufacturerData () {
76
76
return m_manufacturerData;
77
77
} // getManufacturerData
78
78
@@ -81,7 +81,7 @@ std::string BLEAdvertisedDevice::getManufacturerData() {
81
81
* @brief Get the name.
82
82
* @return The name of the advertised device.
83
83
*/
84
- std::string BLEAdvertisedDevice::getName () {
84
+ String BLEAdvertisedDevice::getName () {
85
85
return m_name;
86
86
} // getName
87
87
@@ -115,15 +115,15 @@ int BLEAdvertisedDevice::getServiceDataCount() {
115
115
* @brief Get the service data.
116
116
* @return The ServiceData of the advertised device.
117
117
*/
118
- std::string BLEAdvertisedDevice::getServiceData () {
119
- return m_serviceData.empty () ? std::string () : m_serviceData.front ();
118
+ String BLEAdvertisedDevice::getServiceData () {
119
+ return m_serviceData.empty () ? String () : m_serviceData.front ();
120
120
} // getServiceData
121
121
122
122
/* *
123
123
* @brief Get the service data.
124
124
* @return The ServiceData of the advertised device.
125
125
*/
126
- std::string BLEAdvertisedDevice::getServiceData (int i) {
126
+ String BLEAdvertisedDevice::getServiceData (int i) {
127
127
return m_serviceData[i];
128
128
} // getServiceData
129
129
@@ -296,7 +296,7 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t* payload, size_t total_len)
296
296
297
297
switch (ad_type) {
298
298
case ESP_BLE_AD_TYPE_NAME_CMPL: { // Adv Data Type: 0x09
299
- setName (std::string (reinterpret_cast <char *>(payload), length));
299
+ setName (String (reinterpret_cast <char *>(payload), length));
300
300
break ;
301
301
} // ESP_BLE_AD_TYPE_NAME_CMPL
302
302
@@ -343,7 +343,7 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t* payload, size_t total_len)
343
343
344
344
// See CSS Part A 1.4 Manufacturer Specific Data
345
345
case ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE: {
346
- setManufacturerData (std::string (reinterpret_cast <char *>(payload), length));
346
+ setManufacturerData (String (reinterpret_cast <char *>(payload), length));
347
347
break ;
348
348
} // ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE
349
349
@@ -355,7 +355,7 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t* payload, size_t total_len)
355
355
uint16_t uuid = *(uint16_t *)payload;
356
356
setServiceDataUUID (BLEUUID (uuid));
357
357
if (length > 2 ) {
358
- setServiceData (std::string (reinterpret_cast <char *>(payload + 2 ), length - 2 ));
358
+ setServiceData (String (reinterpret_cast <char *>(payload + 2 ), length - 2 ));
359
359
}
360
360
break ;
361
361
} // ESP_BLE_AD_TYPE_SERVICE_DATA
@@ -368,7 +368,7 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t* payload, size_t total_len)
368
368
uint32_t uuid = *(uint32_t *) payload;
369
369
setServiceDataUUID (BLEUUID (uuid));
370
370
if (length > 4 ) {
371
- setServiceData (std::string (reinterpret_cast <char *>(payload + 4 ), length - 4 ));
371
+ setServiceData (String (reinterpret_cast <char *>(payload + 4 ), length - 4 ));
372
372
}
373
373
break ;
374
374
} // ESP_BLE_AD_TYPE_32SERVICE_DATA
@@ -381,7 +381,7 @@ void BLEAdvertisedDevice::parseAdvertisement(uint8_t* payload, size_t total_len)
381
381
382
382
setServiceDataUUID (BLEUUID (payload, (size_t )16 , false ));
383
383
if (length > 16 ) {
384
- setServiceData (std::string (reinterpret_cast <char *>(payload + 16 ), length - 16 ));
384
+ setServiceData (String (reinterpret_cast <char *>(payload + 16 ), length - 16 ));
385
385
}
386
386
break ;
387
387
} // ESP_BLE_AD_TYPE_32SERVICE_DATA
@@ -444,10 +444,10 @@ void BLEAdvertisedDevice::setAppearance(uint16_t appearance) {
444
444
* @brief Set the manufacturer data for this device.
445
445
* @param [in] The discovered manufacturer data.
446
446
*/
447
- void BLEAdvertisedDevice::setManufacturerData (std::string manufacturerData) {
447
+ void BLEAdvertisedDevice::setManufacturerData (String manufacturerData) {
448
448
m_manufacturerData = manufacturerData;
449
449
m_haveManufacturerData = true ;
450
- char * pHex = BLEUtils::buildHexData (nullptr , (uint8_t *) m_manufacturerData.data (), (uint8_t ) m_manufacturerData.length ());
450
+ char * pHex = BLEUtils::buildHexData (nullptr , (uint8_t *) m_manufacturerData.c_str (), (uint8_t ) m_manufacturerData.length ());
451
451
log_d (" - manufacturer data: %s" , pHex);
452
452
free (pHex);
453
453
} // setManufacturerData
@@ -457,7 +457,7 @@ void BLEAdvertisedDevice::setManufacturerData(std::string manufacturerData) {
457
457
* @brief Set the name for this device.
458
458
* @param [in] name The discovered name.
459
459
*/
460
- void BLEAdvertisedDevice::setName (std::string name) {
460
+ void BLEAdvertisedDevice::setName (String name) {
461
461
m_name = name;
462
462
m_haveName = true ;
463
463
log_d (" - setName(): name: %s" , m_name.c_str ());
@@ -507,7 +507,7 @@ void BLEAdvertisedDevice::setServiceUUID(BLEUUID serviceUUID) {
507
507
* @brief Set the ServiceData value.
508
508
* @param [in] data ServiceData value.
509
509
*/
510
- void BLEAdvertisedDevice::setServiceData (std::string serviceData) {
510
+ void BLEAdvertisedDevice::setServiceData (String serviceData) {
511
511
m_serviceData.push_back (serviceData); // Save the service data that we received.
512
512
} // setServiceData
513
513
@@ -537,16 +537,16 @@ void BLEAdvertisedDevice::setTXPower(int8_t txPower) {
537
537
* @brief Create a string representation of this device.
538
538
* @return A string representation of this device.
539
539
*/
540
- std::string BLEAdvertisedDevice::toString () {
541
- std::string res = " Name: " + getName () + " , Address: " + getAddress ().toString ();
540
+ String BLEAdvertisedDevice::toString () {
541
+ String res = " Name: " + getName () + " , Address: " + getAddress ().toString ();
542
542
if (haveAppearance ()) {
543
543
char val[6 ];
544
544
snprintf (val, sizeof (val), " %d" , getAppearance ());
545
545
res += " , appearance: " ;
546
546
res += val;
547
547
}
548
548
if (haveManufacturerData ()) {
549
- char *pHex = BLEUtils::buildHexData (nullptr , (uint8_t *)getManufacturerData ().data (), getManufacturerData ().length ());
549
+ char *pHex = BLEUtils::buildHexData (nullptr , (uint8_t *)getManufacturerData ().c_str (), getManufacturerData ().length ());
550
550
res += " , manufacturer data: " ;
551
551
res += pHex;
552
552
free (pHex);
0 commit comments