DA14585 - 仅在睡眠中宣传一次

Learn More常见问题解答教程

15 posts / 0 new
最后一篇
markdsylva_2277.
离线
最后一次露面:1周4天前
加入:2019-06-19 04:20
DA14585 - 仅在睡眠中宣传一次

嗨对话小组,

我正在使用SDK文件夹中的“BLE_APP_NONCONN”示例的自定义板。我的项目要求如下。

  • Go to sleep mode (ARCH_EXT_SLEEP_ON) whenever no ble or other activity.
  • When external sensor gives data, dialog chip will wakeup on pin change interrupt and start decoding the data from the sensor using timer 0.
  • 解码数据并在广告字符串上更新它。
  • 开始广告使用“user_app_adv_start()的一个d start an easy timer that will expire in 6 seconds. Till then the advertisement data is advertised. When app_easy timer expires, stop the advertisement using 'app_easy_gap_advertise_stop()' and this will put the chip to sleep.
  • Before stopping advertisement, the wakeup pin will be enabled to wake up the chip from sleep when the next data is ready.

我在调试模式下填写上述步骤。当我在RAM上运行我的程序并断开调试器时,电流消耗会降低到2.4μA。当外部中断发生时,电流上升到大约50μA,振荡在2.4μA至50μA之间。(我猜这是由于广告Internvals之间的睡眠)。所以我认为上面的概念可以很好地工作。

但我陷入了两个问题。

1) During sleep mode ( debugger disconnected condition ) when my chip advertises I think it advertises only once. Because I am checking it on a BLE scanner app and I notice that the RSSI value is updated only once. It it only transmitiing once?. If it is transmitting once, then why the current oscillation between 2.4µA to 50µA for the 6 sec duration?

2)上述条件有效期为一段时间和突然间,电流增加到350μA,然后根本没有广告。我的节目停止了吗?

请注意,仅当我断开调试器时,才会出现上述两个条件。

What could cause these two issues during sleep?

Regards,

Mark

Device:
PM_DIALOG.
离线
最后一次露面:15小时17分钟前
职员
加入:2018-02-08 11:03
Hi Mark,

Hi Mark,

在睡眠模式下执行任何类型的测量时,您不应以调试模式运行固件。否则,该设备无法进入睡眠模式,并且功耗将大大增加。为此,我的建议将成为调试器未连接,因为这可以防止系统睡眠。此外,非常重要的提示是,如果您在您的自定义板中使用SPI Flash,则应将其供电。

你可以尝试再试一次吗?请在调试模式下运行它 - 在此步骤中的功耗并不重要。你提到的是广告一次......在第一个广告之后,FW是什么?WDOG已启用或禁用?我建议您启用它,否则如果FW粘在某个地方,您将不会收到通知。如果您完全确定FW按预期运行(未发生WDOG或NMI),请使用SmartSnippets Toolbox的电源分布程序检查它是否未广告一次。

谢谢,PM_DIALOG.

markdsylva_2277.
离线
最后一次露面:1周4天前
加入:2019-06-19 04:20
嗨pm_dialog,

嗨pm_dialog,

在调试模式下运行时,代码正常通告,固件不会卡住任何地方。我在调试模式下运行了一小时的代码,它可以正常工作。当我断开调试器并运行它时,问题(如第一个帖子中所述)发生。

我确实有别的疑问。您的示例代码在“MISC”文件夹中的“BLE_APP_NONCONN”是否支持扩展睡眠模式?因为在调试模式下连接时它正常工作。但是当我断开调试器时,问题就开始了。

I am advertising for 6 seconds and stopping it. But it advertises only once and but there is an oscillation in current consumption during the whole 6 seconds. That means that it is waking up between advertising intervals but why no packets are being transmitted. ?

Regards,

Mark

PM_DIALOG.
离线
最后一次露面:15小时17分钟前
职员
加入:2018-02-08 11:03
Hi Mark,

Hi Mark,

The ble_app_nonconn project of the SDK6.0.12 does not support sleep mode by default. However, you can change the sleep mode configuration. Since it’s a custom code and custom board, would it be possible to share the changes you have done in order to configure it in sleep mode? Another option to start investigating which is the route cause might be to start toggling a GPIO or printing some debugging messages, as the firmware gests stuck only in non-debug mode. In debug mode, I assume that you have the WDOG enabled..

谢谢,PM_DIALOG.

markdsylva_2277.
离线
最后一次露面:1周4天前
加入:2019-06-19 04:20
嗨pm_dialog,

嗨pm_dialog,

My firmware doesnt get stuck. It transmits only a single advertisement for the entire 6 second duration. But in debug mode it transmits 4 to 5 times for the 6 second duration. Why does it transmit only once in non-debug mode?. Is the sleep mode affecting the ble advertisement?.

对于睡眠模式,我已经进行了以下更改。

static const sleep_state_t app_default_sleep_mode = ARCH_EXT_SLEEP_ON;

6秒后,我停止了广告,我的芯片进入延长睡眠。

Regards,

Mark

PM_DIALOG.
离线
最后一次露面:15小时17分钟前
职员
加入:2018-02-08 11:03
Hi Mark,

Hi Mark,

不确定发生了什么,因为它是自定义板/代码。您能否请在user_app_adv_start()和user_app_adv_nonconn_complete()中使用Arch_Printf()在user_app_adv_nonconn_complete()中?另外,请你发给我一个电力分布器的屏幕截图吗?当调试器附加并取消连接时。

谢谢,PM_DIALOG.

markdsylva_2277.
离线
最后一次露面:1周4天前
加入:2019-06-19 04:20
Hi ,

Hi ,

我没有选择在我的自定义板中打印邮件。我正在使用万用表来测量当前消耗。

我认为问题在于调用user_app_adv_start() function when i am ready to advertise again.

我已经附上下面的代码进行推荐。

void user_app_adv_start(void){struct gapm_start_advertise_cmd * cmd = app_easy_gap_non_connectable_advertise_get_active();//存储初始通告数据和长度italy_add_data_len = cmd-> info.host.adv_data_len;memcpy(initial_adv_data,cmd-> info.host.adv_data,ligit_add_data_len);//存储初始扫描响应数据和长度initial_scan_rsp_data_len = cmd-> info.host.scan_rsp_data_len;memcpy(initial_scan_rsp_data,cmd-> info.host.scan_rsp_data,initial_scan_rsp_data_len);//更改//初始化数据data_init();//加载广告数据和长度cmd-> info.host.adv_data_len = user_add_data_len;memcpy(cmd-> info.host.adv_data,user_add_data,user_add_data_len);//加载扫描响应数据和长度cmd-> info.host.scan_rsp_data_len = user_scan_rsp_data_len;memcpy(cmd-> info.host.scan_rsp_data,user_scan_rsp_data,user_scan_rsp_data_len); //arch_set_extended_sleep(true); app_easy_gap_non_connectable_advertise_start(); //Schedule the next advertising data update app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb); } static void data_init() { // Load initial advertising data and length user_adv_data_len = initial_adv_data_len; memcpy(user_adv_data, initial_adv_data, user_adv_data_len); // Load initial scan response data and length user_scan_rsp_data_len = initial_scan_rsp_data_len; memcpy(user_scan_rsp_data, initial_scan_rsp_data, user_scan_rsp_data_len); //load predefined data user_adv_data_len = ADV_DATA_LEN ; user_scan_rsp_data_len = SCAN_RSP_DATA_LEN ; user_adv_data[12] = 7; user_adv_data[13] = txBuffer[1]; user_adv_data[14] = txBuffer[2]; user_adv_data[15] = txBuffer[3]; user_adv_data[16] = txBuffer[4]; user_adv_data[17] = txBuffer[5]; user_adv_data[18] = txBuffer[6]; user_adv_data[19] = txBuffer[9]; if(user_adv_data[13]==0){ user_adv_data[13]=0xff; } if(user_adv_data[14]==0){ user_adv_data[14]=0xff; } if(user_adv_data[15]==0){ user_adv_data[15]=0xff; } if(user_adv_data[16]==0){ user_adv_data[16]=0xff; } if(user_adv_data[17]==0){ user_adv_data[17]=0xff; } if(user_adv_data[18]==0){ user_adv_data[18]=0xff; } if(user_adv_data[19]==0){ user_adv_data[19]=0xff; } }

markdsylva_2277.
离线
最后一次露面:1周4天前
加入:2019-06-19 04:20
嗨pm_dialog,

嗨pm_dialog,

正如你建议的那样,我拉下了一个gpioperiph_init()然后在睡前睡觉之前把它拉高Arch_Goto_Sleep(Sleep_Mode)在Arch_Main.cn。我附上了示波器输出的屏幕截图。我面临的问题是,当我调用user_app_adv_start()时,芯片仅发送一次数据。我通过查看Android中的BLE Scanner应用程序上的RSSI值来确认这一点。我也附上了示例代码。

As I have an urgent demonstration of my product, I have changed the advertising interval to 200ms and somehow managing to advertise the data by calling 'user_app_adv_start()' and after 1 second I am stopping it and in the advertise complete function I am calling 'user_app_adv_start()' again. I am repeating these steps for 6 seconds and I am getting multpile advertising hits in my app. Each time when I call 'user_app_adv_start()' I get only 1 hit in my app until I stop the advertisement and call it again.

为什么'user_app_adv_start()'只广告数据一次?

请您可以分享我的标志数据的示例代码,用于在外部中断上唤醒并修改广告字符串并传输并睡眠。

Regards,

Mark

附件:
PM_DIALOG.
离线
最后一次露面:15小时17分钟前
职员
加入:2018-02-08 11:03
Hi Mark,

Hi Mark,

让我检查一下,我会回复你。

谢谢,PM_DIALOG.

PM_DIALOG.
离线
最后一次露面:15小时17分钟前
职员
加入:2018-02-08 11:03
Hi Mark,

Hi Mark,

The arch_main.c is SDK file and it is highly recommend NOT modifying any SDK file. All the modifications should be done in the application layer, in the filed that start with user_ . All the other files as SDK related and if any of them is modified we cannot guarantee that the application will work correctly. The SDK should be used as it is provided by dialog without any other modification.

Regarding you source code I am not able to compile it as I am getting couple of errors. Please see below a diff file for how to stop non-connectable advertising, put the device in sleep mode and wake it up. My recommendation would be to start with ble_app_sleepmode example of the SDK which contains advertising data update as well. How you would like to build the application and how to update the beacon data is up to you. Please follow the steps in the ble_app_sleepmode example of the SDK.

diff --git a/projects/target_apps/ble_examples/ble_app_sleepmode/src/config/user_callback_config.h b/projects/target_apps/ble_examples/ble_app_sleepmode/src/config/user_callback_config.h index e61bd1b..060eab8 100644 --- a/projects/target_apps/ble_examples/ble_app_sleepmode/src/config/user_callback_config.h +++ b/projects/target_apps/ble_examples/ble_app_sleepmode/src/config/user_callback_config.h @@ -54,8 +54,8 @@ static const struct app_callbacks user_app_callbacks = { .app_on_update_params_rejected = NULL, .app_on_update_params_complete = NULL, .app_on_set_dev_config_complete = default_app_on_set_dev_config_complete, - .app_on_adv_nonconn_complete = NULL, - .app_on_adv_undirect_complete = user_app_adv_undirect_complete, + .app_on_adv_nonconn_complete = user_app_adv_nonconn_complete, + .app_on_adv_undirect_complete = NULL, .app_on_adv_direct_complete = NULL, .app_on_db_init_complete = default_app_on_db_init_complete, .app_on_scanning_completed = NULL, diff --git a/projects/target_apps/ble_examples/ble_app_sleepmode/src/user_sleepmode.c b/projects/target_apps/ble_examples/ble_app_sleepmode/src/user_sleepmode.c index c4b605e..bf18b3c 100644 --- a/projects/target_apps/ble_examples/ble_app_sleepmode/src/user_sleepmode.c +++ b/projects/target_apps/ble_examples/ble_app_sleepmode/src/user_sleepmode.c @@ -240,8 +240,10 @@ void user_app_adv_start(void) // Schedule the next advertising data update app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb); - struct gapm_start_advertise_cmd* cmd; - cmd = app_easy_gap_undirected_advertise_get_active(); +// struct gapm_start_advertise_cmd* cmd; +// cmd = app_easy_gap_undirected_advertise_get_active(); + + struct gapm_start_advertise_cmd *cmd = app_easy_gap_non_connectable_advertise_get_active(); // Add manufacturer data to initial advertising or scan response data, if there is enough space app_add_ad_struct(cmd, &mnf_data, sizeof(struct mnf_specific_data_ad_structure), 1); @@ -249,7 +251,8 @@ void user_app_adv_start(void) // Set extended sleep with OTP copy during advertising arch_set_extended_sleep(true); - app_easy_gap_undirected_advertise_start(); + //app_easy_gap_undirected_advertise_start(); + app_easy_gap_non_connectable_advertise_start(); } void user_app_connection(uint8_t connection_idx, struct gapc_connection_req_ind const *param) @@ -312,11 +315,13 @@ static void app_button_press_cb(void) */ static void app_wakeup_cb(void) { - // If state is not idle, ignore the message - if (ke_state_get(TASK_APP) == APP_CONNECTABLE) - { - user_app_adv_start(); - } +// // If state is not idle, ignore the message +// if (ke_state_get(TASK_APP) == APP_CONNECTABLE) +// { +// user_app_adv_start(); +// } + + user_app_adv_start(); } /** @@ -335,9 +340,9 @@ static void app_button_enable(void) 40); // debouncing time = 0 } -void user_app_adv_undirect_complete(uint8_t status) +void user_app_adv_nonconn_complete(uint8_t status) { - // Disable wakeup for BLE and timer events. Only external (GPIO) wakeup events can wakeup processor. + // Disable wakeup for BLE and timer events. Only external (GPIO) wakeup events can wakeup processor. if (status == GAP_ERR_CANCELED) { arch_ble_ext_wakeup_on(); @@ -347,6 +352,18 @@ void user_app_adv_undirect_complete(uint8_t status) } } +//void user_app_adv_undirect_complete(uint8_t status) +//{ +// // Disable wakeup for BLE and timer events. Only external (GPIO) wakeup events can wakeup processor. +// if (status == GAP_ERR_CANCELED) +// { +// arch_ble_ext_wakeup_on(); + +// // Configure wakeup button +// app_button_enable(); +// } +//} + void user_app_disconnect(struct gapc_disconnect_ind const *param) { // Cancel the parameter update request timer diff --git a/projects/target_apps/ble_examples/ble_app_sleepmode/src/user_sleepmode.h b/projects/target_apps/ble_examples/ble_app_sleepmode/src/user_sleepmode.h index 8c33892..acae900 100644 --- a/projects/target_apps/ble_examples/ble_app_sleepmode/src/user_sleepmode.h +++ b/projects/target_apps/ble_examples/ble_app_sleepmode/src/user_sleepmode.h @@ -116,7 +116,7 @@ void user_app_connection(uint8_t connection_idx, * @return void **************************************************************************************** */ -void user_app_adv_undirect_complete(uint8_t status); +//void user_app_adv_undirect_complete(uint8_t status); /** **************************************************************************************** @@ -141,6 +141,8 @@ void user_catch_rest_hndl(ke_msg_id_t const msgid, void const *param, ke_task_id_t const dest_id, ke_task_id_t const src_id); + +void user_app_adv_nonconn_complete(uint8_t status); /// @} APP

谢谢,PM_DIALOG.

markdsylva_2277.
离线
最后一次露面:1周4天前
加入:2019-06-19 04:20
嗨pm_dialog,

嗨pm_dialog,

1)你编译我的代码时,你得到了什么样的错误?

2)我修改了你的Arch_main.c文件,因为当我的传感器发送中断时,我必须等待大约20ms来获取数据,但如果我不等待我的代码将恢复入睡,我会错过数据。这就是为什么我修改了ARCH_MAIN.c文件等待我的数据,然后将芯片放入睡眠状态。如何延长芯片的唤醒时间?你能建议一个想法吗?

3)当我开始我的广告时,我添加到Arch_main.c的大多数代码内容都不会执行,因为我正在检查主循环中的条件,我不会在我广告时执行它。为什么会影响你的SDK和广告序列?

4) When I get an interrupt until I process the data from my sensor I will not start advertising. After I get the data I will start the advertising and I am sure none of my code will run during advertising. So why does that give any problem to the sdk?.

Thanks,

Mark

markdsylva_2277.
离线
最后一次露面:1周4天前
加入:2019-06-19 04:20
嗨pm_dialog,

嗨pm_dialog,

请支持上面的积分。正如您所建议的那样,我已经开始在BLE_Examples的SleepMode项目上工作。我最大的怀疑是当我的外部传感器给出中断并仅在20ms后提供数据时,我如何在从睡眠中醒来后,我如何防止芯片进入睡眠。

Regards,

Mark

PM_DIALOG.
离线
最后一次露面:15小时17分钟前
职员
加入:2018-02-08 11:03
Hi Mark,

Hi Mark,

请使用Keil IDE中的错误查找日志文件。指示您正在使用的SDK版本是非常有帮助的。不确定SDK版本,但我们强烈建议使用最新版本(SDK6.0.12)。

  • 删除所有未使用的代码行。这使得难以通过代码并理解实现。
  • 所有修改和开发都应在应用层中完成。没有一个SDK应该修改。如果修改SDK文件,我们无法提供任何支持。
  • Please remove all the code snippets from the SDK files, like in arch_main.c.
  • 所有应用层文件都以“User_”开头。
  • Please provide me a working project to add it under projects\target_apps\misc SDK directory and indicate the SDK version.
  • 为了开始调试它,我应该在上述路径下复制粘贴项目,打开它并编译它。
  • 请记住,您有一个定制董事会,所以我会尝试在我们的专业开发板上复制这个问题。
  • 在睡眠模式下,设备将在广告间隔(或在可连接广告的情况下的连接间隔)之间进入睡眠模式。包括I2C的所有外设域都断电。当传感器有数据发送时,您应该先唤醒设备首先想到唤醒控制器。
  • My recommendation is to start developing in the ble_app_sleepmode example. I have provided you a diff file with the changes required.
  • 应该启用WDOG,否则如果应用程序卡住,则不会通知您。
  • 如果您运行SDK的默认BLE_APP_SLEEPMODE示例,您是否能够停止广告并将设备放入睡眠模式?

谢谢,PM_DIALOG.

附件:
markdsylva_2277.
离线
最后一次露面:1周4天前
加入:2019-06-19 04:20

嗨pm_dialog,

The issue got sorted out after we added the external 32Khz crystal oscillator.

似乎BLE_APP_SLEEPMODE代码在没有32kHz水晶的情况下不稳定。但是你的数据表说,这32kHz是可选的,这是非常误导的。请纠正数据表,也可以误导别人。我在这个问题上花了3-4个月,没有任何内容,没有任何内容。

任何方式,谢谢你的在线支持。

Regards,

Mark

PM_DIALOG.
离线
最后一次露面:15小时17分钟前
职员
加入:2018-02-08 11:03
Hi Mark,

Hi Mark,

很高兴你有工作。这是对我们之前的会议呼叫讨论的内容。谢谢你的迹象。

问候,pm_dialog