DA14585 - 仅在睡眠中宣传一次

⚠️
你好。。谢谢你来参加论坛。令人兴奋的消息!我们现在正在移动到我们的新论坛平台,将提供更好的功能,并包含在主对话网站的过程。所有帖子和账号都已迁移。我们现在只接受新论坛上的流量-请在//www.wsdof.com/support. 我们将在未来几天内修复bug/优化搜索和标记。
15个帖子/ 0新
最后一篇文章
马尔基尔瓦2277
Offline
最后一次见到:3个月2天前
Joined:2019-06-19 04:20
DA14585 - 仅在睡眠中宣传一次

嗨,对话小组,

I am working on a custom board with the 'ble_app_nonconn' example in the misc folder in SDk folder. My project requirement is as follows.

  • 每当没有BLE或其他活动时都会进入睡眠模式(ARCH_EXT_SLEEP_ON)。
  • 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.
  • 在停止广告之前,将启用唤醒引脚以在下一个数据准备就绪时从睡眠中唤醒芯片。

我已设法在调试模式下完成上述步骤。当我在RAM上运行程序并断开调试器的连接时,电流消耗减少到2.4µA.当外部中断发生时,电流上升到50左右µA和在2.4之间振荡µA至50µA.(我想这是因为广告间隙的睡眠)。所以我认为上面的概念很好用。

但我有两个问题。

1)在睡眠模式(调试器断开条件)时,当我的芯片广告时,我认为它仅广告一次。因为我在BLE扫描仪应用上检查它,我注意到RSSI值只会更新一次。它只会传播一次?如果它正在发送一次,那么为什么当前振荡在2.4μA到50μA之间的6秒持续时间?

2) 上述条件工作了一段时间,突然,电流增加到350µA然后就没有广告了。我的程序停止了吗?

请注意,只有在断开调试器的连接时才会出现上述两种情况。

什么可能导致这两个问题在睡眠期间?

Regards,

标记

设备:
PM\U对话框
Offline
最后一次见到:1天14小时前
Staff
Joined:2018-02-08 11:03
Hi Mark,

Hi Mark,

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

Can you please try to debug it furthermore? Please run it in debug mode - power consumption is not important in this step. You mentioned that is advertising once… After the first advertising what does the fw do? The WDOG is enabled or disabled? I would suggest you to have it enabled, otherwise you will not be notified if the fw stucks somewhere. If you are completely sure that the fw is running as expected (no WDOG occurred or NMI), please use the Power Profiler of SmartSnippets Toolbox to check that it is not advertising once.

谢谢,下午好

马尔基尔瓦2277
Offline
最后一次见到:3个月2天前
Joined:2019-06-19 04:20
HI PM_Dialog,

HI PM_Dialog,

在调试模式下运行时,代码正确播发,固件不会在任何地方卡住。我在调试模式下运行了一个多小时的代码,效果很好。当我断开调试器并运行它时,问题(如第一篇文章中所述)就出现了。

I do have another doubt. Does your example code 'ble_app_nonconn' in the 'misc' folder support extended sleep mode?. Because it works properly when connected in debugging mode. But when i disconnect the debugger the problem starts.

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,

标记

PM\U对话框
Offline
最后一次见到:1天14小时前
Staff
Joined:2018-02-08 11:03
Hi Mark,

Hi Mark,

SDK6.0.12的BLE_APP_NONCONN项目默认情况下不支持睡眠模式。但是,您可以更改睡眠模式配置。由于它是自定义代码和自定义板,因此可以共享您在睡眠模式下配置的更改吗?启动调查哪个是路由原因的另一个选项可能是开始切换GPIO或打印一些调试消息,因为仅在非调试模式下卡住的固件gests。在调试模式下,我假设您已启用WDog ..

谢谢,下午好

马尔基尔瓦2277
Offline
最后一次见到:3个月2天前
Joined:2019-06-19 04:20
嗨,PM\U对话,

嗨,PM\U对话,

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?.

For sleep mode i have made the following changes.

static const sleep_state_t app_default_sleep_mode = arch_ext_sleep_on;

I stopped the advertisement after 6 seconds and my chip goes into extended sleep.

Regards,

标记

PM\U对话框
Offline
最后一次见到:1天14小时前
Staff
Joined:2018-02-08 11:03
Hi Mark,

Hi Mark,

不知道会发生什么,因为这是一个自定义板/代码。你能在user\u app\u adv\u start()和user\u app\u adv\u noncon\u complete()中使用arch\u printf()吗?另外,你能给我发一张Power Profiler的截图吗?当调试器被附加和解除附加时。

谢谢,下午好

马尔基尔瓦2277
Offline
最后一次见到:3个月2天前
Joined:2019-06-19 04:20
你好 ,

你好 ,

I dont have an option to print messages in my custom board. I am using a multimeter to measure the current consumption.

我认为问题在于在我准备好宣传的时候调用user_app_adv_start()函数。

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

void user_app_adv_start(void) { struct gapm_start_advertise_cmd *cmd = app_easy_gap_non_connectable_advertise_get_active(); // Store initial advertising data and length initial_adv_data_len = cmd->info.host.adv_data_len; memcpy(initial_adv_data, cmd->info.host.adv_data, initial_adv_data_len); // Store initial scan response data and length 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); //changed // Initialize data data_init(); // Load advertising data and length cmd->info.host.adv_data_len = user_adv_data_len; memcpy(cmd->info.host.adv_data, user_adv_data, user_adv_data_len); // Load scan response data and length 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; } }

马尔基尔瓦2277
Offline
最后一次见到:3个月2天前
Joined:2019-06-19 04:20
嗨,PM\U对话,

嗨,PM\U对话,

正如你所建议的,我在外围初始化()在睡觉前把它拉高进入睡眠(睡眠模式)在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\u app\u adv\u start()”只公布一次数据?

你能给我分享一个信标数据的示例代码,它在外部中断时唤醒,修改广告字符串,传输它,然后进入睡眠状态。

Regards,

标记

PM\U对话框
Offline
最后一次见到:1天14小时前
Staff
Joined:2018-02-08 11:03
Hi Mark,

Hi Mark,

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

谢谢,下午好

PM\U对话框
Offline
最后一次见到:1天14小时前
Staff
Joined:2018-02-08 11:03
Hi Mark,

Hi Mark,

ARCH_MAIN.c是SDK文件,强烈建议不要修改任何SDK文件。所有修改都应在应用程序层中完成,以user_开头的文件中。作为SDK的所有其他文件相关,如果其中任何一个都被修改,我们无法保证应用程序将正常工作。SDK应使用,因为它由对话框提供,而无需任何其他修改。

关于你的源代码,我无法编译它,因为我几乎没有错误。请参阅下面的差异文件,了解如何停止不可连接的广告,将设备放在睡眠模式下并唤醒。我的建议是从包含广告数据更新的SDK的BLE_APP_SLEEPMODE示例开始。您如何建立应用程序以及如何更新信标数据取决于您。请按照SDK的BLE_APP_SLEEPMODE示例中的步骤操作。

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

谢谢,下午好

马尔基尔瓦2277
Offline
最后一次见到:3个月2天前
Joined:2019-06-19 04:20
嗨,PM\U对话,

嗨,PM\U对话,

1) What kind of errors are u getting when u compile my code?.

2) 我修改了你的arch\u main.c文件,因为当我的传感器发送一个中断时,我必须等待大约20毫秒来获取数据,但是如果我不等待,我的代码将返回睡眠状态,我将丢失数据。这就是为什么我修改了arch\u main.c文件,让它等到我把数据拿出来,然后让芯片进入休眠状态。如何延长芯片的唤醒时间?。你能给我个建议吗?。

3) When I start my advertising, most of the code content that I added to arch_main.c will not execute because I am checking for conditions in the main loop and I will not execute it while I am advertising. Why is that affecting your sdk and advertising sequences?.

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,

标记

马尔基尔瓦2277
Offline
最后一次见到:3个月2天前
Joined:2019-06-19 04:20
嗨,PM\U对话,

嗨,PM\U对话,

请在以上几点上支持我。正如你所建议的,我已经开始在bleèu示例中研究睡眠模式项目。我最大的疑问是,当我的外部传感器发出中断信号,并且只在20毫秒后才给出数据时,我该如何防止芯片在我从睡眠中醒来后的20毫秒内进入睡眠状态。

Regards,

标记

PM\U对话框
Offline
最后一次见到:1天14小时前
Staff
Joined:2018-02-08 11:03
Hi Mark,

Hi Mark,

Please find attached a log file with the errors from the Keil IDE. It would be very helpful to indicate the SDK version that you are using. Not sure about the SDK version but we strongly recommend using the latest version (SDK6.0.12).

  • 删除所有未使用的代码行。这使得我们很难看完代码并理解实现。
  • 所有的修改和开发都应该在应用层完成。不应修改任何SDK。如果您修改SDK文件,我们将无法提供任何支持。
  • 请在ARCH_MAIN.c中删除SDK文件中的所有代码片段。
  • All the application layer files start with “ user_ “.
  • 请为我提供一个工作项目,将其添加到Projects \ target_apps \ misc sdk目录下,并指出SDK版本。
  • 为了开始调试它,我应该复制粘贴在前面提到的路径下的项目,打开它并编译它。
  • 请记住,你有一个自定义板,所以我将尝试复制在我们的亲开发板的问题。
  • When in sleep mode, the device will go into sleep mode between advertising intervals (or connection intervals in case of connectable advertising). All the peripheral domains, including the I2C are powered down. When the sensor has data to send, you should wake up the device first thought the wake-up controller.
  • 我的建议是在BLE_APP_SLEEPMODE示例中开始开发。我为您提供了差异文件,需要更改。
  • 应该启用WDOG,否则如果应用程序卡住,将不会通知您。
  • If you run the default ble_app_sleepmode example of the SDK, are you able to stop advertising and put the device into sleep mode?

谢谢,下午好

Attachment:
马尔基尔瓦2277
Offline
最后一次见到:3个月2天前
Joined:2019-06-19 04:20

嗨,PM\U对话,

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

似乎没有32Khz晶体,ble\u app\u睡眠模式代码是不稳定的。但是你的数据表上说32Khz是可选的,这是非常误导的。请更正数据表,否则也可能误导他人。我已经花了3-4个月在这个问题上,没有线索这是由于外部晶体。

Any way, thank you for your online support.

Regards,

标记

PM\U对话框
Offline
最后一次见到:1天14小时前
Staff
Joined:2018-02-08 11:03
Hi Mark,

Hi Mark,

很高兴你找到了工作。这是铁饼sed over our previous conference calls. Thanks for your indication too.

问候,pm_dialog