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.

CC2530: What is the code that retrieves EP, ID, Adresses from ZC?

Part Number: CC2530
Other Parts Discussed in Thread: Z-STACK

Hi,

I noticed that everytime the ZED connects to the ZC, it gathers all the EP, ID, Address information from the ZC so that it can communicate with it. I am curious as to where the code for this retrieval process is - what files and what functions?

  • From "ZDO_ParseSimpleDescRsp( inMsg, &simpleDescRsp );", how can I check if a cluster matches to my cluster?
  • simpleDescRsp contains simpleDesc which is SimpleDescriptionFormat_t and it lists in/out clusters.
  • I see that pAppInClusterList is in uin16 (cId_t form), but how can I use a for loop to check every cluster in the cluster list?
  • AppNumInClusters is the number of In cluster list.
  • Ok. So I am now trying to check each cluster ID in the simple descriptor cluster list. How could I do something like this?

    for(uint8 cluster=0; cluster < simpleDescRsp.simpleDesc.AppNumInClusters; cluster++){
       if(pAppInClusterList[cluster] == ZCL_CLUSTER_ID_GEN_POWER_CFG){
          onOffEP = ep;
       }
    }

  • What is your pAppInClusterList? Again, this is very fundamental in C programming to access a data structure and compare with anther one. I suggest you to google and you can find lots of CC programming skill about this.
  • You said a list of clusters is in the simple descriptor right? And this list is called pAppInClusterList. However it isn't in array format - it's in uint16 format. I don't see how I can read each cluster in this list?

  • pAppInClusterList and pAppOutClusterList inside SimpleDescriptionFormat_t give you in/out cluster array.

    typedef struct
    {
    uint8 EndPoint;
    uint16 AppProfId;
    uint16 AppDeviceId;
    uint8 AppDevVer:4;
    uint8 Reserved:4; // AF_V1_SUPPORT uses for AppFlags:4.
    uint8 AppNumInClusters;
    cId_t *pAppInClusterList;
    uint8 AppNumOutClusters;
    cId_t *pAppOutClusterList;
    } SimpleDescriptionFormat_t;
  • So basically what I got now is a program that checks all EPs of ZC; then sends a Simple Descriptor Request to each EP if more than 1 EP exists; then checks if any cluster in Simple Descriptor Response matches desired cluster ID; then saves value of EP from the Simple Descriptor Response. It looks like the below. My only concern is the parts that say "WAIT FOR..." in the code. That is because the next part of the code is dependent on a response. So I am not sure if I need to add code to wait for a response before the code moves on to the next part. What do you think?

    static uint8 checkCluster( uint8 cID ){
      ////////////////////////////////// Check each EP of ZC if match clusterID
      for(uint8 ep=0; ep < pActiveEndpointRsp->cnt; ep++){
        // Send Simple Descriptor Request to retrieve cluster list to select correct EP
        zAddrType_t destAddr;
        uint16 shortAddr;
    
        /* Dev address */
        destAddr.addrMode = Addr16Bit;
        destAddr.addr.shortAddr = 0x0000;
        /* Network address of interest */
        shortAddr = 0x0000;
      
        ZDP_SimpleDescReq( &destAddr, shortAddr, ep, 0 );
        
        // WAIT FOR Simple Descriptor Response?
        
        // For each cluster in simple descriptor by ZC,
        // check if match ZCL_CLUSTER_ID_GEN_POWER_CFG
        // to set onOffEP to EP
        for(uint8 cluster=0; cluster < simpleDescRsp.simpleDesc.AppNumInClusters; cluster++){
          if(simpleDescRsp.simpleDesc.pAppInClusterList[cluster] == cID){
            return ep;
          }
        }
      }
      return 1;
    }
    /* Below is inside another function */
    
    ZDP_ActiveEPReq( &destAddr, shortAddr, 0 );
      
    // WAIT FOR EP Response?
    
    onOffEP = checkCluster( ZCL_CLUSTER_ID_GEN_ON_OFF );

    
    
  • You cannot do "Wait for..." in that way. I already replied you have to add a new case "Simple_Desc_rsp" in ZDApp_ProcessMsgCBs and use ZDO_ParseSimpleDescRsp to parse Simple Descriptor response.