📄 ztcprimitivehandlerothercomplexprimitive.c
字号:
,{ ZTCPrimHandle_SendMatchDescToSAP, NULL },
{ ZTCPrimHandle_SendEndDeviceBindToSAP, NULL },
{ ZTCPrimHandle_SendAF_KVPDataReqToSAP, NULL },
{ ZTCPrimHandle_SendAF_KVPDataReqForAggregationToSAP, NULL },
{ ZTCPrimHandle_SendAF_MSGDataReqForAggregationToSAP, NULL },
{ NULL, ZTCPrimHandle_StoreKVPIndInZTCQueue },
{ NULL, ZTCPrimHandle_StoreSimpleDescriptorRespInZTCQueue }
#endif
};
/******************************************************************************
*******************************************************************************
* Public functions
*******************************************************************************
******************************************************************************/
/* None */
/******************************************************************************
*******************************************************************************
* Private functions
*******************************************************************************
******************************************************************************/
uint8_t ZTCPrimHandle_StoreNwkScanConfInZTCQueue
(
const uint8_t* const pMsg /* IN: Pointer to the messge from test client */
)
{
#if gZTC_NwkScanConfCapabilty_d == 1
uint8_t resultListLength = ((( nwkScanCnf_t* )pMsg )->scanType ==
gScanModeED_c ) ? sizeof( uint8_t ) : sizeof( panDescriptor_t );
uint8_t msgLength;
uint8_t lengthCopied = gZTCCannotBeQueued_c;
resultListLength *= (( nwkScanCnf_t* )pMsg )->resultListSize;
msgLength = sizeof( nwkScanCnf_t ) - sizeof( uint8_t * );
if(( ZTCQueue_SpaceAvailableToWriteIntoBuffer ) >=
( gHeaderSize_c + msgLength + resultListLength )) {
FLib_MemCpy( &aZTCBuffer[ gtZTCBufferTail + gDataIndex_c ],
( uint8_t * )pMsg, msgLength );
FLib_MemCpy( &aZTCBuffer[ gtZTCBufferTail + gDataIndex_c + msgLength ],
(( nwkScanCnf_t* )pMsg )->resList.pEnergyDetectList, resultListLength );
lengthCopied = msgLength + resultListLength;
}
/* The result list pointer points to a different memory buffer, so if the
NWK-MLME is in hook mode then ZTC has to de-allocate the buffer */
if( gaZTC_SAPMode[ gMLMENwkSAPHandlerId_c ] == gZTC_ModeHook_c ){
MSG_Free( (( nwkScanCnf_t* )pMsg )->resList.pEnergyDetectList );
}
return lengthCopied;
#endif /* gZTC_NwkScanConfCapabilty_d */
}
/******************************************************************************/
uint8_t ZTCPrimHandle_StoreBeaconNotificationIndInZTCQueue
(
const uint8_t* const pMsg /* IN: Pointer to the messge from test client */
)
{
#if gZTC_NwkBeaconNotifyCapability_d == 1
/* Beacon indication packet contains 3 pointers. These needs to be "copied"
to a linear array */
uint8_t lenVarData;
uint8_t lenData = gZTCCannotBeQueued_c;
uint8_t * pDst = &aZTCBuffer[ gtZTCBufferTail + gDataIndex_c ];
nwkMessage_t * pSrc = ( nwkMessage_t * )( pMsg - 1 );
if(( ZTCQueue_SpaceAvailableToWriteIntoBuffer ) >=
mMaxBeaconLengthForZigBee_c + gHeaderSize_c){
pDst[0] = pSrc->msgData.beaconNotifyInd.bsn;
FLib_MemCpy( &pDst[1],pSrc->msgData.beaconNotifyInd.pPanDescriptor,
sizeof(panDescriptor_t));
lenData = 1 + sizeof(panDescriptor_t);
pDst[lenData] = pSrc->msgData.beaconNotifyInd.pendAddrSpec;
lenVarData = ( uint8_t )(( pDst[lenData] & 0x0F ) << 1 )
+ ( uint8_t )(( uint8_t )( pDst[ lenData ] >> 4 ) << 3 );
FLib_MemCpy( &pDst[ lenData + 1 ], pSrc->msgData.beaconNotifyInd.pAddrList,
lenVarData );
lenData += lenVarData + 1;
pDst[ lenData ] = pSrc->msgData.beaconNotifyInd.sduLength;
FLib_MemCpy(&pDst[ lenData+1 ], pSrc->msgData.beaconNotifyInd.pSdu,
pSrc->msgData.beaconNotifyInd.sduLength );
lenData += pSrc->msgData.beaconNotifyInd.sduLength + 1;
}
/* The result list pointer points to a different memory buffer, so if the
NWK-MLME is in hook mode then ZTC has to de-allocate the buffer */
if( gaZTC_SAPMode[ gMLMENwkSAPHandlerId_c ] == gZTC_ModeHook_c ){
/* Free original MEM message and pass the constructed message to upper
layers */
MSG_Free( pSrc->msgData.beaconNotifyInd.pBufferRoot );
}
return lenData;
#endif /* gZTC_NwkBeaconNotifyCapability_d */
}
#if gBeeStackIncluded_d == 1
/******************************************************************************/
uint8_t ZTCPrimHandle_SendMatchDescAndEndDeviceBindToSAP
(
uint8_t* pMsgToSend, /* IN/OUT: Pointer to the message to be
sent to the Beestack */
const uint8_t* const pMsgReceived,/* IN: Pointer to the message received
from test client */
const uint8_t msgId /* IN: ID of the Primitive to be handled*/
)
{
#if gZTC_MatchDescReqCapability_d == 1 || gZTC_EndDeviceBindReqCapability_d == 1
uint8_t msgLength =
maLocOfFirstPlaceHolderLengthForMatchDescAndEndDeviceBind[ msgId ];
uint8_t lenToCopyForFirstPtr;
uint8_t lenToCopyForSecondPtr;
uint8_t sizeOfUnsignedInt = sizeof( uint8_t );
uint8_t * pLengthPosForSecondPtr = pMsgToSend + msgLength +
+ sizeof( uint8_t * );
uint8_t ** pDataLoc = ( uint8_t ** )( pMsgToSend + msgLength );
uint8_t lengthOfaDestAddr = 2;
lenToCopyForFirstPtr = *( pMsgReceived + msgLength - 1 );
lenToCopyForSecondPtr = *( pMsgReceived + msgLength + lenToCopyForFirstPtr );
FLib_MemCpy( pMsgToSend, ( uint8_t * )pMsgReceived, msgLength );
*pDataLoc = ( pMsgToSend + sizeof( endDeviceBindReq_t ) +
lengthOfaDestAddr * sizeOfUnsignedInt); /* Added 2 bytes because the
appToZdpMessage_t has aDestAddr[2] address at the begining */
FLib_MemCpy( *pDataLoc, ( uint8_t * )pMsgReceived + msgLength, lenToCopyForFirstPtr );
pDataLoc = ( uint8_t ** )( pLengthPosForSecondPtr + sizeof( uint8_t ));
*pDataLoc = ( pMsgToSend + sizeof( endDeviceBindReq_t ) +
( 2 * sizeof( uint8_t )) + lenToCopyForFirstPtr );
*pLengthPosForSecondPtr = lenToCopyForSecondPtr;
FLib_MemCpy( *pDataLoc, ( uint8_t * )pMsgReceived + msgLength + lenToCopyForFirstPtr +
sizeof( uint8_t ), lenToCopyForSecondPtr );
return msgLength + lenToCopyForFirstPtr + lenToCopyForSecondPtr;
#endif /* gZTC_MatchDescReqCapability_d || gZTC_EndDeviceBindReqCapability_d */
}
/******************************************************************************/
uint8_t ZTCPrimHandle_SendMatchDescToSAP
(
uint8_t* pMsgToSend, /* IN/OUT: Pointer to the message to be
sent to the Beestack */
const uint8_t* const pMsgReceived /* IN: Pointer to the message received
from test client */
)
{
#if gZTC_MatchDescReqCapability_d == 1
uint8_t msgId = 0;
return ZTCPrimHandle_SendMatchDescAndEndDeviceBindToSAP( pMsgToSend,
pMsgReceived , msgId );
#endif /* gZTC_MatchDescReqCapability_d */
}
/******************************************************************************/
uint8_t ZTCPrimHandle_SendEndDeviceBindToSAP
(
uint8_t* pMsgToSend, /*IN/OUT: Pointer to the message to be
sent to the Beestack */
const uint8_t* const pMsgReceived /*IN: Pointer to the message received
from test client */
)
{
#if gZTC_EndDeviceBindReqCapability_d == 1
uint8_t msgId = 1;
return ZTCPrimHandle_SendMatchDescAndEndDeviceBindToSAP( pMsgToSend,
pMsgReceived, 1 );
#endif /* gZTC_EndDeviceBindReqCapability_d */
}
/******************************************************************************/
uint8_t ZTCPrimHandle_SendAF_KVPDataReqToSAP
(
uint8_t* pMsgToSend, /* IN/OUT: Pointer to the message to be sent
to the Beestack */
uint8_t* pMsgReceived /* IN/OUT: Pointer to the message received
from test client */
)
{
#if gZTC_KVPDataReqCapability_d == 1
uint8_t length ;
uint8_t payloadLength;
length = sizeof( zbDataReq_t ) - sizeof( kvpData_t );
pMsgToSend--;
FLib_MemCpy( pMsgToSend, pMsgReceived, length );
pMsgReceived += length;
payloadLength = *pMsgReceived;
pMsgReceived++;
FLib_MemCpy( pMsgToSend + length, pMsgReceived, payloadLength );
return payloadLength + length;
#endif /* gZtcKvpDataReqCapability_d */
}
/******************************************************************************/
uint8_t ZTCPrimHandle_SendAF_KVPDataReqForAggregationToSAP
(
uint8_t* pMsgToSend, /* IN/OUT: Pointer to the message to be
sent to theBeestack */
uint8_t const* const pMsgReceived /* IN: Pointer to the message received
from test client */
)
{
#if gZTC_AF_KVPAggregationReqCapability_d == 1
uint8_t noOfTrans = *pMsgReceived++;
uint8_t length = ZTCPrimHandle_SendAF_KVPDataReqToSAP( pMsgToSend,
( uint8_t * ) pMsgReceived );
if ( noOfTrans > 1) {
pMsgToSend = MSG_Alloc( sizeof( zbDataReq_t ));
if( NULL != pMsgToSend ){
( void )ZTCPrimHandle_SendAF_KVPDataReqToSAP( pMsgToSend + 1,
( uint8_t * )pMsgReceived + length + 1 );
gInjectedTheMessage = TRUE;
( void )AF_AppToAfdeDataReq(( zbDataReq_t* )pMsgToSend );
}
}
return length << 1;
#endif /* gZtcAfKvpAggregationReqCapability_d */
}
/******************************************************************************/
uint8_t ZTCPrimHandle_SendAF_MSGDataReqForAggregationToSAP
(
uint8_t* pMsgToSend, /* IN/OUT: Pointer to the message to be
sent to the Beestack */
uint8_t const* const pMsgReceived /* IN: Pointer to the message received
from test client */
)
{
#if gZTC_AFMsgAggregationReqCapability_d == 1
uint8_t noOfTrans = *pMsgReceived++;
uint8_t length;
#if gZTC_PrimitiveWithTableListHandlingCapability_d == 1
length = ZTCPrimHandle_SendComplexPrimWithTableListToSAP( pMsgToSend ,
pMsgReceived, gZTC_MSGDataReqId_c - gStartIdOfComplexPrimWithTableList_c );
#endif /* gZTC_PrimitiveWithTableListHandlingCapability_d */
if ( noOfTrans > 1) {
pMsgToSend = MSG_Alloc( sizeof( zbDataReq_t ));
if( NULL != pMsgToSend ){
#if gZTC_PrimitiveWithTableListHandlingCapability_d == 1
( void )ZTCPrimHandle_SendComplexPrimWithTableListToSAP( pMsgToSend + 1 ,
pMsgReceived + length,
gZTC_MSGDataReqId_c - gStartIdOfComplexPrimWithTableList_c);
#endif /* gZTC_PrimitiveWithTableListHandlingCapability_d */
gInjectedTheMessage = TRUE;
( void )AF_AppToAfdeDataReq(( zbDataReq_t* )(pMsgToSend ));
}
}
return length << 1;
#endif /* gZtcAfMsgAggregationReqCapability_d */
}
/******************************************************************************/
/******************************************************************************/
uint8_t ZTCPrimHandle_CopySimpleDesc
(
uint8_t* pDst, /* IN:Destination memory location to copy the
Simple Des */
const uint8_t* const pSrc /* IN:Source memory location to get the details of
Simple Des*/
)
{
uint8_t simpleDescLength = 0;
simpleDescLength = *( pSrc + mOffsetOfNumberOfCIDFldInSimpleDesc_c );
simpleDescLength += *( pSrc +
mOffsetOfNumberOfCIDFldInSimpleDesc_c + simpleDescLength );
simpleDescLength += sizeof( configSimpleDescriptors_t ) -
sizeof( uint8_t ) - sizeof( uint8_t ); /* subtract 2 bytes for input and
output cluster ID array */
FLib_MemCpy( pDst, ( uint8_t *)pSrc, simpleDescLength );
return simpleDescLength + mOffsetOfNumberOfCIDFldInSimpleDesc_c;
}
/******************************************************************************/
uint8_t ZTCPrimHandle_StoreSimpleDescriptorRespInZTCQueue
(
uint8_t* pMsg /* IN/OUT : Source memory location to get the details of
Simple Des */
)
{
#if gZTC_SimpleDescRespCapability_d == 1
uint8_t length = sizeof( simpleDescResp_t ) - sizeof( uint8_t );
uint8_t numOfSimpleDesc = *( pMsg +
mOffsetOfNumberOfSimpleDescInSimpleDescStruct_c );
uint8_t * pDst = &aZTCBuffer[ gtZTCBufferTail + gDataIndex_c ];
length += numOfSimpleDesc;
if(( ZTCQueue_SpaceAvailableToWriteIntoBuffer ) >=
mBufferLengthSimpleDesc_c + gHeaderSize_c) {
FLib_MemCpy( pDst, pMsg, length );
pMsg += length;
pDst += length;
return length;
}
#endif /* gSimpleDescRespCapability_d */
return gZTCCannotBeQueued_c;
}
/******************************************************************************/
uint8_t ZTCPrimHandle_StoreKVPIndInZTCQueue
(
const uint8_t* const pMsg /* IN/OUT :Source memory location to get the
details of data ind */
)
{
#if gZTC_AF_KVPDataIndCapability_d == 1
uint8_t length = sizeof( appKvpDataMessage_t ) - sizeof( uint16_t );
uint8_t attributeLength ;
uint8_t attributeId = *( pMsg + mOffsetAttributeIdInKVPIndication_c ) ;
uint8_t * pDst;
attributeId = attributeId >> 4 ;
if( attributeId < mCharString_c ) {
attributeLength = gaAttributeDataLength_c[ attributeId] ;
}
if(( attributeId == mCharString_c ) || ( attributeId == mOctetString_c )){
pDst = ( uint8_t* )(*(( uint16_t * )( pMsg+ length ))) ;
attributeLength = *pDst;
}
pDst = &aZTCBuffer[ gtZTCBufferTail + gDataIndex_c ];
if(( ZTCQueue_SpaceAvailableToWriteIntoBuffer ) >=
length + attributeLength + 1 + gHeaderSize_c ) {
FLib_MemCpy( pDst,( uint8_t * ) pMsg, length );
aZTCBuffer[gtZTCBufferTail + gDataIndex_c + length] = attributeLength ;
if(( attributeId != mCharString_c ) && ( attributeId != mOctetString_c )){
FLib_MemCpy( pDst+length + 1,( uint8_t* )(*(( uint16_t * )
( pMsg+ length ))), attributeLength );
}
else {
FLib_MemCpy( pDst+length+1,( uint8_t* )(*(( uint16_t *) ( pMsg+ length )))
+ 1, attributeLength );
}
return length + attributeLength + 1 ;
}
return gZTCCannotBeQueued_c;
#endif /* gZtcAfKvpDataIndCapability_d */
}
/******************************************************************************
*******************************************************************************
* Private Debug stuff
*******************************************************************************
******************************************************************************/
/* None */
#endif /* gZTC_OtherComplexPrimitiveHandlingCapability_d */
#endif /* ( gZtcIncluded_d == 1 ) */
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -