昨天发现一个问题,ED设备不定义NV_RESTORE宏,频繁掉电上电多次后,就不能入网了。
然后google了一下找到原因:ED设备反复入网,重新分配ShorAddr,AssociatedDevList就被占满了。
AssociatedDevList是一个类型为associated_devices_t的数组,容量为NWK_MAX_DEVICES。
先看associated_devices_t的定义:
typedef struct {
UINT16 shortAddr; // Short address of associated device
uint16 addrIdx; // Index from the address manager
byte nodeRelation;
byte devStatus; // bitmap of various status values
byte assocCnt;
byte age;
linkInfo_t linkInfo;
} associated_devices_t;
由于未开启NV_RESTORE,那么掉网设备重新入网后会被重新分配ShortAddr,将占用新的设备关联表条目。
而旧的关联条目,在Z-Stack中是不会主动被删除的。
总结一下解决的办法:
一. 全功能节点
类型associated_devices_t中,有一个age域,当关联表的维护者收到一条来自该短地址的Link Status消息,就会重置该域。
全功能