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.

CC2538EMK: How to Configure CC2538EM devices as a Coordinator and End Devices?

Part Number: CC2538EMK
Other Parts Discussed in Thread: Z-STACK, CC2531, LAUNCHXL-CC2650, CC2538

Hello,

I  am new to this Zigbee environment. I know little bit knowledge about it. 

I have a two CC2538EM devices. I want to make them as a one coordinator and another one End device. I am using  Z-Stack 3.0.0 and Z-Tool 2.0.

Yes I successfully configured one device as a Coordinator . I followed this  link .But i am unable to configured another device as a End device.

Please help me anyone.

Thanks in Advance,

Amar.

  • I used script file setup coordinator and end device.

    Coordinator Script file.

    coordinator_light.txt
    /**************************************************************************************************
      Filename:       znp-bringup.zjs
      Revised:        $Date:$
      Revision:       $Revision:$
    
      Description:    This file is a test script bring up ZC and ZR.
    
    
      Copyright 2010 Texas Instruments Incorporated. All rights reserved.
    
      IMPORTANT: Your use of this Software is limited to those specific rights
      granted under the terms of a software license agreement between the user
      who downloaded the software, his/her employer (which must be your employer)
      and Texas Instruments Incorporated (the "License").  You may not use this
      Software unless you agree to abide by the terms of the License. The License
      limits your use, and you acknowledge, that the Software may not be modified,
      copied or distributed unless embedded on a Texas Instruments microcontroller
      or used solely and exclusively in conjunction with a Texas Instruments radio
      frequency transceiver, which is integrated into your product.  Other than for
      the foregoing purpose, you may not use, reproduce, copy, prepare derivative
      works of, modify, distribute, perform, display or sell this Software and/or
      its documentation for any purpose.
    
      YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
      PROVIDED �AS IS� WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
      INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
      NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
      TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
      NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
      LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
      INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
      OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
      OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
      (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    
      Should you have any questions regarding your right to use this Software,
      contact Texas Instruments Incorporated at www.TI.com.
    **************************************************************************************************/
    
    
    /**************************************************************************************************
      Instructions:
    
      Connect a device to be a ZC to a COM nicknamed �C� and another to a COM named �R�
    
    **************************************************************************************************/
    import System;
    import System.Text;
    import TI.ZPI2;
    
    class TheScript
    {
      // Set to 'true' when running the ZNP in order to reset the devices and startup the network.
      private var ZNP_RUN : boolean = true;
      private var SUCCESS : int = 0;
      private var HOMEAUT : int = 0x0104;
      private var LIGHT   : int = 0x0100;
      private var AF_DEFAULT_RADIUS : int = 0x1E;
    
      // Set this variable to the script engine's nickname for the COM port to the target device.
      private var ZR_Com : String = "COM3";
      private var ZC_Com : String = "COM16";
    
      // Set this variable to 'true' to enable the display of log messages (i.e. verbose mode).
      private var showLogMsgs : boolean = true;
    
      // Variables set by the incoming message handler to enable "re-try until success" looping.
      private var gotRstRsp           : boolean = false;
      private var gotCfgRsp           : boolean = false;
      private var gotRegRsp           : boolean = false;
      private var gotStartRsp         : boolean = false;
      private var gotStateRsp         : boolean = false;
      private var gotAfReqExtRsp      : boolean = false;
      private var gotAfIncExt         : boolean = false;
      private var gotAfStoreRsp       : boolean = false;
      private var gotAfRetrieveRsp    : boolean = false;
      private var gotDevRsp           : boolean = false;
      private var gotEpRsp            : boolean = false;
      private var gotSdescRsp         : boolean = false;
      private var gotTogRsp         : boolean = false;
    
      private var isLight             : boolean = false;
      private var lightStatus             : boolean = false;
    
      private var profileId           : UInt16  = 0x0104;  // HA Profile ID
      private var devId               : UInt16  = 0x0100;  // HA Profile ID
      private var endPoint            : Byte    = 0x07;    // SampleSW has endpoint 12 so we use that
      private var inClusterCnt        : Byte    = 5;
      private var outClusterCnt       : Byte    = 1;
      private var inClusterList = new Array(inClusterCnt);
      private var outClusterList = new Array(outClusterCnt);
    
      private var NV_STARTUP_OPTION     : Byte = 0x03;
      private var NV_STARTUP_OPTION_VAL : Byte = 0x03;	// 0x03 = clear configuration
      private var NV_STARTUP_LEN        : Byte = 1;
    
      private var cfgArr = new Array(256);        // Make big enough for any configuration item.
      private var retrieveBuf = new Array(1024);  // Make big enough for any huge message attempted.
      private var retrieveTot           : UInt16 = 741;
      private var retrieveLen           : Byte = 247;
      private var retrieveIdx           : UInt16;
      private var devaddr               : UInt16;
      private var dstEndPoint           : Byte    = 0x00;
    
      //DATA REQUEST VARIABLES
      private var drData = new Array(99);
      private var drCluster           : UInt16;
      private var drTrans          : Byte;
      private var drOption           : Byte;
      private var drRadius           : Byte = 0x1E;//AF_DEFAULT_RADIUS
      private var drLen           : Byte;
    
      //INCOMING MESSAGES VARIABLES
    
      private var imData = new Array(99);
      private var imGroup           : UInt16;
      private var imCluster           : UInt16;
      private var imSrcAddr           : UInt16;
      private var imSrcEndp           : Byte;
      private var imDstEndp           : Byte;
      private var imLen           : Byte;
    
    
    
      // Main class function that effects the work of this test script.
      function run() {
        //set up clusters for light
        inClusterList[0] = 0;
        inClusterList[1] = 3;
        inClusterList[2] = 4;
        inClusterList[3] = 5;
        inClusterList[4] = 6;
    
        outClusterList[0] = 0;
    
        // Subscribe to the incoming message handler.
        ZEngine.add_OnMessageZPI2(this.msgHandler);
    
        if (ZNP_RUN)
        {
          // Force a device out of the boot loader wait routine (no bad effect when SBL is not present).
          //sysReset(ZC_Com);
    
          // Set the Startup_Option to Clear Configuration and reset to effect the action.
          //cfgArr[0] = NV_STARTUP_OPTION_VAL;
          //writeCfg(ZC_Com , NV_STARTUP_OPTION, NV_STARTUP_LEN, cfgArr);
          //sysReset(ZC_Com);
    
          // Force a device out of the boot loader wait routine (no bad effect when SBL is not present).
          sysReset(ZC_Com);
    
          // Set the Startup_Option to Clear Configuration and reset to effect the action.
          cfgArr[0] = NV_STARTUP_OPTION_VAL;
          writeCfg(ZC_Com , NV_STARTUP_OPTION, NV_STARTUP_LEN, cfgArr);
          sysReset(ZC_Com);
    
          // Setup the device type, panId & channel mask and reset to effect the settings.
          cfgArr[0] = 0x00;                    // Set Logical Device Type to ZC.
          //writeCfg(ZC_Com, 0x87, 0x01, cfgArr);
          //cfgArr[0] = 0x01;                    // Set Logical Device Type to ZR.
          writeCfg(ZC_Com, 0x87, 0x01, cfgArr);
          cfgArr[0] = 0x22; cfgArr[1] = 0x06;  // Set Pan Id to 0x0622 // Change this to anything you need to test
          //writeCfg(ZC_Com, 0x83, 0x02, cfgArr);
          writeCfg(ZC_Com, 0x83, 0x02, cfgArr);
          cfgArr[0] = 0x00; cfgArr[1] = 0x08; cfgArr[2] = 0x00; cfgArr[3] = 0x00; //channel 11
                                             // Set Channel Mask to 0x00100000  // 20 - 0x14
    					 // Set Channel Maks to 0x00080000  // 19 - 0x13 - Current channel mask
          //writeCfg(ZC_Com, 0x84, 0x04, cfgArr);
          writeCfg(ZC_Com, 0x84, 0x04, cfgArr);
    	  cfgArr[0] = 0xAA; cfgArr[1] = 0xBB;
          //writeCfg(ZC_Com,0x62, 16, cfgArr); //program the NWK Key 1st two bytes are AA and BB
          // Start the devices on the network.
          //startReq(ZC_Com);
    
          cfgArr[0] = true;
          writeCfg(ZC_Com, 0x8F, 0x01, cfgArr);// Set ZCD_NV_ZDO_DIRECT_CB to true. ZCD_NV_ZDO_DIRECT_CB address = 0x8F
          afReg(ZC_Com); // define end point
          startReq(ZC_Com);
    
          while(1)
          {
              //wait for incoming messages
          }
    
    
        }
    
        ZEngine.Complete(true);
      }
    
    
      function setDataReq(mode : Byte) { // mode: 0 = switch, 1 = default response, 2 = read attribute, 3 = read attribute response
          if (mode == 0)//switch
          {
              drCluster = 0x6;
              drTrans = 0;
              drOption = 0x0;
              drLen = 3;
              drData[0] = 0x01;
              drData[1] = 0x00;
              drData[2] = 0x02;
          }
          else if (mode == 1)//default response
          {
              drCluster = imCluster;
              drTrans = 0;
              drOption = 0x0;
              drLen = 5;
              drData[0] = 0x18; //frame control
              drData[1] = 0x00; //transaction sequence number
              drData[2] = 0x0B; //default response
              drData[3] = imData[2]; //command ID
              drData[4] = 0x00; // status
          }
          else if (mode == 2)//read attribute from light
          {
              drCluster = 0x6;
              drTrans = 0;
              drOption = 0x0;
              drLen = 5;
              drData[0] = 0x00; //frame control
              drData[1] = 0x00; //transaction sequence number
              drData[2] = 0x00; //read attribute
              //attribute ID 16 bits
              drData[3] = 0x00; //attribute ID
              drData[4] = 0x00; // attribute ID
          }
          else if (mode == 3)//read attribute response light
          {
              drCluster = imCluster;
              drTrans = 0;
              drOption = 0x0;
              drLen = 8;
              drData[0] = 0x18; //frame control
              drData[1] = 0x00; //transaction sequence number
              drData[2] = 0x01; //read attribute response
              //attribute ID 16 bits
              drData[3] = imData[3]; //attribute ID
              drData[4] = imData[4]; // attribute ID
              drData[5] = 0x00; //status: success
              drData[6] = 0x20; //Data type: unsigned 8-bit integer
              var attID : UInt16 = (imData[4] << 8) | imData[3]; //attribute ID that will be read
              if(attID == 0)
              {
                drData[7] = lightStatus;
              }
          }
      }
    
    
    // Send a process incoming message.
      function pInMsg(comm : String) {
         if(imData[0] == 1)
         {
             if(imData[2] == 2)
             {
                 lightStatus = (~lightStatus) & 0x01; //toggle light
             }
             else if (imData[2] == 1)
             {
                 lightStatus = 0x01; // light ON
             }
             else if (imData[2] == 0)
             {
                 lightStatus = 0x00; //light OFF
             }
         }
        if ((imData[0] & 0x01) == 0 && imData[2] == 0)//read attribute
         {
             if (imData[0] == 0 && imData[2] == 0)
             {
                setDataReq(3);
                afDataReq(comm, imSrcAddr, imSrcEndp);//send read attribute response
             }
         }
         else if ((imData[0] & 0x10) == 0)//Default response active
         {
             setDataReq(1);
             afDataReq(comm, imSrcAddr, imSrcEndp);// send default response
         }
    
    
      }
    
    // Send a UTIL_GET_DEVICE_INFO message.
      function devInfo(comm : String) {
         var req : UTIL_GET_DEVICE_INFO  = new UTIL_GET_DEVICE_INFO ();
          gotDevRsp = false;
          while(!gotDevRsp)
          {
              logMsg("dev response");
              ZEngine.Send(comm, req);
              ZEngine.Pause(2000);
          }
      }
    
    // Send a ZDO_ACTIVE_EP_REQ message.
      function epReq(comm : String, dst : UInt16, aoi : UInt16) {
        var req : ZDO_ACTIVE_EP_REQ  = new ZDO_ACTIVE_EP_REQ ();
        req.DstAddr = dst;
        req.NWKAddrOfInterest = aoi;
        gotEpRsp = false;
        while(!gotEpRsp)
        {
            logMsg("ZDO_ACTIVE_EP_REQ to " + comm);
            ZEngine.Send(comm, req);
            ZEngine.Pause(1000);
        }
    
      }
    
    // Send a ZDO_SIMPLE_DESC_REQ message.
      function simDescReq(comm : String, dst : UInt16, aoi : UInt16, dstEp : Byte) {
        var req : ZDO_SIMPLE_DESC_REQ  = new ZDO_SIMPLE_DESC_REQ ();
        req.DstAddr = dst;
        req.NWKAddrOfInterest = aoi;
        req.Endpoint = dstEp;
        gotSdescRsp = false;
        isLight = false;
        while(!gotSdescRsp)
        {
          logMsg("ZDO_SIMPLE_DESC_REQ to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(1000);
        }
    
      }
    
      // Send a AF_DATA_REQUEST message.
      function afDataReq(comm : String, dst : UInt16, dstEp : Byte) {
        var req : AF_DATA_REQUEST  = new AF_DATA_REQUEST ();
        req.DstAddr = dst;
        req.DestEndpoint = dstEp;
        req.SrcEndpoint = endPoint;
        req.ClusterID = drCluster;
        req.TransID = drTrans;
        req.Options = drOption;
        req.Radius = drRadius;
        req.Len = drLen;
        for (var idx = 0; idx < drLen; idx++)
        {
              req.Data[idx] = drData[idx];
        }
        logMsg("AF_DATA_REQUEST to " + comm);
        ZEngine.Send(comm, req);
        ZEngine.Pause(1000);
    
      }
    
    
      // Handler for incoming messages.
      function msgHandler(comm : String, id : MESSAGE_ID, msg : Object) {
        switch (id)
        {
        case MESSAGE_ID.SYS_RESET_RESPONSE:
        {
          gotRstRsp = true;
          break;
        }
        case MESSAGE_ID.UTIL_GET_DEVICE_INFO_RESPONSE:
        {
            var devRsp : UTIL_GET_DEVICE_INFO_RESPONSE = msg;
            if (devRsp.Status == SUCCESS && devRsp.NumAssocDevices != 0)
            {
                gotDevRsp = true;
                devaddr = devRsp.AssocDevicesList[0];
            }
    
          break;
        }
        case MESSAGE_ID.ZDO_ACTIVE_EP_RSP:
        {
            var epRsp : ZDO_ACTIVE_EP_RSP = msg;
            if (epRsp.Status == SUCCESS && epRsp.ActiveEPCount != 0)
            {
                gotEpRsp=true;
                dstEndPoint = epRsp.ActiveEPList[0];
            }
    
    
          break;
        }
    
        case MESSAGE_ID.ZDO_SIMPLE_DESC_RSP: /*change*/
        {
            var smpdRsp : ZDO_SIMPLE_DESC_RSP = msg;
            if (smpdRsp.Status == SUCCESS && smpdRsp.ProfileID == HOMEAUT && smpdRsp.DeviceID == LIGHT)
            {
                gotSdescRsp = true;
                isLight = true;
            }
    
    
          break;
        }
    
        case MESSAGE_ID.ZB_WRITE_CONFIGURATION_RSP:
        {
          var cfgRsp : ZB_WRITE_CONFIGURATION_RSP = msg;
    
          if (cfgRsp.Status == SUCCESS)
          {
            gotCfgRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_REGISTER_SRSP:
        {
          var regRsp : AF_REGISTER_SRSP = msg;
    
          if (regRsp.Status == SUCCESS)
          {
            gotRegRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.ZB_START_REQUEST_RSP:
        {
          gotStartRsp = true;
          break;
        }
    
        case MESSAGE_ID.ZDO_STATE_CHANGE_IND:
        {
          var zdoStateInd : ZDO_STATE_CHANGE_IND = msg;
    
          // { DEV_END_DEVICE, DEV_ROUTER, DEV_ZB_COORD } : { 6, 7, 9 }
          if ((zdoStateInd.State == 6) || (zdoStateInd.State == 7) || (zdoStateInd.State == 9))
          {
            gotStateRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_DATA_REQUEST_EXT_SRSP:
        {
          var afRegExtRsp : AF_DATA_REQUEST_EXT_SRSP = msg;
    
          if (afRegExtRsp.Status == SUCCESS)
          {
            gotAfReqExtRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_DATA_STORE_SRSP:
        {
          var afStoreRsp : AF_DATA_STORE_SRSP = msg;
    
          if (afStoreRsp.Status == SUCCESS)
          {
            gotAfStoreRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_INCOMING_MSG_EXT:
        {
          var afIncExt : AF_INCOMING_MSG_EXT = msg;
          afDataRetrieve(comm, msg);
          gotAfIncExt = true;
          break;
        }
    
        case MESSAGE_ID.AF_INCOMING_MSG:
        {
          var inMsgDat : AF_INCOMING_MSG = msg;
          imGroup = inMsgDat.GroupID;
          imCluster = inMsgDat.ClusterID;
          imSrcAddr = inMsgDat.SrcAddr;
          imSrcEndp = inMsgDat.SrcEndpoint;
          imDstEndp = inMsgDat.DstEndpoint;
          imLen = inMsgDat.Len;
          for (var idx = 0; idx < imLen; idx++)
          {
              imData[idx] = inMsgDat.Data[idx];
          }
          pInMsg(comm);
    
          break;
        }
    
        case MESSAGE_ID.AF_DATA_RETRIEVE_SRSP:
        {
          var afRetrieveRsp : AF_DATA_RETRIEVE_SRSP = msg;
    
          if (afRetrieveRsp.Status == SUCCESS)
          {
            var index = retrieveIdx;
    
            for (var idx = 0; idx < afRetrieveRsp.Length; idx++, index++)
            {
              retrieveBuf[index] = afRetrieveRsp.Data[idx];
            }
    
            gotAfRetrieveRsp = true;
          }
          break;
        }
    
        default:
          break;
        }
      }
    
    
      // Send a ZB_SYSTEM_RESET message until success.
      function sysReset(comm : String) {
        var req : ZB_SYSTEM_RESET = new ZB_SYSTEM_RESET();
        gotRstRsp = false;
    
        while (!gotRstRsp)
        {
          logMsg("ZB_SYSTEM_RESET  to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(50);
    
          // Sending SYS_STACK_TUNE as a way to get a 0x07 byte to the SBL before a 0xF8 byte.
          // An 0x07 byte forces the immediate run of valid code.
          //sysStackTune(comm, 7, 7);
          //ZEngine.Pause(300);
        }
      }
    
    
      // Send a SYS_STACK_TUNE message.
      function sysStackTune(comm : String, Operation: Byte, Value: Byte) {
        var req : SYS_STACK_TUNE = new SYS_STACK_TUNE();
        req.Operation = Operation;
        req.Value = Value;
    
        logMsg("SYS_STACK_TUNE to " + comm);
        ZEngine.Send(comm, req);
      }
    
    
      // Send a ZB_WRITE_CONFIGURATION message.
      function writeCfg(comm : String, cfgId : Byte, len : Byte,  value : Array ) {
        var req : ZB_WRITE_CONFIGURATION = new ZB_WRITE_CONFIGURATION();
        req.ConfigId = cfgId;
        req.Len = len;
    		req.Value = new byte[len];
    
        for (var idx = 0; idx < len; idx++)
        {
          req.Value[idx] = value[idx];
        }
    
        gotCfgRsp = false;
        while (!gotCfgRsp)
        {
          logMsg("ZB_WRITE_CONFIGURATION  to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(200);
        }
      }
    
    
      // Send a ZB_AF_REGISTER_REQUEST message.
      function afReg(comm : String) {
        var req : AF_REGISTER  = new AF_REGISTER ();
        req.AppProfID = profileId;
        req.AppDeviceId = devId;
        req.EndPoint = endPoint;
        req.AppInClusterList = inClusterList;
        req.AppNumInClusters = inClusterCnt;
        req.AppOutClusterList = outClusterList;
        req.AppNumOutClusters = outClusterCnt;
    
        gotRegRsp = false;
        while (!gotRegRsp)
        {
          logMsg("ZB_AF_REGISTER_REQUEST to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(200);
        }
      }
    
    
      // Send a ZB_START_REQUEST message.
      function startReq(comm : String) {
        var req : ZB_START_REQUEST  = new ZB_START_REQUEST();
    
        gotStateRsp = false;
        while (!gotStateRsp)
        {
          gotStartRsp = false;
          while (!gotStartRsp)
          {
            logMsg("ZB_START_REQUEST  to " + comm);
            ZEngine.Send(comm, req);
            ZEngine.Pause(1000);
          }
          ZEngine.Pause(5000);
        }
      }
    
    
      /* Make a huge data request via an AF_DATA_REQUEST_EXT message and store the huge data.
       * Since the max MT payload is 250 & the store message header is 3, the max bytes per store
       * is 247. So to simplify the script just use 3 X 247 = 741.
       * Note that we are simultaneously proving the max capacity of 250 bytes per MT message here.
       */
      function afDataReqFrag(comm : String) {
        var req : AF_DATA_REQUEST_EXT = new AF_DATA_REQUEST_EXT();
    
        req.DstAddrMode = 2;  // Addr16Bit = 2
        req.DstAddr[0] = 0; req.DstAddr[1] = 0;  // Short address 0x0000 is for ZC.
        req.DstEndPoint = endPoint;
        req.DstPanId = 0;  // Zero signifies not Inter-PAN.
        req.SrcEndpoint = endPoint;
        req.ClusterID = 1;  // Startup initialization makes cluster Id's 1,2,3... up to count.
        req.TransID = 0;  // Trans Id is a don't care.
        req.Options = 0;  // AF_TX_OPTIONS_NONE = 0
        req.Radius = 15;  // AF_DEFAULT_RADIUS = 15
        req.Len = retrieveTot;
    
        gotAfReqExtRsp = false;
        while (!gotAfReqExtRsp)
        {
          logMsg("AF_DATA_REQUEST_EXT to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(3000);
        }
    
        var index : UInt16 = 0;
        var fragLen : Byte = retrieveLen;
        var fragBuf : Byte[] = new Byte[fragLen];
        for (var idx = 0; idx < fragLen; idx++)
        {
          fragBuf[idx] = idx;
        }
        afDataStore(comm, index, fragLen, fragBuf);
        index += fragLen;
    
        // Change the frag data to enhance verification reliability on Rx.
        for (idx = 0; idx < fragLen; idx++)
        {
          fragBuf[idx]++;
        }
        afDataStore(comm, index, fragLen, fragBuf);
        index += fragLen;
    
        // Change the frag data again to enhance verification reliability on Rx.
        for (idx = 0; idx < fragLen; idx++)
        {
          // Without a type-cast, the script promotes fragBuf[] to int at run-time.
          fragBuf[idx] = (Byte)(idx * 2);
        }
        afDataStore(comm, index, fragLen, fragBuf);
    
        // A store of zero length indicates to send it OTA.
        afDataStore(comm, 0, 0, fragBuf);
      }
    
    
      // Send a AF_DATA_STORE message.
      function afDataStore(comm : String, index : UInt16, len : Byte, buf : Byte[]) {
        var req : AF_DATA_STORE = new AF_DATA_STORE();
    
        req.Index = index;
        req.Length = len;
    
        for (var idx = 0; idx < len; idx++)
        {
          req.Data[idx] = buf[idx];
        }
    
        gotAfStoreRsp = false;
        while (!gotAfStoreRsp)
        {
          logMsg("AF_DATA_STORE to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(100);
        }
      }
    
    
      // Send a series of AF_DATA_RETRIEVE message(s) to get the data of an incoming huge message.
      function afDataRetrieve(comm : String, msgIn : AF_INCOMING_MSG_EXT) {
        var req : AF_DATA_RETRIEVE = new AF_DATA_RETRIEVE();
    
        req.Timestamp = msgIn.Timestamp;
        req.Length = retrieveLen;
    
        for (retrieveIdx = 0; retrieveIdx < msgIn.Len; retrieveIdx += retrieveLen)
        {
          req.Index = retrieveIdx;
    
          gotAfRetrieveRsp = false;
          while (!gotAfRetrieveRsp)
          {
            logMsg("AF_DATA_RETRIEVE to " + comm);
            ZEngine.Send(comm, req);
            ZEngine.Pause(100);
          }
        }
    
        /* Retrieve request with zero length indicates to flush the message and free the dynamic
         * memory. If this request fails, the device times out the incoming huge message buffer and
         * flushes it automatically, so no loop here.
         */
        req.Length = 0;
        logMsg("AF_DATA_RETRIEVE to " + comm);
        ZEngine.Send(comm, req);
        ZEngine.Pause(100);
      }
    
    
      // Verify the data in the global retrieveBuf[] according to what was sent in afDataReqFrag().
      function verifyMsgIn() : boolean {
        /* At first writing of this script, the afDataReqFrag() sent 741 bytes.
         * The first 247 bytes were 0-247; the next 247 bytes were 1-248; and the last 247 bytes were
         * calculated as twice the corresponding index.
         */
        var index = 0;
    
        for (var idx = 0; idx < retrieveLen; idx++, index++)
        {
          if (retrieveBuf[index] != idx)
          {
            break;
          }
        }
    
        for (var idx = 1; idx <= retrieveLen; idx++, index++)
        {
          if (retrieveBuf[index] != idx)
          {
            break;
          }
        }
    
        for (var idx = 0; idx < retrieveLen; idx++, index++)
        {
          if (retrieveBuf[index] != (Byte)(idx * 2))
          {
            break;
          }
        }
    
        if (index < retrieveTot)
        {
          return false;
        }
        else
        {
          return true;
        }
      }
    
    
      // Display a log message if log messages are enabled.
      function logMsg(theMsg : String) {
        if (showLogMsgs)
        {
          ZEngine.WriteLog(theMsg);  // Display the message.
        }
      }
    } // End of TheScript class.
    
    
    // The script engine will execute the following code.
    var script:TheScript = new TheScript();
    script.run();
    
    
    /**************************************************************************************************
    */
    

    End device Script file:

    znp-bringupR.txt
    /**************************************************************************************************
      Filename:       znp-bringup.zjs
      Revised:        $Date:$
      Revision:       $Revision:$
    
      Description:    This file is a test script bring up ZC and ZR.
    
    
      Copyright 2010 Texas Instruments Incorporated. All rights reserved.
    
      IMPORTANT: Your use of this Software is limited to those specific rights
      granted under the terms of a software license agreement between the user
      who downloaded the software, his/her employer (which must be your employer)
      and Texas Instruments Incorporated (the "License").  You may not use this
      Software unless you agree to abide by the terms of the License. The License
      limits your use, and you acknowledge, that the Software may not be modified,
      copied or distributed unless embedded on a Texas Instruments microcontroller
      or used solely and exclusively in conjunction with a Texas Instruments radio
      frequency transceiver, which is integrated into your product.  Other than for
      the foregoing purpose, you may not use, reproduce, copy, prepare derivative
      works of, modify, distribute, perform, display or sell this Software and/or
      its documentation for any purpose.
    
      YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
      PROVIDED �AS IS� WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
      INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
      NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
      TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
      NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
      LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
      INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
      OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
      OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
      (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    
      Should you have any questions regarding your right to use this Software,
      contact Texas Instruments Incorporated at www.TI.com.
    **************************************************************************************************/
    
    
    /**************************************************************************************************
      Instructions:
    
      Connect a device to be a ZC to a COM nicknamed �C� and another to a COM named �R�
    
    **************************************************************************************************/
    import System;
    import System.Text;
    import TI.ZPI2;
    
    class TheScript
    {
      // Set to 'true' when running the ZNP in order to reset the devices and startup the network.
      private var ZNP_RUN : boolean = true;
      private var SUCCESS : int = 0;
    
      // Set this variable to the script engine's nickname for the COM port to the target device.
      private var ZR_Com : String = "COM15";
      private var ZC_Com : String = "COM3";
    
      // Set this variable to 'true' to enable the display of log messages (i.e. verbose mode).
      private var showLogMsgs : boolean = true;
    
      // Variables set by the incoming message handler to enable "re-try until success" looping.
      private var gotRstRsp           : boolean = false;
      private var gotCfgRsp           : boolean = false;
      private var gotRegRsp           : boolean = false;
      private var gotStartRsp         : boolean = false;
      private var gotStateRsp         : boolean = false;
      private var gotAfReqExtRsp      : boolean = false;
      private var gotAfIncExt         : boolean = false;
      private var gotAfStoreRsp       : boolean = false;
      private var gotAfRetrieveRsp    : boolean = false;
    
      private var profileId           : UInt16  = 0x0104;  // HA Profile ID
      private var endPoint            : Byte    = 0x0C;    // SampleSW has endpoint 12 so we use that
      private var inClusterCnt        : Byte    = 1;
      private var outClusterCnt       : Byte    = 1;
      private var inClusterList = new Array(inClusterCnt);
      private var outClusterList = new Array(outClusterCnt);
    
      private var NV_STARTUP_OPTION     : Byte = 0x03;
      private var NV_STARTUP_OPTION_VAL : Byte = 0x03;	// 0x03 = clear configuration
      private var NV_STARTUP_LEN        : Byte = 1;
    
      private var cfgArr = new Array(256);        // Make big enough for any configuration item.
      private var retrieveBuf = new Array(1024);  // Make big enough for any huge message attempted.
      private var retrieveTot           : UInt16 = 741;
      private var retrieveLen           : Byte = 247;
      private var retrieveIdx           : UInt16;
    
      // Main class function that effects the work of this test script.
      function run() {
        for (var idx = 1; idx <= inClusterCnt; idx++)
        {
          inClusterList[idx] = idx;
        }
        for (var idx = 1; idx <= outClusterCnt; idx++)
        {
          outClusterList[idx] = idx;
        }
    
        // Subscribe to the incoming message handler.
        ZEngine.add_OnMessageZPI2(this.msgHandler);
    
        if (ZNP_RUN)
        {
          // Force a device out of the boot loader wait routine (no bad effect when SBL is not present).
          //sysReset(ZC_Com);
    
          // Set the Startup_Option to Clear Configuration and reset to effect the action.
          //cfgArr[0] = NV_STARTUP_OPTION_VAL;
          //writeCfg(ZC_Com , NV_STARTUP_OPTION, NV_STARTUP_LEN, cfgArr);
          //sysReset(ZC_Com);
    
          // Force a device out of the boot loader wait routine (no bad effect when SBL is not present).
          sysReset(ZR_Com);
    
          // Set the Startup_Option to Clear Configuration and reset to effect the action.
          cfgArr[0] = NV_STARTUP_OPTION_VAL;
          writeCfg(ZR_Com , NV_STARTUP_OPTION, NV_STARTUP_LEN, cfgArr);
          sysReset(ZR_Com);
    
          // Setup the device type, panId & channel mask and reset to effect the settings.
          cfgArr[0] = 0x00;                    // Set Logical Device Type to ZC.
          //writeCfg(ZC_Com, 0x87, 0x01, cfgArr);
          cfgArr[0] = 0x01;                    // Set Logical Device Type to ZR.
          writeCfg(ZR_Com, 0x87, 0x01, cfgArr);
          cfgArr[0] = 0x22; cfgArr[1] = 0x06;  // Set Pan Id to 0x0622 // Change this to anything you need to test
          //writeCfg(ZC_Com, 0x83, 0x02, cfgArr);
          writeCfg(ZR_Com, 0x83, 0x02, cfgArr);
          cfgArr[0] = 0x00; cfgArr[1] = 0x00; cfgArr[2] = 0x08; cfgArr[3] = 0x00;
                                             // Set Channel Mask to 0x00100000  // 20 - 0x14
    					 // Set Channel Maks to 0x00080000  // 19 - 0x13 - Current channel mask
          //writeCfg(ZC_Com, 0x84, 0x04, cfgArr);
          writeCfg(ZR_Com, 0x84, 0x04, cfgArr);
    	  cfgArr[0] = 0xAA; cfgArr[1] = 0xBB;
          //writeCfg(ZC_Com,0x62, 16, cfgArr); //program the NWK Key 1st two bytes are AA and BB
          // Start the devices on the network.
          //startReq(ZC_Com);
          startReq(ZR_Com);
        }
    
        ZEngine.Complete(true);
      }
    
    
      // Handler for incoming messages.
      function msgHandler(comm : String, id : MESSAGE_ID, msg : Object) {
        switch (id)
        {
        case MESSAGE_ID.SYS_RESET_RESPONSE:
        {
          gotRstRsp = true;
          break;
        }
    
        case MESSAGE_ID.ZB_WRITE_CONFIGURATION_RSP:
        {
          var cfgRsp : ZB_WRITE_CONFIGURATION_RSP = msg;
    
          if (cfgRsp.Status == SUCCESS)
          {
            gotCfgRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_REGISTER_SRSP:
        {
          var regRsp : AF_REGISTER_SRSP = msg;
    
          if (regRsp.Status == SUCCESS)
          {
            gotRegRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.ZB_START_REQUEST_RSP:
        {
          gotStartRsp = true;
          break;
        }
    
        case MESSAGE_ID.ZDO_STATE_CHANGE_IND:
        {
          var zdoStateInd : ZDO_STATE_CHANGE_IND = msg;
    
          // { DEV_END_DEVICE, DEV_ROUTER, DEV_ZB_COORD } : { 6, 7, 9 }
          if ((zdoStateInd.State == 6) || (zdoStateInd.State == 7) || (zdoStateInd.State == 9))
          {
            gotStateRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_DATA_REQUEST_EXT_SRSP:
        {
          var afRegExtRsp : AF_DATA_REQUEST_EXT_SRSP = msg;
    
          if (afRegExtRsp.Status == SUCCESS)
          {
            gotAfReqExtRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_DATA_STORE_SRSP:
        {
          var afStoreRsp : AF_DATA_STORE_SRSP = msg;
    
          if (afStoreRsp.Status == SUCCESS)
          {
            gotAfStoreRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_INCOMING_MSG_EXT:
        {
          var afIncExt : AF_INCOMING_MSG_EXT = msg;
          afDataRetrieve(comm, msg);
          gotAfIncExt = true;
          break;
        }
    
        case MESSAGE_ID.AF_DATA_RETRIEVE_SRSP:
        {
          var afRetrieveRsp : AF_DATA_RETRIEVE_SRSP = msg;
    
          if (afRetrieveRsp.Status == SUCCESS)
          {
            var index = retrieveIdx;
    
            for (var idx = 0; idx < afRetrieveRsp.Length; idx++, index++)
            {
              retrieveBuf[index] = afRetrieveRsp.Data[idx];
            }
    
            gotAfRetrieveRsp = true;
          }
          break;
        }
    
        default:
          break;
        }
      }
    
    
      // Send a ZB_SYSTEM_RESET message until success.
      function sysReset(comm : String) {
        var req : ZB_SYSTEM_RESET = new ZB_SYSTEM_RESET();
        gotRstRsp = false;
    
        while (!gotRstRsp)
        {
          logMsg("ZB_SYSTEM_RESET  to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(50);
    
          // Sending SYS_STACK_TUNE as a way to get a 0x07 byte to the SBL before a 0xF8 byte.
          // An 0x07 byte forces the immediate run of valid code.
          //sysStackTune(comm, 7, 7);
          //ZEngine.Pause(300);
        }
      }
    
    
      // Send a SYS_STACK_TUNE message.
      function sysStackTune(comm : String, Operation: Byte, Value: Byte) {
        var req : SYS_STACK_TUNE = new SYS_STACK_TUNE();
        req.Operation = Operation;
        req.Value = Value;
    
        logMsg("SYS_STACK_TUNE to " + comm);
        ZEngine.Send(comm, req);
      }
    
    
      // Send a ZB_WRITE_CONFIGURATION message.
      function writeCfg(comm : String, cfgId : Byte, len : Byte,  value : Array ) {
        var req : ZB_WRITE_CONFIGURATION = new ZB_WRITE_CONFIGURATION();
        req.ConfigId = cfgId;
        req.Len = len;
    		req.Value = new byte[len];
    
        for (var idx = 0; idx < len; idx++)
        {
          req.Value[idx] = value[idx];
        }
    
        gotCfgRsp = false;
        while (!gotCfgRsp)
        {
          logMsg("ZB_WRITE_CONFIGURATION  to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(200);
        }
      }
    
    
      // Send a ZB_AF_REGISTER_REQUEST message.
      function afReg(comm : String) {
        var req : AF_REGISTER  = new AF_REGISTER ();
        req.AppProfID = profileId;
        req.EndPoint = endPoint;
        req.AppInClusterList = inClusterList;
        req.AppNumInClusters = inClusterCnt;
        req.AppOutClusterList = outClusterList;
        req.AppNumOutClusters = outClusterCnt;
    
        gotRegRsp = false;
        while (!gotRegRsp)
        {
          logMsg("ZB_AF_REGISTER_REQUEST to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(200);
        }
      }
    
    
      // Send a ZB_START_REQUEST message.
      function startReq(comm : String) {
        var req : ZB_START_REQUEST  = new ZB_START_REQUEST();
    
        gotStateRsp = false;
        while (!gotStateRsp)
        {
          gotStartRsp = false;
          while (!gotStartRsp)
          {
            logMsg("ZB_START_REQUEST  to " + comm);
            ZEngine.Send(comm, req);
            ZEngine.Pause(1000);
          }
          ZEngine.Pause(5000);
        }
      }
    
    
      /* Make a huge data request via an AF_DATA_REQUEST_EXT message and store the huge data.
       * Since the max MT payload is 250 & the store message header is 3, the max bytes per store
       * is 247. So to simplify the script just use 3 X 247 = 741.
       * Note that we are simultaneously proving the max capacity of 250 bytes per MT message here.
       */
      function afDataReqFrag(comm : String) {
        var req : AF_DATA_REQUEST_EXT = new AF_DATA_REQUEST_EXT();
    
        req.DstAddrMode = 2;  // Addr16Bit = 2
        req.DstAddr[0] = 0; req.DstAddr[1] = 0;  // Short address 0x0000 is for ZC.
        req.DstEndPoint = endPoint;
        req.DstPanId = 0;  // Zero signifies not Inter-PAN.
        req.SrcEndpoint = endPoint;
        req.ClusterID = 1;  // Startup initialization makes cluster Id's 1,2,3... up to count.
        req.TransID = 0;  // Trans Id is a don't care.
        req.Options = 0;  // AF_TX_OPTIONS_NONE = 0
        req.Radius = 15;  // AF_DEFAULT_RADIUS = 15
        req.Len = retrieveTot;
    
        gotAfReqExtRsp = false;
        while (!gotAfReqExtRsp)
        {
          logMsg("AF_DATA_REQUEST_EXT to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(3000);
        }
    
        var index : UInt16 = 0;
        var fragLen : Byte = retrieveLen;
        var fragBuf : Byte[] = new Byte[fragLen];
        for (var idx = 0; idx < fragLen; idx++)
        {
          fragBuf[idx] = idx;
        }
        afDataStore(comm, index, fragLen, fragBuf);
        index += fragLen;
    
        // Change the frag data to enhance verification reliability on Rx.
        for (idx = 0; idx < fragLen; idx++)
        {
          fragBuf[idx]++;
        }
        afDataStore(comm, index, fragLen, fragBuf);
        index += fragLen;
    
        // Change the frag data again to enhance verification reliability on Rx.
        for (idx = 0; idx < fragLen; idx++)
        {
          // Without a type-cast, the script promotes fragBuf[] to int at run-time.
          fragBuf[idx] = (Byte)(idx * 2);
        }
        afDataStore(comm, index, fragLen, fragBuf);
    
        // A store of zero length indicates to send it OTA.
        afDataStore(comm, 0, 0, fragBuf);
      }
    
    
      // Send a AF_DATA_STORE message.
      function afDataStore(comm : String, index : UInt16, len : Byte, buf : Byte[]) {
        var req : AF_DATA_STORE = new AF_DATA_STORE();
    
        req.Index = index;
        req.Length = len;
    
        for (var idx = 0; idx < len; idx++)
        {
          req.Data[idx] = buf[idx];
        }
    
        gotAfStoreRsp = false;
        while (!gotAfStoreRsp)
        {
          logMsg("AF_DATA_STORE to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(100);
        }
      }
    
    
      // Send a series of AF_DATA_RETRIEVE message(s) to get the data of an incoming huge message.
      function afDataRetrieve(comm : String, msgIn : AF_INCOMING_MSG_EXT) {
        var req : AF_DATA_RETRIEVE = new AF_DATA_RETRIEVE();
    
        req.Timestamp = msgIn.Timestamp;
        req.Length = retrieveLen;
    
        for (retrieveIdx = 0; retrieveIdx < msgIn.Len; retrieveIdx += retrieveLen)
        {
          req.Index = retrieveIdx;
    
          gotAfRetrieveRsp = false;
          while (!gotAfRetrieveRsp)
          {
            logMsg("AF_DATA_RETRIEVE to " + comm);
            ZEngine.Send(comm, req);
            ZEngine.Pause(100);
          }
        }
    
        /* Retrieve request with zero length indicates to flush the message and free the dynamic
         * memory. If this request fails, the device times out the incoming huge message buffer and
         * flushes it automatically, so no loop here.
         */
        req.Length = 0;
        logMsg("AF_DATA_RETRIEVE to " + comm);
        ZEngine.Send(comm, req);
        ZEngine.Pause(100);
      }
    
    
      // Verify the data in the global retrieveBuf[] according to what was sent in afDataReqFrag().
      function verifyMsgIn() : boolean {
        /* At first writing of this script, the afDataReqFrag() sent 741 bytes.
         * The first 247 bytes were 0-247; the next 247 bytes were 1-248; and the last 247 bytes were
         * calculated as twice the corresponding index.
         */
        var index = 0;
    
        for (var idx = 0; idx < retrieveLen; idx++, index++)
        {
          if (retrieveBuf[index] != idx)
          {
            break;
          }
        }
    
        for (var idx = 1; idx <= retrieveLen; idx++, index++)
        {
          if (retrieveBuf[index] != idx)
          {
            break;
          }
        }
    
        for (var idx = 0; idx < retrieveLen; idx++, index++)
        {
          if (retrieveBuf[index] != (Byte)(idx * 2))
          {
            break;
          }
        }
    
        if (index < retrieveTot)
        {
          return false;
        }
        else
        {
          return true;
        }
      }
    
    
      // Display a log message if log messages are enabled.
      function logMsg(theMsg : String) {
        if (showLogMsgs)
        {
          ZEngine.WriteLog(theMsg);  // Display the message.
        }
      }
    } // End of TheScript class.
    
    
    // The script engine will execute the following code.
    var script:TheScript = new TheScript();
    script.run();
    
    
    /**************************************************************************************************
    */
    

    In that configuration files where i have to set channels and device type. I mean 0=Coordinator, 1=Router, 2=End device.

    Thanks and Regards,

    Amar.

  • Try to search “Set Channel Mask” in two scripts and I see you use different channel mask for Coordinator and end device in your scripts.
  • Thank you for suggestions Chen,

    I tried DarkSide's Script files for setup coordinator and end device. I had successfully setup coordinator and router by using DarkSide's Script files.7360.ZNP_script_example.7z

    But here I have to setup device as a end device instead of router. In DarkSide script files where i have to setup end device instead of a router.

    When I enabled permit join request at coordinator side, got log files in coordinator.

    I didn't get ZDO_END_DEVICE_ANNCE_IND in coordinator side.

    Thanks and Regards,

    Amar.

  • Do you use sniffer to check what happens over the air?
  • I am working on that. Here don't have a idea about how to use packet sniffer tool.
    Please can you provide steps for how to deal with packet sniffer tool.
  • Chen,

    I tried ubiqua packet analyzer sniffer tool. I got No packets captured in ubiqua software.

  • Chen,

    I have been setup coordinator channel mask to end device. Now it is working. I got response as you shared the link.

    Next step is how to transmit a data from coordinator to end device. And end device to coordinator.

    Thanks and Regards,

    Amar.

  • Do you sniff the same channel as coordinator and your end device?
  • In my case set channel mask in both devices.

    cfgArr[0] = 0x00; cfgArr[1] = 0x08; cfgArr[2] = 0x00; cfgArr[3] = 0x00;//channel 11

    // Set Channel Mask to 0x00100000 // 20 - 0x14

    // Set Channel Maks to 0x00080000 // 19 - 0x13 - Current channel mask


    After setting channel mask in both devices, got response in coordinator side.

    In ubiqua software channel mask:

  • I think you should select channel 11 in your Ubiqua.
  • Chen,

    I got some info in ubiqua.

    I successfully setup and coordinator and end device.Below shown.

    Now I have to transmit the data between two devices.

    How to do data transmission?

    Thanks and Regards,

    Amar.

  • You can use AF_DATA_REQUEST to send message.
  • Chen,

    how to check the end device joining in network or not.

    how to use AF_DATA_REQUEST in coordinator side. Which values i have to fill in AF_DATA_REQUEST.

  • Please read Z-Stack Monitor and Test API.pdf in Z-Stack documents folder.
  • According to Z-Stack monitor and test api.pdf. I had setup values in AF_DATA_REQUEST in coordinator below shown.

  • Does your coordinator and end device use 1 as endpoint?
  • I just tried AF_DATA_REQUEST in coordinator side. I had followed AF_DATA_REQUEST section in Z-Stack Monitor and test_api.pdf file. 

    Where i have to check coordinator and end device endpoint.

  • In you Ztool scripts.
  • If you use TheDarkSide's scripts and don't change endpoint, you should set them to 0x0C.
  • Yes..I used DarkSide Script files.I have been used only for end device setup. For coordinator I used as you shared in this link.

    I gone through script files if i set the same endpoint in both scripts file. The coordinator send and receive the data in coordinator itself.

    <TX>03:24:05.08 COM16 AF_DATA_REQUEST (0x2401)
    DstAddr: 0x0000
    DestEndpoint: 0x07
    SrcEndpoint: 0x07
    ClusterID: 0x0002
    TransID: 0x01
    Options: 0x01
    Radius: 0x01
    Len: 0x01
    Data: . (0x08)

    <RX>03:24:05.08 COM16 AF_DATA_REQUEST_SRSP (0x6401)
    Status: afStatus_SUCCESS (0x0)

    <RX>03:24:05.09 COM16 AF_DATA_CONFIRM (0x4480)
    Status: afStatus_SUCCESS (0x0)
    Endpoint: 0x07
    TransID: 0x01

    <RX>03:24:05.09 COM16 AF_INCOMING_MSG (0x4481)
    GroupID: 0x0000
    ClusterID: 0x0002
    SrcAddr: 0x0000
    SrcEndpoint: 0x07
    DstEndpoint: 0x07
    WasBroadcast: 0x00
    LinkQuality: 0xFF
    SecurityUse: 0x00
    Timestamp: 0x00000000
    TransSeqNumber: 0x00
    Len: 0x01
    Data: . (0x08)

    Here What  value i have to give DstAddr in AF_DATA_REQUEST at coordinator.

    How to check the devices are being in network or not?

  • The dstAddr of coordinator should be 0x0000.
  • I tried dstAddr 0x0000 in coordinator. When I send AF_DATA_REQUEST  from coodinator side, got below log files.

    <TX>03:47:37.41 COM16 AF_DATA_REQUEST (0x2401)
    DstAddr: 0x0000
    DestEndpoint: 0x0C
    SrcEndpoint: 0x07
    ClusterID: 0x0002
    TransID: 0x01
    Options: 0x01
    Radius: 0x01
    Len: 0x01
    Data: . (0x08)

    <RX>03:47:37.41 COM16 AF_DATA_REQUEST_SRSP (0x6401)
    Status: afStatus_SUCCESS (0x0)

    <RX>03:47:37.41 COM16 AF_DATA_CONFIRM (0x4480)
    Status: afStatus_SUCCESS (0x0)
    Endpoint: 0x07
    TransID: 0x01


    The end device not getting incoming message from coordinator.

    Here 0x0C is end device endpoint and 0x07 coordinator endpoint.

  • If you want to send message from coordinator to device, dstAddr should be short address of device.
  • I tried end device dstAddr for sending msg from coordinator to end device.When I send AF_DATA_REQUEST from coordinator side, got below log files.

    At end device side not showing incoming msg.

  • Are you sure your end device endpoint is 0x0C not 0x07?
  • Yeah sure...I didn't change endpoint in end device.

    Coordinator script file: 

    coordinator.txt
    /**************************************************************************************************
      Filename:       znp-bringup.zjs
      Revised:        $Date:$
      Revision:       $Revision:$
    
      Description:    This file is a test script bring up ZC and ZR.
    
    
      Copyright 2010 Texas Instruments Incorporated. All rights reserved.
    
      IMPORTANT: Your use of this Software is limited to those specific rights
      granted under the terms of a software license agreement between the user
      who downloaded the software, his/her employer (which must be your employer)
      and Texas Instruments Incorporated (the "License").  You may not use this
      Software unless you agree to abide by the terms of the License. The License
      limits your use, and you acknowledge, that the Software may not be modified,
      copied or distributed unless embedded on a Texas Instruments microcontroller
      or used solely and exclusively in conjunction with a Texas Instruments radio
      frequency transceiver, which is integrated into your product.  Other than for
      the foregoing purpose, you may not use, reproduce, copy, prepare derivative
      works of, modify, distribute, perform, display or sell this Software and/or
      its documentation for any purpose.
    
      YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
      PROVIDED �AS IS� WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
      INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
      NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
      TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
      NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
      LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
      INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
      OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
      OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
      (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    
      Should you have any questions regarding your right to use this Software,
      contact Texas Instruments Incorporated at www.TI.com.
    **************************************************************************************************/
    
    
    /**************************************************************************************************
      Instructions:
    
      Connect a device to be a ZC to a COM nicknamed �C� and another to a COM named �R�
    
    **************************************************************************************************/
    import System;
    import System.Text;
    import TI.ZPI2;
    
    class TheScript
    {
      // Set to 'true' when running the ZNP in order to reset the devices and startup the network.
      private var ZNP_RUN : boolean = true;
      private var SUCCESS : int = 0;
      private var HOMEAUT : int = 0x0104;
      private var LIGHT   : int = 0x0100;
      private var AF_DEFAULT_RADIUS : int = 0x1E;
    
      // Set this variable to the script engine's nickname for the COM port to the target device.
      private var ZR_Com : String = "COM3";
      private var ZC_Com : String = "COM16";
    
      // Set this variable to 'true' to enable the display of log messages (i.e. verbose mode).
      private var showLogMsgs : boolean = true;
    
      // Variables set by the incoming message handler to enable "re-try until success" looping.
      private var gotRstRsp           : boolean = false;
      private var gotCfgRsp           : boolean = false;
      private var gotRegRsp           : boolean = false;
      private var gotStartRsp         : boolean = false;
      private var gotStateRsp         : boolean = false;
      private var gotAfReqExtRsp      : boolean = false;
      private var gotAfIncExt         : boolean = false;
      private var gotAfStoreRsp       : boolean = false;
      private var gotAfRetrieveRsp    : boolean = false;
      private var gotDevRsp           : boolean = false;
      private var gotEpRsp            : boolean = false;
      private var gotSdescRsp         : boolean = false;
      private var gotTogRsp         : boolean = false;
    
      private var isLight             : boolean = false;
      private var lightStatus             : boolean = false;
    
      private var profileId           : UInt16  = 0x0104;  // HA Profile ID
      private var devId               : UInt16  = 0x0100;  // HA Profile ID
      private var endPoint            : Byte    = 0x07;    // SampleSW has endpoint 12 so we use that
      private var inClusterCnt        : Byte    = 5;
      private var outClusterCnt       : Byte    = 1;
      private var inClusterList = new Array(inClusterCnt);
      private var outClusterList = new Array(outClusterCnt);
    
      private var NV_STARTUP_OPTION     : Byte = 0x03;
      private var NV_STARTUP_OPTION_VAL : Byte = 0x03;	// 0x03 = clear configuration
      private var NV_STARTUP_LEN        : Byte = 1;
    
      private var cfgArr = new Array(256);        // Make big enough for any configuration item.
      private var retrieveBuf = new Array(1024);  // Make big enough for any huge message attempted.
      private var retrieveTot           : UInt16 = 741;
      private var retrieveLen           : Byte = 247;
      private var retrieveIdx           : UInt16;
      private var devaddr               : UInt16;
      private var dstEndPoint           : Byte    = 0x00;
    
      //DATA REQUEST VARIABLES
      private var drData = new Array(99);
      private var drCluster           : UInt16;
      private var drTrans          : Byte;
      private var drOption           : Byte;
      private var drRadius           : Byte = 0x1E;//AF_DEFAULT_RADIUS
      private var drLen           : Byte;
    
      //INCOMING MESSAGES VARIABLES
    
      private var imData = new Array(99);
      private var imGroup           : UInt16;
      private var imCluster           : UInt16;
      private var imSrcAddr           : UInt16;
      private var imSrcEndp           : Byte;
      private var imDstEndp           : Byte;
      private var imLen           : Byte;
    
    
    
      // Main class function that effects the work of this test script.
      function run() {
        //set up clusters for light
        inClusterList[0] = 0;
        inClusterList[1] = 3;
        inClusterList[2] = 4;
        inClusterList[3] = 5;
        inClusterList[4] = 6;
    
        outClusterList[0] = 0;
    
        // Subscribe to the incoming message handler.
        ZEngine.add_OnMessageZPI2(this.msgHandler);
    
        if (ZNP_RUN)
        {
          // Force a device out of the boot loader wait routine (no bad effect when SBL is not present).
          //sysReset(ZC_Com);
    
          // Set the Startup_Option to Clear Configuration and reset to effect the action.
          //cfgArr[0] = NV_STARTUP_OPTION_VAL;
          //writeCfg(ZC_Com , NV_STARTUP_OPTION, NV_STARTUP_LEN, cfgArr);
          //sysReset(ZC_Com);
    
          // Force a device out of the boot loader wait routine (no bad effect when SBL is not present).
          sysReset(ZC_Com);
    
          // Set the Startup_Option to Clear Configuration and reset to effect the action.
          cfgArr[0] = NV_STARTUP_OPTION_VAL;
          writeCfg(ZC_Com , NV_STARTUP_OPTION, NV_STARTUP_LEN, cfgArr);
          sysReset(ZC_Com);
    
          // Setup the device type, panId & channel mask and reset to effect the settings.
          cfgArr[0] = 0x00;                    // Set Logical Device Type to ZC.
          //writeCfg(ZC_Com, 0x87, 0x01, cfgArr);
          //cfgArr[0] = 0x01;                    // Set Logical Device Type to ZR.
          writeCfg(ZC_Com, 0x87, 0x01, cfgArr);
          cfgArr[0] = 0x22; cfgArr[1] = 0x06;  // Set Pan Id to 0x0622 // Change this to anything you need to test
          //writeCfg(ZC_Com, 0x83, 0x02, cfgArr);
          writeCfg(ZC_Com, 0x83, 0x02, cfgArr);
          cfgArr[0] = 0x00; cfgArr[1] = 0x08; cfgArr[2] = 0x00; cfgArr[3] = 0x00; //channel 11
                                             // Set Channel Mask to 0x00100000  // 20 - 0x14
    					 // Set Channel Maks to 0x00080000  // 19 - 0x13 - Current channel mask
          //writeCfg(ZC_Com, 0x84, 0x04, cfgArr);
          writeCfg(ZC_Com, 0x84, 0x04, cfgArr);
    	  cfgArr[0] = 0xAA; cfgArr[1] = 0xBB;
          //writeCfg(ZC_Com,0x62, 16, cfgArr); //program the NWK Key 1st two bytes are AA and BB
          // Start the devices on the network.
          //startReq(ZC_Com);
    
          cfgArr[0] = true;
          writeCfg(ZC_Com, 0x8F, 0x01, cfgArr);// Set ZCD_NV_ZDO_DIRECT_CB to true. ZCD_NV_ZDO_DIRECT_CB address = 0x8F
          afReg(ZC_Com); // define end point
          startReq(ZC_Com);
    
          while(1)
          {
              //wait for incoming messages
          }
    
    
        }
    
        ZEngine.Complete(true);
      }
    
    
      function setDataReq(mode : Byte) { // mode: 0 = switch, 1 = default response, 2 = read attribute, 3 = read attribute response
          if (mode == 0)//switch
          {
              drCluster = 0x6;
              drTrans = 0;
              drOption = 0x0;
              drLen = 3;
              drData[0] = 0x01;
              drData[1] = 0x00;
              drData[2] = 0x02;
          }
          else if (mode == 1)//default response
          {
              drCluster = imCluster;
              drTrans = 0;
              drOption = 0x0;
              drLen = 5;
              drData[0] = 0x18; //frame control
              drData[1] = 0x00; //transaction sequence number
              drData[2] = 0x0B; //default response
              drData[3] = imData[2]; //command ID
              drData[4] = 0x00; // status
          }
          else if (mode == 2)//read attribute from light
          {
              drCluster = 0x6;
              drTrans = 0;
              drOption = 0x0;
              drLen = 5;
              drData[0] = 0x00; //frame control
              drData[1] = 0x00; //transaction sequence number
              drData[2] = 0x00; //read attribute
              //attribute ID 16 bits
              drData[3] = 0x00; //attribute ID
              drData[4] = 0x00; // attribute ID
          }
          else if (mode == 3)//read attribute response light
          {
              drCluster = imCluster;
              drTrans = 0;
              drOption = 0x0;
              drLen = 8;
              drData[0] = 0x18; //frame control
              drData[1] = 0x00; //transaction sequence number
              drData[2] = 0x01; //read attribute response
              //attribute ID 16 bits
              drData[3] = imData[3]; //attribute ID
              drData[4] = imData[4]; // attribute ID
              drData[5] = 0x00; //status: success
              drData[6] = 0x20; //Data type: unsigned 8-bit integer
              var attID : UInt16 = (imData[4] << 8) | imData[3]; //attribute ID that will be read
              if(attID == 0)
              {
                drData[7] = lightStatus;
              }
          }
      }
    
    
    // Send a process incoming message.
      function pInMsg(comm : String) {
         if(imData[0] == 1)
         {
             if(imData[2] == 2)
             {
                 lightStatus = (~lightStatus) & 0x01; //toggle light
             }
             else if (imData[2] == 1)
             {
                 lightStatus = 0x01; // light ON
             }
             else if (imData[2] == 0)
             {
                 lightStatus = 0x00; //light OFF
             }
         }
        if ((imData[0] & 0x01) == 0 && imData[2] == 0)//read attribute
         {
             if (imData[0] == 0 && imData[2] == 0)
             {
                setDataReq(3);
                afDataReq(comm, imSrcAddr, imSrcEndp);//send read attribute response
             }
         }
         else if ((imData[0] & 0x10) == 0)//Default response active
         {
             setDataReq(1);
             afDataReq(comm, imSrcAddr, imSrcEndp);// send default response
         }
    
    
      }
    
    // Send a UTIL_GET_DEVICE_INFO message.
      function devInfo(comm : String) {
         var req : UTIL_GET_DEVICE_INFO  = new UTIL_GET_DEVICE_INFO ();
          gotDevRsp = false;
          while(!gotDevRsp)
          {
              logMsg("dev response");
              ZEngine.Send(comm, req);
              ZEngine.Pause(2000);
          }
      }
    
    // Send a ZDO_ACTIVE_EP_REQ message.
      function epReq(comm : String, dst : UInt16, aoi : UInt16) {
        var req : ZDO_ACTIVE_EP_REQ  = new ZDO_ACTIVE_EP_REQ ();
        req.DstAddr = dst;
        req.NWKAddrOfInterest = aoi;
        gotEpRsp = false;
        while(!gotEpRsp)
        {
            logMsg("ZDO_ACTIVE_EP_REQ to " + comm);
            ZEngine.Send(comm, req);
            ZEngine.Pause(1000);
        }
    
      }
    
    // Send a ZDO_SIMPLE_DESC_REQ message.
      function simDescReq(comm : String, dst : UInt16, aoi : UInt16, dstEp : Byte) {
        var req : ZDO_SIMPLE_DESC_REQ  = new ZDO_SIMPLE_DESC_REQ ();
        req.DstAddr = dst;
        req.NWKAddrOfInterest = aoi;
        req.Endpoint = dstEp;
        gotSdescRsp = false;
        isLight = false;
        while(!gotSdescRsp)
        {
          logMsg("ZDO_SIMPLE_DESC_REQ to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(1000);
        }
    
      }
    
      // Send a AF_DATA_REQUEST message.
      function afDataReq(comm : String, dst : UInt16, dstEp : Byte) {
        var req : AF_DATA_REQUEST  = new AF_DATA_REQUEST ();
        req.DstAddr = dst;
        req.DestEndpoint = dstEp;
        req.SrcEndpoint = endPoint;
        req.ClusterID = drCluster;
        req.TransID = drTrans;
        req.Options = drOption;
        req.Radius = drRadius;
        req.Len = drLen;
        for (var idx = 0; idx < drLen; idx++)
        {
              req.Data[idx] = drData[idx];
        }
        logMsg("AF_DATA_REQUEST to " + comm);
        ZEngine.Send(comm, req);
        ZEngine.Pause(1000);
    
      }
    
    
      // Handler for incoming messages.
      function msgHandler(comm : String, id : MESSAGE_ID, msg : Object) {
        switch (id)
        {
        case MESSAGE_ID.SYS_RESET_RESPONSE:
        {
          gotRstRsp = true;
          break;
        }
        case MESSAGE_ID.UTIL_GET_DEVICE_INFO_RESPONSE:
        {
            var devRsp : UTIL_GET_DEVICE_INFO_RESPONSE = msg;
            if (devRsp.Status == SUCCESS && devRsp.NumAssocDevices != 0)
            {
                gotDevRsp = true;
                devaddr = devRsp.AssocDevicesList[0];
            }
    
          break;
        }
        case MESSAGE_ID.ZDO_ACTIVE_EP_RSP:
        {
            var epRsp : ZDO_ACTIVE_EP_RSP = msg;
            if (epRsp.Status == SUCCESS && epRsp.ActiveEPCount != 0)
            {
                gotEpRsp=true;
                dstEndPoint = epRsp.ActiveEPList[0];
            }
    
    
          break;
        }
    
        case MESSAGE_ID.ZDO_SIMPLE_DESC_RSP: /*change*/
        {
            var smpdRsp : ZDO_SIMPLE_DESC_RSP = msg;
            if (smpdRsp.Status == SUCCESS && smpdRsp.ProfileID == HOMEAUT && smpdRsp.DeviceID == LIGHT)
            {
                gotSdescRsp = true;
                isLight = true;
            }
    
    
          break;
        }
    
        case MESSAGE_ID.ZB_WRITE_CONFIGURATION_RSP:
        {
          var cfgRsp : ZB_WRITE_CONFIGURATION_RSP = msg;
    
          if (cfgRsp.Status == SUCCESS)
          {
            gotCfgRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_REGISTER_SRSP:
        {
          var regRsp : AF_REGISTER_SRSP = msg;
    
          if (regRsp.Status == SUCCESS)
          {
            gotRegRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.ZB_START_REQUEST_RSP:
        {
          gotStartRsp = true;
          break;
        }
    
        case MESSAGE_ID.ZDO_STATE_CHANGE_IND:
        {
          var zdoStateInd : ZDO_STATE_CHANGE_IND = msg;
    
          // { DEV_END_DEVICE, DEV_ROUTER, DEV_ZB_COORD } : { 6, 7, 9 }
          if ((zdoStateInd.State == 6) || (zdoStateInd.State == 7) || (zdoStateInd.State == 9))
          {
            gotStateRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_DATA_REQUEST_EXT_SRSP:
        {
          var afRegExtRsp : AF_DATA_REQUEST_EXT_SRSP = msg;
    
          if (afRegExtRsp.Status == SUCCESS)
          {
            gotAfReqExtRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_DATA_STORE_SRSP:
        {
          var afStoreRsp : AF_DATA_STORE_SRSP = msg;
    
          if (afStoreRsp.Status == SUCCESS)
          {
            gotAfStoreRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_INCOMING_MSG_EXT:
        {
          var afIncExt : AF_INCOMING_MSG_EXT = msg;
          afDataRetrieve(comm, msg);
          gotAfIncExt = true;
          break;
        }
    
        case MESSAGE_ID.AF_INCOMING_MSG:
        {
          var inMsgDat : AF_INCOMING_MSG = msg;
          imGroup = inMsgDat.GroupID;
          imCluster = inMsgDat.ClusterID;
          imSrcAddr = inMsgDat.SrcAddr;
          imSrcEndp = inMsgDat.SrcEndpoint;
          imDstEndp = inMsgDat.DstEndpoint;
          imLen = inMsgDat.Len;
          for (var idx = 0; idx < imLen; idx++)
          {
              imData[idx] = inMsgDat.Data[idx];
          }
          pInMsg(comm);
    
          break;
        }
    
        case MESSAGE_ID.AF_DATA_RETRIEVE_SRSP:
        {
          var afRetrieveRsp : AF_DATA_RETRIEVE_SRSP = msg;
    
          if (afRetrieveRsp.Status == SUCCESS)
          {
            var index = retrieveIdx;
    
            for (var idx = 0; idx < afRetrieveRsp.Length; idx++, index++)
            {
              retrieveBuf[index] = afRetrieveRsp.Data[idx];
            }
    
            gotAfRetrieveRsp = true;
          }
          break;
        }
    
        default:
          break;
        }
      }
    
    
      // Send a ZB_SYSTEM_RESET message until success.
      function sysReset(comm : String) {
        var req : ZB_SYSTEM_RESET = new ZB_SYSTEM_RESET();
        gotRstRsp = false;
    
        while (!gotRstRsp)
        {
          logMsg("ZB_SYSTEM_RESET  to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(50);
    
          // Sending SYS_STACK_TUNE as a way to get a 0x07 byte to the SBL before a 0xF8 byte.
          // An 0x07 byte forces the immediate run of valid code.
          //sysStackTune(comm, 7, 7);
          //ZEngine.Pause(300);
        }
      }
    
    
      // Send a SYS_STACK_TUNE message.
      function sysStackTune(comm : String, Operation: Byte, Value: Byte) {
        var req : SYS_STACK_TUNE = new SYS_STACK_TUNE();
        req.Operation = Operation;
        req.Value = Value;
    
        logMsg("SYS_STACK_TUNE to " + comm);
        ZEngine.Send(comm, req);
      }
    
    
      // Send a ZB_WRITE_CONFIGURATION message.
      function writeCfg(comm : String, cfgId : Byte, len : Byte,  value : Array ) {
        var req : ZB_WRITE_CONFIGURATION = new ZB_WRITE_CONFIGURATION();
        req.ConfigId = cfgId;
        req.Len = len;
    		req.Value = new byte[len];
    
        for (var idx = 0; idx < len; idx++)
        {
          req.Value[idx] = value[idx];
        }
    
        gotCfgRsp = false;
        while (!gotCfgRsp)
        {
          logMsg("ZB_WRITE_CONFIGURATION  to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(200);
        }
      }
    
    
      // Send a ZB_AF_REGISTER_REQUEST message.
      function afReg(comm : String) {
        var req : AF_REGISTER  = new AF_REGISTER ();
        req.AppProfID = profileId;
        req.AppDeviceId = devId;
        req.EndPoint = endPoint;
        req.AppInClusterList = inClusterList;
        req.AppNumInClusters = inClusterCnt;
        req.AppOutClusterList = outClusterList;
        req.AppNumOutClusters = outClusterCnt;
    
        gotRegRsp = false;
        while (!gotRegRsp)
        {
          logMsg("ZB_AF_REGISTER_REQUEST to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(200);
        }
      }
    
    
      // Send a ZB_START_REQUEST message.
      function startReq(comm : String) {
        var req : ZB_START_REQUEST  = new ZB_START_REQUEST();
    
        gotStateRsp = false;
        while (!gotStateRsp)
        {
          gotStartRsp = false;
          while (!gotStartRsp)
          {
            logMsg("ZB_START_REQUEST  to " + comm);
            ZEngine.Send(comm, req);
            ZEngine.Pause(1000);
          }
          ZEngine.Pause(5000);
        }
      }
    
    
      /* Make a huge data request via an AF_DATA_REQUEST_EXT message and store the huge data.
       * Since the max MT payload is 250 & the store message header is 3, the max bytes per store
       * is 247. So to simplify the script just use 3 X 247 = 741.
       * Note that we are simultaneously proving the max capacity of 250 bytes per MT message here.
       */
      function afDataReqFrag(comm : String) {
        var req : AF_DATA_REQUEST_EXT = new AF_DATA_REQUEST_EXT();
    
        req.DstAddrMode = 2;  // Addr16Bit = 2
        req.DstAddr[0] = 0; req.DstAddr[1] = 0;  // Short address 0x0000 is for ZC.
        req.DstEndPoint = endPoint;
        req.DstPanId = 0;  // Zero signifies not Inter-PAN.
        req.SrcEndpoint = endPoint;
        req.ClusterID = 1;  // Startup initialization makes cluster Id's 1,2,3... up to count.
        req.TransID = 0;  // Trans Id is a don't care.
        req.Options = 0;  // AF_TX_OPTIONS_NONE = 0
        req.Radius = 15;  // AF_DEFAULT_RADIUS = 15
        req.Len = retrieveTot;
    
        gotAfReqExtRsp = false;
        while (!gotAfReqExtRsp)
        {
          logMsg("AF_DATA_REQUEST_EXT to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(3000);
        }
    
        var index : UInt16 = 0;
        var fragLen : Byte = retrieveLen;
        var fragBuf : Byte[] = new Byte[fragLen];
        for (var idx = 0; idx < fragLen; idx++)
        {
          fragBuf[idx] = idx;
        }
        afDataStore(comm, index, fragLen, fragBuf);
        index += fragLen;
    
        // Change the frag data to enhance verification reliability on Rx.
        for (idx = 0; idx < fragLen; idx++)
        {
          fragBuf[idx]++;
        }
        afDataStore(comm, index, fragLen, fragBuf);
        index += fragLen;
    
        // Change the frag data again to enhance verification reliability on Rx.
        for (idx = 0; idx < fragLen; idx++)
        {
          // Without a type-cast, the script promotes fragBuf[] to int at run-time.
          fragBuf[idx] = (Byte)(idx * 2);
        }
        afDataStore(comm, index, fragLen, fragBuf);
    
        // A store of zero length indicates to send it OTA.
        afDataStore(comm, 0, 0, fragBuf);
      }
    
    
      // Send a AF_DATA_STORE message.
      function afDataStore(comm : String, index : UInt16, len : Byte, buf : Byte[]) {
        var req : AF_DATA_STORE = new AF_DATA_STORE();
    
        req.Index = index;
        req.Length = len;
    
        for (var idx = 0; idx < len; idx++)
        {
          req.Data[idx] = buf[idx];
        }
    
        gotAfStoreRsp = false;
        while (!gotAfStoreRsp)
        {
          logMsg("AF_DATA_STORE to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(100);
        }
      }
    
    
      // Send a series of AF_DATA_RETRIEVE message(s) to get the data of an incoming huge message.
      function afDataRetrieve(comm : String, msgIn : AF_INCOMING_MSG_EXT) {
        var req : AF_DATA_RETRIEVE = new AF_DATA_RETRIEVE();
    
        req.Timestamp = msgIn.Timestamp;
        req.Length = retrieveLen;
    
        for (retrieveIdx = 0; retrieveIdx < msgIn.Len; retrieveIdx += retrieveLen)
        {
          req.Index = retrieveIdx;
    
          gotAfRetrieveRsp = false;
          while (!gotAfRetrieveRsp)
          {
            logMsg("AF_DATA_RETRIEVE to " + comm);
            ZEngine.Send(comm, req);
            ZEngine.Pause(100);
          }
        }
    
        /* Retrieve request with zero length indicates to flush the message and free the dynamic
         * memory. If this request fails, the device times out the incoming huge message buffer and
         * flushes it automatically, so no loop here.
         */
        req.Length = 0;
        logMsg("AF_DATA_RETRIEVE to " + comm);
        ZEngine.Send(comm, req);
        ZEngine.Pause(100);
      }
    
    
      // Verify the data in the global retrieveBuf[] according to what was sent in afDataReqFrag().
      function verifyMsgIn() : boolean {
        /* At first writing of this script, the afDataReqFrag() sent 741 bytes.
         * The first 247 bytes were 0-247; the next 247 bytes were 1-248; and the last 247 bytes were
         * calculated as twice the corresponding index.
         */
        var index = 0;
    
        for (var idx = 0; idx < retrieveLen; idx++, index++)
        {
          if (retrieveBuf[index] != idx)
          {
            break;
          }
        }
    
        for (var idx = 1; idx <= retrieveLen; idx++, index++)
        {
          if (retrieveBuf[index] != idx)
          {
            break;
          }
        }
    
        for (var idx = 0; idx < retrieveLen; idx++, index++)
        {
          if (retrieveBuf[index] != (Byte)(idx * 2))
          {
            break;
          }
        }
    
        if (index < retrieveTot)
        {
          return false;
        }
        else
        {
          return true;
        }
      }
    
    
      // Display a log message if log messages are enabled.
      function logMsg(theMsg : String) {
        if (showLogMsgs)
        {
          ZEngine.WriteLog(theMsg);  // Display the message.
        }
      }
    } // End of TheScript class.
    
    
    // The script engine will execute the following code.
    var script:TheScript = new TheScript();
    script.run();
    
    
    /**************************************************************************************************
    */
    

    End device script file:

    end_device.txt
    /**************************************************************************************************
      Filename:       znp-bringup.zjs
      Revised:        $Date:$
      Revision:       $Revision:$
    
      Description:    This file is a test script bring up ZC and ZR.
    
    
      Copyright 2010 Texas Instruments Incorporated. All rights reserved.
    
      IMPORTANT: Your use of this Software is limited to those specific rights
      granted under the terms of a software license agreement between the user
      who downloaded the software, his/her employer (which must be your employer)
      and Texas Instruments Incorporated (the "License").  You may not use this
      Software unless you agree to abide by the terms of the License. The License
      limits your use, and you acknowledge, that the Software may not be modified,
      copied or distributed unless embedded on a Texas Instruments microcontroller
      or used solely and exclusively in conjunction with a Texas Instruments radio
      frequency transceiver, which is integrated into your product.  Other than for
      the foregoing purpose, you may not use, reproduce, copy, prepare derivative
      works of, modify, distribute, perform, display or sell this Software and/or
      its documentation for any purpose.
    
      YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
      PROVIDED �AS IS� WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
      INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
      NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
      TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
      NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
      LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
      INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
      OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
      OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
      (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
    
      Should you have any questions regarding your right to use this Software,
      contact Texas Instruments Incorporated at www.TI.com.
    **************************************************************************************************/
    
    
    /**************************************************************************************************
      Instructions:
    
      Connect a device to be a ZC to a COM nicknamed �C� and another to a COM named �R�
    
    **************************************************************************************************/
    import System;
    import System.Text;
    import TI.ZPI2;
    
    class TheScript
    {
      // Set to 'true' when running the ZNP in order to reset the devices and startup the network.
      private var ZNP_RUN : boolean = true;
      private var SUCCESS : int = 0;
    
      // Set this variable to the script engine's nickname for the COM port to the target device.
      private var ZR_Com : String = "COM15";
      private var ZC_Com : String = "COM3";
    
      // Set this variable to 'true' to enable the display of log messages (i.e. verbose mode).
      private var showLogMsgs : boolean = true;
    
      // Variables set by the incoming message handler to enable "re-try until success" looping.
      private var gotRstRsp           : boolean = false;
      private var gotCfgRsp           : boolean = false;
      private var gotRegRsp           : boolean = false;
      private var gotStartRsp         : boolean = false;
      private var gotStateRsp         : boolean = false;
      private var gotAfReqExtRsp      : boolean = false;
      private var gotAfIncExt         : boolean = false;
      private var gotAfStoreRsp       : boolean = false;
      private var gotAfRetrieveRsp    : boolean = false;
    
      private var profileId           : UInt16  = 0x0104;  // HA Profile ID
      private var endPoint            : Byte    = 0x0C;    // SampleSW has endpoint 12 so we use that
      private var inClusterCnt        : Byte    = 1;
      private var outClusterCnt       : Byte    = 1;
      private var inClusterList = new Array(inClusterCnt);
      private var outClusterList = new Array(outClusterCnt);
    
      private var NV_STARTUP_OPTION     : Byte = 0x03;
      private var NV_STARTUP_OPTION_VAL : Byte = 0x03;	// 0x03 = clear configuration
      private var NV_STARTUP_LEN        : Byte = 1;
    
      private var cfgArr = new Array(256);        // Make big enough for any configuration item.
      private var retrieveBuf = new Array(1024);  // Make big enough for any huge message attempted.
      private var retrieveTot           : UInt16 = 741;
      private var retrieveLen           : Byte = 247;
      private var retrieveIdx           : UInt16;
    
      // Main class function that effects the work of this test script.
      function run() {
        for (var idx = 1; idx <= inClusterCnt; idx++)
        {
          inClusterList[idx] = idx;
        }
        for (var idx = 1; idx <= outClusterCnt; idx++)
        {
          outClusterList[idx] = idx;
        }
    
        // Subscribe to the incoming message handler.
        ZEngine.add_OnMessageZPI2(this.msgHandler);
    
        if (ZNP_RUN)
        {
          // Force a device out of the boot loader wait routine (no bad effect when SBL is not present).
          //sysReset(ZC_Com);
    
          // Set the Startup_Option to Clear Configuration and reset to effect the action.
          //cfgArr[0] = NV_STARTUP_OPTION_VAL;
          //writeCfg(ZC_Com , NV_STARTUP_OPTION, NV_STARTUP_LEN, cfgArr);
          //sysReset(ZC_Com);
    
          // Force a device out of the boot loader wait routine (no bad effect when SBL is not present).
          sysReset(ZR_Com);
    
          // Set the Startup_Option to Clear Configuration and reset to effect the action.
          cfgArr[0] = NV_STARTUP_OPTION_VAL;
          writeCfg(ZR_Com , NV_STARTUP_OPTION, NV_STARTUP_LEN, cfgArr);
          sysReset(ZR_Com);
    
          // Setup the device type, panId & channel mask and reset to effect the settings.
          cfgArr[0] = 0x00;                    // Set Logical Device Type to ZC.
          //writeCfg(ZC_Com, 0x87, 0x01, cfgArr);
          cfgArr[0] = 0x01;                    // Set Logical Device Type to ZR.
          writeCfg(ZR_Com, 0x87, 0x01, cfgArr);
          cfgArr[0] = 0x22; cfgArr[1] = 0x06;  // Set Pan Id to 0x0622 // Change this to anything you need to test
          //writeCfg(ZC_Com, 0x83, 0x02, cfgArr);
          writeCfg(ZR_Com, 0x83, 0x02, cfgArr); 
          cfgArr[0] = 0x00; cfgArr[1] = 0x08; cfgArr[2] = 0x00; cfgArr[3] = 0x00; //channel 11
                                             // Set Channel Mask to 0x00100000  // 20 - 0x14
    					 // Set Channel Maks to 0x00080000  // 19 - 0x13 - Current channel mask
          //writeCfg(ZC_Com, 0x84, 0x04, cfgArr);
          writeCfg(ZR_Com, 0x84, 0x04, cfgArr);
    	  cfgArr[0] = 0xAA; cfgArr[1] = 0xBB;
          //writeCfg(ZC_Com,0x62, 16, cfgArr); //program the NWK Key 1st two bytes are AA and BB
          // Start the devices on the network.
          //startReq(ZC_Com);
          startReq(ZR_Com);
        }
    
        ZEngine.Complete(true);
      }
    
    
      // Handler for incoming messages.
      function msgHandler(comm : String, id : MESSAGE_ID, msg : Object) {
        switch (id)
        {
        case MESSAGE_ID.SYS_RESET_RESPONSE:
        {
          gotRstRsp = true;
          break;
        }
    
        case MESSAGE_ID.ZB_WRITE_CONFIGURATION_RSP:
        {
          var cfgRsp : ZB_WRITE_CONFIGURATION_RSP = msg;
    
          if (cfgRsp.Status == SUCCESS)
          {
            gotCfgRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_REGISTER_SRSP:
        {
          var regRsp : AF_REGISTER_SRSP = msg;
    
          if (regRsp.Status == SUCCESS)
          {
            gotRegRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.ZB_START_REQUEST_RSP:
        {
          gotStartRsp = true;
          break;
        }
    
        case MESSAGE_ID.ZDO_STATE_CHANGE_IND:
        {
          var zdoStateInd : ZDO_STATE_CHANGE_IND = msg;
    
          // { DEV_END_DEVICE, DEV_ROUTER, DEV_ZB_COORD } : { 6, 7, 9 }
          if ((zdoStateInd.State == 6) || (zdoStateInd.State == 7) || (zdoStateInd.State == 9))
          {
            gotStateRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_DATA_REQUEST_EXT_SRSP:
        {
          var afRegExtRsp : AF_DATA_REQUEST_EXT_SRSP = msg;
    
          if (afRegExtRsp.Status == SUCCESS)
          {
            gotAfReqExtRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_DATA_STORE_SRSP:
        {
          var afStoreRsp : AF_DATA_STORE_SRSP = msg;
    
          if (afStoreRsp.Status == SUCCESS)
          {
            gotAfStoreRsp = true;
          }
          break;
        }
    
        case MESSAGE_ID.AF_INCOMING_MSG_EXT:
        {
          var afIncExt : AF_INCOMING_MSG_EXT = msg;
          afDataRetrieve(comm, msg);
          gotAfIncExt = true;
          break;
        }
    
        case MESSAGE_ID.AF_DATA_RETRIEVE_SRSP:
        {
          var afRetrieveRsp : AF_DATA_RETRIEVE_SRSP = msg;
    
          if (afRetrieveRsp.Status == SUCCESS)
          {
            var index = retrieveIdx;
    
            for (var idx = 0; idx < afRetrieveRsp.Length; idx++, index++)
            {
              retrieveBuf[index] = afRetrieveRsp.Data[idx];
            }
    
            gotAfRetrieveRsp = true;
          }
          break;
        }
    
        default:
          break;
        }
      }
    
    
      // Send a ZB_SYSTEM_RESET message until success.
      function sysReset(comm : String) {
        var req : ZB_SYSTEM_RESET = new ZB_SYSTEM_RESET();
        gotRstRsp = false;
    
        while (!gotRstRsp)
        {
          logMsg("ZB_SYSTEM_RESET  to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(50);
    
          // Sending SYS_STACK_TUNE as a way to get a 0x07 byte to the SBL before a 0xF8 byte.
          // An 0x07 byte forces the immediate run of valid code.
          //sysStackTune(comm, 7, 7);
          //ZEngine.Pause(300);
        }
      }
    
    
      // Send a SYS_STACK_TUNE message.
      function sysStackTune(comm : String, Operation: Byte, Value: Byte) {
        var req : SYS_STACK_TUNE = new SYS_STACK_TUNE();
        req.Operation = Operation;
        req.Value = Value;
    
        logMsg("SYS_STACK_TUNE to " + comm);
        ZEngine.Send(comm, req);
      }
    
    
      // Send a ZB_WRITE_CONFIGURATION message.
      function writeCfg(comm : String, cfgId : Byte, len : Byte,  value : Array ) {
        var req : ZB_WRITE_CONFIGURATION = new ZB_WRITE_CONFIGURATION();
        req.ConfigId = cfgId;
        req.Len = len;
    		req.Value = new byte[len];
    
        for (var idx = 0; idx < len; idx++)
        {
          req.Value[idx] = value[idx];
        }
    
        gotCfgRsp = false;
        while (!gotCfgRsp)
        {
          logMsg("ZB_WRITE_CONFIGURATION  to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(200);
        }
      }
    
    
      // Send a ZB_AF_REGISTER_REQUEST message.
      function afReg(comm : String) {
        var req : AF_REGISTER  = new AF_REGISTER ();
        req.AppProfID = profileId;
        req.EndPoint = endPoint;
        req.AppInClusterList = inClusterList;
        req.AppNumInClusters = inClusterCnt;
        req.AppOutClusterList = outClusterList;
        req.AppNumOutClusters = outClusterCnt;
    
        gotRegRsp = false;
        while (!gotRegRsp)
        {
          logMsg("ZB_AF_REGISTER_REQUEST to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(200);
        }
      }
    
    
      // Send a ZB_START_REQUEST message.
      function startReq(comm : String) {
        var req : ZB_START_REQUEST  = new ZB_START_REQUEST();
    
        gotStateRsp = false;
        while (!gotStateRsp)
        {
          gotStartRsp = false;
          while (!gotStartRsp)
          {
            logMsg("ZB_START_REQUEST  to " + comm);
            ZEngine.Send(comm, req);
            ZEngine.Pause(1000);
          }
          ZEngine.Pause(5000);
        }
      }
    
    
      /* Make a huge data request via an AF_DATA_REQUEST_EXT message and store the huge data.
       * Since the max MT payload is 250 & the store message header is 3, the max bytes per store
       * is 247. So to simplify the script just use 3 X 247 = 741.
       * Note that we are simultaneously proving the max capacity of 250 bytes per MT message here.
       */
      function afDataReqFrag(comm : String) {
        var req : AF_DATA_REQUEST_EXT = new AF_DATA_REQUEST_EXT();
    
        req.DstAddrMode = 2;  // Addr16Bit = 2
        req.DstAddr[0] = 0; req.DstAddr[1] = 0;  // Short address 0x0000 is for ZC.
        req.DstEndPoint = endPoint;
        req.DstPanId = 0;  // Zero signifies not Inter-PAN.
        req.SrcEndpoint = endPoint;
        req.ClusterID = 1;  // Startup initialization makes cluster Id's 1,2,3... up to count.
        req.TransID = 0;  // Trans Id is a don't care.
        req.Options = 0;  // AF_TX_OPTIONS_NONE = 0
        req.Radius = 15;  // AF_DEFAULT_RADIUS = 15
        req.Len = retrieveTot;
    
        gotAfReqExtRsp = false;
        while (!gotAfReqExtRsp)
        {
          logMsg("AF_DATA_REQUEST_EXT to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(3000);
        }
    
        var index : UInt16 = 0;
        var fragLen : Byte = retrieveLen;
        var fragBuf : Byte[] = new Byte[fragLen];
        for (var idx = 0; idx < fragLen; idx++)
        {
          fragBuf[idx] = idx;
        }
        afDataStore(comm, index, fragLen, fragBuf);
        index += fragLen;
    
        // Change the frag data to enhance verification reliability on Rx.
        for (idx = 0; idx < fragLen; idx++)
        {
          fragBuf[idx]++;
        }
        afDataStore(comm, index, fragLen, fragBuf);
        index += fragLen;
    
        // Change the frag data again to enhance verification reliability on Rx.
        for (idx = 0; idx < fragLen; idx++)
        {
          // Without a type-cast, the script promotes fragBuf[] to int at run-time.
          fragBuf[idx] = (Byte)(idx * 2);
        }
        afDataStore(comm, index, fragLen, fragBuf);
    
        // A store of zero length indicates to send it OTA.
        afDataStore(comm, 0, 0, fragBuf);
      }
    
    
      // Send a AF_DATA_STORE message.
      function afDataStore(comm : String, index : UInt16, len : Byte, buf : Byte[]) {
        var req : AF_DATA_STORE = new AF_DATA_STORE();
    
        req.Index = index;
        req.Length = len;
    
        for (var idx = 0; idx < len; idx++)
        {
          req.Data[idx] = buf[idx];
        }
    
        gotAfStoreRsp = false;
        while (!gotAfStoreRsp)
        {
          logMsg("AF_DATA_STORE to " + comm);
          ZEngine.Send(comm, req);
          ZEngine.Pause(100);
        }
      }
    
    
      // Send a series of AF_DATA_RETRIEVE message(s) to get the data of an incoming huge message.
      function afDataRetrieve(comm : String, msgIn : AF_INCOMING_MSG_EXT) {
        var req : AF_DATA_RETRIEVE = new AF_DATA_RETRIEVE();
    
        req.Timestamp = msgIn.Timestamp;
        req.Length = retrieveLen;
    
        for (retrieveIdx = 0; retrieveIdx < msgIn.Len; retrieveIdx += retrieveLen)
        {
          req.Index = retrieveIdx;
    
          gotAfRetrieveRsp = false;
          while (!gotAfRetrieveRsp)
          {
            logMsg("AF_DATA_RETRIEVE to " + comm);
            ZEngine.Send(comm, req);
            ZEngine.Pause(100);
          }
        }
    
        /* Retrieve request with zero length indicates to flush the message and free the dynamic
         * memory. If this request fails, the device times out the incoming huge message buffer and
         * flushes it automatically, so no loop here.
         */
        req.Length = 0;
        logMsg("AF_DATA_RETRIEVE to " + comm);
        ZEngine.Send(comm, req);
        ZEngine.Pause(100);
      }
    
    
      // Verify the data in the global retrieveBuf[] according to what was sent in afDataReqFrag().
      function verifyMsgIn() : boolean {
        /* At first writing of this script, the afDataReqFrag() sent 741 bytes.
         * The first 247 bytes were 0-247; the next 247 bytes were 1-248; and the last 247 bytes were
         * calculated as twice the corresponding index.
         */
        var index = 0;
    
        for (var idx = 0; idx < retrieveLen; idx++, index++)
        {
          if (retrieveBuf[index] != idx)
          {
            break;
          }
        }
    
        for (var idx = 1; idx <= retrieveLen; idx++, index++)
        {
          if (retrieveBuf[index] != idx)
          {
            break;
          }
        }
    
        for (var idx = 0; idx < retrieveLen; idx++, index++)
        {
          if (retrieveBuf[index] != (Byte)(idx * 2))
          {
            break;
          }
        }
    
        if (index < retrieveTot)
        {
          return false;
        }
        else
        {
          return true;
        }
      }
    
    
      // Display a log message if log messages are enabled.
      function logMsg(theMsg : String) {
        if (showLogMsgs)
        {
          ZEngine.WriteLog(theMsg);  // Display the message.
        }
      }
    } // End of TheScript class.
    
    
    // The script engine will execute the following code.
    var script:TheScript = new TheScript();
    script.run();
    
    
    /**************************************************************************************************
    */
    

  • I see you attach a screenshot which shows you can send message with both coordinator device endpoint are 0x07. If you change endpoint back to 0x07, does it work?

  • No Not working..

    If i use the same endpoint values(0x0C) for both devices  and set dstAddr 0x0000 values in coordinator. The coordinator receive incoming msg.

    Coordinator side:

    <TX>04:54:37.48 COM16 AF_DATA_REQUEST (0x2401)
    DstAddr: 0x0000
    DestEndpoint: 0x0C
    SrcEndpoint: 0x0C
    ClusterID: 0x0002
    TransID: 0x01
    Options: 0x01
    Radius: 0x01
    Len: 0x01
    Data: . (0x08)

    <RX>04:54:37.49 COM16 AF_DATA_REQUEST_SRSP (0x6401)
    Status: afStatus_SUCCESS (0x0)

    <RX>04:54:37.49 COM16 AF_DATA_CONFIRM (0x4480)
    Status: afStatus_SUCCESS (0x0)
    Endpoint: 0x0C
    TransID: 0x01

    <RX>04:54:37.5 COM16 AF_INCOMING_MSG (0x4481)
    GroupID: 0x0000
    ClusterID: 0x0002
    SrcAddr: 0x0000
    SrcEndpoint: 0x0C
    DstEndpoint: 0x0C
    WasBroadcast: 0x00
    LinkQuality: 0xFF
    SecurityUse: 0x00
    Timestamp: 0x00000000
    TransSeqNumber: 0x00
    Len: 0x01
    Data: . (0x08)

    Can we set same endpoint for both deices(Coordinator and end device)?

  • Yes, you can set the same endpoint on coordinator and device.
  • Now I had set same endpoint value (0x0C) for both devices(Coordinator and end device).

    My Coordinator Configuration:

    <TX>05:06:34.49 COM16 AF_DATA_REQUEST (0x2401)
    DstAddr: 0xE021
    DestEndpoint: 0x0C
    SrcEndpoint: 0x0C
    ClusterID: 0x0002
    TransID: 0x01
    Options: 0x01
    Radius: 0x01
    Len: 0x01
    Data: . (0x08)

    <RX>05:06:34.49 COM16 AF_DATA_REQUEST_SRSP (0x6401)
    Status: afStatus_SUCCESS (0x0)

    <RX>05:06:35.2 COM16 AF_DATA_CONFIRM (0x4480)
    Status: afStatus_SUCCESS (0x0)
    Endpoint: 0x0C
    TransID: 0x01

     

    Here  0xE021 is end device short address. EndPoint Value (0x0C) for both devices.

    End Device Configuration:

    <TX>04:48:24.07 COM17 UTIL_GET_DEVICE_INFO (0x2700)

    <RX>04:48:24.08 COM17 UTIL_GET_DEVICE_INFO_RESPONSE (0x6700)
    Status: SUCCESS (0x0)
    IEEEAddr: 0x00124B0006272A09
    ShortAddress: 0xE021
    DeviceType: COORDINATOR, ROUTER, END_DEVICE (0x7)
    DeviceState: DEV_END_DEVICE (0x6)
    NumAssocDevices: 0x00
    AssocDevicesList

    I am not getting incoming message from coordinator in end device.

    Is there being any wrong configuration? 

  • Try to use 0x0001 as cluster ID.
  • I tried cluster ID 0x0001 in coordinator.

    Coordinator side:

    <TX>05:30:31.69 COM16 AF_DATA_REQUEST (0x2401)
    DstAddr: 0xE021
    DestEndpoint: 0x0C
    SrcEndpoint: 0x0C
    ClusterID: 0x0001
    TransID: 0x01
    Options: 0x01
    Radius: 0x01
    Len: 0x01
    Data: . (0x06)

    <RX>05:30:31.69 COM16 AF_DATA_REQUEST_SRSP (0x6401)
    Status: afStatus_SUCCESS (0x0)

    <RX>05:30:32.28 COM16 AF_DATA_CONFIRM (0x4480)
    Status: afStatus_SUCCESS (0x0)
    Endpoint: 0x0C
    TransID: 0x01


    No results..I am not getting data in end device side.

  • Try to use ZDO_ACTIVE_EP_REQ to request endpoint of your device from coordinator and show me the results.

  • I tried ZDO_ACTIVE_EP_REQ in coordinator side and result showing below.

    <TX>05:41:31.35 COM16 ZDO_ACTIVE_EP_REQ (0x2505)
    DstAddr: 0xE021
    NWKAddrOfInterest: 0x0000

    <RX>05:41:31.36 COM16 ZDO_ACTIVE_EP_REQ_SRSP (0x6505)
    Status: afStatus_SUCCESS (0x0)

    <RX>05:41:31.8 COM16 ZDO_ACTIVE_EP_RSP (0x4585)
    SrcAddr: 0xE021
    Status: ZDP_INVALID_REQTYPE (0x80)
    NwkAddr: 0x0000
    ActiveEPCount: 0x00
    ActiveEPList:

    Here 0xE201 is a end device short address.

  • You should put short address of your device in NWKAddrOfInterest instead of 0x0000.
  • Tried ZDO_ACTIVE_EP_REQ with the values of DstAddr: 0xE021, NWKAddrOfInterest: 0xE021  in coordinator side.

    I got below results:

    <TX>05:51:17.39 COM16 ZDO_ACTIVE_EP_REQ (0x2505)
    DstAddr: 0xE021
    NWKAddrOfInterest: 0xE021

    <RX>05:51:17.4 COM16 ZDO_ACTIVE_EP_REQ_SRSP (0x6505)
    Status: afStatus_SUCCESS (0x0)

    <RX>05:51:17.93 COM16 ZDO_ACTIVE_EP_RSP (0x4585)
    SrcAddr: 0xE021
    Status: ZDP_SUCCESS (0x0)
    NwkAddr: 0xE021
    ActiveEPCount: 0x00
    ActiveEPList:

  • According to your ZTool log, there’s no endpoint registered. You should check your device ZTool script.
  • Thanks for your valuable suggestions YKChen,

    Which device script file i have to check.

    How to register endpoint.

  • I mean you should check the ZTool script you run to setup end device.
  • So..Which script file i have to check?

    I mean Coordinator script file or End device Script file? In that script file which part have to check?

    Please can you provide steps.

    Thanks in advance.

  • End device Script file and search endpoint to compare with Coordinator script.
  • So both script files should have same endpoint functionality.

    I will compare both script files,where i have to compare exactly in both devices.

    And get back to you.

    Thanks Chen.

  • Hi YKChen,

    Now I just connected both devices to my pc and I checked ubiqua software, got below results.

    Now I got  coordinator and end device in ubiqua software.

    Thanks and Regards,

    Amar.

  • I suppose you have to include device joining process so Ubiqua can get network key to decrypt packets.
  • Thanks for response chen,

    I had compare both script files by using endpoint keyword. 

    Here is coordinator script file:

    private var endPoint            : Byte    = 0x0C;

    // Send a AF_DATA_REQUEST message.
    function afDataReq(comm : String, dst : UInt16, dstEp : Byte) {
    var req : AF_DATA_REQUEST = new AF_DATA_REQUEST ();
    req.DstAddr = dst;
    req.DestEndpoint = dstEp;
    req.SrcEndpoint = endPoint;
    req.ClusterID = drCluster;
    req.TransID = drTrans;
    req.Options = drOption;
    req.Radius = drRadius;
    req.Len = drLen;
    for (var idx = 0; idx < drLen; idx++)
    {
    req.Data[idx] = drData[idx];
    }
    logMsg("AF_DATA_REQUEST to " + comm);
    ZEngine.Send(comm, req);
    ZEngine.Pause(1000);

    }

    // Send a ZB_AF_REGISTER_REQUEST message.
    function afReg(comm : String) {
    var req : AF_REGISTER = new AF_REGISTER ();
    req.AppProfID = profileId;
    req.AppDeviceId = devId;
    req.EndPoint = endPoint;
    req.AppInClusterList = inClusterList;
    req.AppNumInClusters = inClusterCnt;
    req.AppOutClusterList = outClusterList;
    req.AppNumOutClusters = outClusterCnt;

    gotRegRsp = false;
    while (!gotRegRsp)
    {
    logMsg("ZB_AF_REGISTER_REQUEST to " + comm);
    ZEngine.Send(comm, req);
    ZEngine.Pause(200);
    }
    }

    function afDataReqFrag(comm : String) {
    var req : AF_DATA_REQUEST_EXT = new AF_DATA_REQUEST_EXT();

    req.DstAddrMode = 2; // Addr16Bit = 2
    req.DstAddr[0] = 0; req.DstAddr[1] = 0; // Short address 0x0000 is for ZC.
    req.DstEndPoint = endPoint;
    req.DstPanId = 0; // Zero signifies not Inter-PAN.
    req.SrcEndpoint = endPoint;
    req.ClusterID = 1; // Startup initialization makes cluster Id's 1,2,3... up to count.
    req.TransID = 0; // Trans Id is a don't care.
    req.Options = 0; // AF_TX_OPTIONS_NONE = 0
    req.Radius = 15; // AF_DEFAULT_RADIUS = 15
    req.Len = retrieveTot;

    gotAfReqExtRsp = false;
    while (!gotAfReqExtRsp)
    {
    logMsg("AF_DATA_REQUEST_EXT to " + comm);
    ZEngine.Send(comm, req);
    ZEngine.Pause(3000);
    }

    var index : UInt16 = 0;
    var fragLen : Byte = retrieveLen;
    var fragBuf : Byte[] = new Byte[fragLen];
    for (var idx = 0; idx < fragLen; idx++)
    {
    fragBuf[idx] = idx;
    }
    afDataStore(comm, index, fragLen, fragBuf);
    index += fragLen;

    // Change the frag data to enhance verification reliability on Rx.
    for (idx = 0; idx < fragLen; idx++)
    {
    fragBuf[idx]++;
    }
    afDataStore(comm, index, fragLen, fragBuf);
    index += fragLen;

    // Change the frag data again to enhance verification reliability on Rx.
    for (idx = 0; idx < fragLen; idx++)
    {
    // Without a type-cast, the script promotes fragBuf[] to int at run-time.
    fragBuf[idx] = (Byte)(idx * 2);
    }
    afDataStore(comm, index, fragLen, fragBuf);

    // A store of zero length indicates to send it OTA.
    afDataStore(comm, 0, 0, fragBuf);
    }

    End Device Script file:

    private var endPoint            : Byte    = 0x0C;

    // Send a ZB_AF_REGISTER_REQUEST message.
    function afReg(comm : String) {
    var req : AF_REGISTER = new AF_REGISTER ();
    req.AppProfID = profileId;
    req.EndPoint = endPoint;
    req.AppInClusterList = inClusterList;
    req.AppNumInClusters = inClusterCnt;
    req.AppOutClusterList = outClusterList;
    req.AppNumOutClusters = outClusterCnt;

    gotRegRsp = false;
    while (!gotRegRsp)
    {
    logMsg("ZB_AF_REGISTER_REQUEST to " + comm);
    ZEngine.Send(comm, req);
    ZEngine.Pause(200);
    }
    }

    function afDataReqFrag(comm : String) {
    var req : AF_DATA_REQUEST_EXT = new AF_DATA_REQUEST_EXT();

    req.DstAddrMode = 2; // Addr16Bit = 2
    req.DstAddr[0] = 0; req.DstAddr[1] = 0; // Short address 0x0000 is for ZC.
    req.DstEndPoint = endPoint;
    req.DstPanId = 0; // Zero signifies not Inter-PAN.
    req.SrcEndpoint = endPoint;
    req.ClusterID = 1; // Startup initialization makes cluster Id's 1,2,3... up to count.
    req.TransID = 0; // Trans Id is a don't care.
    req.Options = 0; // AF_TX_OPTIONS_NONE = 0
    req.Radius = 15; // AF_DEFAULT_RADIUS = 15
    req.Len = retrieveTot;

    gotAfReqExtRsp = false;
    while (!gotAfReqExtRsp)
    {
    logMsg("AF_DATA_REQUEST_EXT to " + comm);
    ZEngine.Send(comm, req);
    ZEngine.Pause(3000);
    }

    var index : UInt16 = 0;
    var fragLen : Byte = retrieveLen;
    var fragBuf : Byte[] = new Byte[fragLen];
    for (var idx = 0; idx < fragLen; idx++)
    {
    fragBuf[idx] = idx;
    }
    afDataStore(comm, index, fragLen, fragBuf);
    index += fragLen;

    // Change the frag data to enhance verification reliability on Rx.
    for (idx = 0; idx < fragLen; idx++)
    {
    fragBuf[idx]++;
    }
    afDataStore(comm, index, fragLen, fragBuf);
    index += fragLen;

    // Change the frag data again to enhance verification reliability on Rx.
    for (idx = 0; idx < fragLen; idx++)
    {
    // Without a type-cast, the script promotes fragBuf[] to int at run-time.
    fragBuf[idx] = (Byte)(idx * 2);
    }
    afDataStore(comm, index, fragLen, fragBuf);

    // A store of zero length indicates to send it OTA.
    afDataStore(comm, 0, 0, fragBuf);
    }

    what is the procedure for device joining process.

    Thanks in advance.

     

     

  • what is the procedure for device joining process.

    Please read Zigbee spec for details. You can also refer to for quick glance.

  • Now I just change the some settings in Ubiqua. The results shown below.

    Here End Device connected to Coordinator.

    There is no bidirectional. I mean the coordinator also connect to end device.

    I gone through link

    Here I got little bit confused which procedure have to follow.

    Can you please tell about it.

    Thanks,

    Amar.

  • Have you read Zigbee spec about the join process?
  • Yeah according to Zigbee spec,

    According to my knowledge, we have to register end device endpoint in coordinator script file.

    When end device joins to network , the end device will announce msg with short/IEEE address.