Update advertising address and data on the fly

⚠️
嗨,...感谢您来论坛。令人兴奋的消息!我们现在正在迁至我们的新论坛平台,将提供更好的功能,并包含在主对话框网站中。所有帖子和帐户都已迁移。我们现在只接受新论坛上的流量 - 请发布任何新线程https://www.dialog-seminile.com/support.。我们将在未来几天修复错误/优化搜索和标记。
9 posts / 0 new
最后一篇
Peter Luo
离线
最后一次露面:1 month 1 week ago
加入:2016-01-17 13:37
Update advertising address and data on the fly

Hi Dialog,

We need update advertising address and data on the fly in main loop.
Attached arch_main.c can work except for the sometimes inconsistency of address and data.
For example, according to application logic, if we update in this way:
addr数据
XX:XX:XX:XX:XX:00 INFO00
xx:xx:xx:xx:xx:01 Info01

我们应该得到以下情况:
addr数据
XX:XX:XX:XX:XX:00 INFO00
xx:xx:xx:xx:xx:01 Info01

事实上,我们有时会出现意外结果:
addr数据
xx: xx: xx: xx: xx: 01 Info00

我们认为,广告地址更新(通过写入寄存器BLE_BDADDRL_REG和BLE_BDADDRU_REG)可以立即完成,
the advertising data update (through GAPM_UPDATE_ADVERTISE_DATA message) is delayed or not synchronized with the advertising procedure.

虽然SDK 6中的示例BLE_APP_NONCON可以在没有不一致的情况下实现我们的功能,但成本似乎很高,我们希望在主循环中更新任何内容以降低电流消耗。

So, is there any other way to update safely?

Thanks in advance!

Best Regards,
Peter

----------------------------------- arch_main.c ---------------------------------------------
......
UINT8_T FLY_UPDATE_COUNT __ATtribute __((部分(“RETETINE_MEM_AREA0”),ZERO_INIT));

extern void adv_addr_update(void); /* Update advertising device address */
extern void avd_data_update(void);/ *更新广告数据* /
......。

int main(void)
{
sleep_mode_t sleep_mode;

// initialize retention mode
init_retention_mode();

//全球初始化
system_init();

/*
************************************************************************************
*平台初始化
************************************************************************************
* /

while(1)
{
做 {
// schedule all pending events
schedule_hile_ble_on();
}
while(app_asynch_proc()!= goto_sleep);//授予控件到应用程序,尝试掉电
//if the application returns GOTO_SLEEP

//在这里更新!!!
fly_update_count ++;
if((fly_update_count%50)== 0)
{
adv_addr_update();
adv_data_update();
}

......

//wait for interrupt and go to sleep if this is allowed
if (((!BLE_APP_PRESENT) && (check_gtl_state())) || (BLE_APP_PRESENT))
{
//Disable the interrupts
GLOBAL_INT_STOP();

app_asynch_sleep_proc();

//获取允许的睡眠模式
// time from rwip_power_down() to WFI() must be kept as short as possible!!
sleep_mode = rwip_power_down();

if((sleep_mode == mode_ext_sleep)||(sleep_mode == mode_ext_sleep_otp_copy)))
{
//power down the radio and whatever is allowed
Arch_Goto_Sleep(Sleep_Mode);

//在扩展睡眠模式下,看门狗定时器被禁用
// (power domain PD_SYS is automatically OFF). Although, if the debugger
// is attached the watchdog timer remains enabled and must be explicitly
// disabled.
if((getword16(sys_stat_reg)&dbg_is_up)== dbg_is_up)
{
wdg_freeze(); // Stop watchdog timer
}

//wait for an interrupt to resume operation
WFI();

//恢复操作
arch_resume_from_sleep();
}
else if (sleep_mode == mode_idle)
{
if((!ble_app_present)&& check_gtl_state())||(ble_app_present))
{
//wait for an interrupt to resume operation
WFI();
}
}
//恢复中断
GLOBAL_INT_START();
}
wdg_reload(WATCHDOG_DEFAULT_PERIOD);
}
}

Keywords:
Device:
mt_dialog.
离线
最后一次露面:3 months 2 days ago
职员
加入:2015-06-08 11:34
Hi Peter Luo,

Hi Peter Luo,

我不确定究竟是你的要求是关于广告数据更新的要求,据我所知,你的问题是因为定时器醒来,BLE_APP_NONCONN项目不适合您,所以你想减少它额外从计时器唤醒并发送命令,以便在主循环中更新广告数据。你可以尝试的是不要用SDK弄乱,是在.app_on_ble_powered回调中放置广告更新命令,然后在向堆栈发出该命令时,您可以强制持续到更长时间才能保持持续您将通过返回keep_power的命令安排的命令,在命令计划之后,您可以从app_on_ble_powered返回goto_sleep。

关于改变BD地址,没有建议通过直接在585的寄存器中直接编写设备的BD地址,特别是当设备通告时,您应该让堆栈处理任何改变,也没有建议改变BD地址在广告时的设备,因此您必须停止广告过程更改DB地址,然后使用新的BD地址进行广告。一般来说,关于固定BLE地址(公共或静态)的BLE规范定义了一个地址当EASH电源周期后静态可以改变,可以在产品的寿命(公共)期间固定地址或在重启期间更改,因此更改BD地址而不处理您应该重置堆栈的那种问题,让App_easy_gap_dev_configure()更改设备的BD地址,使用app_easy_gap_dev_config_get_active()以获取就绪消息,更改BD地址并更改地址。

谢谢mt_dialog.

Peter Luo
离线
最后一次露面:1 month 1 week ago
加入:2016-01-17 13:37
Hi Dialog,

Hi Dialog,

Thank you so much for your so useful information!

BR/Peter

RAGHU.SBD
离线
最后一次露面:2 years 3 months ago
加入:2019-01-16 20:50
Hi Dialog,

Hi Dialog,
我正在尝试在上面提到的那样改变BD地址。启动后,我运行一个计时器,然后我想继续将bd地址更改为不同的值。我向堆栈发送重置,我在app_easy_dev_configure()断点中的土地。但我如何使用app_easy_gap_dev_config_get_active()来更改BD地址。感谢您的帮助。谢谢。

PM_DIALOG.
离线
最后一次露面:1 day 9 hours ago
职员
加入:2018-02-08 11:03
Hi RAGHU.SBD,

Hi RAGHU.SBD,

When then app_easy_gap_dev_configure() is triggered, you should modify it a little bit more like follow:

void app_easy_gap_dev_configure(void)

{

uint8_t bd[6] = {0xC2,0x2A,0x35,0xD7,0x7B,0xD3};

struct gapm_set_dev_config_cmd * cmd = app_easy_gap_dev_config_create_msg();

if (bd_flag) { memcpy(cmd->addr.addr, bd, 6); }

app_gapm_configure_msg_send(cmd);

set_dev_config_cmd = null;

}

谢谢,PM_DIALOG.

RAGHU.SBD
离线
最后一次露面:2 years 3 months ago
加入:2019-01-16 20:50
Hi PM_Dialog

Hi PM_Dialog
Thank you for the reply. I have exactly done that.
我尝试每30秒使用该技术使用计时器切换我的BD地址。
After every reset, the device address is changed and in the user_app_adv_start() function, I restart my 30 seconds timer.
But seems like the timer runs only for couple of iterations...

重置ble堆栈是否有多少次,我们可以做到。

谢谢。

PM_DIALOG.
离线
最后一次露面:1 day 9 hours ago
职员
加入:2018-02-08 11:03
Hi RAGHU.SBD,

Hi RAGHU.SBD,

不,没有任何限制OM定时器运行多少次。计时器运行多少次?当它停止运行时,您是否得到了任何断言或硬质难?你能在调试模式下运行它吗?

谢谢,PM_DIALOG.

RAGHU.SBD
离线
最后一次露面:2 years 3 months ago
加入:2019-01-16 20:50
Hi PM_Dialog,

Hi PM_Dialog,

Thanks for the reply.
I don't get any assertions. I am running in debug mode. It seems to be a MULTIPLE timer issue, as many people have complained in other posts.
The moment I stop the second timer and run only this main timer, everything seems to work fine without any issue.

Any examples of multiple times ?

Thanks

PM_DIALOG.
离线
最后一次露面:1 day 9 hours ago
职员
加入:2018-02-08 11:03
Hi RAGHU.SBD,

Hi RAGHU.SBD,

I worked on the ble_app_bearebone example of the SDK and I used the timer which is in user_app_adv_start() function but I am not able to replicate your issue. You mentioned that many people have complained for this issue, so could you please share the forum post complaining for that?

谢谢,PM_DIALOG.