Пример #1
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 );
        }
    }
}
Пример #2
0
/*********************************************************************
 * @fn      SerialApp_ProcessZDOMsgs()
 *
 * @brief   Process response messages
 *
 * @param   none
 *
 * @return  none
 */
static void SerialApp_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg )
{
  switch ( inMsg->clusterID )
  {
    case End_Device_Bind_rsp:
      if ( ZDO_ParseBindRsp( inMsg ) == ZSuccess )
      {
        // Light LED
        HalLedSet( HAL_LED_1, HAL_LED_MODE_ON );
        osal_stop_timerEx(SerialApp_TaskID,SERIALAPP_MSG_AUTOMATCH);
             
      }
#if defined(BLINK_LEDS)
      else
      {
        // Flash LED to show failure
        HalLedSet ( HAL_LED_1, HAL_LED_MODE_FLASH );
      }
#endif
      break;

    case Match_Desc_rsp:
      {
        ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( inMsg );
        if ( pRsp )
        {
          if ( pRsp->status == ZSuccess && pRsp->cnt  
               && SerialApp_DstAddr.addrMode == afAddrNotPresent
                )
          {
            osal_stop_timerEx(SerialApp_TaskID,SERIALAPP_MSG_AUTOMATCH);
            SerialApp_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
#if defined(ZDO_COORDINATOR)          
            SerialApp_DstAddr.addr.shortAddr = pRsp->nwkAddr;
#else
            SerialApp_DstAddr.addr.shortAddr = NWK_BROADCAST_SHORTADDR_DEVZCZR;
#endif            
            // Take the first endpoint, Can be changed to search through endpoints
            SerialApp_DstAddr.endPoint = pRsp->epList[0];
            // Light LED
            HalLedSet( HAL_LED_2, HAL_LED_MODE_ON );
            
#if defined(ZDO_COORDINATOR)
            HalUARTWrite(SERIAL_APP_PORT,"OK\n",3);
#endif 
          }
          osal_mem_free( pRsp );
        }
      }
      break;
  }
}
Пример #3
0
/*********************************************************************
 * @fn      zclSampleSw_ProcessZDOMsgs
 *
 * @brief   Called when this node receives a ZDO/ZDP response.
 *
 * @param   none
 *
 * @return  status
 */
static void zclSampleSw_ProcessZDOMsgs( zdoIncomingMsg_t *pMsg )
{

  // Let EZ-Mode know of the Match Descriptor Reponse (same as ActiveEP Response)
  if ( pMsg->clusterID == Match_Desc_rsp )
  {
    zclEZMode_ActionData_t data;
    ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( pMsg );
    data.pMatchDescRsp = pRsp;
    zcl_EZModeAction( EZMODE_ACTION_MATCH_DESC_RSP, &data );
    osal_mem_free(pRsp);
  }
}
/*********************************************************************
 * @fn      zclSampleTemperatureSensor_ProcessZDOMsgs
 *
 * @brief   Called when this node receives a ZDO/ZDP response.
 *
 * @param   none
 *
 * @return  status
 */
static void zclSampleTemperatureSensor_ProcessZDOMsgs( zdoIncomingMsg_t *pMsg )
{
  zclEZMode_ActionData_t data;
  ZDO_MatchDescRsp_t *pMatchDescRsp;

  // Let EZ-Mode know of the Match Descriptor Response
  if ( pMsg->clusterID == Match_Desc_rsp )
  {
    pMatchDescRsp = ZDO_ParseEPListRsp( pMsg );
    data.pMatchDescRsp = pMatchDescRsp;
    zcl_EZModeAction( EZMODE_ACTION_MATCH_DESC_RSP, &data );
    osal_mem_free( pMatchDescRsp );
  }
}
/*********************************************************************
 * @fn      SAPI_ProcessZDOMsgs()
 *
 * @brief   Process response messages
 *
 * @param   none
 *
 * @return  none
 */
void SAPI_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg )
{
  switch ( inMsg->clusterID )
  {
    case NWK_addr_rsp:
      {
        // Send find device callback to application
        ZDO_NwkIEEEAddrResp_t *pNwkAddrRsp = ZDO_ParseAddrRsp( inMsg );
        SAPI_FindDeviceConfirm( ZB_IEEE_SEARCH, (uint8*)&pNwkAddrRsp->nwkAddr, pNwkAddrRsp->extAddr );
      }
      break;

    case Match_Desc_rsp:
      {
        zAddrType_t dstAddr;
        ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( inMsg );

        if ( sapi_bindInProgress != 0xffff )
        {
          // Create a binding table entry
          dstAddr.addrMode = Addr16Bit;
          dstAddr.addr.shortAddr = pRsp->nwkAddr;

          if ( APSME_BindRequest( sapi_epDesc.simpleDesc->EndPoint,
                     sapi_bindInProgress, &dstAddr, pRsp->epList[0] ) == ZSuccess )
          {
            osal_stop_timerEx(sapi_TaskID,  ZB_BIND_TIMER);
            osal_start_timerEx( ZDAppTaskID, ZDO_NWK_UPDATE_NV, 250 );

            // Find IEEE addr
            ZDP_IEEEAddrReq( pRsp->nwkAddr, ZDP_ADDR_REQTYPE_SINGLE, 0, 0 );
#if defined ( MT_SAPI_CB_FUNC )
            zb_MTCallbackBindConfirm( sapi_bindInProgress, ZB_SUCCESS );
#endif              
            // Send bind confirm callback to application
#if ( SAPI_CB_FUNC )
            zb_BindConfirm( sapi_bindInProgress, ZB_SUCCESS );
#endif
            sapi_bindInProgress = 0xffff;
          }
        }
      }
      break;
  }
}
Пример #6
0
/*********************************************************************
 * @fn      GenericApp_ProcessZDOMsgs()
 *
 * @brief   Process response messages
 *
 * @param   none
 *
 * @return  none
 */
static void GenericApp_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg )
{
  switch ( inMsg->clusterID )
  {
    case End_Device_Bind_rsp:
      if ( ZDO_ParseBindRsp( inMsg ) == ZSuccess )
      {
        // Light LED
        HalLedSet( HAL_LED_2, HAL_LED_MODE_ON );
      }
#if defined( BLINK_LEDS )
      else
      {
        // Flash LED to show failure
        HalLedSet ( HAL_LED_2, HAL_LED_MODE_FLASH );
      }
#endif
      break;

    case Match_Desc_rsp:
      {
        uprint("Match_Decs_rsp");
        ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( inMsg );
        if ( pRsp )
        {
          if ( pRsp->status == ZSuccess && pRsp->cnt )
          {
            GenericApp_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
            //GenericApp_DstAddr.addr.shortAddr = pRsp->nwkAddr;
            GenericApp_DstAddr.addr.shortAddr = 0xFFFF;
            
            // Take the first endpoint, Can be changed to search through endpoints
            GenericApp_DstAddr.endPoint = pRsp->epList[0];

            // Light LED
            //HalLedSet( HAL_LED_2, HAL_LED_MODE_ON );
          }
          osal_mem_free( pRsp );
        }
      }
      break;
  }
}
Пример #7
0
/*********************************************************************
 * @fn      rangeext_ProcessZDOMsgs
 *
 * @brief   Called to process callbacks from the ZDO.
 *
 * @param   none
 *
 * @return  none
 */
static void rangeext_ProcessZDOMsgs( zdoIncomingMsg_t *pMsg )
{
  if (pMsg->clusterID == Match_Desc_rsp)
  {
    ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( pMsg );

    if (pRsp)
    {
      if (pRsp->cnt)
      {
        // Record the trust center
        ESPAddr.endPoint = pRsp->epList[0];
        ESPAddr.addr.shortAddr = pMsg->srcAddr.addr.shortAddr;

        // send out key establishment request
        osal_set_event( rangeExtTaskID, RANGEEXT_KEY_ESTABLISHMENT_REQUEST_EVT);
      }
      osal_mem_free(pRsp);
    }
  }
}
Пример #8
0
//This function process the ZDO events to bind
static void ParkWay_ProcessZDOMsgs( zdoIncomingMsg_t *inMsg )
{
  switch ( inMsg->clusterID )
  {
    case End_Device_Bind_rsp:
      if ( ZDO_ParseBindRsp( inMsg ) == ZSuccess )
      {
        // Light LED
        //HalLedSet ( HAL_LED_2, HAL_LED_MODE_FLASH );
      }
      break;

    case Match_Desc_rsp:
      {
        ZDO_ActiveEndpointRsp_t *pRsp = ZDO_ParseEPListRsp( inMsg );
        if ( pRsp )
        {
          if ( pRsp->status == ZSuccess && pRsp->cnt )
          {
            ParkWay_DstAddr.addrMode = (afAddrMode_t)Addr16Bit;
            ParkWay_DstAddr.addr.shortAddr = pRsp->nwkAddr;
            // Take the first endpoint, Can be changed to search through endpoints
            ParkWay_DstAddr.endPoint = pRsp->epList[0];

            // Light LED
            //HalLedSet( HAL_LED_2, HAL_LED_MODE_ON );

            //This stop the peer from send request do the coordinator
            //HalLedSet ( HAL_LED_1, HAL_LED_MODE_OFF);
            osal_stop_timerEx( ParkWay_TaskID,POLLING_OF_DEV_EVT);
          }
          osal_mem_free( pRsp );
        }
      }
      break;
  }
}
Пример #9
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;
  }
}