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 2020#include " BLEAdvertisingData.h"
2121
2222#define AD_FIELD_OVERHEAD (2 )
23+ #define AD_NAME_LENGTH (19 )
2324
2425BLEAdvertisingData::BLEAdvertisingData () :
2526 _dataLength(0 ),
@@ -320,13 +321,11 @@ bool BLEAdvertisingData::hasFlags() const
320321
321322bool BLEAdvertisingData::addLocalName (const char *localName)
322323{
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);
330329}
331330
332331bool BLEAdvertisingData::addAdvertisedServiceUuid (const char * advertisedServiceUuid)
You can’t perform that action at this time.
0 commit comments