This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2530: 节点退网问题

Part Number: CC2530
Other Parts Discussed in Thread: Z-STACK

我想让h大于某个值的时候让网络中的节点退网,加入另外一个网络,我太小白了,现在退网都做不到,以下是我的代码,黄色部分。

1、判断加在这里对吗?如果不对应该加在哪?

2、退网函数用的对吗,应该怎么用?有没有例子。

3、求大神们可以讲清楚一点,我刚入门,靠在网上找资料自学,没有系统的学过,很多地方都不懂。望多多包涵。

uint16 SampleApp_ProcessEvent( uint8 task_id, uint16 events )
{
uint8 Display_Buf[6] = {0};
uint16 shortAddr = 0;
uint16 shortAddrNew = 0;
uint16 PANID=0;
uint16 parentshortAddr = 0;
uint16 parentshortAddrNew = 0;

zAddrType_t destAddr;
uint8 *pIEEEAddr;

// uint16 h;

afIncomingMSGPacket_t *MSGpkt;

(void)task_id; // Intentionally unreferenced parameter

if ( events & SYS_EVENT_MSG ) /*系统消息事件*/
{

MSGpkt = (afIncomingMSGPacket_t *)osal_msg_receive( SampleApp_TaskID );
while ( MSGpkt ) /*调用数据接收函数接收数据.2*/
{


switch ( MSGpkt->hdr.event ) /*判断具体事件*/
{
// Received when a key is pressed
case KEY_CHANGE:
SampleApp_HandleKeys( ((keyChange_t *)MSGpkt)->state, ((keyChange_t *)MSGpkt)->keys );
break; /*如果为按键事件,调用案件处理函数.3*/

// Received when a messages is received (OTA) for this endpoint
case AF_INCOMING_MSG_CMD:
HAL_TOGGLE_LED1(); /*?*/
SampleApp_MessageMSGCB( MSGpkt );

h=i;
num_to_str(h,Display_Buf, 4 , 16);
Gui_DrawFont_GBK16(0,96,BLACK,YELLOW,Display_Buf);
i++;

if ( h>0x010)
{
ZDP_MgmtLeaveReq( &destAddr, pIEEEAddr, TRUE, FALSE, 0);
}
else
{}


break; /*如果为数据接收事件,调用数据接收函数.3*/