⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ztceventmonitor.c

📁 FREESCALE的基于802.15.4无线通讯原代码
💻 C
📖 第 1 页 / 共 2 页
字号:
  &mApsmeQueue,         /* ZDO_APSME_SapHandler */
#else
  NULL,
  NULL,
#endif  /*( gResCapability_d == 1 ) || ( gComCapability_d == 1 )  */    
  &mAppZdpInputQueue,   /* APP_ZDP_SapHandler */
  NULL                  /* ZDP_APP_SapHandler */
};

/*  This table maps SAPids to the task events of corresponding Tasks  */
static event_t * const maSAPIdToTaskIdTable[] = {
  &aTaskArray[gMacTaskPriority_c].taskEvent,
  &aTaskArray[gNwkTaskPriority_c].taskEvent,
  &aTaskArray[gMacTaskPriority_c].taskEvent,
  &aTaskArray[gNwkTaskPriority_c].taskEvent,
  &aTaskArray[gMacTaskPriority_c].taskEvent,
  &aTaskArray[gNwkTaskPriority_c].taskEvent,
  &aTaskArray[gNwkTaskPriority_c].taskEvent,
  &aTaskArray[gApsTaskPriority_c].taskEvent,
  &aTaskArray[gNwkTaskPriority_c].taskEvent,
  &aTaskArray[gZdoTaskPriority_c].taskEvent,
  &aTaskArray[gApsTaskPriority_c].taskEvent,
  &aTaskArray[gAfTaskPriority_c] .taskEvent,
  &aTaskArray[gAfTaskPriority_c] .taskEvent,
  NULL,
  &aTaskArray[gApsTaskPriority_c].taskEvent,
  &aTaskArray[gZdoTaskPriority_c].taskEvent,
  &aTaskArray[gZdoTaskPriority_c].taskEvent,
  NULL 
};

/*  This table is used to clear the events after Dequeing in HOOk Mode  */
static const uint8_t maSAPIdToTaskEventIdMaskTable[] = {
  ~gMACEventNwkMCPSMsgQueuedEvent_c ,
  ~gMCPSToNwkEvent_c                ,
  ~gMACEventNwkMLMEMsgQueuedEvent_c , 
  ~gMLMEToNwkEvent_c                ,							  
  ~gMACEventMemASPMsgQueuedEvent_c  ,
  0                                 , /* ASP to NWK */ 
  ~gAPSToNLDEEvent_c                ,
  ~gNLDEToAPSEvent_c                ,
  ~gZDOToNLMEEvent_c                ,
  ~gNLMEToZDOEvent_c                ,
  ~gAFToAPSDEEvent_c                ,
  ~gAPSDEToAFEvent_c                ,
  ~gAppToAFEvent_c                  ,
  0                                 , /* AF to APP */
  ~gZDOToAPSMEEvent_c               ,
  ~gAPSMEToZDOEvent_c               ,
  ~gAPPToZDPEvent_c                 ,
  0                                  /* ZDP to APP */
};

/* This look up stores 1 if the SAP Id is from upper layer to the lower layer 
else stores 0. */ 
static const uint8_t maIsSAPIdFromUpperToLowerLayer[] = {
  1,/* gNwkMCPS_SAPHandlerId_c */
  0,/* gMCPSNwkSAPHandlerId_c */
  1,/* gNwkMLME_SAPHandlerId_c */
  0,/* gMLMENwkSAPHandlerId_c */ 
  1,/* gNwkASP_SAPHandlerId_c */
  0,/* gASPNwkSAPHandlerId_c */
  1,/* gAPS_NLDE_SAPHandlerId_c */ 
  0,/* gNLDE_APS_SAPHandlerId_c */
  1,/* gZDO_NLME_SAPHandlerId_c */
  0,/* gNLME_ZDO_SAPHandlerId_c */
  1,/* gAF_APSDE_SAPHandlerId_c */ 
  0,/* gAPSDE_AF_SAPHandlerId_c */
  1,/* gAppAFDE_SAPHandlerId_c */
  0,/* gAFDEAppSAPHandlerId_c */
  1,/* gZDO_APSME_SAPHandlerId_c */
  0,/* gAPSME_ZDO_SAPHandlerId_c */
  1,/* gAppZDP_SAPHandlerId_c */
  0 /* gZDPAppSAPHandlerId_c */  
};

#endif
/******************************************************************************
*******************************************************************************
Public memory declarations
*******************************************************************************
******************************************************************************/
/* None */

/******************************************************************************
*******************************************************************************
* Public functions
*******************************************************************************
******************************************************************************/
uint8_t ZTCEventMonitor_ConvertSAPIdToZTCMsgId
  (
  const uint8_t msgType,  /* IN:Message type used in the primitive */
  const uint8_t  SAPId   /* IN:SapId used by ZTC
    (Opcode Grp converted to SapId) */
  ) 
{
  uint8_t msgIdUsedInZTC;  
  if( SAPId < gZDO_APSME_SAPHandlerId_c ) {  /* other SAPId's primitives are 
    special cases.ie they are not in order  */ 
     
    if((SAPId !=  gAFDEAppSAPHandlerId_c )&&(SAPId != gAppAFDE_SAPHandlerId_c))
    {
      msgIdUsedInZTC = maStartMsgIdForSAPId[ SAPId ] + msgType; 
    }
#if gBeeStackIncluded_d == 1    
    else {
      if(SAPId ==  gAFDEAppSAPHandlerId_c ) {
        msgIdUsedInZTC = maStartMsgIdForSAPId[ SAPId ] + 
    		  msgType - mMsgTypeForAFToAppSAP;
      }
      else {
        msgIdUsedInZTC = maStartMsgIdForSAPId[ SAPId ] + msgType; 
      }
    }
  }
 
  else if( SAPId == gZDO_APSME_SAPHandlerId_c || 
    SAPId == gAPSME_ZDO_SAPHandlerId_c )  {
    if( msgType <= mApsmeSetToReadyState )  {
      msgIdUsedInZTC = maZDO_APSMENonSecPrimitivesToZTCMsgId[ msgType ]; 
    }
    else  {
      msgIdUsedInZTC = maZDO_APSMESecPrimitivesToZTCMsgId[ msgType - 
        gApsmeEstablishKeyReq_c ];   
    }
  } 
  else {
    if( msgType <= gMgmtDirectJoinResp_c )  {
      msgIdUsedInZTC =  ( uint8_t )( ( msgType & gGetRespBit_c ) ? 
        maZDPPrimitivesToZTCMsgId[( msgType & mMaskResponseBit_c )] + 
          gZTCNwkAddrResp_c - gZTCNwkAddrReq_c:
      maZDPPrimitivesToZTCMsgId[ msgType ] );
    }
    else  {
      msgIdUsedInZTC = maOtherZDPPrimitivesToZTCMsgId[ msgType
        - gZdoApsmeEstKeyReq_c ]; 
    }
  }
#else
}
#endif
  return msgIdUsedInZTC;
}

/****************************************************************************/

void ZTC_TaskEventMonitor
  (
  const uint8_t SAPId,  /*  IN: SAP Id used in ZTC  */
  uint8_t*      pMsg,   /*  IN/OUT: pointer to message  */
  const uint8_t status  /*  IN: status returned from the SAP handler */
  ) 
{ 
uint8_t msgIdUsedInZTC;
  if((SAPId != gAFDEAppSAPHandlerId_c )&&(SAPId != gAppAFDE_SAPHandlerId_c)) {
    msgIdUsedInZTC = ZTCEventMonitor_ConvertSAPIdToZTCMsgId( * pMsg, SAPId );   
  }
  else  {
    msgIdUsedInZTC = ZTCEventMonitor_ConvertSAPIdToZTCMsgId( status, SAPId );
  }
  
  if( gInjectedTheMessage == TRUE ) {
    gInjectedTheMessage = FALSE;
    return;
  }
  if( gaZTC_SAPMode[ SAPId ] ) {
#if gZTC_FilterCapability_d == 1
    if( ZTCFilter_IsToBeFiltered( msgIdUsedInZTC )) {
#endif  /*  gFilterCapability_d  */  								
      ZTCQueue_QueueToSendToTestClient( pMsg, SAPId, msgIdUsedInZTC,status );   
#if gZTC_FilterCapability_d == 1    
    }
#endif  /*  gZTC_FilterCapability_d  */
#if gBeeStackIncluded_d == 1      
    if( gaZTC_SAPMode[ SAPId ] == gZTC_ModeHook_c && 
      !maIsSAPIdFromUpperToLowerLayer[ SAPId ])  {
      if(( SAPId != gAppAFDE_SAPHandlerId_c ) && 
        ( SAPId !=  gAFDEAppSAPHandlerId_c )) {          
        pMsg = MSG_DeQueue( maAddrOfSAPQueueTable[ SAPId ]);
        
        *maSAPIdToTaskIdTable[ SAPId ] &= 
        ( event_t )maSAPIdToTaskEventIdMaskTable[ SAPId ]; 
        MSG_Free( pMsg );
      }
    }
#if gZTC_AutomatedScriptEnabled_d == 1   
    else  {
      ZTCEventMonitor_SendSAPHandlerCallEvent( SAPId, *pMsg );  
    }
#endif  /*  gZTC_AutomatedScriptEnabled_d */
#endif   
  } 
}
/******************************************************************************
*******************************************************************************
* Private functions
*******************************************************************************
******************************************************************************/
/*If Automated Script is enabled then only this part of code will be enabled*/
#if gZTC_AutomatedScriptEnabled_d == 1   
void ZTCEventMonitor_SendSAPHandlerCallEvent
  (
   const uint8_t SAPId, /* IN : SAP ID used in the ZTC */
   const uint8_t msgId  /* IN : Message ID passed to the layer */
  ) 
{
  uint8_t aData[ gLengthOfSAPCalledEvent ];
  aData[ gFirstFieldForTheSAPCalledEvent_c ] = SAPId;
  aData[ gSecondFieldForTheSAPCalledEvent_c ] = msgId;
   if(( ZTCQueue_SpaceAvailableToWriteIntoBuffer ) >= 
      ( gHeaderSize_c + gLengthOfSAPCalledEvent )) {
      ( void ) ZTCQueue_QueueToTestClient(( uint8_t* ) aData,
        gOpCodeGrpForZTCConf_c, gSendSAPCalledEvent_c, 
          gLengthOfSAPCalledEvent );   
      }
}
#endif  /*  gZTC_AutomatedScriptEnabled_d */


/******************************************************************************
*******************************************************************************
* Private Debug stuff
*******************************************************************************
******************************************************************************/
/* None */
#else
/* Dummy function to avoid linker error for the target without ZTC */
void ZTC_TaskEventMonitor
  (
  const uint8_t SAPId,  /*  IN: SAP Id used in ZTC  */
  uint8_t*      pMsg,   /*  IN/OUT: pointer to message  */
  const uint8_t status  /*  IN: status returned from the SAP handler */
  ) 
{
  ( void )SAPId;
  ( void )pMsg;
  ( void )status; 
}
#endif  

 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -