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

📄 ztcprimitivehandlercomplexprimutilitysupport.c

📁 FREESCALE的基于802.15.4无线通讯原代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/******************************************************************************
* This module formats the complex primitives which are to be exchanged between
* the test client and BeeStack Layers. Complex primitives are one for which
* ZTC has to format.Here formatting means ZTC has to put the messages in proper
* way so that BeeStack can understand when test client sends and vice-versa    
*
*
* (c) Copyright 2006, Freescale, Inc. All rights reserved.
*
* Freescale Semiconductor Confidential Proprietary
*
* No part of this document must be reproduced in any form - including copied,
* transcribed, printed or by any electronic means - without specific written
* permission from Freescale Semiconductor Danmark A/S.
*
******************************************************************************/
#if ( gZtcIncluded_d == 1  )
#if ( gBeeStackIncluded_d ==1 )
#include "EmbeddedTypes.h"
#include "PublicConst.h"
#include "ZtcInterface.h"
#include "NV_Data.h"
#include "ZtcPrimitiveHandlerComplexPrimitive.h" 
#include "BeeStackConfiguration.h"
#include "BeeStackUtil.h"
#include "ZDOStateMachineHandler.h"
#include "AfZdoInterface.h"
#include "ZtcPrimitiveHandlerComplexPrimWithOnePtr.h"
#include "ZtcPrimitiveHandlerComplexPrimWithTableList.h"
#include "ZtcPrimitiveHandlerComplexPrimSyncPrim.h"
#include "ZtcConfiguration.h"
#include "AppsMain.h"
#include "ZtcEventMonitor.h"
#include "ZtcPrimitiveHandlerComplexPrimUtilitySupport.h"

/*If utility Support capability is enabled then only this part of code will be 
enabled*/
#if gZTC_UtilitySupportCapability_d == 1

/******************************************************************************
*******************************************************************************
* Private macros
*******************************************************************************
******************************************************************************/

/*Note: The user can register maximum of 6 clusterIds( both inclusterlist 
  and OutClusterList)*/
#define mMaxClusterIdSupported_c      0x06     
#define mStackBottom_c                0x0100
#define mStackTop_c                   0x025F
#define mStackFunctionCallOverhead_c  0x0A
#define mNumOfByteParams_c            11
#define mByteParaLength_c             0x04
#define mSetAPSTable_c                0x01
/* Opcode group ID for the confirmation of Utility support */
enum  {
  mOpCodeGrpIdForRegConf_c                   = 0x0,
  mOpCodeGrpIdForDeRegConf_c                 = 0x1,
  mOpCodeGrpIdForConfigAttrConf_c            = 0xDD,
  mOpCodeGrpIdForWriteExtendedAddrConf_c     = 0xDE,      
  mOpCodeGrpIdForReadExtendedAddrConf_c      = 0xD3,
  mOpCodeGrpIdForBeeStackSaveConf_c          = 0xE5,
  mOpCodeGrpIdForStartNwkConf_c              = 0x19,
  mOpCodeGrpIdForReStartNwkConf_c  			     = 0x17,
  mOpCodeGrpIdForStopNwkConf_c					     = 0x20,
  mOpCodeGrpIdForInitialiseStackUsageConf_c	 = 0xEC,
  mOpCodeGrpIdForFindStackUsageConf_c				 = 0xED,
  mAFResetConf_c														 = 0x06,
  mAPSResetConf_c                            = 0x0B,
  mAPSSetToReadyStateConf_c                  = 0x0C,
  
};

/*opdode id's for messages from AF to APP*/
enum {
  mOpcodeGrpIdForNumOfActiveEpConf_c     = 0x09,
  mOpcodeGrpIdForEpDescConf_c            = 0x07,
  mOpcodeGrpIdForEpListConf_c            = 0x08
};

/******************************************************************************
*******************************************************************************
* Private prototypes
*******************************************************************************
******************************************************************************/
/*****************************************************************************
* Writes the extended address into the NVRAM.
*
* Interface assumptions:
*   None
*
* The routine limitations.
*   None
*
* Return value:
*   Returns message Id used by Ztc 
*
* Effects on global data.
*   None
*
* Source of algorithm used.
*   None
*
* Revison history:
*   date    Author   Comments
*   ------  ------   --------
*   240306  SP,      Updated
*****************************************************************************/
#if ( gZTC_WriteExtendedAddrReqCapabilty_d == 1 )
static uint8_t ZTC_WriteExtendedAddress
  ( 
  uint8_t* pAddress  /* IN: Pointer to the address where the address to 
    update is stored */
  );
#endif /* gZTC_WriteExtendedAddrReqCapabilty_d */

/*****************************************************************************
* This function fills the stack space by 0xDD
*
* Interface assumptions:
*   None
*
* The routine limitations.
*   None
*
* Return value:
*   current stack top (initially it is 0x25f )
*
* Effects on global data.
*   None
*
* Source of algorithm used.
*   None
*
* Revison history:
*   date    Author   Comments
*   ------  ------   --------
*   240306  SP,      Updated
*****************************************************************************/
static uint16_t InitializeStackUsage
  (
  void
  );

/*****************************************************************************
* Writes teh extended address into the NVRAM.
*
* Interface assumptions:
*   None
*
* The routine limitations.
*   None
*
* Return value:
*   Returns message Id used by Ztc 
*
* Effects on global data.
*   None
*
* Source of algorithm used.
*   None
*
* Revison history:
*   date    Author   Comments
*   ------  ------   --------
*   240306  SP,      Updated
*****************************************************************************/
static uint16_t FindStackUsed
 (
 void
  
 );
/*****************************************************************************
* This function is used for revesing all the 4 bytes parameters of the 
* beeStackConfigParams_t structure which is paased for setting the BeeStack
* configuration.
*
* Interface assumptions:
*   None
*
* The routine limitations.
*   None
*
* Return value:
*   None
*
* Effects on global data.
*   None
*
* Source of algorithm used.
*   None
*
* Revison history:
*   date    Author   Comments
*   ------  ------   --------
*   240306  SP,      Updated
*****************************************************************************/
static void ReverseCopyLongParameters
  (
  uint8_t* pConfig 
  );

/******************************************************************************
*******************************************************************************
* Private type definitions
*******************************************************************************
******************************************************************************/
/* None */

/******************************************************************************
*******************************************************************************
* Private memory declarations
*******************************************************************************
******************************************************************************/
#if  gBeeStackIncluded_d == 1
#if gAfCTRegCapability_d == 0 /* Runtime capability */ 
  static simpleDescriptor_t maSimpleDescriptor[ gNumberOfEndPoints_c + 1 ];
  static endPointDesc_t maZTCEpDesc[ gNumberOfEndPoints_c + 1 ];
  static uint8_t maIpCIdLst[ gNumberOfEndPoints_c + 1 ]
                           [ mMaxClusterIdSupported_c ];
  static uint8_t maOpCIdLst[ gNumberOfEndPoints_c + 1 ]
  												 [ mMaxClusterIdSupported_c ];
#endif /*gAfCTRegCapability_d*/
#endif
#if gZTC_WriteConfigureAttribReqCapabilty_d == 1 
  uint8_t maArray[ mNumOfByteParams_c ] = { 0,24,28,32,36,40,44,48,68,96,101 };
#endif 
/******************************************************************************
*******************************************************************************
* Public functions
*******************************************************************************
******************************************************************************/
void ZTCPrimHandle_ProcessUtilityFunctionReq
  (
  uint8_t* pMsgToSend, /* IN/OUT: Pointer to the message to be sent to the
                                   Beestack*/
  uint8_t* pMsgReceived,  /* IN: Pointer to the message received from test 
                                  client*/
  uint8_t   msgId        /* IN: message ID of the Primitive to be handled*/
) 
{
  uint8_t opCodeGrpId;
  uint8_t opCodeGrp = gOpCodeGrpForZDPToAppSAP_c;
  uint8_t msgLength = sizeof( uint8_t );
#if gZTC_WriteConfigureAttribReqCapabilty_d == 1 
  beeStackConfigParams_t* pBeestackConfig = 
    ( beeStackConfigParams_t* )pMsgToSend; 
#endif  
   
#if ( ( gAfCTRegCapability_d == 0 ) \
  && ( ( gZTC_FindEpDescReqCapability_d == 1 ) ||  \
  ( gZTC_DeRegEpCapabilty_d == 1 )  || (  gZTC_RegEpCapabilty_d  == 1 ) ) )
   uint8_t iIndex;  
#endif

#if ( ( gAfCTRegCapability_d  == 0 ) && (  gZTC_RegEpCapabilty_d  == 1 ) )
	 uint8_t noOfCId;
 #endif

#if ( ( gAfCTRegCapability_d == 0 ) && ( gZTC_FindEpDescReqCapability_d == 1 ) )
	 uint8_t length;
	 uint8_t numClusters;
	 uint8_t *pLocalPtr;
	 const uint8_t *pStrClusterList;
	 simpleDescriptor_t  *pSimpleDes;  
#endif

#if gZTC_FindEpListReqCapability_d == 1    
  uint8_t numOfActiveEp;
  uint8_t *pEpList;
#endif 

#if gZTC_StackTestingCapability_d == 1
 	 uint16_t stackUsed; 
#endif 
#if gZTC_APSResetCapability_d == 1
  apsmeMessage_t msgForAPSReset;
#endif  
   
  switch( msgId ) {
#if gZTC_WriteConfigureAttribReqCapabilty_d == 1  
    case gWriteConfigureAttribReqId_c:
      pBeestackConfig = MSG_AllocType( beeStackConfigParams_t );
      *pMsgToSend = gZTCFailure_c;
      if( NULL != pBeestackConfig ) {
        FLib_MemCpy( pBeestackConfig, GetZdoNvmPtr,
          sizeof( beeStackConfigParams_t ) );
        /*83 excluding start variable*/
        FLib_MemCpy( &pBeestackConfig->channelSelected,pMsgReceived,109 );
        /* Reverse all the four bytes(or uint32_t)paramters of the structure */
        ReverseCopyLongParameters( ( uint8_t* )pBeestackConfig );  
        /*Fucntion call to write the configuration attributes to the NVM*/
        ( void )BUtl_SaveBeeStackConfig ( pBeestackConfig );
        MSG_Free( pBeestackConfig );
        /* Update the Status */ 
        *pMsgToSend = gZTCSucess_c;
      }
      opCodeGrpId = mOpCodeGrpIdForConfigAttrConf_c;
                
      break;
#endif /* gZTC_WriteConfigureAttribReqCapabilty_d */
    
#if gZTC_WriteExtendedAddrReqCapabilty_d == 1  
    case gWriteExtendedAddrReqId_c:            
      opCodeGrpId = mOpCodeGrpIdForWriteExtendedAddrConf_c;
      /* Update the Status */
      *pMsgToSend = ZTC_WriteExtendedAddress( pMsgReceived );
      break;
#endif  /*  gZTC_WriteExtendedAddrReqCapabilty_d      */

#if gZTC_ReadExtendedAddrReqCapabilty_d == 1    
    case gReadExtendedAddrReqId_c:
      /* Update the Status */
      *pMsgToSend = gSuccess_c;
      FLib_MemCpy( pMsgToSend + sizeof( uint8_t ), aExtendedAddress, 
        gExtAddressLength_c );
      opCodeGrpId = mOpCodeGrpIdForReadExtendedAddrConf_c;
			msgLength = gExtAddressLength_c + sizeof( uint8_t );
      break;
#endif  /*  gZTC_ReadExtendedAddrReqCapabilty_d   */     

#if gZTC_StartNwkReqCapabilty_d == 1  
    case gStartNwkReqId_c :
      TS_SendEvent( gZdoStateMachineTaskID_c,gStartWithNVM_c );
      *pMsgToSend = gSuccess_c;

⌨️ 快捷键说明

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