Demo HCI Implementation for WiMOD-LR Devices  V1.3.1
ComSLIP.h
1 //------------------------------------------------------------------------------
2 //
3 // File: ComSlip.cpp
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 //------------------------------------------------------------------------------
15 
16 #ifndef COMSLIP_H
17 #define COMSLIP_H
18 
19 //------------------------------------------------------------------------------
20 //
21 // Include Files
22 //
23 //------------------------------------------------------------------------------
24 
25 #include "WMDefs.h"
26 
27 #include "Arduino.h"
28 
29 //------------------------------------------------------------------------------
30 //
31 // General Definitions
32 //
33 //------------------------------------------------------------------------------
34 
35 //------------------------------------------------------------------------------
36 //
37 // Class Declaration
38 //
39 //------------------------------------------------------------------------------
40 
45 {
46  public:
47  TComSlipClient() {}
48  virtual ~TComSlipClient() {}
49 
50 
51  // virtual receiver function - must be implemented by real client
52  virtual UINT8* ProcessRxMessage(UINT8* /* rxBuffer */, UINT16 /* rxLength */) { return 0;}
53 };
54 
58 class TComSlip
59 {
60  public:
61  TComSlip(Stream& s);
62 
63  void begin(/*int baudrate*/);
64  void end(void);
65 
66  void RegisterClient(TComSlipClient* client);
67 
68  bool SendMessage(UINT8* msg, UINT16 msgLength);
69 
70  bool SetRxBuffer(UINT8* rxBuffer, UINT16 rxbufferSize);
71 
72  void DecodeData(UINT8* rxData, UINT16 length);
73 
74  void SendWakeUpSequence(UINT8 nbr);
75 
76  private:
77 
78  void StoreRxByte(UINT8 rxByte);
79 
80  Stream& serial;
81 
82  // receiver/decoder state
83  int RxState;
84 
85  // rx buffer index
86  UINT16 RxIndex;
87 
88  // size of RxBuffer
89  UINT16 RxBufferSize;
90 
91  // pointer to RxBuffer
92  UINT8* RxBuffer;
93 
94  // client for received messages
95  TComSlipClient* RxClient;
96 
97 };
98 
99 #endif // COMSLIP_H
100 
101 //------------------------------------------------------------------------------
102 // end of file
103 //------------------------------------------------------------------------------
Class for handling SLIP encoding and decoding of HCI messages.
Definition: ComSLIP.h:58
Class definition for enabling OO inheritance.
Definition: ComSLIP.h:44