Quantcast
Viewing all articles
Browse latest Browse all 116964

Forum Post: RE: function of SceneCopy in ZLL

Bill,
    These API's are documented in Section 4 of "Documents\API\Z-Stack Lighting API.pdf" in the ZStack-Lighting-1.0.1 installer. I have a very rough code snip below, this is purely for a reference to help you get started, I have not tested this so there may be issues to fix. But I hope this help you progress:

ZStatus_t zllSampleRemote_GetEPListRsp( afAddrType_t *srcAddr, zclLLGetEPListRsp_t *pRsp );

// ZLL Command Callbacks table
static zclLL_AppCallbacks_t zllSampleRemote_LLCmdCBs =
{
  // Received Server Commands
  zllSampleRemote_GetGrpIDsReqCB, // Get Group Identifiers Request command
  zllSampleRemote_GetEPListReqCB, // Get Endpoint List Request command

  // Received Client Commands
  zllSampleRemote_GetEndpointInfoCB, // Endpoint Information command
  NULL, // Get Group Identifiers Response command
  //TC: Regedter the callback
  zllSampleRemote_GetEPListRsp // Get Endpoint List Response command
};


ZStatus_t zllSampleRemote_GetEPListRsp( afAddrType_t *srcAddr, zclLLGetEPListRsp_t *pRsp )
{
  uint8 tagetIdx, rspEpIdx;

  //Index through the Ep's in the response. Assume cnt is 1 and the lights only support 1 sub device
  for(rspEpIdx=pRsp->startIndex; rspEpIdx < pRsp->total; rspEpIdx++)
  {
    //See if the target is already in our list 
    for ( tagetIdx = 0; tagetIdx < MAX_LINKED_TARGETS; tagetIdx++ )
    {
      if ( ( linkedTargets.arr[tagetIdx].Addr == pRsp->epInfoRec[rspEpIdx].nwkAddr )
      && ( linkedTargets.arr[tagetIdx].EP == pRsp->epInfoRec[rspEpIdx].endpoint ) )
      {
        break; // found existing entry, overwrite.
      }
    }
    //this target is not in our records
    if ( tagetIdx == MAX_LINKED_TARGETS )
    {
      tagetIdx = linkedAddrNextIdx;
      if( linkedAddrNextIdx > (MAX_LINKED_TARGETS-1) )
      {
        //wrap around and overwrite previous address
        linkedAddrNextIdx=0;
      }
      else
      {
        linkedAddrNextIdx++;
        if ( linkedAddrNum < MAX_LINKED_TARGETS )
        {
          linkedAddrNum++;
        }
      }
    }
    linkedTargets.arr[tagetIdx].Addr = pRsp->epInfoRec[rspEpIdx].nwkAddr;
    linkedTargets.arr[tagetIdx].profileID = pRsp->epInfoRec[rspEpIdx].profileID;
    linkedTargets.arr[tagetIdx].deviceID = pRsp->epInfoRec[rspEpIdx].deviceID;
    linkedTargets.arr[tagetIdx].deviceVersion = pRsp->epInfoRec[rspEpIdx].version;
    linkedTargets.arr[tagetIdx].EP = pRsp->epInfoRec[rspEpIdx].endpoint;
    linkedAddrSelIdx = tagetIdx;

    // update linkedAddr in NV
#if defined ( NV_RESTORE )
    osal_nv_write( ZCD_NV_ZLL_REMOTE_LINK_TARGETS, 0, sizeof( linkedTargets ), &linkedTargets );
#endif
  }
}


Viewing all articles
Browse latest Browse all 116964

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>