Skip to content

Commit 633e1aa

Browse files
authored
Merge pull request #29 from sandeepmistry/service-data-fixes
Fix for advertised service data not working
2 parents 95ce2e1 + 5533643 commit 633e1aa

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/utility/GAP.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ int GAPClass::advertise()
7979

8080
uint8_t type = (_connectable) ? 0x00 : (_localName ? 0x02 : 0x03);
8181

82-
_advertising = false;
82+
stopAdvertise();
8383

8484
if (HCI.leSetAdvertisingParameters(_advertisingInterval, _advertisingInterval, type, 0x00, 0x00, directBdaddr, 0x07, 0) != 0) {
8585
return 0;
@@ -110,7 +110,7 @@ int GAPClass::advertise()
110110
advertisingDataLen += _manufacturerDataLength;
111111
}
112112

113-
if (_serviceData && _serviceDataLength > 0 && advertisingDataLen >= (_serviceDataLength + 4)) {
113+
if (_serviceData && _serviceDataLength > 0 && (sizeof(advertisingData) - advertisingDataLen) >= (_serviceDataLength + 4)) {
114114
advertisingData[advertisingDataLen++] = _serviceDataLength + 3;
115115
advertisingData[advertisingDataLen++] = 0x16;
116116

@@ -153,7 +153,7 @@ int GAPClass::advertise()
153153
return 0;
154154
}
155155

156-
_advertising = false;
156+
_advertising = true;
157157

158158
return 1;
159159
}

0 commit comments

Comments
 (0)