AnsweredAssumed Answered

Changing device's advertising name

Question asked by Tero Nikula on Jul 9, 2019
Latest reply on Jul 12, 2019 by Tero Nikula

Hi,

 

I am using custom hardware with MCUXpresso SDK 2.2 for MKW41Z512xxx4. The hardware is included by Rigado R41Z chip.

 

I'm trying to change device's Bluetooth advertising name in my code. Later I'm going to need this because iOS can't show MAC address so I want to add shortened MAC to device name so I can separate the one I want to use from others.

 

My problem is that I'm not able to get enough long name for that advertising name (gAData). It seems that 8 is the maximum length that is working. When I try 9 or more for length, the device is not advertising itself.

 

I have used these links as help:

How to update advScanStruct after initialization? 

Hexiwear_v2/app_config.c at master · ErichStyger/Hexiwear_v2 · GitHub 

Hexiwear_v2/app.h at master · ErichStyger/Hexiwear_v2 · GitHub 

Hexiwear_v2/app.c at master · ErichStyger/Hexiwear_v2 · GitHub 

 

Here is my code:


// app_config.c

/* Scanning and Advertising Data */

 

uint8_t gAData[8] = "12345678";                    // working
//uint8_t gAData[12] = "123456789012";        // not working

 

static const uint8_t adData0[1] =  { (gapAdTypeFlags_t)(gLeGeneralDiscoverableMode_c | gBrEdrNotSupported_c) };

 

const gapAdStructure_t advScanStruct[3] = {
  {
    .length = NumberOfElements(adData0) + 1,
    .adType = gAdFlags_c,
    .aData = (uint8_t *)adData0
  },  
  {
    .length = NumberOfElements(uuid_service_xxxx) + 1,
    .adType = gAdComplete128bitServiceList_c,
    .aData = (uint8_t *)uuid_service_xxxx
  },  
  {
    .length = 9,                                                         // working
    //.length = 13,                                                     // not working
    .adType = gAdShortenedLocalName_c,
    .aData = (uint8_t *)&gAData
  }  
};

 

// app.h


/* Public memory declarations */

 

extern gapAdvertisingData_t         gAppAdvertisingData;
extern gapScanResponseData_t        gAppScanRspData;
extern gapAdvertisingParameters_t   gAdvParams;
extern uint8_t                      gAData[];
extern const gapAdStructure_t       advScanStruct[];

 

// app.c

/*! *********************************************************************************
* \brief        Configures BLE Stack after initialization. Usually used for
*               configuring advertising, scanning, white list, services, et al.
********************************************************************************** */

static void BleApp_Config()
{
    ...

    /* Set device name */
    gAppAdvertisingData.cNumAdStructures = 3;
    gAppAdvertisingData.aAdStructures = (void *)advScanStruct;

 

    memcpy(&gAData, "TEST1234", 9);                     // working
    //memcpy(&gAData, "TEST12345678", 13);         // not working

 

    Gap_SetAdvertisingData(&gAppAdvertisingData, &gAppScanRspData);

    ...
}

 

So my question is how to get that longer name working?

 

That would be great if anyone could help me with this!

 

Thanks,

Tero

Outcomes