📄 ztcprimitivehandlercomplexprimitive.c
字号:
/******************************************************************************
* 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 )
#include "EmbeddedTypes.h"
#include "FunctionLib.h"
#include "ZtcInterface.h"
#include "ZtcQueue.h"
#include "ZtcPrimitiveHandler.h"
#include "ZtcConfiguration.h"
#if gBeeStackIncluded_d == 1
#include "BeeStackConfiguration.h"
#endif
#include "ZtcPrimitiveHandlerComplexPrimitive.h"
#include "ZtcPrimitiveHandlerComplexPrimWithOnePtr.h"
#include "ZtcPrimitiveHandlerComplexPrimWithTableList.h"
#include "ZtcPrimitiveHandlerComplexPrimSyncPrim.h"
#include "ZtcPrimitiveHandlerComplexPrimUtilitySupport.h"
#include "ZtcPrimitiveHandlerOtherComplexPrimitive.h"
#include "MsgSystem.h"
/******************************************************************************
*******************************************************************************
* Private macros
*******************************************************************************
******************************************************************************/
#define mExcessMemoryToAdd_c 9
#define mDataBufferSize_c 100
/******************************************************************************
*******************************************************************************
* Private prototypes
*******************************************************************************
******************************************************************************/
/* None */
/******************************************************************************
*******************************************************************************
* Private type definitions
*******************************************************************************
******************************************************************************/
/* None */
/******************************************************************************
*******************************************************************************
* Private memory declarations
*******************************************************************************
******************************************************************************/
/* None */
/******************************************************************************
*******************************************************************************
* Public functions
*******************************************************************************
******************************************************************************/
void ZTCPrimHandle_SendComplexPrimToSAP
(
const ZTCMessage_t* const pMsg, /* IN: Msg received from the test client */
const uint8_t SAPId, /* IN: Sap ID to which the prim has to be sent */
uint8_t complexMsgId /* IN: MSG ID used for complex primitive */
)
{
uint8_t length = pMsg->length + mExcessMemoryToAdd_c;
uint8_t* pMsgToSend;
if( SAPId == gAPS_NLDE_SAPHandlerId_c ) {
length = mDataBufferSize_c;
}
pMsgToSend = MSG_Alloc( length );
if( NULL != pMsgToSend ) {
*pMsgToSend = pMsg->opCodeId;
if( complexMsgId == gAFDeregReqId_c || complexMsgId == gAFRegReqId_c ) {
complexMsgId += ( gDeRegEpId_c - gAFDeregReqId_c );
}
/* Complex Primitives with one pointer are sent to corresponding handlers */
#if gZTC_PrimitiveWithOnePointerHandlingCapability_d == 1
if( complexMsgId >= gStartIdOfComplexPrimWithOnePtr_c &&
complexMsgId < gEndIdOfComplexPrimWithOnePtr_c ) {
ZTCPrimHandle_SendComplexPrimWithOnePtrToSAP( pMsgToSend + 1,
pMsg->data, complexMsgId - gStartIdOfComplexPrimWithOnePtr_c );
}
#endif /* gZTC_PrimitiveWithOnePointerHandlingCapability_d */
/* Complex Primitives with attributes are sent to corresponding handlers */
#if gZTC_SyncPrimitiveHandlingCapability_d == 1
else if( complexMsgId >= gStartIdOfSyncPrimitives_c &&
complexMsgId < gEndIdOfSyncPrim_c ) {
ZTCPrimHandle_SendSynchronousPrimToSAP( pMsgToSend + 1,
pMsg->data, SAPId, complexMsgId - gStartIdOfSyncPrimitives_c );
return;
}
#endif /* gZTC_SyncPrimitiveHandlingCapability_d == 1 */
#if gBeeStackIncluded_d == 1
#if gZTC_PrimitiveWithTableListHandlingCapability_d == 1
else if( complexMsgId >= gStartIdOfComplexPrimWithTableList_c &&
complexMsgId < gEndIdOfComplexPrimWithTableList_c ) {
( void )ZTCPrimHandle_SendComplexPrimWithTableListToSAP( pMsgToSend + 1,
pMsg->data, complexMsgId - gStartIdOfComplexPrimWithTableList_c );
}
#endif /* gZTC_PrimitiveWithTableListHandlingCapability_d */
/* Complex Primitives for utility support are sent to corresponding handlers */
#if gZTC_UtilitySupportCapability_d == 1
else if( complexMsgId >= gStartIdOfUtilitySupport_c &&
complexMsgId < gEndIdOfUtilitySupport_c ) {
( void )ZTCPrimHandle_ProcessUtilityFunctionReq( pMsgToSend,
pMsg->data, complexMsgId );
MSG_Free( pMsgToSend );
return;
}
#endif /* gZTC_UtilitySupportCapability_d */
#endif /* gBeeStackIncluded_d */
#if gZTC_OtherComplexPrimitiveHandlingCapability_d == 1
/*Other Complex Primitives are sent to corresponding handlers */
else if( complexMsgId >= gStartIdOfOtherComplexPrim_c &&
complexMsgId < gEndIdOfOtherComplexPrim_c ) {
( void )ZTCPrimHandle_SendOtherComplexPrimToSAP( pMsgToSend + 1,
pMsg->data, complexMsgId - gStartIdOfOtherComplexPrim_c );
}
#endif
else {
MSG_Free( pMsgToSend );
return;
}
gInjectedTheMessage = TRUE;
( void )gaSAPIdToSAPHandlers[ SAPId ]( pMsgToSend );
}
}
/*****************************************************************************/
uint8_t ZTCPrimHandle_StoreComplexPrimInZTCQueue
(
const uint8_t complexMsgId, /* IN: MSG ID used for complex primitive */
const uint8_t status, /* IN: Status returned from the SAP Handler */
const uint8_t * const pMsg /* IN: Pointer to the memory sent to the SAP */
)
{
uint8_t length = gZTCCannotBeQueued_c;
( void )status;
( void )complexMsgId;
( void )pMsg;
#if gZTC_PrimitiveWithOnePointerHandlingCapability_d == 1
if( complexMsgId >= gStartIdOfComplexPrimWithOnePtr_c &&
complexMsgId < gEndIdOfComplexPrimWithOnePtr_c ) {
length = ZTCPrimHandle_StoreComplexPrimWithOnePtrInZTCQueue( pMsg,
complexMsgId - gStartIdOfComplexPrimWithOnePtr_c );
}
#endif /* gZTCPrimitiveWithOnePointerHandlingCapability_d */
#if gZTC_SyncPrimitiveHandlingCapability_d == 1
else if( complexMsgId >= gStartIdOfSyncPrimitives_c &&
complexMsgId < gEndIdOfSyncPrim_c ) {
length = ZTCPrimHandle_StoreSyncPrimInZTCQueue( pMsg,
complexMsgId - gStartIdOfSyncPrimitives_c, status );
}
#endif /* gZTC_SyncPrimitiveHandlingCapability_d */
#if gBeeStackIncluded_d == 1
#if gZTC_PrimitiveWithTableListHandlingCapability_d == 1
else if( complexMsgId >= gStartIdOfComplexPrimWithTableList_c &&
complexMsgId < gEndIdOfComplexPrimWithTableList_c ) {
length = ZTCPrimHandle_StoreComplexPrimWithTableListInZTCQueue( pMsg,
complexMsgId - gStartIdOfComplexPrimWithTableList_c );
}
#endif /* gZTC_PrimitiveWithTableListHandlingCapability_d */
#endif
#if gZTC_OtherComplexPrimitiveHandlingCapability_d == 1
else if( complexMsgId >= gStartIdOfOtherComplexPrim_c &&
complexMsgId < gEndIdOfOtherComplexPrim_c ) {
length = ZTCPrimHandle_StoreOtherComplexPrimInZTCQueue( ( uint8_t * )pMsg,
complexMsgId - gStartIdOfOtherComplexPrim_c );
}
#endif
return length;
}
/******************************************************************************
*******************************************************************************
* Private functions
*******************************************************************************
******************************************************************************/
/* None */
/******************************************************************************
*******************************************************************************
* Private Debug stuff
*******************************************************************************
******************************************************************************/
/* None */
#endif /* ( gZtcIncluded_d == 1 ) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -