Dynamic assignment of BLE Advertising Data MKW39A512xxx4

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Dynamic assignment of BLE Advertising Data MKW39A512xxx4

跳至解决方案
1,493 次查看
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 项奖励
回复
1 解答
1,447 次查看
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 项奖励
回复
3 回复数
1,448 次查看
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 项奖励
回复
1,472 次查看
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 项奖励
回复
1,466 次查看
jacklooks4answers
Contributor II
Hello Ricardo and thanks,

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

Best,
Jack
0 项奖励
回复