MCPcopy Create free account
hub / github.com/Heltec-Aaron-Lee/WiFi_Kit_series / toString

Method toString

libraries/BLE/src/BLEUUID.cpp:268–298  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

266}
267
268String BLEUUID::toString() const {
269 if (!m_valueSet) {
270 return "<NULL>"; // If we have no value, nothing to format.
271 }
272
273 if (UUID_LEN(m_uuid) == BLE_UUID_16_BITS) { // If the UUID is 16bit, pad correctly.
274 char hex[9];
275 snprintf(hex, sizeof(hex), "%08x", UUID_VAL_16(m_uuid));
276 return String(hex) + "-0000-1000-8000-00805f9b34fb";
277 } // End 16bit UUID
278
279 if (UUID_LEN(m_uuid) == BLE_UUID_32_BITS) { // If the UUID is 32bit, pad correctly.
280 char hex[9];
281 snprintf(hex, sizeof(hex), "%08" PRIx32, UUID_VAL_32(m_uuid));
282 return String(hex) + "-0000-1000-8000-00805f9b34fb";
283 } // End 32bit UUID
284
285 // The UUID is not 16bit or 32bit which means that it is 128bit.
286 auto size = 37; // 32 for UUID data, 4 for '-' delimiters and one for a terminator == 37 chars
287 char *hex = (char *)malloc(size);
288 snprintf(
289 hex, size, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", UUID_VAL_128(m_uuid)[15], UUID_VAL_128(m_uuid)[14],
290 UUID_VAL_128(m_uuid)[13], UUID_VAL_128(m_uuid)[12], UUID_VAL_128(m_uuid)[11], UUID_VAL_128(m_uuid)[10], UUID_VAL_128(m_uuid)[9], UUID_VAL_128(m_uuid)[8],
291 UUID_VAL_128(m_uuid)[7], UUID_VAL_128(m_uuid)[6], UUID_VAL_128(m_uuid)[5], UUID_VAL_128(m_uuid)[4], UUID_VAL_128(m_uuid)[3], UUID_VAL_128(m_uuid)[2],
292 UUID_VAL_128(m_uuid)[1], UUID_VAL_128(m_uuid)[0]
293 );
294
295 String res(hex);
296 free(hex);
297 return res;
298} // toString
299
300bool BLEUUID::operator==(const BLEUUID &rhs) const {
301 return equals(rhs);

Callers 15

ssl_client.cppFile · 0.45
connectMethod · 0.45
runMethod · 0.45
equalsMethod · 0.45
gattIdToStringFunction · 0.45
dumpGapEventMethod · 0.45
dumpGattClientEventMethod · 0.45
dumpGattServerEventMethod · 0.45
eraseMethod · 0.45
dumpMethod · 0.45

Calls 1

StringClass · 0.85

Tested by

no test coverage detected