Change Advertising-Data on runtime

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
5 posts / 0 new
Last post
dsandbue
Offline
Last seen:1 year 9 months ago
加入:2017-02-15 14:09
Change Advertising-Data on runtime

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:
MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi dsandbue,

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

dsandbue
Offline
Last seen:1 year 9 months ago
加入:2017-02-15 14:09
Thank you for your answer,

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

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi dsandbue,

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

dsandbue
Offline
Last seen:1 year 9 months ago
加入:2017-02-15 14:09
非常感谢! !: -)

非常感谢! !: -)