File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 20
20
#include " BLEAdvertisingData.h"
21
21
22
22
#define AD_FIELD_OVERHEAD (2 )
23
+ #define AD_NAME_LENGTH (19 )
23
24
24
25
BLEAdvertisingData::BLEAdvertisingData () :
25
26
_dataLength(0 ),
@@ -320,13 +321,11 @@ bool BLEAdvertisingData::hasFlags() const
320
321
321
322
bool BLEAdvertisingData::addLocalName (const char *localName)
322
323
{
323
- bool success = false ;
324
- if (strlen (localName) > (MAX_AD_DATA_LENGTH - AD_FIELD_OVERHEAD)) {
325
- success = addField (BLEFieldShortLocalName, (uint8_t *)localName, (MAX_AD_DATA_LENGTH - AD_FIELD_OVERHEAD));
326
- } else {
327
- success = addField (BLEFieldCompleteLocalName, localName);
328
- }
329
- return success;
324
+ uint8_t tempData[AD_NAME_LENGTH];
325
+ uint8_t tempDataLength = strlen (localName);
326
+ memcpy (tempData, (uint8_t *)localName, tempDataLength + 1 );
327
+ memset (&tempData[tempDataLength + 1 ], 0x20 , AD_NAME_LENGTH - tempDataLength - 1 );
328
+ return addField (BLEFieldCompleteLocalName, tempData, AD_NAME_LENGTH);
330
329
}
331
330
332
331
bool BLEAdvertisingData::addAdvertisedServiceUuid (const char * advertisedServiceUuid)
You can’t perform that action at this time.
0 commit comments