From 77585f97c943c02e8961d57d756f4d4e071249ca Mon Sep 17 00:00:00 2001 From: Paolo Calao Date: Tue, 3 Nov 2020 11:37:01 +0100 Subject: [PATCH] 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. --- src/BLEAdvertisingData.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/BLEAdvertisingData.cpp b/src/BLEAdvertisingData.cpp index 50063913..d528bdfa 100644 --- a/src/BLEAdvertisingData.cpp +++ b/src/BLEAdvertisingData.cpp @@ -186,7 +186,7 @@ bool BLEAdvertisingData::setLocalName(const char *localName) bool BLEAdvertisingData::setRawData(const uint8_t* data, int length) { if (length > MAX_AD_DATA_LENGTH) { - length = MAX_AD_DATA_LENGTH; + return false; } _rawData = data; _rawDataLength = length; @@ -195,11 +195,11 @@ bool BLEAdvertisingData::setRawData(const uint8_t* data, int length) bool BLEAdvertisingData::setRawData(const BLEAdvertisingRawData& rawData) { + if (rawData.length > MAX_AD_DATA_LENGTH) { + return false; + } _rawData = rawData.data; _rawDataLength = rawData.length; - if (_rawDataLength > MAX_AD_DATA_LENGTH) { - _rawDataLength = MAX_AD_DATA_LENGTH; - } return true; }