📄 ztcprimitivehandlercomplexprimsyncprim.c
字号:
NWK_MLME_SapHandler,
ZDO_NLME_SapHandler,
ZDO_APSME_SapHandler,
NWK_MLME_SapHandler,
ZDO_NLME_SapHandler,
ZDO_APSME_SapHandler,
ZDO_APSME_SapHandler,
ZDO_APSME_SapHandler,
NWK_MLME_SapHandler,
ZDO_NLME_SapHandler
};
#else
/* Table to get the length to be copied for sync primitives */
static const uint8_t maLengthtoBeCopiedForSyncPrim[] = {
sizeof( mlmeGetReq_t ) - sizeof( uint8_t * ),
0, 0, 0, 0, 0, 0, 0, /* Padded with zero for proper indexing */
sizeof( mlmeResetReq_t ),
0, 0, 0, /* Padded with zero for proper indexing */
sizeof( mlmeGetReq_t ) - sizeof( uint8_t * ),
0, 0, /* Padded with zero for proper indexing */
sizeof( mlmeSetReq_t ) - sizeof( uint8_t * ),
0, 0, 0, 0, 0, 0, 0 /* Padded with zero for proper indexing */
};
/* This Table gives OpcodeGrp and OpcodeGrpId for sync primitives */
static const ZTCHeaderDetailForSyncPrim_t maZTCHeaderDetailForSyncPrimConf[] ={
{ gOpCodeGrpForMLMEToNwkSAP_c, mOpCodeGrpIdForMlmeGetConf_c },
{ gOpCodeGrpForNLMEToZDO_SAP_c, mOpCodeGrpIdForNlmeGetConf_c },
{ gOpCodeGrpForAPSMEToZDO_SAP_c,mOpCodeGrpIdForApsmeGetConf_c },
{ gOpCodeGrpForMLMEToNwkSAP_c, mOpCodeGrpIdForMlmeSetConf_c },
{ gOpCodeGrpForNLMEToZDO_SAP_c, mOpCodeGrpIdForNlmeSetConf_c },
{ gOpCodeGrpForAPSMEToZDO_SAP_c,mOpCodeGrpIdForApsmeSetConf_c },
{ gOpCodeGrpForAPSMEToZDO_SAP_c,mOpCodeGrpIdForApsmeBindConf_c },
{ gOpCodeGrpForAPSMEToZDO_SAP_c,mOpCodeGrpIdForApsmeUnbindConf_c},
{ gOpCodeGrpForMLMEToNwkSAP_c, mOpCodeGrpIdForMlmeResetConf_c },
{ gOpCodeGrpForNLMEToZDO_SAP_c, mOpCodeGrpIdForNlmeResetConf_c }
};
/* Function pointer to Sap handlers */
static const pfToSAPHandler_t maSyncMsgIdToSapHandler[] = {
NWK_MLME_SapHandler,
NULL,
NULL,
NWK_MLME_SapHandler,
NULL,
NULL,
NULL,
NULL,
NWK_MLME_SapHandler
};
#endif
/******************************************************************************
*******************************************************************************
* Public functions
*******************************************************************************
******************************************************************************/
bool_t ZTCPrimHandle_IsLengthFieldUpdationNeeded
(
const uint8_t msgId /* IN : Message ID used in ZTC */
)
{
uint8_t returnValue = TRUE;
uint8_t complexPrimMsgId = ZTCPrimHandle_GetInfoOnPrimitive( msgId );
if(( complexPrimMsgId >= gStartIdOfSyncPrimitives_c ) &&
( complexPrimMsgId <= gEndIdOfSyncPrim_c )) {
returnValue = FALSE;
}
return returnValue;
}
/*****************************************************************************/
void ZTCPrimHandle_SendSynchronousPrimToSAP
(
uint8_t* pMsgToSend, /* IN/OUT: Pointer to the message to be sent
to the Beestack*/
const uint8_t* pMsgReceived, /* IN: Pointer to the message received from
test client*/
const uint8_t SAPId, /* IN: Sap ID to which the prim has to be sent */
const uint8_t msgId /* IN: message ID of the Primitive to be handled */
)
{
uint8_t status;
uint8_t length;
uint8_t syncMsgId;
uint8_t** pAttributeValue = ( uint8_t** )( pMsgToSend +
maLengthtoBeCopiedForSyncPrim[ msgId ] );
syncMsgId = msgId + gStartIdOfSyncPrimitives_c;
if( syncMsgId >= gMLMEGetReqId_c && syncMsgId <= gAPSMESetReqId_c ) {
*pAttributeValue = ( uint8_t* )( pMsgToSend +
maLengthtoBeCopiedForSyncPrim[ msgId ] + sizeof( uint8_t* ));
}
( void )ZTCPrimHandle_CopyForSyncPrim( pMsgToSend, pMsgReceived, msgId );
gInjectedTheMessage = TRUE;
status = maSyncMsgIdToSapHandler[ msgId ]( pMsgToSend - 1 );
#if gZTC_FilterCapability_d == 1
if( gaZTC_SAPMode[ SAPId ] ) {
if( ZTCFilter_IsToBeFiltered( msgId + gStartIdOfSyncPrimitives_c )){
length = ZTCPrimHandle_FormReqAndConfForSyncPrim( status,
&aZTCBuffer[ gtZTCBufferTail ], pMsgToSend, msgId, FALSE );
gtZTCBufferTail += length;
TS_SendEvent( gZTCTaskId, gDataFromZTCToTestClientEvent_c );
}
}
#endif /* gZTC_FilterCapability_d */
MSG_Free( pMsgToSend - 1 );
}
/*****************************************************************************/
uint8_t ZTCPrimHandle_FormReqAndConfForSyncPrim
(
const uint8_t status, /* IN: Status of the sync primitive call */
uint8_t* pDst, /* IN: Pointer to the memory location where the req & conf
is to formed */
const uint8_t* pSrc, /* IN: Pointer to the memory location to get the
information */
uint8_t msgId, /* IN/OUT: Message ID of the sync primitive used in ZTC */
const bool_t sendReq /* IN: TRUE : If req is to be formed else FALSE */
)
{
uint8_t length = 0;
uint8_t retLength = 0;
uint8_t * pZTCLengthField = pDst - ( gDataIndex_c - gLengthIndex_c );
if( sendReq ) {
if(( ZTCQueue_SpaceAvailableToWriteIntoBuffer ) >=
( gHeaderSize_c + mMaxSyncPrimitiveLength_c )) {
if( msgId != gAFRegReqId_c ) {
length = ZTCPrimHandle_CopyForSyncPrim( pDst, pSrc, msgId );
}
#if gBeeStackIncluded_d == 1
else {
length = ZTCPrimHandle_CopySimpleDesc( pDst, pSrc );
}
#endif
retLength = length;
pDst += length;
*pZTCLengthField = length;
}
}
if(( ZTCQueue_SpaceAvailableToWriteIntoBuffer ) >=
( gHeaderSize_c + mMaxSyncPrimitiveLength_c )) {
*pDst++ = maZTCHeaderDetailForSyncPrimConf[ msgId ].opCodeGrp;
*pDst++ = maZTCHeaderDetailForSyncPrimConf[ msgId ].opCodeGrpId;
pZTCLengthField = pDst++;
*pDst++ = status;
retLength += gHeaderSize_c + sizeof( status );
if( msgId <= ( gNLMEResetReqId_c - gStartIdOfSyncPrimitives_c )) {
length = ZTCPrimHandle_CopyForSyncPrim( pDst, pSrc,
msgId + ZTCPrimHandle_OffsetBtwnSyncConfAndSyncReq );
*pZTCLengthField = length + 1;
retLength += length;
}
}
retLength = ( retLength == 0 ) ? gZTCCannotBeQueued_c : retLength;
return retLength;
}
/******************************************************************************
*******************************************************************************
* Private functions
*******************************************************************************
******************************************************************************/
uint8_t ZTCPrimHandle_CopyForSyncPrim
(
uint8_t* pDest, /* IN: Pointer to the memory location to write data */
const uint8_t* pSrc, /* IN: Pointer to the memory location to get the
information */
uint8_t msgId /* IN: Message ID of the sync primitive used in ZTC */
)
{
uint8_t lengthOfDataInPointedLoc = 0;
uint8_t length = maLengthtoBeCopiedForSyncPrim[ msgId ];
uint8_t** pAttrValue;
msgId += gStartIdOfSyncPrimitives_c;
FLib_MemCpy( pDest, (uint8_t *)pSrc, length );
pDest += length;
if( msgId == gMLMESetReqId_c || msgId == gMLMEGetConfId_c ) {
lengthOfDataInPointedLoc = maMAClengthForGetSetPrimitive[( *pSrc ) -
gMAC_PIBOffset_c ];
}
#if gBeeStackIncluded_d == 1
else if( msgId == gAPSMESetReqId_c || msgId == gAPSMEGetConfId_c ) {
lengthOfDataInPointedLoc = maAPSlengthForGetSetPrimitive[( *pSrc ) -
gAPS_IBOffset_c];
}
else if( msgId == gNLMESetReqId_c ) {
lengthOfDataInPointedLoc = *( pSrc + mNIBLengthPosition_c );
pDest -= sizeof( uint8_t* );
}
else if( msgId == gNLMEGetConfId_c ) {
lengthOfDataInPointedLoc = *( pDest - mNIBGetLengthPosition_c );
}
else if( msgId == gNLMEGetReqId_c ) {
*( pDest - 1 ) = *pSrc;
}
#endif
pSrc += length;
if( msgId >= gMLMESetReqId_c && msgId <= gAPSMESetReqId_c ) {
pDest += sizeof( uint8_t* );
pAttrValue = ( uint8_t** )( pDest );
FLib_MemCpy( pAttrValue, ( uint8_t* )pSrc, lengthOfDataInPointedLoc );
}
else if( msgId >= gMLMEGetConfId_c && msgId <= gAPSMEGetConfId_c ) {
pAttrValue = ( uint8_t** )( pSrc );
FLib_MemCpy( pDest, *pAttrValue, lengthOfDataInPointedLoc );
}
return lengthOfDataInPointedLoc + length;
}
/******************************************************************************
*******************************************************************************
* Private Debug stuff
*******************************************************************************
******************************************************************************/
/* None */
#endif /* gZTC_SyncPrimitiveHandlingCapability_d */
#endif /* ( gZtcIncluded_d == 1 ) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -