DA14585 - 仅在睡眠中宣传一次

⚠️
大家好. .谢谢光临论坛。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 athttps://www.dialog-seminile.com/support.. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
15个帖子/ 0新
Last post
标记Dsylva_2277
离线
Last seen:3 months 1 day ago
加入:2019-06-19 04:20
DA14585 - 仅在睡眠中宣传一次

Hi Dialog Team,

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

  • 每当没有BLE或其他活动时都会进入睡眠模式(ARCH_EXT_SLEEP_ON)。
  • 当外部传感器提供数据时,对话框芯片将唤醒引脚更改中断并使用计时器0开始从传感器中解码数据。
  • Decode the data and update it on the advertisement string.
  • 使用'user_app_adv_start()'启动广告,并启动一个易于计时器,将在6秒内过期。直到那时广告数据被宣传。当App_easy Timer到期时,使用'app_easy_gap_advertise_stop()'停止广告,这将使芯片睡眠。
  • 在停止广告之前,将启用唤醒引脚以在下一个数据准备就绪时从睡眠中唤醒芯片。

I have mananged to complete the above steps in debugging mode. When I run my program on the RAM and disconnect the debugger the current consumption reduces to 2.4µA. When the external interrupt occurs the current rises to around 50µA and oscillates between 2.4µA to 50µA. ( I guess this is due to the sleep between advertising internvals). So I think the above concept works fine.

But I am stuck at two problems.

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

2) The above condition works for a while and all of a sudden, the current increases to 350µA and then there is no advertisement at all. Is my program halted?

Please note that the above two condition occurs only when I disconnect the debugger.

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

问候,

标记

设备:
PM_Dialog
离线
Last seen:1 day 8 hours ago
职员
加入:2018-02-08 11:03
嗨马克,

嗨马克,

When performing any kind of measurements in sleep mode, you should not run the firmware in debug mode. Otherwise, the device fails to go into sleep mode and the power consumption will be dramatically increased. To do so, my suggestion would be to have the debugger de-attached, as this prevents the system to sleep. Additionally, a very important tip is that in case you are using SPI Flash in your custom board, you should power it down.

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

谢谢,PM_Dialog

标记Dsylva_2277
离线
Last seen:3 months 1 day ago
加入:2019-06-19 04:20
嗨pm_dialog,

嗨pm_dialog,

When running in debug mode, the code advertises properly and the firmware does not get stuck anywhere. I ran the code in debug mode for more than an hour and it works fine. When I disconnect the debugger and run it, the problem ( as mentioned in the first post) occurs.

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

我是广告6秒钟并停止它。但它仅广告一次,但整个6秒内的当前消耗量有振荡。这意味着它在广告间隔之间唤醒,但为什么不发送数据包。?

问候,

标记

PM_Dialog
离线
Last seen:1 day 8 hours ago
职员
加入:2018-02-08 11:03
嗨马克,

嗨马克,

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

谢谢,PM_Dialog

标记Dsylva_2277
离线
Last seen:3 months 1 day ago
加入:2019-06-19 04:20
Hi PM_Dialog,

Hi PM_Dialog,

我的固件不会被卡住。它仅在整个6秒持续时间传输单个广告。但是在调试模式下,它会在6秒持续时间传输4到5次。为什么它只在非调试模式中传输一次?是影响BLE广告的睡眠模式吗?

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

static const sleep_state_t app_default_sleep_mode = arch_ext_sleep_on;

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

问候,

标记

PM_Dialog
离线
Last seen:1 day 8 hours ago
职员
加入:2018-02-08 11:03
嗨马克,

嗨马克,

Not sure what happen since it is a custom board/code. Can you please use the arch_printf() in the user_app_adv_start() and in the user_app_adv_nonconn_complete()? Also, can you please send me a screenshot from the Power Profiler? When the debugger is attached and de-attached.

谢谢,PM_Dialog

标记Dsylva_2277
离线
Last seen:3 months 1 day ago
加入:2019-06-19 04:20
你好 ,

你好 ,

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

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

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

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; } }

标记Dsylva_2277
离线
Last seen:3 months 1 day ago
加入:2019-06-19 04:20
Hi PM_Dialog,

Hi PM_Dialog,

As u suggested, i pulled down a GPIO onperiph_init()and pulled it high before going to sleep beforearch_goto_sleep(sleep_mode)在Arch_Main.cn。我附上了示波器输出的屏幕截图。我面临的问题是,当我调用user_app_adv_start()时,芯片仅发送一次数据。我通过查看Android中的BLE Scanner应用程序上的RSSI值来确认这一点。我也附上了示例代码。

正如我对我的产品的紧急演示一样,我已经改变了广告间隔到200ms和以某种方式通过调用'user_app_adv_start()'和1秒后我停止它以及在我打电话的广告完整功能之后宣传数据。user_app_adv_start()'再次。我在我的应用中重复了6秒钟,我正在获得多面广告命中。每次我打电话'user_app_adv_start()',我在我的应用程序中只有1个点击,直到我停止广告并再次调用它。

Why does 'user_app_adv_start()' advertising the data only once?

Can u please share me a sample code for beacon data which wakes up on an external interrupt and modifies the advertising string and transmits it and goes to sleep.

问候,

标记

附件:
PM_Dialog
离线
Last seen:1 day 8 hours ago
职员
加入:2018-02-08 11:03
嗨马克,

嗨马克,

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

谢谢,PM_Dialog

PM_Dialog
离线
Last seen:1 day 8 hours ago
职员
加入:2018-02-08 11:03
嗨马克,

嗨马克,

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

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

diff--git a/projects/target\u apps/ble\u examples/ble\u app\u sleepmode/src/config/user\u callback\u config.h b/projects/target\u apps/ble\u examples/ble\u app\u sleepmode/src/config/user\u callback\u config.h索引e61bd1b..060eab8 100644--a/projects/target\u apps/ble\u examples/ble\u app\u sleepmode/src/config/user\u callback\u config.h++b/projects/target\u apps/ble\u examples/ble\u app\u sleepmode/src/config/user\u callback\u config.h@@@54,8+54,8@@static const struct app\u callbacks user\u app\u callbacks={.app\u on\u update\u params\u rejected=NULL,.app\u on\u update\u params\u complete=NULL,.app\u on\u set\u dev\u config\u complete=default\u on\u set\u dev\u config\u complete,-.app_on_adv_noncon_complete=NULL,-.app_on_adv_indirect_complete=user_app_adv_indirect_complete,+.app_on_adv_noncon_complete=user_app_adv_noncon_complete,+.app_on_adv_indirect_complete=NULL,.app_on_adv_direct_complete=NULL,.app_on_db_init_complete=default_db_init_complete,.app_on_scanning_complete=NULL,diff--git a/projects/target\u apps/ble\u examples/ble\u app\u sleepmode/src/user\u sleepmode.c b/projects/target\u apps/ble\u examples/ble\u app\u sleepmode/src/user\u sleepmode.c索引c4b605e..bf18b3c 100644--a/projects/target\u apps/ble\u examples/ble\u app\u sleepmode/src/user\u sleepmode.c+++b/projects/target\u apps/ble\u examples/ble\u app sleepmode/src@@-240,8+240,10@@void user\u app\u adv\u start(void)//计划下一个广告数据更新app\u adv\u data\u update\u timer\u used=app\u easy\u timer(app\u adv\u data\u update\u TO,adv\u data\u update\u timer\u cb);-结构gapm\u开始\u播发\u cmd*cmd;-cmd=app_easy_gap_undirected_advertise_get_active();+/结构gapm\u开始\u播发\u cmd*cmd;+/cmd=app_easy_gap_undirected_advertise_get_active();++struct gapm_start_advertive_cmd*cmd=app_easy_gap_non_connectable_advertive_get_active();//将制造商数据添加到初始广告或扫描响应数据,如果有足够的空间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)//在广告搜索期间使用OTP copy设置扩展睡眠\u Set_extended_sleep(true);-app_easy_gap_undirected_advertise_start();+//app_easy_gap_undirected_advertise_start();+应用程序_easy _gap _non _connectable _Advertised _start();}void user_app_connection(uint8_t connection_idx,struct gapc_connection_req_ind const*param)@@-312,11+315,13@@静态void app_按钮_press_cb(void)*/static void app_wakeup_cb(void){-//如果状态不是空闲,忽略消息-If(ke_state_get(TASK_app)==app_CONNECTABLE){-user_app adv_start();-}+//如果state不是空闲的,则忽略消息+//If(ke_state_get(TASK_APP)==APP_CONNECTABLE)+//{+//user_APP_adv_start();+/}++用户_app_adv_start();}/**@@-335,9+340,9@@static void app_button_enable(void)40);//去抖动时间=0}-void user\u app\u adv\u undirect\u complete(uint8\u t status)+void user\u app\u adv\u noncon\u complete(uint8\u t status){-//禁用BLE和计时器事件的唤醒。只有外部(GPIO)唤醒事件才能唤醒处理器。+//禁用BLE和计时器事件的唤醒。只有外部(GPIO)唤醒事件才能唤醒处理器。if(status==GAP_ERR_cancelled){arch_ble_ext_wakeup_on();@@-347,6+352,18@@void user\u app\u adv\u unddirect\u complete(uint8\u t status)}+//无效用户\u app\u adv\u unddirect\u complete(uint8\u t status)+/{+///禁用BLE和计时器事件的唤醒。只有外部(GPIO)唤醒事件才能唤醒处理器。+//if(status==GAP\u ERR\u cancelled)+//{+//arch\u ble\u ext\u wakeup\u on();++///配置唤醒按钮+//app_button_enable();+/}+//}+void user\u app\u disconnect(struct gapc\u disconnect\u ind const*param){//取消参数更新请求计时器diff--git a/projects/target\u apps/ble\u examples/ble\u app\u sleepmode/src/user\u sleepmode.h b/projects/target\u apps/ble\u examples/ble\u app\u sleepmode/src/user\u sleepmode.h索引8c33892..acae900 100644--a/projects/target\u apps/ble\u examples/ble\u app\u sleepmode/src/user\u sleepmode.h+++b/projects/target\u apps/ble\u examples/ble\u app\u sleepmode/src/user\u sleepmode.h@@@116,7+116,7@@void user\u app\u connection(uint8\u t connection\u idx,*@返回void**********************************************************************************************************************/-void user\u app\u adv\u undirect\u complete(uint8\t status)+//void user\u app\u adv\u unddirect\u complete(uint8\u t status);/***************************************************************************************************************************@@-141,6+141,8@@void user\u catch\u rest\u hndl(ke\u msg\u id\u t const msgid,void const*param,ke\u task\u id\u t const dest\u id,ke\u task\u id\u t const src\u id);++void user_app_adv_noncon_complete(uint8_t status);//@}应用程序

谢谢,PM_Dialog

标记Dsylva_2277
离线
Last seen:3 months 1 day ago
加入:2019-06-19 04:20
Hi PM_Dialog,

Hi PM_Dialog,

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

2) I modified your arch_main.c file because, when my sensor sends an interrupt I have to wait around 20ms for getting the data, but if I dont wait my code will go back into sleep and I will miss the data. That's why I modified the arch_main.c file to wait till I get the data out and then put the chip to sleep. How to prolong the wake time of the chip?. Can you suggest an idea for that?.

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

4)当我收到中断时,直到我从传感器处理数据时,我就不会启动广告。在我收到数据后,我将开始广告,我相信我的代码都不会在广告期间运行。那么为什么这对SDK给出了任何问题?

谢谢,

标记

标记Dsylva_2277
离线
Last seen:3 months 1 day ago
加入:2019-06-19 04:20
Hi PM_Dialog,

Hi PM_Dialog,

Please support me on the above points. As you suggested I have started working on the sleepmode project in ble_examples. My biggest doubt is when my external sensor gives an interrupt and gives the data only after 20ms, how do I have to prevent the chip from going into sleep for that 20ms after I had woken up from sleep.

问候,

标记

PM_Dialog
离线
Last seen:1 day 8 hours ago
职员
加入:2018-02-08 11:03
嗨马克,

嗨马克,

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

  • Remove all the unused code lines. This makes the thing difficult to go through the code and understand the implementation.
  • All the modifications and the development should be done in the APPLICATION layer. None of the SDK should be modified. If you modify the SDK files, we cannot provide any support.
  • 请在ARCH_MAIN.c中删除SDK文件中的所有代码片段。
  • 所有应用层文件都以“User_”开头。
  • 请为我提供一个工作项目,将其添加到Projects \ target_apps \ misc sdk目录下,并指出SDK版本。
  • In order to start debugging it, I should copy paste the project under the aforementioned path, open it and compile it.
  • Keep in mind that you have a custom board, so I will try to replicate the issue in our Pro Development Board.
  • 在睡眠模式下,设备将在广告间隔(或在可连接广告的情况下的连接间隔)之间进入睡眠模式。包括I2C的所有外设域都断电。当传感器有数据发送时,您应该先唤醒设备首先想到唤醒控制器。
  • 我的建议是在BLE_APP_SLEEPMODE示例中开始开发。我为您提供了差异文件,需要更改。
  • The WDOG should be enabled, otherwise you will not be notified if the application gets stuck.
  • 如果您运行SDK的默认BLE_APP_SLEEPMODE示例,您是否能够停止广告并将设备放入睡眠模式?

谢谢,PM_Dialog

附件:
标记Dsylva_2277
离线
Last seen:3 months 1 day ago
加入:2019-06-19 04:20

Hi PM_Dialog,

在添加外部32kHz晶体振荡器后,该问题被整理出来。

It seems that that the ble_app_sleepmode code is unstable without the 32Khz crystal. But your datasheets say that this 32Khz is optional which is very much misleading. Please correct the datasheets or it may mislead others too. I have spent 3-4 months on this issue and had no clue it was due to the external crystal.

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

问候,

标记

PM_Dialog
离线
Last seen:1 day 8 hours ago
职员
加入:2018-02-08 11:03
嗨马克,

嗨马克,

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

你好,下午好