const cId_t zb_InCmdList[NUM_IN_CMD_COLLECTOR] = { TEMPERATURE_SENSOR_CMD_ID //temperature sensor IN cluster(defined in respective sensor file) }; const cId_t zb_InCmdList[NUM_IN_CMD_COLLECTOR] = { PIR_SENSOR_CMD_ID //pir sensor IN cluster(defined in respective sensor file) }; const cId_t zb_InCmdList[NUM_IN_CMD_COLLECTOR] = { ENERGY_METER_CMD_ID //energy meter IN cluster(defined in respective sensor file) }; #define PIR_SENSOR_ENDPOINT_ID 0x02 #define ENERGY_METER_ENDPOINT_ID 0X02 #define TEMP_ENDPOINT_ID 0x02 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 == device_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(device_list[i].endpoint == NULL) //check which is the last device registered, endpoint with NULL means no device registered at that device list { device_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 == device_list[j].nwkAddr) //match the short address of the end point for which end point response has arrived { device_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[j], 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 ); if((simpleDescRsp.simpleDesc.pAppInClusterList[0] == TEMPERATURE_SENSOR_CMD_ID) && (simpleDescRsp.simpleDesc.EndPoint == TEMP_ENDPOINT_ID)) //match clusterid and endpoint to store short address in array { device_list[0].nwkAddr = simpleDescRsp.nwkAddr; //store short address in array } else if((simpleDescRsp.simpleDesc.pAppInClusterList[0] == PIR_SENSOR_CMD_ID) && (simpleDescRsp.simpleDesc.EndPoint == PIR_SENSOR_ENDPOINT_ID)) { device_list[1].nwkAddr = simpleDescRsp.nwkAddr; } else if((simpleDescRsp.simpleDesc.pAppInClusterList[0] == ENERGY_METER_ENDPOINT_ID) && (simpleDescRsp.simpleDesc.EndPoint == ENERGY_METER_ENDPOINT_ID)) { device_list[2].nwkAddr = simpleDescRsp.nwkAddr; } if ( simpleDescRsp.simpleDesc.pAppInClusterList != NULL ) //free memory if not empty { osal_mem_free( simpleDescRsp.simpleDesc.pAppInClusterList ); } if ( simpleDescRsp.simpleDesc.pAppOutClusterList != NULL ) { osal_mem_free( simpleDescRsp.simpleDesc.pAppOutClusterList ); } } break;