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.
所以我的问题是,当我有新数据时,我如何再次调用此功能。我必须首先停止广告,然后重建包装,还是我可以重建包装?
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?
首先,必须停止BLE收音机,然后可以更新ADV数据。
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.
问候,
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.
问候,
Tzvika
Hi, Dialog team,
所以,没有*回拨*类型函数可用于在BLE堆栈将要发送新数据包之前更改ADV数据包,对吧?
嗨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 thecompletetion提供广告操作的回调。
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).
简而言之,如果我想在20ms的间隔内拥有信标,并在每个广告中旋转3个不同的消息,这将是可能的吗?
嗨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,
谢谢,是的,我根据这种方式成功完成了此功能。
Cheers!