Skip to content

Commit 77585f9

Browse files
committed
Change advertising raw data setting
If a BLEAdvertisingData packet has the raw data parameter set, all the other parameters are ignored when encoding the actual data packet. This means that the raw data parameter can be as long as the maximum length for an advertising packet (MAX_AD_DATA_LENGTH), that is 31 bytes as per BLE standard. During the setting of the raw data parameter: if the passed raw data length is larger than this maximum value, then the raw data is not set and the function returns false.
1 parent 51595db commit 77585f9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: src/BLEAdvertisingData.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ bool BLEAdvertisingData::setLocalName(const char *localName)
186186
bool BLEAdvertisingData::setRawData(const uint8_t* data, int length)
187187
{
188188
if (length > MAX_AD_DATA_LENGTH) {
189-
length = MAX_AD_DATA_LENGTH;
189+
return false;
190190
}
191191
_rawData = data;
192192
_rawDataLength = length;
@@ -195,11 +195,11 @@ bool BLEAdvertisingData::setRawData(const uint8_t* data, int length)
195195

196196
bool BLEAdvertisingData::setRawData(const BLEAdvertisingRawData& rawData)
197197
{
198+
if (rawData.length > MAX_AD_DATA_LENGTH) {
199+
return false;
200+
}
198201
_rawData = rawData.data;
199202
_rawDataLength = rawData.length;
200-
if (_rawDataLength > MAX_AD_DATA_LENGTH) {
201-
_rawDataLength = MAX_AD_DATA_LENGTH;
202-
}
203203
return true;
204204
}
205205

0 commit comments

Comments
 (0)