Skip to content

Commit

Permalink
Merge pull request arduino-libraries#29 from sandeepmistry/service-da…
Browse files Browse the repository at this point in the history
…ta-fixes

Fix for advertised service data not working
  • Loading branch information
facchinm authored Aug 17, 2020
2 parents 95ce2e1 + 5533643 commit 633e1aa
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/utility/GAP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int GAPClass::advertise()

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

_advertising = false;
stopAdvertise();

if (HCI.leSetAdvertisingParameters(_advertisingInterval, _advertisingInterval, type, 0x00, 0x00, directBdaddr, 0x07, 0) != 0) {
return 0;
Expand Down Expand Up @@ -110,7 +110,7 @@ int GAPClass::advertise()
advertisingDataLen += _manufacturerDataLength;
}

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

Expand Down Expand Up @@ -153,7 +153,7 @@ int GAPClass::advertise()
return 0;
}

_advertising = false;
_advertising = true;

return 1;
}
Expand Down

0 comments on commit 633e1aa

Please sign in to comment.