Demo HCI Implementation for WiMOD-LR Devices  V2.0.3
ComSLIP.h
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //
3 // File: ComSlip.h
4 //
5 // Abstract: SLIP Wrapper Class Declaration
6 //
7 // Version: 0.1
8 //
9 // Date: 09.02.2015
10 //
11 // Disclaimer: This example code is provided by IMST GmbH on an "AS IS" basis
12 // without any warranties.
13 //
14 //------------------------------------------------------------------------------
21 
22 
23 
24 #ifndef COMSLIP_H
25 #define COMSLIP_H
26 
27 //------------------------------------------------------------------------------
28 //
29 // Include Files
30 //
31 //------------------------------------------------------------------------------
32 
33 #include "WMDefs.h"
34 
35 #include "Arduino.h"
36 
37 //------------------------------------------------------------------------------
38 //
39 // General Definitions
40 //
41 //------------------------------------------------------------------------------
42 
43 //------------------------------------------------------------------------------
44 //
45 // Class Declaration
46 //
47 //------------------------------------------------------------------------------
48 
53 {
54  public:
55  TComSlipClient() {}
56  virtual ~TComSlipClient() {}
57 
58 
60  // virtual receiver function - must be implemented by real client
61  virtual UINT8* ProcessRxMessage(UINT8* /* rxBuffer */, UINT16 /* rxLength */) { return 0;}
63 };
64 
68 class TComSlip
69 {
70  public:
71  /*explicit*/ TComSlip(Stream& s);
72 
73  void begin(/*int baudrate*/);
74  void end(void);
75 
76  void RegisterClient(TComSlipClient* client);
77 
78  bool SendMessage(UINT8* msg, UINT16 msgLength);
79 
80  bool SetRxBuffer(UINT8* rxBuffer, UINT16 rxbufferSize);
81 
82  void DecodeData(UINT8* rxData, UINT16 length);
83 
84  void SendWakeUpSequence(UINT8 nbr);
85 
86  private:
87 
88  void StoreRxByte(UINT8 rxByte);
89 
90  Stream& serial;
91 
92  // receiver/decoder state
93  int RxState;
94 
95  // rx buffer index
96  UINT16 RxIndex;
97 
98  // size of RxBuffer
99  UINT16 RxBufferSize;
100 
101  // pointer to RxBuffer
102  UINT8* RxBuffer;
103 
104  // client for received messages
105  TComSlipClient* RxClient;
106 
107 };
108 
109 #endif // COMSLIP_H
110 
111 //------------------------------------------------------------------------------
112 // end of file
113 //------------------------------------------------------------------------------
TComSlip::RegisterClient
void RegisterClient(TComSlipClient *client)
register a client for processing
Definition: ComSLIP.cpp:98
TComSlip::SendMessage
bool SendMessage(UINT8 *msg, UINT16 msgLength)
Generic function to transfer a message from the host to the module.
Definition: ComSLIP.cpp:124
TComSlip::end
void end(void)
De-Init function.
Definition: ComSLIP.cpp:88
TComSlip::TComSlip
TComSlip(Stream &s)
Constructor.
Definition: ComSLIP.cpp:59
ComSLIP.h
TComSlip::SendWakeUpSequence
void SendWakeUpSequence(UINT8 nbr)
: Send a sequence of dummy chars to give the WiMOD some time to wake up
Definition: ComSLIP.cpp:308
TComSlip::DecodeData
void DecodeData(UINT8 *rxData, UINT16 length)
process received byte stream
Definition: ComSLIP.cpp:193
TComSlip::begin
void begin()
Init function that must be called once prior to any other function of this object.
Definition: ComSLIP.cpp:77
TComSlip
Class for handling SLIP encoding and decoding of HCI messages.
Definition: ComSLIP.h:68
TComSlipClient
Class definition for enabling OO inheritance.
Definition: ComSLIP.h:52
TComSlip::SetRxBuffer
bool SetRxBuffer(UINT8 *rxBuffer, UINT16 rxbufferSize)
configure a rx-buffer and enable receiver/decoder
Definition: ComSLIP.cpp:168