typedef struct { uint16 nwkAddr; // Network address uint8 endpoint; // Endpoint identifier uint16 profileID; // Profile identifier uint16 deviceID; // Device identifier uint8 version; // Version } epInfoRec_t; epInfoRec_t dev_list[10]; void SAPI_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg ) { zAddrType_t destAddr; uint16 shortAddr; uint8 epInt; static zAddrType_t addr; addr.addrMode = Addr16Bit; uint8 dev_cnt; . . case Device_annce: { ZDO_DeviceAnnce_t devAnnce; ZDO_ParseDeviceAnnce( inMsg, &devAnnce ); destAddr.addrMode = Addr16Bit; destAddr.addr.shortAddr = devAnnce.nwkAddr; for(dev_cnt =0;dev_cnt<10;dev_cnt++) //check whether any device with short address same as devAnnce.nwkAddr is already present or not { if(destAddr.addr.shortAddr == dev_list[dev_cnt].nwkAddr) { break; //break loop if device is already registered } } if( dev_cnt == 10) //dev_cnt == 10 means device is not registered in the device list,dev_cnt<10 means device already present in list { for(uint8 i = 0;i < 10;i++) { if(dev_list[i].endpoint != null) //check which is the last device registered { dev_list[i].nwkAddr = devAnnce.nwkAddr; //register short address of the announced device into device list at location where device is not registered ZDP_ActiveEPReq( &destAddr, devAnnce.nwkAddr, 0); //send active end point request for the new device announced break; //exit further registering of devices } } } break; case Active_EP_rsp: { ZDO_ActiveEndpointRsp_t *pActiveEPs = NULL; pActiveEPs = ZDO_ParseEPListRsp( inMsg ); //get end point response if ( pActiveEPs->status == ZSuccess ) { for (uint8 j=0; j < pActiveEPs->cnt; j++ ) { if(pActiveEPs->nwkAddr == dev_list[j].nwkAddr) //match the short address of the end point for which end point response has arrived { dev_list[j].endpoint = pActiveEPs->epList[j]; //store the end point of the responded end point in the device list addr.addr.shortAddr = pActiveEPs->nwkAddr; addr.addrMode = Addr16Bit; ZDP_SimpleDescReq( &addr, pActiveEPs->nwkAddr, pActiveEPs->epList[i], 0 ); //send simple descriptor request to the responded end device break; //exit from further request } } if ( pActiveEPs != NULL ) { osal_mem_free( pActiveEPs ); //free memory } } } break; case Simple_Desc_rsp: { ZDO_SimpleDescRsp_t simpleDescRsp; simpleDescRsp.simpleDesc.pAppInClusterList = simpleDescRsp.simpleDesc.pAppOutClusterList = NULL; ZDO_ParseSimpleDescRsp( inMsg, &simpleDescRsp ); for (uint8 k=0; k < 10; k++ ) { if((simpleDescRsp.nwkAddr == dev_list[k].nwkAddr) && (simpleDescRsp.simpleDesc.EndPoint == dev_list[k].endpoint)) //match short address and end point of the end device in the dev_list { dev_list[k].profileID = simpleDescRsp.simpleDesc.AppProfId; //store end point information in the device list dev_list[k].deviceID = simpleDescRsp.simpleDesc.AppDeviceId; dev_list[k].version = simpleDescRsp.simpleDesc.AppDevVer; } break; //exit further storing } if ( simpleDescRsp.simpleDesc.pAppInClusterList != NULL ) { osal_mem_free( simpleDescRsp.simpleDesc.pAppInClusterList ); } if ( simpleDescRsp.simpleDesc.pAppOutClusterList != NULL ) { osal_mem_free( simpleDescRsp.simpleDesc.pAppOutClusterList ); } } break; } } //This dev_list informations can be used for sending unicast data from coordinator to the end device