📄 ztcprimitivehandlercomplexprimutilitysupport.c
字号:
opCodeGrpId = mOpCodeGrpIdForStartNwkConf_c;
break;
#endif /* gZTC_StartNwkReqCapabilty_d */
#if gZTC_RestartNwkReqCapabilty_d == 1
case gRestartNwkReqId_c :
TS_SendEvent( gZdoStateMachineTaskID_c,gStartWithOutNVM_c );
*pMsgToSend = gSuccess_c;
opCodeGrpId = mOpCodeGrpIdForReStartNwkConf_c;
break;
#endif /* gZTC_RestartNwkReqCapabilty_d */
#if gZTC_BeestackSaveReqCapabilty_d == 1
case gBeestackSaveReqId_c:
/*BeeStack Save Function is called to save all BeeStack informations into
NVM */
BUtl_BeeStackSave( );
opCodeGrpId = mOpCodeGrpIdForBeeStackSaveConf_c;
/* Update the Status */
*pMsgToSend = gSuccess_c;
break;
#endif /* gZTC_BeestackSaveReqCapabilty_d */
#if gZTC_StopNwkReqCapabilty_d == 1
case gStopNwkReqId_c:
TS_SendEvent( gZdoStateMachineTaskID_c,gStop_c );
opCodeGrpId = mOpCodeGrpIdForStopNwkConf_c;
/* Update the Status */
*pMsgToSend = gSuccess_c;
break;
#endif /* gZTC_StopNwkReqCapabilty_d */
#if gZTC_FindNumOfEpReqCapability_d == 1
case gFindNumOfEpReqId_c:
*pMsgToSend = AF_NumOfEndPoints( );
opCodeGrpId = mOpcodeGrpIdForNumOfActiveEpConf_c;
opCodeGrp = gOpCodeGrpForAFDEToAppSAP_c;
break;
#endif /* gZTC_FindNumOfEpReqCapability_d */
#if ( gAfCTRegCapability_d == 0 )
#if gZTC_FindEpDescReqCapability_d == 1
case gFindEpDescReqId_c:
( simpleDescriptor_t* )pMsgToSend = AF_FindEndPointDesc( *pMsgReceived );
opCodeGrpId = mOpcodeGrpIdForEpDescConf_c;
/*if the endpoint has NULL as Simple descriptor pointer,the status in
confirmation is given as 0xFF*/
if( NULL == pMsgToSend ) {
*( ( uint8_t* )&( pMsgToSend ) ) = 0xff;
}
else {
iIndex =0;
length = sizeof( simpleDescriptor_t ) - 2*sizeof( void* );
pSimpleDes = ( simpleDescriptor_t* )pMsgToSend;
FLib_MemCpy( pMsgToSend, pSimpleDes, sizeof( simpleDescriptor_t ) );
pLocalPtr = ( pMsgToSend ) + 7;
numClusters = pSimpleDes->appNumInClusters;
pStrClusterList = pSimpleDes->pAppInClusterList;
length += numClusters;
for ( iIndex =0; iIndex <numClusters ; iIndex ++ ) {
pLocalPtr[ iIndex ] = pStrClusterList[ iIndex ];
}
pLocalPtr += numClusters;
numClusters = pSimpleDes->appNumOutClusters;
pStrClusterList = pSimpleDes->pAppOutClusterList;
*pLocalPtr = numClusters;
pLocalPtr++;
length += numClusters;
for ( iIndex =0; iIndex <numClusters ; iIndex ++ ) {
pLocalPtr[ iIndex ] = pStrClusterList[ iIndex ];
}
msgLength = length;
}
opCodeGrp = gOpCodeGrpForAFDEToAppSAP_c;
break;
#endif /* gZTC_FindEpDescReqCapability_d */
#endif /* gZTC_AfCTRegCapability_d */
#if gZTC_FindEpListReqCapability_d == 1
case gFindEpListReqId_c:
pEpList = AF_EndPointsList( &numOfActiveEp );
/*if endpointlist is NULL then there are no active endpoints*/
if( NULL == pMsgToSend ) {
opCodeGrpId = mOpcodeGrpIdForEpListConf_c;
msgLength = 0;
}
else {
opCodeGrpId = mOpcodeGrpIdForEpListConf_c;
msgLength = numOfActiveEp;
}
FLib_MemCpy( pMsgToSend, pEpList, msgLength );
/*pointer allocated by the AF layer has to be freed*/
MSG_Free( pEpList );
opCodeGrp = gOpCodeGrpForAFDEToAppSAP_c;
break;
#endif /* gZTC_FindEpListReqCapability_d */
#if gCompileTimeReg_d == 0 /*Runtime capability*/
#if gZTC_RegEpCapabilty_d == 1
case gRegEpId_c:
/*get the next free index in the End point table to register the End
point*/
for( iIndex = 0; iIndex < gNoOfEndPoints; iIndex++ ) {
if( maSimpleDescriptor[ iIndex ].endPoint == 0 ) {
break;
}
}
/*Copy the Simple discriptor of the end point to be registered */
FLib_MemCpy ( &maSimpleDescriptor[ iIndex ], pMsgReceived,
sizeof( simpleDescriptor_t ) - 5
/* 2 each for the pointer to CID List and one for number of Op */ );
/*Copy the input and output cluster ID supported by the End point*/
pMsgReceived += sizeof( simpleDescriptor_t ) - 5;
noOfCId = *( pMsgReceived - 1 );
FLib_MemCpy( &maIpCIdLst[ iIndex ], pMsgReceived, noOfCId );
pMsgReceived += noOfCId;
noOfCId = *pMsgReceived;
FLib_MemCpy( &maOpCIdLst[ iIndex ], pMsgReceived + 1, noOfCId );
/*Update the Simple Discriptor with the proper cluster ID details*/
maSimpleDescriptor[ iIndex ].appNumOutClusters = noOfCId;
maSimpleDescriptor[ iIndex ].pAppInClusterList = maIpCIdLst[ iIndex ];
maSimpleDescriptor[ iIndex ].pAppOutClusterList = maOpCIdLst[ iIndex ];
maZTCEpDesc[ iIndex ].pSimpleDesc = &maSimpleDescriptor[ iIndex ];
/*Update the Function pointer into the End point decriptor table*/
/*KvpDataCallBack*/
maZTCEpDesc[ iIndex ].pDataKvpCallBackFuncPtr = kvpDataCallBack;
/*MsgDataCallBack*/
maZTCEpDesc[ iIndex ].pDataMsgCallBackFuncPtr = msgDataCallBack;
/*ConfDataCallBack*/
maZTCEpDesc[ iIndex ].pDataConfCallBackFuncPtr = confDataCallBack;
/*Call the AF function to register the endpoit*/
*pMsgToSend = AF_RegisterEndPoint( &maZTCEpDesc[ iIndex ] );
/*If the regiateration is not Successful then clear the details filled
in the table*/
if( *pMsgToSend == gRegFailure_c ) {
maSimpleDescriptor[ iIndex ].endPoint = 0;
}
opCodeGrp = gOpCodeGrpForAFDEToAppSAP_c;
opCodeGrpId = mOpCodeGrpIdForRegConf_c;
break;
#endif /* gZTC_RegEpCapabilty_d */
#if gZTC_DeRegEpCapabilty_d == 1
case gDeRegEpId_c:
/* Call the AF Deregistration function */
*pMsgToSend = AF_DeRegisterEndPoint( *pMsgReceived );
/*if deregistration is successful free the Endpoint*/
if( *pMsgToSend == gSuccess_c ) {
for( iIndex = 0; iIndex < gNoOfEndPoints; iIndex++ ) {
if( maSimpleDescriptor[ iIndex ].endPoint == *pMsgToSend ) {
maSimpleDescriptor[ iIndex ].endPoint = 0;
break;
}
}
}
opCodeGrp = gOpCodeGrpForAFDEToAppSAP_c;
opCodeGrpId = mOpCodeGrpIdForDeRegConf_c;
break;
#endif /* gZTC_DeRegEpCapabilty_d */
#endif /*gCompileTimeReg_d == 0*/
#if gZTC_StackTestingCapability_d == 1
case gInitStackUsageId_c:
stackUsed = InitializeStackUsage( );
*pMsgToSend = gSuccess_c ;
opCodeGrpId = mOpCodeGrpIdForInitialiseStackUsageConf_c;
break;
case gMaximumStackUsedId_c:
stackUsed = FindStackUsed( );
FLib_MemCpyReverseOrder( pMsgToSend, &stackUsed, 2 );
opCodeGrpId = mOpCodeGrpIdForFindStackUsageConf_c;
msgLength = sizeof( uint16_t );
break;
#endif /* gZTC_StackTestingCapability_d */
#if gZTC_AFResetCapability_d == 1
case gZTC_AFResetReqId_c:
AF_Init( );
*pMsgToSend = gSuccess_c ;
opCodeGrp = gOpCodeGrpForAFDEToAppSAP_c;
opCodeGrpId = mAFResetConf_c;
break;
#endif
#if gZTC_APSResetCapability_d == 1
case gZTC_APSMEResetId_c:
msgForAPSReset.msgType = gApsmeReset_c;
( void )MSG_Send( ZDO_APSME, &msgForAPSReset );
*pMsgToSend = gSuccess_c ;
opCodeGrp = gOpCodeGrpForAPSMEToZDO_SAP_c;
opCodeGrpId = mAPSResetConf_c;
break;
#endif
#if gZTC_APSSetToReadyStateCapability_d == 1
case gZTC_APSMESetToReadyStateId_c:
gDevReadyState = TRUE;
*pMsgToSend = gSuccess_c ;
opCodeGrp = gOpCodeGrpForAPSMEToZDO_SAP_c;
opCodeGrpId = mAPSSetToReadyStateConf_c;
break;
#endif
/* Default case is not handled */
}
/*Send the confirmation to the Test Client*/
( void )ZTCQueue_QueueToTestClient( pMsgToSend, opCodeGrp, opCodeGrpId,
msgLength );
}
/******************************************************************************
*******************************************************************************
* Private functions
*******************************************************************************
******************************************************************************/
#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 */
)
{
uint8_t status = gZTCFailure_c;
beeStackConfigParams_t* pBeestackConfig = MSG_Alloc(
sizeof( beeStackConfigParams_t ) );
if( NULL != pBeestackConfig ) {
/* Reading the latest values from the ZDO Section of NVM */
FLib_MemCpy( pBeestackConfig, GetZdoNvmPtr,
sizeof( beeStackConfigParams_t ) );
/*updating the 8 bytes Extended Address into the ZDO NVM Structure*/
FLib_MemCpy( pBeestackConfig->gaExtAddr, pAddress,
( sizeof( uint8_t )*8 ) );
/* Fucntion call to write the configuration attributes to the NVM */
BUtl_SaveBeeStackConfig( pBeestackConfig );
status = gSuccess_c;
MSG_Free( pBeestackConfig );
}
return status;
}
#endif /* gZTC_WriteExtendedAddrReqCapabilty_d */
/*****************************************************************************/
#if gZTC_StackTestingCapability_d == 1
static uint16_t InitializeStackUsage ( void ) {
uint16_t spContent;
asm PSHH
asm PSHX
asm TSX
asm STHX spContent
asm PULX
asm PULH
/* To avoid writing to the stack frame used for calling this
function */
spContent -= mStackFunctionCallOverhead_c;
while( spContent-- != mStackBottom_c ) {
*( ( uint8_t * )spContent ) = 0xDD;
}
return spContent ;
}
#endif
/*****************************************************************************/
#if gZTC_StackTestingCapability_d == 1
static uint16_t FindStackUsed( void) {
uint16_t stackUsed;
uint16_t stackMemoryFree = 0;
uint8_t *pStack ;
pStack = ( uint8_t* )mStackBottom_c;
for( ; *pStack == 0xDD ;pStack++ ) {
stackMemoryFree++;
}
stackUsed = ( mStackTop_c - mStackBottom_c ) - stackMemoryFree;
return stackUsed;
}
#endif
/*****************************************************************************/
#if gZTC_WriteConfigureAttribReqCapabilty_d == 1
static void ReverseCopyLongParameters( uint8_t* pConfig ) {
uint8_t controlVar;
uint8_t offsetToByteParameter ;
uint8_t aStoredData[ mByteParaLength_c ];
for( controlVar = 0; controlVar < mNumOfByteParams_c ; controlVar++ ) {
offsetToByteParameter = maArray[ controlVar ];
FLib_MemCpyReverseOrder( aStoredData,
( uint8_t* )&pConfig[ offsetToByteParameter ], mByteParaLength_c );
FLib_MemCpy( ( uint8_t* )&pConfig[ offsetToByteParameter ],
aStoredData,mByteParaLength_c );
}
}
#endif /* gWriteConfigureAttribReqCapabilty_d == 1 */
/******************************************************************************
*******************************************************************************
* Private Debug stuff
*******************************************************************************
******************************************************************************/
/* None */
#endif /* gZTC_UtilitySupportCapability_d */
#endif /* gBeeStackIncluded_d */
#endif /* ( gZtcIncluded_d == 1 ) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -