更新广告地址和速度的数据

⚠️
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.
9个帖子/ 0新
Last post
彼得罗
Offline
Last seen:6 days 10 hours ago
加入:2016-01-17 13:37
更新广告地址和速度的数据

嗨对话框,

我们需要在主循环中的速度更新广告地址和数据。
附加的Arch_Main.c可以工作除了地址和数据的有时不一致。
例如,根据应用程序逻辑,如果我们以这种方式更新:
ADDR DATA
xx:xx:xx:xx:xx:00 Info00
XX:XX:XX:XX:XX:01 INFO01

we should get following:
ADDR DATA
xx:xx:xx:xx:xx:00 Info00
XX:XX:XX:XX:XX:01 INFO01

In fact, we sometimes get following unexpected result:
ADDR DATA
XX:XX:XX:XX:XX:01 INFO00

We think, the advertising address update (through writing register BLE_BDADDRL_REG and BLE_BDADDRU_REG) can complete immediately,
广告数据更新(通过GAPM_UPDATE_ADVERTES_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));

extern void adv_addr_update(void);/ *更新广告设备地址* /
extern void adv_data_update(void); /* Update advertising data */
....

int main(空白)
{
sleep_mode_t sleep_mode;

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

//global initialise
system_init();

/ *
************************************************************************************
* 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_sleep

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

...

//等待中断,如果允许这样做,请睡觉
if(((!ble_app_present)&&(check_gtl_state()))||(ble_app_present)))
{
//禁用中断
global_int_stop();

app_asynch_sleep_proc();

// get the allowed sleep mode
//从rwip_power_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
//(电源域PD_SYS自动关闭)。虽然,如果调试器
//附加看门狗定时器保持启用,必须明确
//禁用。
if ((GetWord16(SYS_STAT_REG) & DBG_IS_UP) == DBG_IS_UP)
{
wdg_freeze();//停止看门狗定时器
}

//等待中断恢复操作
WFI();

//resume operation
ARCH_RESUME_FROM_SLEEP();
}
否则if(sleep_mode == mode_idle)
{
if (((!BLE_APP_PRESENT) && check_gtl_state()) || (BLE_APP_PRESENT))
{
//等待中断恢复操作
WFI();
}
}
// restore interrupts
global_int_start();
}
wdg_reload(watchdog_default_period);
}
}

关键词:
设备:
MT_dialog
Offline
Last seen:1 month 3 weeks ago
工作人员
加入:2015-06-08 11:34
嗨Peter Luo,

嗨Peter Luo,

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

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:6 days 10 hours ago
加入:2016-01-17 13:37
嗨对话框,

嗨对话框,

非常感谢您所以有用的信息!

布鲁克/彼得

Raghu.sbd.
Offline
Last seen:2 years 1 month ago
加入: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:11小时20分钟前
工作人员
加入:2018-02-08 11:03
嗨raghu.sbd,

嗨raghu.sbd,

当触发app_easy_gap_dev_configure()时,您应该更像如下修改它:

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 =零;

}

谢谢, PM_Dialog

Raghu.sbd.
Offline
Last seen:2 years 1 month ago
加入:2019-01-16 20:50
嗨PM_DIALOG.

嗨PM_DIALOG.
感谢您的答复。我完全这样做了。
I am trying to switch my BD address every 30 seconds using this technique by using the Timer.
每次重置后,设备地址都更改,并在User_App_Adv_start()函数中,我重新启动30秒的计时器。
但似乎计时器只运行几个迭代......

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

谢谢。

PM_Dialog
Offline
Last seen:11小时20分钟前
工作人员
加入: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

Raghu.sbd.
Offline
Last seen:2 years 1 month ago
加入:2019-01-16 20:50
嗨pm_dialog,

嗨pm_dialog,

谢谢回复。
我没有得到任何断言。我正在调试模式下运行。它似乎是一个多个定时器问题,因为很多人都抱怨了其他帖子。
我停止第二个定时器并仅运行这个主计时器时,一切似乎都在没有任何问题。

多次的任何例子?

谢谢

PM_Dialog
Offline
Last seen:11小时20分钟前
工作人员
加入:2018-02-08 11:03
嗨raghu.sbd,

嗨raghu.sbd,

我工作在SDK的BLE_APP_BEAKEBONE示例中,我使用了位于User_App_Adv_Start()函数中的计时器,但我无法复制您的问题。你提到很多人为这个问题抱怨,所以请你能分享抱怨的论坛帖子吗?

谢谢, PM_Dialog