Hello,
I'm working with the ble_multi_link-demo and I'd like to adapt the Advertising data on runtime. If I put a variable in adv_data[], the Compiler throws an error that the variable must be a const.
I've already searched the Forum, but the older Topics seem to belong to an older/different chipset.
Thanks a lot in advance,
Philipp
Device:
Hi dsandbue,
In order to dynamically change the data on the 68x you will need to stop the advertising procedure (via timer for example) and set the new advertising data and then start advertising again.
I dont quite get what you mean that you put a variable in the advertising data, can you please share some code with what is that you are trying to do ? The adv_data[] array that keeps the advertising data is declared as a constant, and i suppose that this is the reason for the compiler complaining, but this is not a nessecity, you can set your advertising data without the const type.
Also please have a look at this post,https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bl...,也许将give you some insight.
Thanks MT_dialog
Thank you for your answer, here is an example that throws an compiler-error, I tried to change the adv_data in the PXP-reporter-demo:
uint8_t test_adv = 100;
uint8_t adv_data[] = {
0x05, GAP_DATA_TYPE_UUID16_LIST_INC,
0x03, 0x18, // = 0x1803 (LLS UUID)
0x02, 0x18, // = 0x1802 (IAS UUID)
test_adv,
};
The Errors are:
Building file: ../pxp_reporter_task.c
Invoking: Cross ARM C Compiler
../pxp_reporter_task.c:93:9: error: initializer element is not constant
test_adv,
^
../pxp_reporter_task.c:93:9: error: (near initialization for 'adv_data[6]')
make: *** [pxp_reporter_task.o] Error 1
Thanks in advance,
Philipp
Hi dsandbue,
I am sorry but what you are trying to do is not a valid expression in C, you are decalring a variable, and you are trying to assign that variable in a array initialization, you cannot have a variable in an array initialization. If you would like to update your string you can use memcpy in run time in order to update your array with that variable.
Thanks MT_Dialog
非常感谢! !: -)