Dynamic assignment of BLE Advertising Data MKW39A512xxx4

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dynamic assignment of BLE Advertising Data MKW39A512xxx4

Jump to solution
1,497 Views
jacklooks4answers
Contributor II

Hi,

I am using custom hardware with MCUXpresso SDK 2.x for MKW41Z512xxx4. My board is the MKW38A512VFT4.

I would like to set the BLE advertising name to the device model that it receives externally during runtime. Unfortunately, the gap_interface.h function to set the data takes in constants that cannot be changed during run time:

bleResult_t Gap_SetAdvertisingData

(
    const gapAdvertisingData_t*         pAdvertisingData,
    const gapScanResponseData_t*        pScanResponseData
);
 
Would there be another work around to declare advertising data dynamically in this SDK?
Many thanks,
Jack
 
EDIT to complete: 
I was particularly interested in this topic
 
However did not get a satisfactory result. It looks to me like undefined behaviour...
In runtime, after I've received "app_data" I define advScanRsp:
   
            uint8_t adData3[25] = {0};
            FLib_MemCpy(adData3,model_names[app_data.proxy_system_config[1]],  
            strlen(model_names[_app_data.proxy_system_config[1]]+1));
 
            gapAdStructure_t advScanRsp = {
            .adType = gAdCompleteLocalName_c,
            .length = strlen(model_names[app_data.proxy_system_config[1]]+1),
            .aData = (uint8_t*)adData3
            };

            gapScanResponseData_t gAppScanRspData =
            {
                1,
                (void *)&advScanRsp
            };
            (void)Gap_SetAdvertisingData(&gAppAdvertisingData, &gAppScanRspData);
 
 
 
The code compiles and often the first go I might get the correct name up to the first 18 characters however if I change the model, the name would flash correct and then be overwritten with the previously compiled model name, hence my assumption that I have caused undefined behaviour.
0 Kudos
Reply
1 Solution
1,451 Views
jacklooks4answers
Contributor II

I apologise for my mistake, the library is working just as it should. My aData variable was being overwritten elsewhere... I hope you have a nice day and I thank you for your time.

Best,

Jack

View solution in original post

0 Kudos
Reply
3 Replies
1,452 Views
jacklooks4answers
Contributor II

I apologise for my mistake, the library is working just as it should. My aData variable was being overwritten elsewhere... I hope you have a nice day and I thank you for your time.

Best,

Jack

0 Kudos
Reply
1,476 Views
Ricardo_Zamora
NXP TechSupport
NXP TechSupport

Hello,

 

Hope you are doing well. First of all, could you please clarify what MCU are you using? What SDK version are you using?

We always encourage to use the latest SDK for the specific MCU.

 

Regards,

Ricardo

0 Kudos
Reply
1,470 Views
jacklooks4answers
Contributor II
Hello Ricardo and thanks,

I am using the MKW38A512VFT4 and the SDK version is 2.6.11.

Best,
Jack
0 Kudos
Reply