📄 ztcprimitivehandlercomplexprimwithoneptr.c
字号:
mSizeOfTableForNLDEDataInd_c },
/* gZTC_AF_MSGDataIndId_c */
{ mOffsetForPtrLocInAFMsgDataInd_c, mOffsetForPosOfnumOfListInAFMsgDataInd_c,
mLengthOfDataAfterPtrLocInAFMsgDataInd_c, mOffsetAddedToThePtrForAFMsgDataInd_c,
mSizeOfTableForAFMsgDataInd_c },
/* gNLMENwkDiscConfId_c */
{ mOffsetForPtrLocInNLMENwkDiscConf_c, mOffsetForPosOfnumOfListInNLMENwkDiscConf_c,
mLengthOfDataAfterPtrLocInNLMENwkDiscConf_c, mOffsetAddedToThePtrForNLMENwkDiscConf_c,
mSizeOfTableForNLMENwkDiscConf_c },
/* gApsdeDataReqID_c */
{ mOffsetForPtrLocInApsdeDataReq_c, mOffsetForPosOfnumOfListInApsdeDataReq_c,
mLengthOfDataAfterPtrLocInApsdeDataReq_c, mOffsetAddedToThePtrForApsdeDataReq_c,
mSizeOfTableForApsdeDataReq_c },
/* gApsdeDataIndID_c */
{ mOffsetForPtrLocInApsdeDataInd_c, mOffsetForPosOfnumOfListInApsdeDataInd_c,
mLengthOfDataAfterPtrLocInApsdeDataInd_c, mOffsetAddedToThePtrForApsdeDataInd_c,
mSizeOfTableForApsdeDataInd_c } ,
/*gZDPNwkDiscConfId_c */
{ mOffsetForPtrLocInZDPNwkDiscConf_c, mOffsetForPosOfnumOfListInZDPNwkDiscConf_c,
mLengthOfDataAfterPtrLocInZDPNwkDiscConf_c, mOffsetAddedToThePtrForZDPNwkDiscConf_c,
mSizeOfTableForZDPNwkDiscConf_c }
#endif /* gBeeStackIncluded_d */
};
/******************************************************************************
*******************************************************************************
* Public functions
*******************************************************************************
******************************************************************************/
/* message received from the Test client
_______________________________________________________________________
| |len|<-sizeOfTable * | |
| |gth| content of | |
|<---------ptrLoc-|-->| posOfnumOfList-> |<-lengthOfDataAfterPtrLoc->|
| | | | |
-----------------------------------------------------------------------
<-posOfnumOfList->
After formating the message which has to be sent to SAP
______________________________________________________ _________________
| |len| | | |<-sizeOfTable * |
| |gth| | | | content of |
|<---------ptrLoc-|-->|Ptr|<-lengthOfDataAfterPtrLoc->|<->| posOfnumOfList->|
| | | | | | | |
------------------------------------------------------ | -------------------
<-posOfnumOfList-> offsetAddedToThePtr
*/
void ZTCPrimHandle_SendComplexPrimWithOnePtrToSAP
(
uint8_t* pMsgToSend, /* IN/OUT: Memory loaction to the data part of the
primitive has to be written to send to the SAP */
const uint8_t* pMsgReceived,/* IN: Memory location to the data part received
from the test client */
const uint8_t msgId /* IN: Msg ID of primitive with one pointer Here
ID 0 is gMcpsDataReqID_c and 1 is gMCPSDataIndId_c and so on */
)
{
uint8_t msgLength = maComplexPrimWithPtr[ msgId ].ptrLoc;
uint8_t ** pPtrToWrite = ( uint8_t ** )( pMsgToSend + msgLength );
uint8_t payloadLength =
*( pMsgReceived + maComplexPrimWithPtr[ msgId ].posOfnumOfList );
payloadLength *= maComplexPrimWithPtr[ msgId ].sizeOfTable;
FLib_MemCpy( pMsgToSend, ( uint8_t *)pMsgReceived, msgLength );
*pPtrToWrite = ( uint8_t* )pPtrToWrite + sizeof( uint8_t * ) +
maComplexPrimWithPtr[ msgId ].lengthOfDataAfterPtrLoc +
maComplexPrimWithPtr[ msgId ].offsetAddedToThePtr;
FLib_MemCpy( *pPtrToWrite, ( uint8_t *)pMsgReceived + msgLength, payloadLength );
FLib_MemCpy( pMsgToSend + msgLength + sizeof( uint8_t * ),
( uint8_t *)pMsgReceived + msgLength + payloadLength,
maComplexPrimWithPtr[ msgId ].lengthOfDataAfterPtrLoc );
}
/******************************************************************************/
/* Message received from the SAP.
The memory location pointed by the pointer
has to be freed up if the memory location is not a part of that memory buffer
and the SAP is in Hook mode.
______________________________________________________ _________________
| |len| | | |<-sizeOfTable * |
| |gth| | | | content of |
|<---------ptrLoc-|-->|Ptr|<-lengthOfDataAfterPtrLoc->| | posOfnumOfList->|
| | | | | | |
------------------------------------------------------ -------------------
<-posOfnumOfList->
After formating the message which has to be sent to the test client
_______________________________________________________________________
| |len|<-sizeOfTable * | |
| |gth| content of | |
|<---------ptrLoc-|-->| posOfnumOfList-> |<-lengthOfDataAfterPtrLoc->|
| | | | |
-----------------------------------------------------------------------
<-posOfnumOfList->
*/
uint8_t ZTCPrimHandle_StoreComplexPrimWithOnePtrInZTCQueue
(
const uint8_t* const pMsg, /* IN: Memory location to the data part received
from the SAP */
const uint8_t msgId /* IN: IN: Msg ID of primitive with one pointer Here
ID 0 is gMcpsDataReqID_c and 1 is gMCPSDataIndId_c and so on */
)
{
uint8_t TotalLength = gZTCCannotBeQueued_c ;
uint8_t msgLength = maComplexPrimWithPtr[ msgId ].ptrLoc +
maComplexPrimWithPtr[ msgId ].lengthOfDataAfterPtrLoc;
uint8_t payloadLength = *( pMsg + maComplexPrimWithPtr[ msgId ].
posOfnumOfList ) * maComplexPrimWithPtr[ msgId ].sizeOfTable;
uint16_t ** pPtrToRead = ( uint16_t** )( pMsg +
maComplexPrimWithPtr[ msgId ].ptrLoc );
if(( ZTCQueue_SpaceAvailableToWriteIntoBuffer ) >=
( gHeaderSize_c + msgLength + payloadLength )) {
FLib_MemCpy( &aZTCBuffer[ gtZTCBufferTail + gDataIndex_c ],(uint8_t *)pMsg,
maComplexPrimWithPtr[ msgId ].ptrLoc );
FLib_MemCpy( &aZTCBuffer[ gtZTCBufferTail + gDataIndex_c +
maComplexPrimWithPtr[ msgId ].ptrLoc ], *pPtrToRead, payloadLength);
FLib_MemCpy( &aZTCBuffer[ gtZTCBufferTail + gDataIndex_c +
maComplexPrimWithPtr[ msgId ].ptrLoc + payloadLength ],
(uint8_t *)pMsg + maComplexPrimWithPtr[ msgId ].ptrLoc + sizeof( uint8_t*),
maComplexPrimWithPtr[ msgId ].lengthOfDataAfterPtrLoc );
TotalLength = msgLength + payloadLength;
}
/* Pointer of Discovery confirmation points to an different meory buffer, so
if the NLME-ZDO SAP is in hook mode then ZTC has to free up the memory. */
if(((( msgId + gStartIdOfComplexPrimWithOnePtr_c ) ==
gNLMENwkDiscConfId_c ) && ( gaZTC_SAPMode[ gNLME_ZDO_SAPHandlerId_c ]
== gZTC_ModeHook_c )) || ((( msgId + gStartIdOfComplexPrimWithOnePtr_c ) ==
gZDPNwkDiscConfId_c ) && ( gaZTC_SAPMode[ gZDPAppSAPHandlerId_c ]
== gZTC_ModeHook_c ))) {
MSG_Free( *pPtrToRead );
}
return TotalLength;
}
/******************************************************************************
*******************************************************************************
* Private functions
*******************************************************************************
******************************************************************************/
/* None */
/******************************************************************************
*******************************************************************************
* Private Debug stuff
*******************************************************************************
******************************************************************************/
/* None */
#endif /* gPrimitiveWithOnePointerHandlingCapability_d */
#endif /* ( gZtcIncluded_d == 1 ) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -