📄 ztcprimitivehandlercomplexprimwithtablelist.c
字号:
/******************************************************************************
* This module formats the complex primitives with table list, which are to be
* exchanged between the test client and BeeStack Layers. Complex primitives are
* one, which are of varibale length. ZTC has to format, meaning it 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 )
#if gBeeStackIncluded_d == 1
#include "EmbeddedTypes.h"
#include "ZtcInterface.h"
#include "ZtcQueue.h"
#include "ZtcPrimitiveHandlerComplexPrimitive.h"
#include "ZtcConfiguration.h"
#include "ZtcPrimitiveHandlerComplexPrimWithOnePtr.h"
#include "ZtcPrimitiveHandlerComplexPrimWithTableList.h"
/* If Table list Handling capability is enabled then only this part of code
will be enabled */
#if gZTC_PrimitiveWithTableListHandlingCapability_d == 1
/******************************************************************************
*******************************************************************************
* Private macros
*******************************************************************************
******************************************************************************/
#define mOffsetOfPosOfnumOfListInNwkAddrResp_c 11
#define mOffsetOfPosOfnumOfListInIEEEAddrResp_c 11
#define mOffsetOfPosOfnumOfListInActiveEpResp_c 3
#define mOffsetOfPosOfnumOfListInMatchDescResp_c 5
#define mOffsetOfPosOfnumOfListInUserDescResp_c 3
#define mOffsetOfPosOfnumOfListInMgmtNwkDiscResp_c 3
#define mOffsetOfPosOfnumOfListInMgmtLQIResp_c 3
#define mOffsetOfPosOfnumOfListInMgmtRtgResp_c 3
#define mOffsetOfPosOfnumOfListInMgmtBindResp_c 3
#define mOffsetOfPosOfnumOfListInZTCMSGDataReq_c 44
#define mOffsetOfPosOfnumOfListInZTCActiveEpResp_c 3
#define mOffsetOfPosOfplaceHolderInNwkAddrResp_c 13
#define mOffsetOfPosOfplaceHolderInIEEEAddrResp_c 13
#define mOffsetOfPosOfplaceHolderInActiveEpResp_c 4
#define mOffsetOfPosOfplaceHolderInMatchDescResp_c 6
#define mOffsetOfPosOfplaceHolderInUserDescResp_c 4
#define mOffsetOfPosOfplaceHolderInMgmtNwkDiscResp_c 4
#define mOffsetOfPosOfplaceHolderInMgmtLQIResp_c 4
#define mOffsetOfPosOfplaceHolderInMgmtRtgResp_c 4
#define mOffsetOfPosOfplaceHolderInMgmtBindResp_c 4
#define mOffsetOfPosOfplaceHolderInZTCMSGDataReq_c 45
#define mOffsetOfPosOfplaceHolderInZTCActiveEpResp_c 4
#define mSizeOfTableForNwkAddrResp_c 2
#define mSizeOfTableForIEEEAddrResp_c 2
#define mSizeOfTableForActiveEpResp_c 1
#define mSizeOfTableForMatchDescResp_c 1
#define mSizeOfTableForUserDescResp_c sizeof(configUserDescriptor_t)
#define mSizeOfTableForMgmtNwkDiscResp_c sizeof( networkDesc_t )
#define mSizeOfTableForMgmtLQIResp_c sizeof( neighborTableData_t )
#define mSizeOfTableForMgmtRtgResp_c sizeof( routeTable_t )
#define mSizeOfTableForMgmtBindResp_c sizeof( apsmeBinding_t )
#define mSizeOfTableForZTCMSGDataReq_c 1
#define mSizeOfTableForZTCActiveEpResp_c 1
/******************************************************************************
*******************************************************************************
* Private prototypes
*******************************************************************************
******************************************************************************/
/* None */
/******************************************************************************
*******************************************************************************
* Private type definitions
*******************************************************************************
******************************************************************************/
/* The below type definition will be used to locate the number of list and the
place holder in the primitive structure and the size of the list e.g. for
mgmtLqiResp_t, value of posOfnumOfList is 4 and posOfplaceHolder is 5 and
sizeOfTable is sizeof( neighborTable_t )
_____________________________________________
| |len|<-sizeOfTable * |
| |gth| content of |
|<-posOfplaceHolder-|-->| posOfnumOfList-> |
| | | |
---------------------------------------------
<--posOfnumOfList-->
*/
typedef struct complexPrimWithTableList_tag{
uint8_t posOfnumOfList; /* Location of the number of list in the pointer
location */
uint8_t posOfplaceHolder; /* Location of the place holder */
uint8_t sizeOfTable; /* Size of the table list the place holder
holds */
}complexPrimWithTableList_t;
/******************************************************************************
*******************************************************************************
* Private memory declarations
*******************************************************************************
******************************************************************************/
/* Look up table to store information on the primitives with Table list */
static const complexPrimWithTableList_t maComplexPrimWithTableList[] = {
/* gNwkAddrRespId_c */
{ mOffsetOfPosOfnumOfListInNwkAddrResp_c,
mOffsetOfPosOfplaceHolderInNwkAddrResp_c, mSizeOfTableForNwkAddrResp_c },
/* gIEEEAddrRespId_c */
{ mOffsetOfPosOfnumOfListInIEEEAddrResp_c,
mOffsetOfPosOfplaceHolderInIEEEAddrResp_c, mSizeOfTableForIEEEAddrResp_c },
/* gActiveEpRespId_c */
{ mOffsetOfPosOfnumOfListInActiveEpResp_c,
mOffsetOfPosOfplaceHolderInActiveEpResp_c, mSizeOfTableForActiveEpResp_c },
/* gMatchDescRespId_c */
{ mOffsetOfPosOfnumOfListInMatchDescResp_c,
mOffsetOfPosOfplaceHolderInMatchDescResp_c,
mSizeOfTableForMatchDescResp_c },
/* gUserDescRespId_c */
{ mOffsetOfPosOfnumOfListInUserDescResp_c,
mOffsetOfPosOfplaceHolderInUserDescResp_c, mSizeOfTableForUserDescResp_c },
/* gMgmtNwkDiscRespId_c */
{ mOffsetOfPosOfnumOfListInMgmtNwkDiscResp_c,
mOffsetOfPosOfplaceHolderInMgmtNwkDiscResp_c,
mSizeOfTableForMgmtNwkDiscResp_c },
/* gMgmtLQIRespId_c */
{ mOffsetOfPosOfnumOfListInMgmtLQIResp_c,
mOffsetOfPosOfplaceHolderInMgmtLQIResp_c, mSizeOfTableForMgmtLQIResp_c },
/* gMgmtRtgRespId_c */
{ mOffsetOfPosOfnumOfListInMgmtRtgResp_c,
mOffsetOfPosOfplaceHolderInMgmtRtgResp_c, mSizeOfTableForMgmtRtgResp_c },
/* gMgmtBindRespId_c */
{ mOffsetOfPosOfnumOfListInMgmtBindResp_c,
mOffsetOfPosOfplaceHolderInMgmtBindResp_c, mSizeOfTableForMgmtBindResp_c },
/* gZTC_MSGDataReqId_c */
{ mOffsetOfPosOfnumOfListInZTCMSGDataReq_c,
mOffsetOfPosOfplaceHolderInZTCMSGDataReq_c,
mSizeOfTableForZTCMSGDataReq_c },
/* gZTCActiveEpRespId_c */
{ mOffsetOfPosOfnumOfListInZTCActiveEpResp_c,
mOffsetOfPosOfplaceHolderInZTCActiveEpResp_c,
mSizeOfTableForZTCActiveEpResp_c }
};
/******************************************************************************
*******************************************************************************
* Public functions
*******************************************************************************
******************************************************************************/
uint8_t ZTCPrimHandle_SendComplexPrimWithTableListToSAP
(
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 msgId /* IN: message ID of the Primitive to be
handled */
)
{
uint8_t msgLength = 0;
uint8_t posOfnumOfList = maComplexPrimWithTableList[ msgId ].posOfnumOfList;
if(msgId == ( gZTC_MSGDataReqId_c - gStartIdOfComplexPrimWithTableList_c ) ){
pMsgToSend--;
}
msgLength = maComplexPrimWithTableList[ msgId ].posOfplaceHolder
+ *( pMsgReceived + posOfnumOfList ) *
maComplexPrimWithTableList[ msgId ].sizeOfTable;
FLib_MemCpy( pMsgToSend, ( uint8_t* )pMsgReceived, msgLength );
return msgLength;
}
/*****************************************************************************/
uint8_t ZTCPrimHandle_StoreComplexPrimWithTableListInZTCQueue
(
const uint8_t* pMsg, /* IN: Memory location to the data part received
from the SAP */
const uint8_t msgId /* IN: Msg ID of primitive with one pointer Here
ID 0 is gMcpsDataReqID_c and 1 is g
MCPSDataIndId_c and so on */
)
{
uint8_t msgLength = maComplexPrimWithTableList[ msgId ].posOfplaceHolder
+ *( pMsg + maComplexPrimWithTableList[ msgId ].posOfnumOfList ) *
maComplexPrimWithTableList[ msgId ].sizeOfTable;
if( ( ZTCQueue_SpaceAvailableToWriteIntoBuffer ) >=
( gHeaderSize_c + msgLength ) ) {
FLib_MemCpy( &aZTCBuffer[ gtZTCBufferTail + gDataIndex_c ],
( uint8_t * )pMsg, msgLength );
return msgLength;
}
return gZTCCannotBeQueued_c;
}
/******************************************************************************
*******************************************************************************
* Private functions
*******************************************************************************
******************************************************************************/
/* None */
/******************************************************************************
*******************************************************************************
* Private Debug stuff
*******************************************************************************
******************************************************************************/
/* None */
#endif /* gZTC_PrimitiveWithTableListHandlingCapability_d */
#endif /* gBeeStackIncluded_d */
#endif /* ( gZtcIncluded_d == 1 ) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -