/*********************************************************************
 * @fn      zcl_ProcessZDOMsgs
 *
 * @brief   Process response messages.
 *
 * @param   inMsg - ZDO response message.
 *
 * @return  none
 */
static void zcl_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg ) {
  uint8 response;
  
  switch( inMsg->clusterID ) {
    case End_Device_Bind_rsp:
      response = ZDO_ParseBindRsp( inMsg );
      if ( response == ZSuccess ) {
        debug_str( "Bind succeeded." );
#if DEV_TYPE != COORDINATOR
        zcl_SendDeviceData();
#endif
      }
      break;

#if DEV_TYPE == COORDINATOR      
    case Device_annce: {
      ZDO_DeviceAnnce_t msg;
      uint8 buffer[50];
      
      ZDO_ParseDeviceAnnce( inMsg, &msg );
      sprintf( ( char* )buffer, "New device joined, address: %d", msg.nwkAddr );
      zcl_SendBindRequest();
      }
      break;
#endif
  }
}
예제 #2
0
/*********************************************************************
 * @fn      OTA_ProcessZDOMsgs
 *
 * @brief   Process messages from the ZDO layer.
 *
 * @param   pMsg - The message from the server.
 *
 * @return  none
 */
void OTA_ProcessZDOMsgs(zdoIncomingMsg_t * pMsg)
{
    if (pMsg)
    {
        if (pMsg->clusterID == Match_Desc_rsp)
        {
            ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( pMsg );

            if (pRsp)
            {
                // Notify the console application of the client device's OTA endpoint
                if (pRsp->cnt)
                    OTA_Send_EndpointInd(pRsp->nwkAddr, pRsp->epList[0]);

                osal_mem_free(pRsp);
            }
        }
        else if (pMsg->clusterID == Device_annce)
        {
            cId_t otaCluster = ZCL_CLUSTER_ID_OTA;
            zAddrType_t dstAddr;

            ZDO_DeviceAnnce_t devAnnce;
            ZDO_ParseDeviceAnnce(pMsg, &devAnnce);
            OTA_Send_DeviceInd(devAnnce.nwkAddr);

            // Send out a match for the OTA cluster ID
            dstAddr.addrMode = Addr16Bit;
            dstAddr.addr.shortAddr = devAnnce.nwkAddr;
            ZDP_MatchDescReq( &dstAddr, devAnnce.nwkAddr, ZCL_OTA_SAMPLE_PROFILE_ID,
                              0, NULL, 1, &otaCluster, FALSE );
        }
    }
}
예제 #3
0
/*********************************************************************
 * @fn          zllSampleBridge_ProcessZDOMsg
 *
 * @brief       Process ZDO messages for Device Discovery
 *
 * @param       inMsg - Incoming ZDO message
 *
 * @return      none
 */
static void zllSampleBridge_ProcessZDOMsg( zdoIncomingMsg_t *inMsg )
{
  static zAddrType_t addr;
  addr.addrMode = Addr16Bit;

  switch ( inMsg->clusterID )
  {
    case Device_annce:
      {
        ZDO_DeviceAnnce_t devAnnce;

        ZDO_ParseDeviceAnnce( inMsg, &devAnnce );
        if ( ( lastDevAnnceAddr != INVALID_NODE_ADDR ) && ( lastDevAnnceAddr != devAnnce.nwkAddr ) )
        {
          zllSampleBridge_SendActiveEPReq( lastDevAnnceAddr );
        }
        lastDevAnnceAddr = devAnnce.nwkAddr;
        osal_start_timerEx( zllSampleBridge_TaskID, SAMPLEBRIDGE_DEV_ANNCE_EVT, DEVICE_DISCOVERY_DELAY );
      }
      break;

    case Active_EP_rsp:
      {
        ZDO_ActiveEndpointRsp_t *pActiveEPs = NULL;
        pActiveEPs = ZDO_ParseEPListRsp( inMsg );
        if ( pActiveEPs->status == ZSuccess )
        {
          for (uint8 i=0; i < pActiveEPs->cnt; i++ )
          {
            addr.addr.shortAddr = pActiveEPs->nwkAddr;
            ZDP_SimpleDescReq( &addr, pActiveEPs->nwkAddr, pActiveEPs->epList[i], 0 );
          }
        }

        if ( pActiveEPs != NULL )
        {
          osal_mem_free( pActiveEPs );
        }
      }
      break;

    case Simple_Desc_rsp:
      {
        ZDO_SimpleDescRsp_t simpleDescRsp;
        simpleDescRsp.simpleDesc.pAppInClusterList = simpleDescRsp.simpleDesc.pAppOutClusterList = NULL;
        ZDO_ParseSimpleDescRsp( inMsg, &simpleDescRsp );

        if ( ( simpleDescRsp.status == ZDP_SUCCESS ) && ( zllSampleBridge_SelectTargetSimpleDesc( &(simpleDescRsp.simpleDesc) ) ) )
        {
          epInfoRec_t rec;
          rec.nwkAddr = simpleDescRsp.nwkAddr;
          rec.endpoint = simpleDescRsp.simpleDesc.EndPoint;
          rec.profileID = simpleDescRsp.simpleDesc.AppProfId;
          rec.deviceID = simpleDescRsp.simpleDesc.AppDeviceId;
          rec.version = simpleDescRsp.simpleDesc.AppDevVer;
          zllSampleBridge_UpdateLinkedTarget( &rec );
          HalLcdWriteStringValueValue( "linked:", simpleDescRsp.nwkAddr, 16, simpleDescRsp.simpleDesc.EndPoint, 16, HAL_LCD_LINE_3 );
        }
        if ( simpleDescRsp.simpleDesc.pAppInClusterList != NULL )
        {
          osal_mem_free( simpleDescRsp.simpleDesc.pAppInClusterList );
        }
        if ( simpleDescRsp.simpleDesc.pAppOutClusterList != NULL )
        {
          osal_mem_free( simpleDescRsp.simpleDesc.pAppOutClusterList );
        }
      }
      break;

    default:
      break;
  }
}