动态更新广告地址和数据

⚠️
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.wsdof.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
9个职位/0个新职位
Last post
罗彼得
Offline
Last seen:2 weeks 4 days ago
加入:2016-01-17 13:37
动态更新广告地址和数据

嗨,对话,

我们需要更新广告地址和数据在主循环飞行。
附加的arch\u main.c可以工作,除了有时地址和数据不一致。
例如,根据应用程序逻辑,如果我们这样更新:
ADDR DATA
xx:xx:xx:xx:xx:00 Info00
xx:xx:xx:xx:xx:01信息01

we should get following:
ADDR DATA
xx:xx:xx:xx:xx:00 Info00
xx:xx:xx:xx:xx:01信息01

In fact, we sometimes get following unexpected result:
ADDR DATA
xx:xx:xx:xx:xx:xx:01信息00

We think, the advertising address update (through writing register BLE_BDADDRL_REG and BLE_BDADDRU_REG) can complete immediately,
广告数据更新(通过GAPM\ U update\ U ADVISTED\ U data消息)延迟或与广告过程不同步。

Although the example ble_app_noncon in SDK 6 can implement our function without inconsistency, the cost seems high, we want to update anything in main loop to reduce current consumption.

那么,还有其他安全更新的方法吗?

提前谢谢!

致以最诚挚的问候,
彼得

-----------------------------------主拱门---------------------------------------------
...
uint8_t fly_update_count __attribute__((section("retention_mem_area0"), zero_init));

外部void adv_addr_update(void);/*更新播发设备地址*/
extern void adv_data_update(void); /* Update advertising data */
....

int主(空)
{
sleep_mode_t sleep_mode;

//初始化保留模式
初始化保留模式();

//global initialise
系统初始化();

/*
************************************************************************************
* Platform initialization
************************************************************************************
*/

而(1)
{
{做
//安排所有挂起事件
根据dule_while_ble_on();
}
while (app_asynch_proc() != GOTO_SLEEP); //grant control to the application, try to go to power down
//如果应用程序返回GOTO\u SLEEP

// Update in here !!!
fly_update_count++;
if ((fly_update_count%50) == 0)
{
adv_addr_update();
adv_data_update();
}

...

//如果允许的话,等待中断并进入睡眠状态
如果((!BLE_APP_PRESENT)&(check_gtl_state())| |(BLE_APP_PRESENT))
{
//禁用中断
全局\u INT \u STOP();

app_asynch_sleep_proc();

// get the allowed sleep mode
//从rwip\u power\u down()到WFI()的时间必须尽可能短!!
sleep_mode=rwip_power_down();

if ((sleep_mode == mode_ext_sleep) || (sleep_mode == mode_ext_sleep_otp_copy))
{
//关掉收音机和任何允许的东西
arch_goto_sleep(sleep_mode);

// In extended sleep mode the watchdog timer is disabled
//(power domain PD\ U SYS自动关闭)。不过,如果调试器
//如果已连接,则看门狗计时器将保持启用状态,并且必须显式
//已禁用。
if ((GetWord16(SYS_STAT_REG) & DBG_IS_UP) == DBG_IS_UP)
{
wdg_freeze();//停止看门狗定时器
}

//等待中断恢复操作
注射用水();

//resume operation
arch_resume_from_sleep();
}
else if(睡眠模式==空闲模式)
{
if (((!BLE_APP_PRESENT) && check_gtl_state()) || (BLE_APP_PRESENT))
{
//等待中断恢复操作
注射用水();
}
}
// restore interrupts
全局\u INT \u START();
}
wdg\U重新加载(看门狗\U默认\U周期);
}
}

关键词:
设备:
MT_dialog
Offline
Last seen:2 months 1 week ago
工作人员
加入:2015-06-08 11:34
你好,罗彼得,

你好,罗彼得,

我不确定你的要求到底是什么,关于广告数据更新,据我所知,你的问题是ble\u app\u noncon项目不适合你,因为计时器醒了,因此,您希望减少从计时器中额外唤醒并发送命令的次数,以便在主循环中更新广告数据。为了不弄乱SDK,您可以尝试将广告更新命令放在.app\u中的table\u-powered回调中,然后在向堆栈发出该命令时,您可以强制table保留更长时间,以确保通过返回KEEP\u-powered来安排您放置的命令,在命令被安排之后,你可以从应用程序返回到睡眠状态。

Regarding changing the bd address, it is not suggested to change the bd address of the device by directly writing in the 585's registers especially when the device advertises, you should let the stack handle any change, also it is not suggested to change the bd address of the device while advertising, so you will have to stop the advertising procedure change the db address and then advertise with the new bd address. In general the BLE specification regarding the fixed BLE addresses (public or static) defines that an address when static can change after eash power cycle, an address can either be fixed during the product's lifetime (public) or change during reboot, so in order to change the bd address without dealing with those kind of issues you should reset the stack and let the app_easy_gap_dev_configure() change the bd address of your device, use the app_easy_gap_dev_config_get_active() in order to get a ready message, change the bd address and change the address.

谢谢MT_dialog

罗彼得
Offline
Last seen:2 weeks 4 days ago
加入:2016-01-17 13:37
嗨,对话,

嗨,对话,

非常感谢您提供的有用信息!

比尔/彼得

拉格胡.SBD
Offline
Last seen:2年2个月前
加入:2019-01-16 20:50
嗨,对话,

嗨,对话,
I am trying to change the BD address on the fly as you have mentioned above. After boot up, I run a timer and in that I want to keep changing BD address to different values. I send a RESET to the stack and I do land at the app_easy_dev_configure() breakpoint. But how do I use the app_easy_gap_dev_config_get_active() to change BD address. Appreciate your help. Thanks.

PM_Dialog
Offline
Last seen:3 days 19 min ago
工作人员
加入:2018-02-08 11:03
你好,RAGHU.SBD,

你好,RAGHU.SBD,

当app\u easy\u gap\u dev\u configure()被触发时,您应该修改它,如下所示:

void app\u easy\u gap\u dev\u configure(无效)

{

uint8\u 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\u gapm\u configure\u msg\u send(命令);

set_dev_config_cmd =零;

}

谢谢, PM_Dialog

拉格胡.SBD
Offline
Last seen:2年2个月前
加入:2019-01-16 20:50
Hi PM\u对话框

Hi PM\u对话框
谢谢你的回复。我确实做到了。
I am trying to switch my BD address every 30 seconds using this technique by using the Timer.
每次重置后,设备地址都会更改,在user\u app\u adv\u start()函数中,我会重新启动30秒计时器。
但似乎计时器只运行了几次迭代。。。

Does resetting BLE stack has any limitations on how many times, we can do it.

谢谢。

PM_Dialog
Offline
Last seen:3 days 19 min ago
工作人员
加入:2018-02-08 11:03
你好,RAGHU.SBD,

你好,RAGHU.SBD,

No, there isn’t any limitation om how many times the timer runs. How many times the timer runs? And when it is stopped running, do you get any assertion or a hardfault? Could you please run it in debug mode?

谢谢, PM_Dialog

拉格胡.SBD
Offline
Last seen:2年2个月前
加入:2019-01-16 20:50
嗨,PM\U对话,

嗨,PM\U对话,

谢谢你的回复。
我没有得到任何断言。我正在调试模式下运行。这似乎是一个多定时器的问题,因为许多人抱怨在其他职位。
当我停止第二个计时器并只运行这个主计时器时,一切似乎都正常工作,没有任何问题。

有多次的例子吗?

谢谢

PM_Dialog
Offline
Last seen:3 days 19 min ago
工作人员
加入:2018-02-08 11:03
你好,RAGHU.SBD,

你好,RAGHU.SBD,

我在SDK的ble\u app\u bearebone示例中工作,并使用了user\u app\u adv\u start()函数中的计时器,但我无法复制您的问题。你提到很多人抱怨这个问题,所以你能分享论坛帖子抱怨吗?

谢谢, PM_Dialog