Skip to content

Commit f79e492

Browse files
committed
Change default flags on advertising data packets
In BLELocalDevice constructor, the flags field of the advertising data is set to a default value. If a new advertising data is passed to BLELocalDevice, then: if it has no flags -> default flags are set (if there is enough space) if it already has flags -> nothing happens, the already set flags are used
1 parent d27fff5 commit f79e492

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

src/BLEAdvertisingData.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,11 @@ int BLEAdvertisingData::dataLength() const
227227
return _dataLength;
228228
}
229229

230+
bool BLEAdvertisingData::hasFlags() const
231+
{
232+
return _hasFlags;
233+
}
234+
230235
bool BLEAdvertisingData::addLocalName(const char *localName)
231236
{
232237
bool success = false;

src/BLEAdvertisingData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class BLEAdvertisingData {
7171
uint8_t* data();
7272
int dataLength() const;
7373
int remainingLength() const;
74+
bool hasFlags() const;
7475

7576
private:
7677
bool updateRemainingLength(int fieldLength);

src/local/BLELocalDevice.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ void BLELocalDevice::setLocalName(const char *localName)
217217
void BLELocalDevice::setAdvertisingData(BLEAdvertisingData& advertisingData)
218218
{
219219
_advertisingData = advertisingData;
220+
if (!_advertisingData.hasFlags()) {
221+
_advertisingData.setFlags(BLEFlagsGeneralDiscoverable | BLEFlagsBREDRNotSupported);
222+
}
220223
}
221224

222225
void BLELocalDevice::setScanResponseData(BLEAdvertisingData& scanResponseData)

0 commit comments

Comments
 (0)