微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI Zigbee设计交流 > z-stack 如何进入休眠状态

z-stack 如何进入休眠状态

时间:10-02 整理:3721RD 点击:

z-stack 如何进入休眠状态 ,板子工作时的电流为40MA,太大了,用三天就没电了。若是路由终端无法休眠,只能全部用终端吗?可是终端节点有时候会收不到数据,不太稳定啊,求大神帮忙。

是的,路由节点是无法休眠的

请问能否请您描述下您现在的应用环境?

每隔5s,协调器发送数据,节点收到后,采集电压,然后发送给协调器。协调器进行广播主要是为了采集的电压时同一时间的电压。路由是40ma,终端节点使10ma左右。

ZStack路由器和协调器是无法进入休眠的,只有终端节点可以。你终端数据接收不稳定,协调器或路由器是采用的广播发送数据吧,广播时终端数据容易丢包,建议用单播。

有30多个终端,太多了,路由每次都能收到,可能是终端休眠了,有时候会收不到吧

我的这边怎么进入不了休眠模式啊?

你好!BEACON到下一个BEACON之间,怎么进入休眠状态?

我的end device 在BEACON到下一个BEACON之间有8mA电流,入网成功后,就进入uA级别的休眠状态。

是否方便把设置贴出来?

/*
* f8wConfig.cfg
*
* Compiler command-line options used to define a TI Z-Stack ZigBee device.
* To move an option from here to the project file, comment out or delete the
* option from this file and enter it into the "Define Symbols" box under the
* Preprocessor tab of the C/C++ Compiler Project Options. New user defined
* options may be added to this file, as necessary.
*
* Each macro is prefixed with '-D'. The entries are to be constructed as if
* they are to be on the compiler command line invocation (which they are).
*
* NOTE: The RHS (Right-Hand-Side) must be quoted if there are embedded blanks.
* See the DEFAULT_KEY definition for an example.
*/

/* Enable ZigBee-Pro */
-DZIGBEEPRO

/* Set to 0 for no security, otherwise non-0 */
-DSECURE=0
-DZG_SECURE_DYNAMIC=0

/* Enable the Reflector */
-DREFLECTOR

/* Default channel is Channel 11 - 0x0B */
// Channels are defined in the following:
// 0 : 868 MHz 0x00000001
// 1 - 10 : 915 MHz 0x000007FE
// 11 - 26 : 2.4 GHz 0x07FFF800
//
//-DMAX_CHANNELS_868MHZ 0x00000001
//-DMAX_CHANNELS_915MHZ 0x000007FE
//-DMAX_CHANNELS_24GHZ 0x07FFF800
//-DDEFAULT_CHANLIST=0x04000000 // 26 - 0x1A
//-DDEFAULT_CHANLIST=0x02000000 // 25 - 0x19
//-DDEFAULT_CHANLIST=0x01000000 // 24 - 0x18
//-DDEFAULT_CHANLIST=0x00800000 // 23 - 0x17
//-DDEFAULT_CHANLIST=0x00400000 // 22 - 0x16
//-DDEFAULT_CHANLIST=0x00200000 // 21 - 0x15
-DDEFAULT_CHANLIST=0x00100000 // 20 - 0x14
//-DDEFAULT_CHANLIST=0x00080000 // 19 - 0x13
//-DDEFAULT_CHANLIST=0x00040000 // 18 - 0x12
//-DDEFAULT_CHANLIST=0x00020000 // 17 - 0x11
//-DDEFAULT_CHANLIST=0x00010000 // 16 - 0x10
//-DDEFAULT_CHANLIST=0x00008000 // 15 - 0x0F
//-DDEFAULT_CHANLIST=0x00004000 // 14 - 0x0E
//-DDEFAULT_CHANLIST=0x00002000 // 13 - 0x0D
//-DDEFAULT_CHANLIST=0x00001000 // 12 - 0x0C
//-DDEFAULT_CHANLIST=0x00000800 // 11 - 0x0B

/* Define the default PAN ID.
*
* Setting this to a value other than 0xFFFF causes
* ZDO_COORD to use this value as its PAN ID and
* Routers and end devices to join PAN with this ID
*/
-DZDAPP_CONFIG_PAN_ID=0xFFFF

/* Minimum number of milliseconds to hold off the start of the device
* in the network and the minimum delay between joining cycles.
*/
-DNWK_START_DELAY=500

/* Mask for the random joining delay. This value is masked with
* the return from osal_rand() to get a random delay time for
* each joining cycle. This random value is added to NWK_START_DELAY.
* For example, a value of 0x007F will be a joining delay of 0 to 127
* milliseconds.
*/
-DEXTENDED_JOINING_RANDOM_MASK=0x000F

/* Minimum number of milliseconds to delay between each beacon request
* in a joining cycle.
*/
-DBEACON_REQUEST_DELAY=1500

/* Mask for the random beacon request delay. This value is masked with the
* return from osal_rand() to get a random delay time for each joining cycle.
* This random value is added to DBEACON_REQUEST_DELAY. For example, a value
* of 0x00FF will be a beacon request delay of 0 to 255 milliseconds.
*/
-DBEACON_REQ_DELAY_MASK=0x000F

/* Jitter mask for the link status report timer. This value is masked with the
* return from osal_rand() to add a random delay to _NIB.nwkLinkStatusPeriod.
* For example, a value of 0x007F allows a jitter between 0-127 milliseconds.
*/
-DLINK_STATUS_JITTER_MASK=0x000F

/* in seconds; set to 0 to turn off route expiry */
-DROUTE_EXPIRY_TIME=30

/* This number is used by polled devices, since the spec'd formula
* doesn't work for sleeping end devices. For non-polled devices,
* a formula is used. Value is in 2 milliseconds periods
*/
-DAPSC_ACK_WAIT_DURATION_POLLED=3000

/* Default indirect message holding timeout value:
* 1-65535 (0 -> 65536) X CNT_RTG_TIMER X RTG_TIMER_INTERVAL
*/
-DNWK_INDIRECT_MSG_TIMEOUT=7

/* uThe nmber of simultaneous route discoveries in network */
-DMAX_RREQ_ENTRIES=8

/* The maximum number of retries allowed after a transmission failure */
-DAPSC_MAX_FRAME_RETRIES=3

/* Max number of times retry looking for the next hop address of a message */
-DNWK_MAX_DATA_RETRIES=2

/* Number of times retry to poll parent before indicating loss of synchronization
* with parent. Note that larger value will cause longer delay for the child to
* rejoin the network.
*/
-DMAX_POLL_FAILURE_RETRIES=2

/* The number of items in the broadcast table */
-DMAX_BCAST=10//9

/* The maximum number of groups in the groups table */
-DAPS_MAX_GROUPS=16

/* Number of entries in the regular routing table plus additional
* entries for route repair
*/
-DMAX_RTG_ENTRIES=40

/* Maximum number of entries in the Binding table. */
-DNWK_MAX_BINDING_ENTRIES=4//4

/* Maximum number of cluster IDs for each binding table entry.
* Note that any value other than the default value may cause a
* compilation warning but Device Binding will function correctly.
*/
-DMAX_BINDING_CLUSTER_IDS=4

/* Default security key. */
-DDEFAULT_KEY="{0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0D}"

/* Reset when ASSERT occurs, otherwise flash LEDs */
//-DASSERT_RESET

/* Set the MAC MAX Frame Size (802.15.4 default is 102) */
-DMAC_MAX_FRAME_SIZE=116

/* Minimum transmissions attempted for Channel Interference detection,
* Frequency Agility can be disabled by setting this parameter to zero.
*/
-DZDNWKMGR_MIN_TRANSMISSIONS=20

/* Compiler keywords */
-DCONST="const __code"
-DGENERIC=__generic

/****************************************
* The following are for End Devices only
***************************************/

-DRFD_RCVC_ALWAYS_ON=FALSE//TRUE

/* The number of milliseconds to wait between data request polls to the coordinator. */
-DPOLL_RATE=2000

/* This is used after receiving a data indication to poll immediately
* for queued messages...in milliseconds.
*/
-DQUEUED_POLL_RATE=100

/* This is used after receiving a data confirmation to poll immediately
* for response messages...in milliseconds
*/
-DRESPONSE_POLL_RATE=100

/* This is used as an alternate response poll rate only for rejoin request.
* This rate is determined by the response time of the parent that the device
* is trying to join.
*/
-DREJOIN_POLL_RATE=440

/*
* f8wConfig.cfg
*
* Compiler command-line options used to define a TI Z-Stack ZigBee device.
* To move an option from here to the project file, comment out or delete the
* option from this file and enter it into the "Define Symbols" box under the
* Preprocessor tab of the C/C++ Compiler Project Options. New user defined
* options may be added to this file, as necessary.
*
* Each macro is prefixed with '-D'. The entries are to be constructed as if
* they are to be on the compiler command line invocation (which they are).
*
* NOTE: The RHS (Right-Hand-Side) must be quoted if there are embedded blanks.
* See the DEFAULT_KEY definition for an example.
*/

/* Enable ZigBee-Pro */
-DZIGBEEPRO

/* Set to 0 for no security, otherwise non-0 */
-DSECURE=0
-DZG_SECURE_DYNAMIC=0

/* Enable the Reflector */
-DREFLECTOR

/* Default channel is Channel 11 - 0x0B */
// Channels are defined in the following:
// 0 : 868 MHz 0x00000001
// 1 - 10 : 915 MHz 0x000007FE
// 11 - 26 : 2.4 GHz 0x07FFF800
//
//-DMAX_CHANNELS_868MHZ 0x00000001
//-DMAX_CHANNELS_915MHZ 0x000007FE
//-DMAX_CHANNELS_24GHZ 0x07FFF800
//-DDEFAULT_CHANLIST=0x04000000 // 26 - 0x1A
//-DDEFAULT_CHANLIST=0x02000000 // 25 - 0x19
//-DDEFAULT_CHANLIST=0x01000000 // 24 - 0x18
//-DDEFAULT_CHANLIST=0x00800000 // 23 - 0x17
//-DDEFAULT_CHANLIST=0x00400000 // 22 - 0x16
//-DDEFAULT_CHANLIST=0x00200000 // 21 - 0x15
-DDEFAULT_CHANLIST=0x00100000 // 20 - 0x14
//-DDEFAULT_CHANLIST=0x00080000 // 19 - 0x13
//-DDEFAULT_CHANLIST=0x00040000 // 18 - 0x12
//-DDEFAULT_CHANLIST=0x00020000 // 17 - 0x11
//-DDEFAULT_CHANLIST=0x00010000 // 16 - 0x10
//-DDEFAULT_CHANLIST=0x00008000 // 15 - 0x0F
//-DDEFAULT_CHANLIST=0x00004000 // 14 - 0x0E
//-DDEFAULT_CHANLIST=0x00002000 // 13 - 0x0D
//-DDEFAULT_CHANLIST=0x00001000 // 12 - 0x0C
//-DDEFAULT_CHANLIST=0x00000800 // 11 - 0x0B

/* Define the default PAN ID.
*
* Setting this to a value other than 0xFFFF causes
* ZDO_COORD to use this value as its PAN ID and
* Routers and end devices to join PAN with this ID
*/
-DZDAPP_CONFIG_PAN_ID=0xFFFF

/* Minimum number of milliseconds to hold off the start of the device
* in the network and the minimum delay between joining cycles.
*/
-DNWK_START_DELAY=500

/* Mask for the random joining delay. This value is masked with
* the return from osal_rand() to get a random delay time for
* each joining cycle. This random value is added to NWK_START_DELAY.
* For example, a value of 0x007F will be a joining delay of 0 to 127
* milliseconds.
*/
-DEXTENDED_JOINING_RANDOM_MASK=0x000F

/* Minimum number of milliseconds to delay between each beacon request
* in a joining cycle.
*/
-DBEACON_REQUEST_DELAY=1500

/* Mask for the random beacon request delay. This value is masked with the
* return from osal_rand() to get a random delay time for each joining cycle.
* This random value is added to DBEACON_REQUEST_DELAY. For example, a value
* of 0x00FF will be a beacon request delay of 0 to 255 milliseconds.
*/
-DBEACON_REQ_DELAY_MASK=0x000F

/* Jitter mask for the link status report timer. This value is masked with the
* return from osal_rand() to add a random delay to _NIB.nwkLinkStatusPeriod.
* For example, a value of 0x007F allows a jitter between 0-127 milliseconds.
*/
-DLINK_STATUS_JITTER_MASK=0x000F

/* in seconds; set to 0 to turn off route expiry */
-DROUTE_EXPIRY_TIME=30

/* This number is used by polled devices, since the spec'd formula
* doesn't work for sleeping end devices. For non-polled devices,
* a formula is used. Value is in 2 milliseconds periods
*/
-DAPSC_ACK_WAIT_DURATION_POLLED=3000

/* Default indirect message holding timeout value:
* 1-65535 (0 -> 65536) X CNT_RTG_TIMER X RTG_TIMER_INTERVAL
*/
-DNWK_INDIRECT_MSG_TIMEOUT=7

/* uThe nmber of simultaneous route discoveries in network */
-DMAX_RREQ_ENTRIES=8

/* The maximum number of retries allowed after a transmission failure */
-DAPSC_MAX_FRAME_RETRIES=3

/* Max number of times retry looking for the next hop address of a message */
-DNWK_MAX_DATA_RETRIES=2

/* Number of times retry to poll parent before indicating loss of synchronization
* with parent. Note that larger value will cause longer delay for the child to
* rejoin the network.
*/
-DMAX_POLL_FAILURE_RETRIES=2

/* The number of items in the broadcast table */
-DMAX_BCAST=10//9

/* The maximum number of groups in the groups table */
-DAPS_MAX_GROUPS=16

/* Number of entries in the regular routing table plus additional
* entries for route repair
*/
-DMAX_RTG_ENTRIES=40

/* Maximum number of entries in the Binding table. */
-DNWK_MAX_BINDING_ENTRIES=4//4

/* Maximum number of cluster IDs for each binding table entry.
* Note that any value other than the default value may cause a
* compilation warning but Device Binding will function correctly.
*/
-DMAX_BINDING_CLUSTER_IDS=4

/* Default security key. */
-DDEFAULT_KEY="{0x01, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0F, 0x00, 0x02, 0x04, 0x06, 0x08, 0x0A, 0x0C, 0x0D}"

/* Reset when ASSERT occurs, otherwise flash LEDs */
//-DASSERT_RESET

/* Set the MAC MAX Frame Size (802.15.4 default is 102) */
-DMAC_MAX_FRAME_SIZE=116

/* Minimum transmissions attempted for Channel Interference detection,
* Frequency Agility can be disabled by setting this parameter to zero.
*/
-DZDNWKMGR_MIN_TRANSMISSIONS=20

/* Compiler keywords */
-DCONST="const __code"
-DGENERIC=__generic

/****************************************
* The following are for End Devices only
***************************************/

-DRFD_RCVC_ALWAYS_ON=FALSE//TRUE

/* The number of milliseconds to wait between data request polls to the coordinator. */
-DPOLL_RATE=2000

/* This is used after receiving a data indication to poll immediately
* for queued messages...in milliseconds.
*/
-DQUEUED_POLL_RATE=100

/* This is used after receiving a data confirmation to poll immediately
* for response messages...in milliseconds
*/
-DRESPONSE_POLL_RATE=100

/* This is used as an alternate response poll rate only for rejoin request.
* This rate is determined by the response time of the parent that the device
* is trying to join.
*/
-DREJOIN_POLL_RATE=440

你好!把休眠设置为一个任务可以吗?在这个任务里面调用睡眠函数!

默认设置为电池供电就可以了;

恩,但是默认的最大休眠时间只能是510S,我的休眠时间是一个月,在Z-stack中如何设置?

没设置过那么长时间,唤醒后如果没有其他任务就很快又进入休眠,功耗也很小

我的需求是周期性的采集节点数据,但是这个周期是一个月一次,这个长周期该怎么设置?如果按你说的方式任务完成完成之后就休眠,但是休眠唤醒后又开始工作,这个周期达不到一个月的休眠时间

具体休眠的时间设置你不需要关心,系统会帮你做好的。

比方说你开了一个超过510s的timer event,假设是600s,这个事件就是最小的timeout事件,那么第一次休眠时间是

是510s,因为休眠定时器单次的休眠时间最长是510s

在休眠510s,唤醒以后,会再去查找最小的timeout,由于这个时候只有一个600-510s的timeout的了

那么这次的休眠时间就是600-510=90s,在休眠90s以后,唤醒最这个600s的timer要做的事情。

由于中间唤醒后立即又休眠了,所以不会有很大的功耗消耗的。

請問,如果要設一個超過 510s 的 event,例如 600s

那是寫成

1) osal_start_timerEx( zclSampleFireDetector_TaskID, SAMPLEFIREDETECTOR_IDENTIFY_TIMEOUT_EVT, 600000 );

還是要自己寫成兩個不超過 510s 的 osal_start_timerEx()

2) osal_start_timerEx( zclSampleFireDetector_TaskID, SAMPLEFIREDETECTOR_IDENTIFY_TIMEOUT_EVT, 510000 );

   第二次再執行

   osal_start_timerEx( zclSampleFireDetector_TaskID, SAMPLEFIREDETECTOR_IDENTIFY_TIMEOUT_EVT, 90000 );

osal_start_timerEx( zclSampleFireDetector_TaskID, SAMPLEFIREDETECTOR_IDENTIFY_TIMEOUT_EVT, 600000 );

osal_start_timerEx的 timeout_value是一个uint16的变量,但是我试了一下好像即使超出了2^16似乎函数也不会有warning?

其实低功耗没有这么难的,主要是很多人不明白有哪些坑。PM3 0.2uA和PM21.2uA很容易就实现了。

关于低功耗的设计,可以去我的博客看看这篇文章:

Z-Stack低功耗设置详解

http://www.kaleidscope.cn:1020/archives/1542

Z-Stack core 1.2.2的SDK增强库文件

我写了一个入网控制功耗的库文件,提供了几个API函数接口,直接调用就可以控制节点的beacon request,并且可以通过简单的调用一个api就可以进入PM3模式,以及从PM3模式中唤醒的功能。详细点击链接可以看到。

功能改进:

  • Add – 未入网节点定时beacon request后进入PM2睡眠模式
  • Add – 未入网节点定时beacon request后进入PM3深度睡眠模式
  • Add – 手动进入PM3低功耗模式
  • Add – 中断唤醒HLOD电源以解决串口、定时器不准确问题

Hi,VV

在DemoSensor.c 文件中

 void zb_HandleOsalEvent( uint16 event )函数增加了一个睡眠的任务

 if ( event & MY_CHANGE_SLEEP_EVT )

  {

      OSAL_SET_CPU_INTO_SLEEP(NvSleepTimeSet);//休眠时间

      osal_start_timerEx( sapi_TaskID, MY_CHANGE_SLEEP_EVT, 500 );

  } 

NvSleepTimeSet 睡眠时间设置如果超过510s的时候,依然在510s系统唤醒,执行发送数据的任务,怎么才能够使得该终端立即又休眠呢?

谢谢!

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top