Demo HCI Implementation for WiMOD-LR Devices  V2.0.3
WiMOD_SAP_RadioLink.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
31 //------------------------------------------------------------------------------
32 
33 
34 /*
35  * THIS IS AN EXAMPLE IMPLEMENTATION ACCORDING THE THE HCI SPEC: V1.10
36  * FOR FIRMWARE: LR-BASE
37  *
38  * SEE FILE: WiMOD_LR_Base_HCI_Spec_V1_10.pdf for detailed information
39  */
40 
41 
42 
43 #ifndef ARDUINO_SAP_WIMOD_SAP_RADIOLINK_H_
44 #define ARDUINO_SAP_WIMOD_SAP_RADIOLINK_H_
45 
46 //------------------------------------------------------------------------------
47 //
48 // Section Includes Files
49 //
50 //------------------------------------------------------------------------------
51 
53 #include "../HCI/WiMODLRHCI.h"
54 
55 /*
56  * C++11 supports a better way for function pointers / function objects
57  * But C++11 mode is not supported by all platforms.
58  */
59 #ifdef WIMOD_USE_CPP11
60 #include <functional>
61 #endif
62 //------------------------------------------------------------------------------
63 //
64 // Section defines
65 //
66 //------------------------------------------------------------------------------
67 
69 #define WiMOD_RADIOLINK_MSG_SIZE (WiMODLRBASE_APP_PAYLOAD_LEN)
70 
72 
73 
74 //-----------------------------------------------------------------------------
75 //
76 // types for callback functions
77 //
78 //-----------------------------------------------------------------------------
79 
80 
81 // C++11 check
82 #ifdef WIMOD_USE_CPP11
83  /* C++11 function callback definitions */
84 
86  typedef std::function<void (TWiMODLR_HCIMessage& rxMsg)> TRadioLinkUDataRxIndicationCallback;
87 
89  typedef std::function<void (void)> TRadioLinkUDataTxIndicationCallback;
90 
92  typedef std::function<void (TWiMODLR_HCIMessage& rxMsg)> TRadioLinkRawDataRxIndicationCallback;
93 
95  typedef std::function<void (TWiMODLR_HCIMessage& rxMsg)> TRadioLinkCDataRxIndicationCallback;
96 
98  typedef std::function<void (TWiMODLR_HCIMessage& rxMsg)> TRadioLinkCDataTxIndicationCallback;
99 
101  typedef std::function<void (TWiMODLR_HCIMessage& rxMsg)> TRadioLinkAckRxIndicationCallback;
102 
104  typedef std::function<void (void)> TRadioLinkAckRxTimeoutIndicationCallback;
105 
107  typedef std::function<void (TWiMODLR_HCIMessage& rxMsg)> TRadioLinkAckTxIndicationCallback;
108 
109 #else
110  /* pre C++11 function callback definitions */
111 
112 
113 
116 
118  typedef void (*TRadioLinkUDataTxIndicationCallback)(TWiMODLR_HCIMessage& rxMsg); // V1.10 : added parameter
119 
122 
125 
128 
131 
134 
137 
138 #endif
139 
140 
141 //------------------------------------------------------------------------------
142 //
143 // Section class
144 //
145 //------------------------------------------------------------------------------
146 
147 
152 public:
153  WiMOD_SAP_RadioLink(TWiMODLRHCI* hci, UINT8* buffer, UINT16 bufferSize);
154  virtual ~WiMOD_SAP_RadioLink(void);
155 
156  virtual TWiMODLRResultCodes SendUData(const TWiMODLR_RadioLink_Msg* txMsg, UINT8* statusRsp);
157  virtual bool convert(TWiMODLR_HCIMessage& RxMsg, TWiMODLR_RadioLink_Msg* radioLinkMsg);
158  virtual TWiMODLRResultCodes SendCData(const TWiMODLR_RadioLink_Msg* txMsg, UINT8* statusRsp);
159  virtual bool convert(TWiMODLR_HCIMessage& RxMsg, TWiMODLR_RadioLink_CdataInd* cDataTxInfo);
160  virtual bool convert(TWiMODLR_HCIMessage& RxMsg, TWiMODLR_RadioLink_UdataInd* uDataTxInfo);
161  virtual bool convert(TWiMODLR_HCIMessage& RxMsg, TWiMODLR_AckTxInd_Msg* txAckIndInfo);
162  virtual TWiMODLRResultCodes SetAckData(const TWiMODLR_RadioLink_Msg* txMsg, UINT8* statusRsp);
163 
164  /* only for sniffer mode */
165  virtual bool convert(TWiMODLR_HCIMessage& RxMsg, TWiMODLR_RadioLink_RawMsg* radioLinkRawMsg);
166 
167 
176 
177  virtual void DispatchRadioLinkMessage(TWiMODLR_HCIMessage& rxMsg);
178 
179 protected:
181  UINT8* txPayload;
182  UINT16 txPayloadSize;
183 
184  TWiMODLRHCI* HciParser;
186 
187 private:
189 
190  TRadioLinkUDataRxIndicationCallback UDataRxIndCallback;
191  TRadioLinkUDataTxIndicationCallback UDataTxIndCallback;
192  TRadioLinkRawDataRxIndicationCallback RawDataRxIndCallback;
193  TRadioLinkCDataRxIndicationCallback CDataRxIndCallback;
194  TRadioLinkCDataTxIndicationCallback CDataTxIndCallback;
195  TRadioLinkAckRxIndicationCallback AckRxDataIndCallback;
196  TRadioLinkAckRxTimeoutIndicationCallback AckRxTimeoutIndCallback;
197  TRadioLinkAckTxIndicationCallback AckTxIndCallack;
199 };
200 
201 
202 
203 #endif /* ARDUINO_SAP_WIMOD_SAP_RADIOLINK_H_ */
TWiMODLR_AckTxInd_Msg::Status
UINT8 Status
Definition: WiMOD_SAP_RadioLink_IDs.h:245
TWiMODLRHCI
Internal helper class for processing SLIP frames.
Definition: WiMODLRHCI.h:235
WiMODLR_RESULT_TRANMIT_ERROR
@ WiMODLR_RESULT_TRANMIT_ERROR
Definition: WiMODLRHCI.h:154
TWiMODLR_AckTxInd_Msg
Structure containing information about an acknowledgment transmission.
Definition: WiMOD_SAP_RadioLink_IDs.h:243
TWiMODLR_HCIMessage
basic low level HCI message structure used for all serial messages to/from WiMOD
Definition: WiMODLRHCI.h:120
WiMODLR_RESULT_OK
@ WiMODLR_RESULT_OK
Definition: WiMODLRHCI.h:151
TWiMODLR_HCIMessage::Length
UINT16 Length
Definition: WiMODLRHCI.h:123
TWiMODLR_HCIMessage::MsgID
UINT8 MsgID
Definition: WiMODLRHCI.h:129
TWiMODLR_HCIMessage::Payload
UINT8 Payload[WIMODLR_HCI_MSG_PAYLOAD_SIZE]
Definition: WiMODLRHCI.h:132
WiMODLR_RESULT_PAYLOAD_PTR_ERROR
@ WiMODLR_RESULT_PAYLOAD_PTR_ERROR
Definition: WiMODLRHCI.h:153
TWiMODLRResultCodes
TWiMODLRResultCodes
Result codes for the local serial communication itself.
Definition: WiMODLRHCI.h:149
WiMODLR_RESULT_PAYLOAD_LENGTH_ERROR
@ WiMODLR_RESULT_PAYLOAD_LENGTH_ERROR
Definition: WiMODLRHCI.h:152