⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nwk_data_sendandrecive.h

📁 ucos在NEC平台下的移植
💻 H
字号:
#ifndef NWK_DATA_SENDANDRECIVE_H
#define  NWK_DATA_SENDANDRECIVE_H

#define mlmeGetMacDsn()      macDsn++;
// The unicast data transmission status returned to nldeDataRequest(...)
typedef enum 
{
    NLDE_UNICAST_DATA_TRANSMISSION_STATUS_ACTIVE,
    NLDE_UNICAST_DATA_TRANSMISSION_STATUS_FINISHED
 } NLDE_UNICAST_DATA_TRANSMISSION_STATUS;
//the definition of the route reply command
typedef struct
{
    BYTE            commandFrameIdentifier;
    BYTE            commandOptions;
    BYTE            routeRequestIdentifier;
    UINT16         originatorAddress;
    UINT16         responderAddress;
    BYTE            pathCost;
} ROUTE_REPLY_COMMAND;

//the definition of the route request command
typedef struct 
{
    BYTE            commandFrameIdentifier;
    BYTE            commandOptions;
    BYTE            routeRequestIdentifier;
    UINT16         destinationAddress;
    BYTE            pathCost;
} ROUTE_REQUEST_COMMAND;

//The broadcast data transmission status returned to nldeDataRequest()
typedef enum{

   NLDE_BROADCAST_DATA_TRANSMISSION_STATUS_ACTIVE,
   NLDE_BROADCAST_DATA_TRANSMISSION_STATUS_FINISHED
   
} NLDE_BROADCAST_DATA_TRANSMISSION_STATUS;
typedef struct 
{
    BYTE    msduHandle;
    BYTE    nsduHandle;
} NWK_FRAMES;

//We store the network handle in nwkConfirmationHandles array.
#define          INVALID_NWK_HANDLE               0x00
#define          INVALID_MAC_HANDLE               0X00
typedef struct{
ADDRESS       *pDestAddr;
UINT8         nsduLength;
BYTE          *pNsdu;
BYTE           nsduHandle; 
UINT8         broadcastRadius;
UINT8         discoverRoute;
ZBOOL          securityEnable;
volatile NLDE_UNICAST_DATA_TRANSMISSION_STATUS unicastTransmissionStatus;
volatile NLDE_BROADCAST_DATA_TRANSMISSION_STATUS broadcastTransmissionStatus;
}NLDE_DATA_REQUEST_INFO;


typedef struct{
BYTE              addrModes;
WORD            srcPanId;
ADDRESS    * pSrcAddr;
WORD            destPanId;
ADDRESS    * pDestAddr;
UINT8            msduLength;
BYTE           * pMsdu;
BYTE              msduHandle;
BYTE              txOptions;
}MCPS_DATA_REQUEST_INFO;

typedef struct
{
BYTE           nsduHandle;
NWK_ENUM  status;
}NLDE_DATA_CONFIRM_INFO;



//-------------------------------------------------------------------------------------------------------
// Unicast data transmission state machine

// Initial preparations
#define NWK_STATE_INITIALIZE_DATA_UNICAST_TRANSMISSION               0        
#define NWK_STATE_CONSTRUCT_NWK_HEADER                               1

// Determine the route path
#define NWK_STATE_DETERMINE_ROUTE_PATH                               2

// Prepare the parameters passed to the mcpsDataRequest
#define NWK_STATE_PREPARE_MAC_PARAMETER                              3
// Data unicast transmission complete
#define NWK_STATE_DATA_UNICAST_TRANSMISSION_FINISH                   4
// Data unicast transmission failed
#define NWK_STATE_DATA_UNICAST_TRANSMISSION_FAILED                   5
//-------------------------------------------------------------------------------------------------------

//-----------------------------------------------------------------
// Broadcast data transmission state machine

//Initial preparations
#define NWK_STATE_INITIALIZE_DATA_BROADCAST_TRANSMISSION  0
//Deal with the recived broadcast transaction record
#define NWK_STATE_DEAL_WITH_BTR                           1
//Data broadcast transmission complete
#define NWK_STATE_DATA_BROADCAST_TRANSMISSION_FINISH          2
#define NWK_STATE_DATA_BROADCAST_TRANSMISSION_FAILED          3
//-----------------------------------------------------------------

#define   NWK_HEADER_LENGTH                               8
#define   NWK_HEADER_FRAME_CONTROL_FIELD_INDEX                        0
#define   NWK_HEADER_DESTINATION_ADDRESS_FIELD_INDEX      2
#define   NWK_HEADER_SOURCE_ADDRESS_FIELD_INDEX                  4
#define   NWK_HEADER_RADIUS_FIELD_INDEX                                        6//we can only send leave request command ti our direct child.
#define   NWK_HEADER_SEQUENCE_NUMBER_FIELD_INDEX                7  

#define   NWK_RREP_PAYLOAD_COMMAND_FRAME_IDENTIFIER_INDEX    8
#define   NWK_RREP_PAYLOAD_COMMAND_OPTIONS_INDEX                   9
#define   NWK_RREP_PAYLOAD_ROUTE_REQUEST_IDENTIFIER_INDEX      10
#define   NWK_RREP_PAYLOAD_ORIGINATOR_ADDRESS_INDEX              11
#define   NWK_RREP_PAYLOAD_RESPONDER_ADDRESS_INDEX                13
#define   NWK_RREP_PAYLOAD_PATH_COST_INDEX                                 15

#define   NWK_RERR_PAYLOAD_COMMAND_FRAME_IDENTIFIER_INDEX           8
#define   NWK_RERR_PAYLOAD_ERROR_CODE_INDEX                                    9
#define   NWK_RERR_PAYLOAD_DESTINATION_ADDRESS_INDEX                   10

#define   NWK_RREQ_PAYLOAD_COMMAND_FRAME_IDENTIFIER_INDEX              8
#define   NWK_RREQ_PAYLOAD_COMMAND_OPTIONS_INDEX                 9   
#define   NWK_RREQ_PAYLOAD_ROUTE_REQUEST_IDENTIFIER_INDEX    10
#define   NWK_RREQ_PAYLOAD_DESTINATION_ADDRESS_INDEX           11
#define   NWK_RREQ_PAYLOAD_PATH_COST_INDEX                              13

#define  NWK_LEAVE_PAYLOAD_COMMAND_FRAME_IDENTIFIER_INDEX  8
 #define  NWK_LEAVE_PAYLOAD_COMMAND_OPTIONS_INDEX              9

#define NWK_RREQ_PAYLOAD_LENGTH           6


//---------------------------------------------------------------
//   void nwkDataUnicastProcedure(void * nTask);
//   DESCRIPTION:
//           This task function will do the data uincast transmission.
//   PARAMETER:
//           void * nTask,
//                 some information about the data unicast transmission task.
//   RETURN-VALUE:
//           NO
//---------------------------------------------------------------
void nwkDataUnicastProcedure(void * nTask);

//---------------------------------------------------------------
//  void nwkDataBroadcastProcedure(void * nTask);
//
//   DESCRIPTION:
//          This task function will do the data broadcast transmission.
//   PARAMETER:
//          void * nTask,
//                some information about the data broadcast transmission task.
//   RETURN-VALUE:
//           NO
//---------------------------------------------------------------
void nwkDataBroadcastProcedure(void * nTask);

//---------------------------------------------------------------
//   void nwkDealWithRecivedRrepFromMCPS(void);
//   
//   DESCRIPTION:
//          This function deal with the recived rrep from the mcpsDataIndication 
//          function.
//   PARAMETER:
//          NO.
//   RETURN-VALUE:
//          NO.
//   NOTE:The device may recive some route reply command from some remote
//          device,the route reply command is for this device or not ,I wrap the 
//          concrete operation in this function.
//---------------------------------------------------------------
void nwkDealWithRecivedRrepFromMCPS(void);

//---------------------------------------------------------------
//    void nwkDealWithRecivedRerrFromMCPS(void);
//
//    DESCRIPTION:
//           This function deals with the recived rerr from the mcpsDataIndication
//           function.
//    PARAMETER:
//          NO.
//    RETURN-VALUE:
//          NO.
//    NOTE:The device may recive some route error command from some remote 
//          device ,the route error command is for this device or not.I wrap the 
//          concrete operation in this function.
//----------------------------------------------------------------
void nwkDealWithRecivedRerrFromMCPS(void);

//----------------------------------------------------------------
//   void nwkDealWithRecivedLeaveRequestFromMCPS(void);
//
//   DESCRIPTION:
//         This function deals with the recived leave request command from the 
//         mcpsDataIndication function.
//   PARAMETER:
//          NO.
//   RETURN-VALUE:
//          NO.
//   NOTE:The device may recive some leave request command from its parent
//          device ,when recived the leave request command,the device should do 
//           some operation.I wrap the operations in this function.
//----------------------------------------------------------------
void nwkDealWithRecivedLeaveRequestFromMCPS(void);

//---------------------------------------------------------------
//    void nwkDealWithRecivedLeaveIndicationFromMCPS(void);
//
//    DESCRIPTION:
//           This function deals with the recived leave indication command from 
//           the mcpsDataIndication function.
//    PARAMETER:
//          NO.
//    RETURN-VALUE:
//          NO.
//    NOTE:The device may recive some leave indication commands from its
//          child device,I wrap the operations executed when recived the leave
//          indication command in this function.
//----------------------------------------------------------------
void nwkDealWithRecivedLeaveIndicationFromMCPS(void);

//----------------------------------------------------------------
//     void nwkDealWithRecivedUnicastDataFrameFromMCPS(void);
//
//     DESCRIPTION:
//            This function deals with the recived unicast data through the 
//             mcpsDataIndication function.
//     PARAMETER:
//            NO;
//     RETURN-VALUE:
//            NO.
//     NOTE:The device may recive some unicast data frame from some remote
//            device,the device maybe the destination of the unicast  data frame,or
//            maybe not.I wrap some relate operation in this function.
//----------------------------------------------------------------
void nwkDealWithRecivedUnicastDataFrameFromMCPS(void);

//---------------------------------------------------------------------------
//      void nwkDealWithRecivedBroadcastDataFrameFromMCPS(void);
//
//      PARAMETER:
//             NO
//      RETURN-VALUE:
//            NO.
//     NOTE:The device may recive some unicast data frame from some remote
//            device,the device maybe the destination of the unicast  data frame,or
//            maybe not.I wrap some relate operation in this function.
//----------------------------------------------------------------
void nwkDealWithRecivedBroadcastDataFrameFromMCPS(void);

//--------------------------------------------------------------------------
//        void nwkDealWithRecivedRreqFromMCPS(void);
//
//        DESCRIPTION:
//                This  function deals with the recived route request command through mcpsDataIndication function.
//        PARAMETER:
//                 NO
//         RETURN-VALUE:
//                 NO
//         NOTE:
//                The meaning of the function name is :network deals with recived route request command
//                recived through mcpsDataIndication function;this route request command is probably  from
//                some remote device.
//-----------------------------------------------------------------------------
void nwkDealWithRecivedRreqFromMCPS(void);


//-----------------------------------------------------------------------------------------------
//    void nwkPrepareParametersForMcpsDataRequest(UINT16 destinationAddress,BYTE *msduHandle);
//
//    DESCRIPTION:
//            This function is used to initialize the parameters for the mcpsDataRequest function.
//    PARAMETER:
//            UINT16 destinationAddress,
//              The short address of the destination device.It is not the same as the 'destination address' field
//              in NWK header.
//            BYTE *msduHandle,
//              The msdu handle of the outgoing NWK packet.
//            UINT8 length.
//              The length of the data byte array.
//    RETURN-VALUE:
//            NO.
//-----------------------------------------------------------------------------------------------
void nwkPrepareParametersForMcpsDataRequest(UINT16 destinationAddress,BYTE *msduHandle,UINT8 length);

//-------------------------------------------------------------------------------------------------------------------
//     void nwkConstructRouteRequestCommandMsduLocally(BYTE discoverRoute,BYTE commandOptions,UINT16 destinedAddress);
//
//      DESCRIPTION:
//              In the program,use nwkTxFrame[] to construct the outgoing frame,so use this
//              function to wrap the operations.
//      PARAMETER:
//              BYTE discoverRoute,
//                 This parameter is used to initialize the 'discoverRoute' field in the NWK header.
//              BYTE commandOptions,
//                  Corresponding to the 'Route repair' field in the nwk payload.
//              UINT16 destinedAddress,
//                   The destined device's short address.
//      RETURN-VALUE:
//               NO
//- -------------------------------------------------------------------------------------------------------------------
void nwkConstructRouteRequestCommandMsduLocally(BYTE discoverRoute,BYTE commandOptions,UINT16 destinedAddress);

//--------------------------------------------------------------------------------------------
//    void nwkConstructRouteErrorCommandMsduLocally(PACKET_ROUTING_STATUS routingStatus);
//
//    DESCRIPTION:
//              In the program,use nwkTxFrame[] to construct the outgoing frame,so use this function to wrap the 
//              operations needed when constructing a route error command locally.
//    PARAMETER:
//              PACKET_ROUTING_STATUS routingStatus,
//                  This parameter is used to initialize the 'error code' field in the route error command payload.
//    RETURN-VALUE:
//              NO.
//--------------------------------------------------------------------------------------------
void nwkConstructRouteErrorCommandMsduLocally(PACKET_ROUTING_STATUS routingStatus);

//--------------------------------------------------------------------------------------------
//    void nwkConstructRouteReplyCommandMsduLocally(UINT16 destinationAddress,BYTE pathCost);
//
//     DESCRIPTION:
//            Construct the route reply command.
//     PARAMETER:
//            UINT16 destinationAddress.
//            真

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -