| 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
52 #include "WiMOD_SAP_RadioLink_IDs.h"
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
115 typedef void (*TRadioLinkUDataRxIndicationCallback)(TWiMODLR_HCIMessage& rxMsg);
116
118 typedef void (*TRadioLinkUDataTxIndicationCallback)(TWiMODLR_HCIMessage& rxMsg); // V1.10 : added parameter
119
121 typedef void (*TRadioLinkRawDataRxIndicationCallback)(TWiMODLR_HCIMessage& rxMsg);
122
124 typedef void (*TRadioLinkCDataRxIndicationCallback)(TWiMODLR_HCIMessage& rxMsg);
125
127 typedef void (*TRadioLinkCDataTxIndicationCallback)(TWiMODLR_HCIMessage& rxMsg);
128
130 typedef void (*TRadioLinkAckRxIndicationCallback)(TWiMODLR_HCIMessage& rxMsg);
131
133 typedef void (*TRadioLinkAckRxTimeoutIndicationCallback)(void);
134
136 typedef void (*TRadioLinkAckTxIndicationCallback)(TWiMODLR_HCIMessage& rxMsg);
137
138 #endif
139
140
141 //------------------------------------------------------------------------------
142 //
143 // Section class
144 //
145 //------------------------------------------------------------------------------
146
147
151 class WiMOD_SAP_RadioLink {
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
168 virtual void RegisterUDataRxClient(TRadioLinkUDataRxIndicationCallback cb);
169 virtual void RegisterUDataTxClient(TRadioLinkUDataTxIndicationCallback cb);
170 virtual void RegisterRawDataRxClient(TRadioLinkRawDataRxIndicationCallback cb);
171 virtual void RegisterCDataRxClient(TRadioLinkCDataRxIndicationCallback cb);
172 virtual void RegisterCDataTxClient(TRadioLinkCDataTxIndicationCallback cb);
173 virtual void RegisterAckRxClient(TRadioLinkAckRxIndicationCallback cb);
174 virtual void RegisterAckRxTimeoutClient(TRadioLinkAckRxTimeoutIndicationCallback cb);
175 virtual void RegisterAckTxCallback(TRadioLinkAckTxIndicationCallback cb);
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_ */
WiMOD_SAP_RadioLink::~WiMOD_SAP_RadioLink
virtual ~WiMOD_SAP_RadioLink(void)
Destructor.
Definition: WiMOD_SAP_RadioLink.cpp:88
WiMOD_SAP_RadioLink::RegisterAckRxTimeoutClient
virtual void RegisterAckRxTimeoutClient(TRadioLinkAckRxTimeoutIndicationCallback cb)
Register a callback function for the Ack Timeout Indication - optional -.
Definition: WiMOD_SAP_RadioLink.cpp:623
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
TRadioLinkUDataRxIndicationCallback
void(* TRadioLinkUDataRxIndicationCallback)(TWiMODLR_HCIMessage &rxMsg)
Definition: WiMOD_SAP_RadioLink.h:115
TWiMODLR_RadioLink_Msg::Payload
UINT8 Payload[WIMOD_RADIOLINK_PAYLOAD_LEN]
Definition: WiMOD_SAP_RadioLink_IDs.h:175
WiMOD_SAP_RadioLink::SetAckData
virtual TWiMODLRResultCodes SetAckData(const TWiMODLR_RadioLink_Msg *txMsg, UINT8 *statusRsp)
Sets additional user payload for the next ack frame to send.
Definition: WiMOD_SAP_RadioLink.cpp:481
TWiMODLR_RadioLink_UdataInd::AirTime
UINT32 AirTime
Definition: WiMOD_SAP_RadioLink_IDs.h:236
TWiMODLR_RadioLink_CdataInd::AirTime
UINT32 AirTime
Definition: WiMOD_SAP_RadioLink_IDs.h:225
TWiMODLR_RadioLink_Msg::DestinationDeviceAddress
UINT16 DestinationDeviceAddress
Definition: WiMOD_SAP_RadioLink_IDs.h:167
TWiMODLR_RadioLink_Msg
Structure containing a general RadioLink HCI message.
Definition: WiMOD_SAP_RadioLink_IDs.h:160
TWiMODLR_RadioLink_Msg::SNR
INT8 SNR
Definition: WiMOD_SAP_RadioLink_IDs.h:183
WiMODLR_RESULT_TRANMIT_ERROR
@ WiMODLR_RESULT_TRANMIT_ERROR
Definition: WiMODLRHCI.h:154
TRadioLinkAckRxIndicationCallback
void(* TRadioLinkAckRxIndicationCallback)(TWiMODLR_HCIMessage &rxMsg)
Definition: WiMOD_SAP_RadioLink.h:130
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
TRadioLinkRawDataRxIndicationCallback
void(* TRadioLinkRawDataRxIndicationCallback)(TWiMODLR_HCIMessage &rxMsg)
Definition: WiMOD_SAP_RadioLink.h:121
TWiMODLR_RadioLink_Msg::MIC
INT16 MIC
Definition: WiMOD_SAP_RadioLink_IDs.h:187
TWiMODLR_HCIMessage::Length
UINT16 Length
Definition: WiMODLRHCI.h:123
TWiMODLR_HCIMessage::MsgID
UINT8 MsgID
Definition: WiMODLRHCI.h:129
WiMOD_SAP_RadioLink::RegisterAckTxCallback
virtual void RegisterAckTxCallback(TRadioLinkAckTxIndicationCallback cb)
Register a callback function for the TX Ack Indication - optional -.
Definition: WiMOD_SAP_RadioLink.cpp:638
TRadioLinkCDataTxIndicationCallback
void(* TRadioLinkCDataTxIndicationCallback)(TWiMODLR_HCIMessage &rxMsg)
Definition: WiMOD_SAP_RadioLink.h:127
TWiMODLR_HCIMessage::Payload
UINT8 Payload[WIMODLR_HCI_MSG_PAYLOAD_SIZE]
Definition: WiMODLRHCI.h:132
TWiMODLR_RadioLink_CdataInd::Status
UINT8 Status
Definition: WiMOD_SAP_RadioLink_IDs.h:223
TWiMODLR_RadioLink_Msg::SourceGroupAddress
UINT8 SourceGroupAddress
Definition: WiMOD_SAP_RadioLink_IDs.h:170
TWiMODLR_RadioLink_Msg::DestinationGroupAddress
UINT8 DestinationGroupAddress
Definition: WiMOD_SAP_RadioLink_IDs.h:166
TWiMODLR_RadioLink_UdataInd::Status
UINT8 Status
Definition: WiMOD_SAP_RadioLink_IDs.h:234
WiMOD_SAP_RadioLink::RegisterCDataRxClient
virtual void RegisterCDataRxClient(TRadioLinkCDataRxIndicationCallback cb)
Register a callback function for the RX C-Data Indication - optional -.
Definition: WiMOD_SAP_RadioLink.cpp:574
WiMOD_SAP_RadioLink::RegisterAckRxClient
virtual void RegisterAckRxClient(TRadioLinkAckRxIndicationCallback cb)
Register a callback function for the RX Ack (+data) Indication - optional -.
Definition: WiMOD_SAP_RadioLink.cpp:608
WiMOD_SAP_RadioLink::RegisterUDataTxClient
virtual void RegisterUDataTxClient(TRadioLinkUDataTxIndicationCallback cb)
Register a callback function for the TX U-Data Indication - optional -.
Definition: WiMOD_SAP_RadioLink.cpp:540
TWiMODLR_RadioLink_UdataInd::TxEventCounter
UINT16 TxEventCounter
Definition: WiMOD_SAP_RadioLink_IDs.h:235
WiMOD_SAP_RadioLink::SendUData
virtual TWiMODLRResultCodes SendUData(const TWiMODLR_RadioLink_Msg *txMsg, UINT8 *statusRsp)
Tries to send transmit U-Data to peer module via RF link.
Definition: WiMOD_SAP_RadioLink.cpp:107
WiMOD_SAP_RadioLink_IDs.h
TRadioLinkCDataRxIndicationCallback
void(* TRadioLinkCDataRxIndicationCallback)(TWiMODLR_HCIMessage &rxMsg)
Definition: WiMOD_SAP_RadioLink.h:124
WiMOD_SAP_RadioLink::RegisterRawDataRxClient
virtual void RegisterRawDataRxClient(TRadioLinkRawDataRxIndicationCallback cb)
Register a callback function for the RX Raw-Data Indication - optional -.
Definition: WiMOD_SAP_RadioLink.cpp:557
TWiMODLR_RadioLink_Msg::SourceDeviceAddress
UINT16 SourceDeviceAddress
Definition: WiMOD_SAP_RadioLink_IDs.h:171
TWiMODLR_RadioLink_Msg::StatusFormat
UINT8 StatusFormat
Definition: WiMOD_SAP_RadioLink_IDs.h:163
TWiMODLR_RadioLink_Msg::Length
UINT8 Length
Definition: WiMOD_SAP_RadioLink_IDs.h:174
WiMODLR_RESULT_PAYLOAD_PTR_ERROR
@ WiMODLR_RESULT_PAYLOAD_PTR_ERROR
Definition: WiMODLRHCI.h:153
TWiMODLR_RadioLink_Msg::RSSI
INT16 RSSI
Definition: WiMOD_SAP_RadioLink_IDs.h:182
WiMOD_SAP_RadioLink::RegisterCDataTxClient
virtual void RegisterCDataTxClient(TRadioLinkCDataTxIndicationCallback cb)
Register a callback function for the TX C-Data Indication - optional -.
Definition: WiMOD_SAP_RadioLink.cpp:591
TRadioLinkAckRxTimeoutIndicationCallback
void(* TRadioLinkAckRxTimeoutIndicationCallback)(void)
Definition: WiMOD_SAP_RadioLink.h:133
WiMOD_SAP_RadioLink.h
TWiMODLRResultCodes
TWiMODLRResultCodes
Result codes for the local serial communication itself.
Definition: WiMODLRHCI.h:149
TWiMODLR_RadioLink_Msg::RxTime
INT32 RxTime
Definition: WiMOD_SAP_RadioLink_IDs.h:184
TWiMODLR_RadioLink_CdataInd::TxEventCounter
UINT16 TxEventCounter
Definition: WiMOD_SAP_RadioLink_IDs.h:224
WiMOD_SAP_RadioLink::convert
virtual bool convert(TWiMODLR_HCIMessage &RxMsg, TWiMODLR_RadioLink_Msg *radioLinkMsg)
Convert a received low level HCI-Msg to a high-level RadioLink-Msg.
Definition: WiMOD_SAP_RadioLink.cpp:153
WiMOD_SAP_RadioLink::SendCData
virtual TWiMODLRResultCodes SendCData(const TWiMODLR_RadioLink_Msg *txMsg, UINT8 *statusRsp)
Tries to send transmit C-Data to peer module via RF link.
Definition: WiMOD_SAP_RadioLink.cpp:329
TWiMODLR_RadioLink_UdataInd
Structure containing information about a U-Data indication (TX only)
Definition: WiMOD_SAP_RadioLink_IDs.h:232
WiMOD_SAP_RadioLink::WiMOD_SAP_RadioLink
WiMOD_SAP_RadioLink(TWiMODLRHCI *hci, UINT8 *buffer, UINT16 bufferSize)
Constructor.
Definition: WiMOD_SAP_RadioLink.cpp:67
WiMOD_SAP_RadioLink::RegisterUDataRxClient
virtual void RegisterUDataRxClient(TRadioLinkUDataRxIndicationCallback cb)
Register a callback function for the RX U-Data Indication - optional -.
Definition: WiMOD_SAP_RadioLink.cpp:526
TWiMODLR_RadioLink_CdataInd
Structure containing information about a C-Data indication (TX only)
Definition: WiMOD_SAP_RadioLink_IDs.h:221
WiMOD_SAP_RadioLink
Implementation for the ServiceAccessPoint RadioLink (LR-Base firmware only)
Definition: WiMOD_SAP_RadioLink.h:151
TRadioLinkAckTxIndicationCallback
void(* TRadioLinkAckTxIndicationCallback)(TWiMODLR_HCIMessage &rxMsg)
Definition: WiMOD_SAP_RadioLink.h:136
RADIOLINK_SAP_ID
#define RADIOLINK_SAP_ID
Definition: WiMOD_SAP_RadioLink_IDs.h:60
TWiMODLR_RadioLink_Msg::OptionalInfoAvaiable
bool OptionalInfoAvaiable
Definition: WiMOD_SAP_RadioLink_IDs.h:180
TRadioLinkUDataTxIndicationCallback
void(* TRadioLinkUDataTxIndicationCallback)(TWiMODLR_HCIMessage &rxMsg)
Definition: WiMOD_SAP_RadioLink.h:118
WiMODLR_RESULT_PAYLOAD_LENGTH_ERROR
@ WiMODLR_RESULT_PAYLOAD_LENGTH_ERROR
Definition: WiMODLRHCI.h:152