节点的每次状态改变都有跳转到 case ZDO_STATE_CHANGE:下吗? 例如节点先加入到一个协调器组成的网络中,然后协调器断电了,这时节点应该重新搜网,这时的网络状态应该是变化的,但好像程序再不进入到 case ZDO_STATE_CHANGE下进行了,加一个个串口打印状态,只有第一次加入有输出,协调器断电,就没有输出了?
case ZDO_STATE_CHANGE:
SampleApp_NwkState = (devStates_t)(MSGpkt->hdr.status);
if ( //(SampleApp_NwkState == DEV_ZB_COORD)
(SampleApp_NwkState == DEV_ROUTER)
|| (SampleApp_NwkState == DEV_END_DEVICE) )
{
// Start sending the periodic message in a regular interval.
HalUARTWrite(0,"change state\n",13);
zhongwei xu1:
因为不满足你的if条件,所以打印不出,协调器断电,节点成孤点了,一直在搜网,SampleApp_NwkState == DEV_NWK_ORPHAN;
你可以打断电查看下 SampleApp_NwkState 的值。
ZDApp.h中:
typedef enum{ DEV_HOLD, // Initialized – not started automatically DEV_INIT, // Initialized – not connected to anything DEV_NWK_DISC, // Discovering PAN's to join DEV_NWK_JOINING, // Joining a PAN DEV_NWK_REJOIN, // ReJoining a PAN, only for end devices DEV_END_DEVICE_UNAUTH, // Joined but not yet authenticated by trust center DEV_END_DEVICE, // Started as device after authentication DEV_ROUTER, // Device joined, authenticated and is a router DEV_COORD_STARTING, // Started as Zigbee Coordinator DEV_ZB_COORD, // Started as Zigbee Coordinator DEV_NWK_ORPHAN // Device has lost information about its parent..} devStates_t;
flyaway_peak:
回复 zhongwei xu1:
谢谢,我试试看。
不能加入协调器的原因找到了,协调器重新启动后,PANID变了,节点还在找原来ID的网络,所以不加入新的网络中