I'm using the Beacon example project as a basis, but I would like to add changing data to the advertising data package.
For example, some values from the ADC, or even just an incrementing counter.
I'm finding the structure of the example confusing - I'm guessing it sets the advertising package in app_adv_func in app_dialog beacon_proj.c but its not immediately apparent where this is actually called from. I think its only called once in setting up and then it just advertises.
So my question is, how do I call this function again when I have new data. Do I have to stop advertising first and then reconstruct the package, or can I just reconstruct the package?
Where in the program should I do this, and whats the best way of doing this?
Many thanks
Hi,
You are fully right.
Here are the answers to your question:
How to dynamically change the advertising data?
First, BLE radio must be stopped, then the ADV data can be updated.
The KERNEL timer must be used to update the advertising string after a certain time .
Example of KERNEL timer function: app_timer_set(APP_ADV_TIMER, TASK_APP, 300);
function which has to be called in the app_adv_func ().
Once the time has elapsed, a GAPM_CANCEL message has to be sent to the KERNEL.
This is going to cancel the ongoing activities before advertising the new parameters.
This is done by calling the app_adv_stop () in the BLE timer handler.
广告明星t again
In the gapm_cmp_evt_handler (), case GAPM_ADV_NON_CONN, the function app_adv_start() must be called to start advertising again.
regards,
DIALOG TEAM.
Hi,
I also try to Modifying advertising data package (sequence number) every advertising message ,
from the explanation above I can't understand what to do ?
setting app_timer_set(APP_ADV_TIMER, TASK_APP, 300); at the app_adv_func (). Once the time has elapsed the app_adv_timer_handler(..) function is start ,
and setting again app_adv_start() at gapm_cmp_evt_handler(), case case GAPM_ADV_UNDIRECT endless loop.
regards,
Tzvika
Hi, Dialog team,
So, there is no *call-back* type function available for changing the ADV packet before the BLE stack is going to send new packet, right?
Hi hardy.chen,
You mean a callback function that will be called after completing the sending of one advertising packet? No, there is no such a callback. If you want to implement this kind of functionallity check the beacon reference design in the app_sleep.h file in app_async_trm() function maybe this will help. Only thecompletetioncallback of the advertising operation is available.
Thanks MT_dialog
Hi MT_dialog,
Is there any document for explaining the event reported from app_last_rwble_evt_get?
i.e. when will the event BLE_EVT_END be available? *every* ADV packet being sent? or termination of BLE connection? or every packet of connection PDU?
Hi Hardy.chen,
Please refer also to your other post,http://support.dialog-semiconductor.com/please-explain-last-ble-event-enum. The BLE_EVT_END will be available when a Transmition is over, meaning at the ending of each BLE event, you will get one BLE_EVT_END for every advertising event completed and for every connection interval completed.
Thanks MT_dialog
Hi Dialog team,
So, will it be possible to update the advertising content by hooking the event BLE_EVT_END (also by checking the previous event code. i.e. BLE_EVT_TX) which is supposed to be generated in each completion of transmission?
But I wonder if the *latency* should be considered as that *app_adv_stop* & *app_adv_start* should be always called for changing the advertising content. Shall I wait for any call-back or event that is reporting from kernel for the completion of each call to *app_adv_stop* & *app_adv_start*? If such change of advertising content should be done in this manner, what's the maximum speed (or say minimum interval) that DA14580 support to change advertising content in *every ADV packet* (take ADV_NONCONN as example).
简而言之,如果我想有一个灯塔间隔of 20ms, and to rotate the 3 different message in each advertisement, will this be possible?
Hi hardy.chen,
I believe that you can do that, check the last_ble_evt for a BLE_EVT_END and when that happens issue a advertising stop in order to change the advertising string. After the the completetion of the stop advertise procedure you can catch the advertise ending message in the gapm_cmp_evt_handler, case GAPM_ADV_UNDIRECT or GAPM_ADV_NON_CONN change the advertising string and start advertising again. I dont believe that the latency from the commands (app_adv_stop and app_adv_start) would be that large in order to be taken into account. You can have a look at the beacon implementation in the app_sleep.h file in the app_asynch_trm() function to get some ideas.
Thanks MT_dialog
Hi Dialog team,
Thanks, and yes, I've successfully completed this feature according to this manner.
Cheers!