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.

CC2650: Z-Stack Binding and EZ-Mode Identify Cluster

Part Number: CC2650
Other Parts Discussed in Thread: CC2531EMK, Z-STACK

Hello,

I am trying to get the SensorTag Z-Stack (Z-Stack Home Automation 1.2.2a) running with a XBee S2C as coordinator module which I have configured to support the HA Profile. Additionally, I am using the CC2531EMK Dongle with the Packet Sniffer application to monitor the ZigBee frames which are exchanged.

Now as far as I can tell from the packet sniffer log the association process after I invoke EZ-Mode by pushing Button SW2 is successful and the green Led starts flashing. But I don't seem to receive the dummy temperature data, which is sent by the SensorTagApp_sendTemp() - Function. 

I'm not sure why the communication fails and have attached some screenshots from the sniffer log. I am fairly new to ZigBee and I am not sure what the frames that are exchanged between coordinator and SensorTag mean, maybe these are the Identify Cluster data requests?

This is the successful association:

(1) Association

And after that these packets are being sent:

(2) Data requests

(3a) First part of packets

(3b) Payloads corresponding to the packets from (3a)

Any help is much appreciated! Thanks for your effort!

Cheers,

Felix

 

  • Hi,

    Can you post the sniffer log files please? (.psd)
  • Hi,

    unfortunately I haven't saved the sniffer log as .psd. I'll post the sniffer log as .psd first thing on monday morning!
    Thanks for your help!

    Regards,
    Felix
  • Do you do binding after device join to your XBee HA network?
  • Ahh, I think you pointed me in the right direction YiKai. Yes, I did try binding, but didn't think of the fact that the XBee Coordinator has probably not configured the ZigBee Cluster Library...and as I only have one EndDevice for now, there's no other device to bind to I guess.

    For now, it would be sufficient for me to just join the network and then periodically send sensor data to the coordinator. Is there a fairly simple way to do that without using the ZCL Commands?

    By looking through the zstackapi.h file I thought of calling the suggested routine in the comment section at the beginning of the file.
    And then after the joining process invoked by calling Zstackapi_DevStartReq(), it is said that I should receive a "zstackmsg_CmdIDs_DEV_STATE_CHANGE_IND" message. And that message is just posted to the ICall entity, right? So, I should be able to catch it with ICall_fetchServiceMsg() and then process it further?

    Thanks for your effort!

    Regards,
    Felix
  • If you only want to send data to XBee coordinator, you can revise the code to use 0x0000 as short address and use correct XBee endpoint to send it.
  • I've tried both options now and I think revising the code for sensortag worked, but unfortunately I can only verify it on wednesday when I have access to the serial adapter for the XBee.

    However, I encountered a different problem, when trying to implement it without zcl commands: after the association the sensortag application does a "xdc_runtime_Syscallback_default_abort" at address 0x126c. What could be the source of that error?

    Here's .c application file and the .psd Sniffer log from running the application:

    #include "sensortagapp.h"
    
    #include <xdc/std.h>
    
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    
    #include <ti/sysbios/BIOS.h>
    
    #include <ti/sysbios/knl/Clock.h>
    #include <ti/sysbios/family/arm/m3/Hwi.h>
    #include <ti/sysbios/knl/Semaphore.h>
    #include <ti/sysbios/family/arm/cc26xx/Power.h>
    #include <string.h>
    #include <inc/hw_ints.h>
    #include <ti/drivers/Pin.h>
    #include "ICall.h"
    #include "zstackapi.h"
    #include "zstack.h"
    #include "znwk_config.h"
    
    
    #include <driverlib/ioc.h>
    
    
    /* Board Header files */
    #include <VEML6070.h>
    #include <MMA8452q.h>
    #include "Board.h"
    #include "util.h"
    
    #define LED_TIMEOUT_VALUE 1000
    
    #define LED_TIMEOUT_EVT 0x01
    
    static ICall_Semaphore sem;
    static ICall_EntityID staEntity;
    
    static PIN_State ledPinState;
    static PIN_Handle ledPinHandle;
    
    static NVINTF_nvFuncts_t *pfnStaNV = NULL;
    
    static Clock_Struct ledClkStruct;
    static Clock_Handle ledClkHandle;
    
    static zstack_AFAddr_t smartBBDstAddr;
    static uint8_t smartBB_endpoint = 0xB4;
    static zstack_SimpleDescriptor_t simpleDesc;
    static zstack_DevState savedState = zstack_DevState_HOLD;
    zstack_sysNwkInfoReadRsp_t * pnwkInfo;
    
    static I2C_Handle i2c;
    I2C_Params params;
    static UInt peripheralNum = 0;
    
    static uint16_t events = 0;
    
    void SmartBBApp_task(NVINTF_nvFuncts_t *pfnNV);
    void SmartBB_process();
    void SmartBB_initialization();
    void SmartBB_initializeClocks();
    void SmartBB_initializeZStack();
    void handleLEDTimeout();
    void ledClkCB();
    void SmartBBApp_processZStackMsgs(zstackmsg_genericReq_t *pMsg);
    
    
    
    void SmartBBApp_task(NVINTF_nvFuncts_t *pfnNV){
      pfnStaNV = pfnNV;
      
      SmartBB_initialization();
      
      SmartBB_process(); 
    }
    
    void SmartBB_initialization(){
      smartBBDstAddr.addrMode = zstack_AFAddrMode_NONE;
      smartBBDstAddr.addr.shortAddr = 0;
      smartBBDstAddr.endpoint = 0;
      smartBBDstAddr.panID = 0;
      
      ledPinHandle = PIN_open(&ledPinState, BoardGpioInitTable);
      PIN_setOutputValue(ledPinHandle, Board_LED1, Board_LED_ON);
      
      //SmartBB_initializeClocks();
      
      ICall_registerApp(&staEntity, &sem); 
      
      SmartBB_initializeZStack();
    }
    
    void SmartBB_initializeZStack(){
      
       //Register Endpoint
       zstack_afRegisterReq_t smartBB_RegReq = {0};
       simpleDesc.deviceID = 0x000C;
       simpleDesc.deviceVer = 0;
       simpleDesc.endpoint = smartBB_endpoint;
       simpleDesc.n_inputClusters = 0;
       simpleDesc.n_outputClusters = 0;
       simpleDesc.pInputClusters = NULL;
       simpleDesc.pOutputClusters = NULL;
       simpleDesc.profileID = 0x0104;
       smartBB_RegReq.endpoint = smartBB_endpoint;
       smartBB_RegReq.latencyReq = zstack_NetworkLatency_NO_LATENCY_REQS;
       smartBB_RegReq.pSimpleDesc = &simpleDesc;
       Zstackapi_AfRegisterReq(staEntity, &smartBB_RegReq); 
       
       //Register for Callbacks
       zstack_devZDOCBReq_t zdoCBReq = {0};
       zdoCBReq.has_devStateChange = true;
       zdoCBReq.devStateChange = true;
       (void)Zstackapi_DevZDOCBReq(staEntity, &zdoCBReq);
       
       //Write Z-Stack parameters
       zstack_sysConfigWriteReq_t  writeReq = { 0 };
       uint8_t extendedPANID[] = ZNWK_CONFIG_EXTENDED_PAN_ID;
       writeReq.has_nwkUseMultiCast = true;
       writeReq.nwkUseMultiCast = false;
       writeReq.has_chanList = true;
       writeReq.chanList = ZNWK_DEFAULT_CHANLIST;
       writeReq.has_extendedPANID = true;
       memcpy(&(writeReq.extendedPANID), extendedPANID, 8);
       writeReq.has_panID = true;
       writeReq.panID = ZNWK_CONFIG_PAN_ID;
      (void) Zstackapi_sysConfigWriteReq(staEntity, &writeReq);
      
      //Start Z-Stack Thread and joining process
      zstack_devStartReq_t  startReq = { 0 };
      startReq.startDelay = 0;
      (void) Zstackapi_DevStartReq(staEntity, &startReq);
      
    }
    
    void SmartBB_initializeClocks(){
      ledClkHandle = Util_constructClock(
                         &ledClkStruct,
                         ledClkCB,
                         LED_TIMEOUT_VALUE,
                         0,
                         false,
                         0);
    }
    
    void SmartBB_initializeI2C(){
      I2C_Params_init(&params);
      
      params.transferMode = I2C_MODE_BLOCKING;
      params.transferCallbackFxn = NULL;
      
      i2c = I2C_open(peripheralNum, &params);
      
      initialize_VEML6070(i2c,0x03);
      initialize_MMA8452(i2c);
    }
    
    void SmartBB_process(){
      ICall_ServiceEnum       stackid;
      ICall_EntityID          dest;
      zstackmsg_genericReq_t  *pMsg;
      
      for(;;){
        if(ICall_wait(ICALL_TIMEOUT_FOREVER) == ICALL_ERRNO_SUCCESS){
          
          if(ICall_fetchServiceMsg(&stackid, &dest, (void **) &pMsg) ==
               ICALL_ERRNO_SUCCESS)
          {
            if((stackid == ICALL_SERVICE_CLASS_ZSTACK) && (dest == staEntity))
            {
              if(pMsg)
              {
                SmartBBApp_processZStackMsgs(pMsg);
    
                // Free any separately allocated memory
                Zstackapi_freeIndMsg(pMsg);
              }
            }
    
            if(pMsg)
            {
              ICall_freeMsg(pMsg);
            }
          }
          if(events & LED_TIMEOUT_EVT){
            
            handleLEDTimeout();
            
            events &= ~(LED_TIMEOUT_EVT);
          }
        }
      }
    }
    
     
    void ledClkCB(UArg a0){
     
      events |= LED_TIMEOUT_EVT;
    
      Semaphore_post(sem);
    }
    
    void handleLEDTimeout(){
      if(Util_isClockActive(&ledClkStruct)){
        Util_stopClock(&ledClkStruct);
      }
      
      PIN_setOutputValue(ledPinHandle, Board_LED1, !PIN_getOutputValue(Board_LED1));
      Util_startClock(&ledClkStruct);
    }
    
    void SmartBBApp_processZStackMsgs(zstackmsg_genericReq_t *pMsg){
      switch(pMsg->hdr.event){
        case zstackmsg_CmdIDs_DEV_STATE_CHANGE_IND:
          {
            zstackmsg_devStateChangeInd_t *pInd =
                                           (zstackmsg_devStateChangeInd_t *) pMsg;
            
            if(savedState != pInd->req.state){
              savedState = pInd->req.state;
              if(savedState == zstack_DevState_DEV_END_DEVICE){
                //Read Device Info
                Zstackapi_sysNwkInfoReadReq(staEntity, pnwkInfo);
                if(pnwkInfo == NULL){
                  System_abort("Network parameters invalid!");
                }
                
                zstack_sysConfigWriteReq_t  writeReq = { 0 };
                // Set the new poll rate
                writeReq.has_pollRate = true;
                writeReq.pollRate = ZNWK_POLL_RATE;
                (void) Zstackapi_sysConfigWriteReq(staEntity, &writeReq);
              }
            
            }
            
          }
          break;
        case zstackmsg_CmdIDs_AF_INCOMING_MSG_IND:
            {
                // Process incoming data messages
                zstackmsg_afIncomingMsgInd_t *pInd
                    = (zstackmsg_afIncomingMsgInd_t *)pMsg;
                SmartBB_processAfIncomingMsgInd( &(pInd->req) );
            }
            break;
        case zstackmsg_CmdIDs_AF_DATA_CONFIRM_IND:
        case zstackmsg_CmdIDs_ZDO_DEVICE_ANNOUNCE:
        case zstackmsg_CmdIDs_ZDO_NWK_ADDR_RSP:
        case zstackmsg_CmdIDs_ZDO_IEEE_ADDR_RSP:
        case zstackmsg_CmdIDs_ZDO_NODE_DESC_RSP:
        case zstackmsg_CmdIDs_ZDO_POWER_DESC_RSP:
        case zstackmsg_CmdIDs_ZDO_SIMPLE_DESC_RSP:
        case zstackmsg_CmdIDs_ZDO_ACTIVE_EP_RSP:
        case zstackmsg_CmdIDs_ZDO_COMPLEX_DESC_RSP:
        case zstackmsg_CmdIDs_ZDO_USER_DESC_RSP:
        case zstackmsg_CmdIDs_ZDO_USER_DESC_SET_RSP:
        case zstackmsg_CmdIDs_ZDO_SERVER_DISC_RSP:
        case zstackmsg_CmdIDs_ZDO_END_DEVICE_BIND_RSP:
        case zstackmsg_CmdIDs_ZDO_BIND_RSP:
        case zstackmsg_CmdIDs_ZDO_UNBIND_RSP:
        case zstackmsg_CmdIDs_ZDO_MGMT_NWK_DISC_RSP:
        case zstackmsg_CmdIDs_ZDO_MGMT_LQI_RSP:
        case zstackmsg_CmdIDs_ZDO_MGMT_RTG_RSP:
        case zstackmsg_CmdIDs_ZDO_MGMT_BIND_RSP:
        case zstackmsg_CmdIDs_ZDO_MGMT_LEAVE_RSP:
        case zstackmsg_CmdIDs_ZDO_MGMT_DIRECT_JOIN_RSP:
        case zstackmsg_CmdIDs_ZDO_MGMT_PERMIT_JOIN_RSP:
        case zstackmsg_CmdIDs_ZDO_MGMT_NWK_UPDATE_NOTIFY:
        case zstackmsg_CmdIDs_ZDO_SRC_RTG_IND:
        case zstackmsg_CmdIDs_ZDO_CONCENTRATOR_IND:
        case zstackmsg_CmdIDs_ZDO_NWK_DISC_CNF:
        case zstackmsg_CmdIDs_ZDO_BEACON_NOTIFY_IND:
        case zstackmsg_CmdIDs_ZDO_JOIN_CNF:
        case zstackmsg_CmdIDs_ZDO_LEAVE_CNF:
        case zstackmsg_CmdIDs_ZDO_LEAVE_IND:
        case zstackmsg_CmdIDs_SYS_RESET_IND:
        case zstackmsg_CmdIDs_AF_REFLECT_ERROR_IND:
        case zstackmsg_CmdIDs_ZDO_TC_DEVICE_IND:
        case zstackmsg_CmdIDs_DEV_PERMIT_JOIN_IND:
            break;
          
        default:
          break;
      }
    }

    smartBBLog.psd

    Thanks for helping me!

    Regards,
    Felix

  • Can you specify where and what you revise your sensortagapp.c?
  • For the sensortagapp revision I changed:

    #define SENSORTAG_TS_EP 9 to #define SENSORTAG_TS_EP 0xB4 (the Packet Sniffer shows that APS Src. Endpoint from Xbee is 0xB4)


    And in SensorTagApp_sendTemp(void) I wrote:

    dstAddr.addrMode = (afAddrMode_t) zstack_AFAddrMode_BROADCAST;
    dstAddr.addr.shortAddr = 0x0000;
    dstAddr.endPoint = 0xB4;

    I didn't modify anything else..
  • You should use zstack_AFAddrMode_SHORT instead of zstack_AFAddrMode_BROADCAST and there is no need to define SENSORTAG_TS_EP as 0xB4 instead of 9. SENSORTAG_TS_EP 9 is the endpoint of sensortag not XBEE.

  • It's working now...Thank you a lot YK!