Fix NimBLEExtAdvertisement::setServiceData data length.

This commit is contained in:
h2zero 2024-09-15 10:28:49 -06:00
parent 6f03b9a6ef
commit b4b3b0c455

View file

@ -778,7 +778,7 @@ void NimBLEExtAdvertisement::setServices(const bool complete, const uint8_t size
*/
void NimBLEExtAdvertisement::setServiceData(const NimBLEUUID &uuid, const std::string &data) {
uint8_t size = uuid.bitSize() / 8;
char cdata[2] = {static_cast<char>(1 + size), BLE_HS_ADV_TYPE_SVC_DATA_UUID16};
char cdata[2] = {static_cast<char>(1 + size + data.length()), BLE_HS_ADV_TYPE_SVC_DATA_UUID16};
switch (size) {
case 2: {
// [Len] [0x16] [UUID16] data