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.

How can I differentiate a node from another node as node address is dynamic

Dear friends,

Please let me know if there are 4 nodes B1, B2, B3 and B4 and each one has got attached to sensors and communicate the sensor data to Coordinator and coordinator shall send commands to switch on/off a light based on the sensor data received from the other nodes.

How can I differentiate from which device I shall received the sensor data and ignore same kind of data from other nodes.

How can I get the device name and map to the short address of the same node?

Thanks,

  • When a device joins network, there is a end node announcement with its short address. You should keep that and use it.

  • Which function will process that announcement? But address is not enough to know which device I am talking to, its name is also necessary.

    Please point me to the code where this announcement  from the device is processed.

    Thanks

  • You can register it by "ZDO_RegisterForZDOMsg(task_id, Device_annce);" in your init function and process "case Device_annce:" in XXX_ProcessZDOMsgs. By the way, you said " its name is also necessary." but I have no idea about name of zigbee device. How do you give a name to device?

  • Dear YiKai,

    I have done the following highlighted change in my code...

    void zclSampleHCUnit_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg )

    {

    ZDO_DeviceAnnce_t devAnnce;
    switch ( inMsg->clusterID )
    {
    case End_Device_Bind_rsp:
    if ( ZDO_ParseBindRsp( inMsg ) == ZSuccess )
    {
    // Light LED
    HalLedSet( HAL_LED_4, HAL_LED_MODE_ON );
    }
    #if defined(BLINK_LEDS)
    else
    {
    // Flash LED to show failure
    HalLedSet ( HAL_LED_4, HAL_LED_MODE_FLASH );
    }
    #endif
    break;

    case Match_Desc_rsp:
    {
    ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( inMsg );
    if ( pRsp )
    {
    if ( pRsp->status == ZSuccess && pRsp->cnt )
    {
    //zclSampleThermostat_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
    //zclSampleThermostat_DstAddr.addr.shortAddr = pRsp->nwkAddr;
    // Take the first endpoint, Can be changed to search through endpoints
    //zclSampleThermostat_DstAddr.endPoint = pRsp->epList[0];

    zclHCUnit_DstThermostatAddr.addrMode = (afAddrMode_t)Addr16Bit;
    zclHCUnit_DstThermostatAddr.addr.shortAddr = pRsp->nwkAddr;
    // Take the first endpoint, Can be changed to search through endpoints
    zclHCUnit_DstThermostatAddr.endPoint = pRsp->epList[0];

    // Light LED
    HalLedSet( HAL_LED_4, HAL_LED_MODE_ON );
    }
    osal_mem_free( pRsp );
    }
    }
    break;

    case Device_annce:
    {
    ZDO_ParseDeviceAnnce( inMsg, &devAnnce );
    }
    break;

    default:
    break;
    }
    }

    But for example if I have one coordinator B1 and have node B2 to measure the Temperature value send it to B1. I also have two more nodes B3 and B4 which are used to control the heater and cooler respectively.

    If temp < 20 C then I would like to send a command to switch on the heater to B3 and if the temperature is > 30 C I would like to send command to switch on the cooler then how can I differentiate B3 and B4.

    If I know the address of both of them what is the way it is connected to the heater or cooler?

    I mean the Device name can be sent using an application message using the AF_DataRequest() function. I got the reference from the GenericApp for sending "Hello World" message.

    Thanks

  • How to differentiate B3 and B4? This is about device management of automation and nothing to do with zigbee spec. You need to do that on your application. My suggestion approach is :

    When you get a new end node announcement from B3, specify it as heater and keep its short address. On the contrary, specify B4 as cooler and also keep its short address. Then, apply the control rules: If temp < 20 C then I would like to send a command to switch on the heater to B3 and if the temperature is > 30 C.

  • YiKai,

    Unfortunately I am not receiving the Device_annce notification from the SampleLight node to the Coordinator (SampleHCUnit). Is the ZDO_AddrChangeIndicationCB() responsible to send the announcement ot Coordinator. But I found it is not called anywhere in the code. Where to call this function from SampleLight node, if this is the correct function?

    Thanks

  • Do you register Device_annce by "ZDO_RegisterForZDOMsg(task_id, Device_annce);" in your init function?

  • Yes, I did in HCUnit only.

  • Try to enable packet sniffer and restart your end device. Check if your device send end node announcement in sniffer first.

  • I will check the sniffer log, but if it does not send what to do?

    Thanks

  • It should send end node announcement  because it is handled by zstack.

  • Dear YiKai,

    I found some short address association status message in the sniffer log, is it the Device announce message. Please find attached the log file.

    I go the Device_annce now

    Can I add the following code under case Device_Annce to bind the Coordinator with the recently joined node so that I can control light with using the SW2 and SW4 presses?

    ZDO_ParseDeviceAnnce( inMsg, &devAnnce );
    MyAddress = devAnnce.nwkAddr;

    // Initiate an End Device Bind Request, this bind request will
    // only use a cluster list that is important to binding.
    dstAddr.addrMode = afAddr16Bit;
    dstAddr.addr.shortAddr = 0; // Coordinator makes the match
    ZDP_EndDeviceBindReq( &dstAddr, NLME_GetShortAddr(),
    SAMPLEHCUNIT_ENDPOINT,
    ZCL_HA_PROFILE_ID,
    ZCLSampleHCUnit_BINDING_INLIST, bindingInClusters,
    ZCLSampleHCUnit_BINDING_OUTLIST, bindingOutClusters,
    TRUE );


    // Send config report command to the thermostat
    zclCfgReportCmd_t cfgRptCmd;
    cfgRptCmd.numAttr = 1;
    cfgRptCmd.attrList[0].direction = 0;
    cfgRptCmd.attrList[0].attrID = ATTRID_HVAC_THERMOSTAT_LOCAL_TEMPERATURE;
    cfgRptCmd.attrList[0].dataType = ZCL_DATATYPE_INT16;
    cfgRptCmd.attrList[0].minReportInt = 5;
    cfgRptCmd.attrList[0].maxReportInt = 10;
    cfgRptCmd.attrList[0].timeoutPeriod = 0;
    cfgRptCmd.attrList[0].reportableChange = NULL;

    zcl_SendConfigReportCmd(SAMPLEHCUNIT_ENDPOINT,
    &zclHCUnit_DstThermostatAddr,
    ZCL_CLUSTER_ID_HVAC_THERMOSTAT,
    &cfgRptCmd,
    ZCL_FRAME_CLIENT_SERVER_DIR,
    0, 1);

    // Send config report command to the humidity sensor
    cfgRptCmd.numAttr = 1;
    cfgRptCmd.attrList[0].direction = 0;
    cfgRptCmd.attrList[0].attrID = ATTRID_MS_RELATIVE_HUMIDITY_MEASURED_VALUE;
    cfgRptCmd.attrList[0].dataType = ZCL_DATATYPE_UINT16;
    cfgRptCmd.attrList[0].minReportInt = 5;
    cfgRptCmd.attrList[0].maxReportInt = 10;
    cfgRptCmd.attrList[0].timeoutPeriod = 0;
    cfgRptCmd.attrList[0].reportableChange = NULL;

    zcl_SendConfigReportCmd(SAMPLEHCUNIT_ENDPOINT,
    &zclHCUnit_DstThermostatAddr,
    ZCL_CLUSTER_ID_MS_RELATIVE_HUMIDITY,
    &cfgRptCmd,
    ZCL_FRAME_CLIENT_SERVER_DIR,
    0, 1);

    // Send config report command to the light on/off
    cfgRptCmd.numAttr = 1;
    cfgRptCmd.attrList[0].direction = 0;
    cfgRptCmd.attrList[0].attrID = ATTRID_ON_OFF;
    cfgRptCmd.attrList[0].dataType = ZCL_DATATYPE_UINT8;
    cfgRptCmd.attrList[0].minReportInt = 20;
    cfgRptCmd.attrList[0].maxReportInt = 50;
    cfgRptCmd.attrList[0].timeoutPeriod = 0;
    cfgRptCmd.attrList[0].reportableChange = NULL;

    zcl_SendConfigReportCmd(SAMPLEHCUNIT_ENDPOINT,
    &zclHCUnit_DstThermostatAddr,
    ZCL_CLUSTER_ID_GEN_ON_OFF,
    &cfgRptCmd,
    ZCL_FRAME_CLIENT_SERVER_DIR,
    0, 1);

    // Initiate a Match Description Request (Service Discovery)
    dstAddr.addrMode = AddrBroadcast;
    dstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR;
    ZDP_MatchDescReq( &dstAddr, NWK_BROADCAST_SHORTADDR,
    ZCL_HA_PROFILE_ID,
    ZCLSampleHCUnit_BINDING_OUTLIST, bindingOutClusters,
    ZCLSampleHCUnit_BINDING_INLIST, bindingInClusters, // No incoming clusters to bind
    FALSE );

    Thanks

  • Yes, it is the Device announce message and good to hear that you get the end node announcement. If you want to bind the coordinator with the latest joined device, you should use ZDP_BindReq, not ZDP_EndDeviceBindReq and ZDP_MatchDescReq.

  • You mean I shall send ZDP_BindReq and ZDP_MatchDescReq.

    I have two nodes, one with THERMOSTAT and HUMIDITY SENSOR clusters and other with SAMPLELIGHT ON/OFF cluster. How I will differentiate them with the Device announcement?

    What will be the difference in sending the messages to both the nodes?

    When I am using Samplelight and Coordinator it is working but when I replace the Samplelight with Thermostat node it doesn't work with the node as expected ( I am not receiving the temperature and humidity periodically).

    What can be the problem?

    Thanks

  • 1. No, I mean you should use ZDP_BindReq only in your case.

    2. When you receive end node announcement, you should use ZDP_SimpleDescReq to ask for simple description of it. The simple description of device will show you the device information such as profile ID, device ID, endpoint, and supported clusters.

    3. When you replace the Samplelight with Thermostat node, you need to put ON/OFF cluster support into Thermostat.

  • 1. ok. 

    2. I will try this

    3. I mean sample light is not functionally replaced with Thermostat, as I have only two ZigBee nodes and need to test for three nodes I am overwriting the Samplelight program with the Thermostat program to the same node. If I test these functionalities individually it works fine. But when I overwrite it with another while keeping the Coordinator on, does not receive the temperature and humidity updates to the Coordinator.

    Thanks

  • I don't understand what you mean to overwrite it with another while keeping the Coordinator on. It sounds weird.

  • I have only two devices I need to have a Coordinator, one node for Temperature and Humidity measurement and another for switching on a relay when Coordinator sends a command. Sensor node reports the sensor data periodically to Coordinator.

    But when I would like to test the sensor node I will program the sensor interfacing code into that node, when I would like to use it to switch on/off relay I will program the relay on/off code into that. I don't want both relay and sensor functionality in the same node.

    But when I flash the relay on/off code into the node it works but when I flash again the sensor code into the same node, coordinator is not receiving any updates from the sensor node.

    Please let me know how to solve this problem.

    Thanks

  • Hi Raghu,
    I am working on home automation profile. I want to send data from coordinator to the end device and for this i need to know the short address of the end device which we can know using ZED device announce and what you have discussed in forum. I want to know how we can store and use short address for future reference when end device announcement takes place. I can see in your Snifferlog for device announce. If possible can you please share files or functions which are related to end device announcement.
    Thanks
  • Hi Raghu,
    I have completely got stuck as i am not able to think how to proceed for sending data from coordinator to the end device as i am not able to retrieve the short address of the end device after end node announcement(binding). I don't know how to differentiate short addresses of different end devices when multiple devices are connected to the coordinator . I am asking all these because my application is similar to yours and you have already gone through these what i can see in this forum discussion.
    Therefore i request you to kindly share only that part of code(functions) which are related to end node announcement and assigning unique identification based on their command id to the short address for identification when multiple devices are connected. It will be helpful for me in proceeding further. i will be highly obliged to you if you can share it.
  • Dear Kumar Singh,

    I am very sorry for the late response, but I have done it long back. Now I don't even remember what I did to fix the issue.

    But if I recollect the same I will definitely forward you the same without fail.

    Please apologize me for not able to help you.

    Thanks,

    Raghu Devisetti

  • Hi Raghu Devisetti,
    Thanks a lot to hear back from you and no need to apologize at all. I know that you had done it long back some two years ago and it will be difficult for you to recollect those things. Actually my project is much similar to yours what you had discussed in forum. I have little knowledge about zigbee protocol and that's why i had requested for sample code so that i can get idea how to proceed further. If i get it then it will be very much helpful and easy to understand the flow. Any way i am trying to do it step by step.

    Thanks again for your kind response.
  • Dear Kumar Singh,

    Please find below some code which may have the logic you are looking for but I am not still sure if it is there. But there is definitely a chance you may get it.

    TI.rar

    Wish you all the best.

    Thanks,

    Raghu Devisetti

  • Hi Raghu Devisetti,
    Thanks a lot for your kind help. Its going to be too much helpful for me as i was looking for such kind of sample code. i will definitely gain different types of logic from your code for interfacing different kinds of sensor and utilize it in my application.
    Thanks again.
    Regards
    Kumar