SerialTransport.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * SerialTransport.h
8  *
9  * @author 2021 Slavey Karadzhov <slav@attachix.com>
10  *
11  *
12  ****/
13 
14 #pragma once
15 
16 #include <HardwareSerial.h>
17 #include "BaseTransport.h"
18 
19 namespace Hosted
20 {
21 namespace Transport
22 {
24 {
25 public:
27  {
28  stream.onDataReceived(StreamDataReceivedDelegate(&SerialTransport::process, this));
29  }
30 
31 private:
32  void process(Stream& source, char arrivedChar, uint16_t availableCharsCount)
33  {
34  handler(source);
35  }
36 };
37 
38 } // namespace Transport
39 
40 } // namespace Hosted
Hardware serial class.
Definition: HardwareSerial.h:107
bool onDataReceived(StreamDataReceivedDelegate dataReceivedDelegate)
Set handler for received data.
Definition: HardwareSerial.h:350
Definition: BaseTransport.h:24
DataHandler handler
Definition: BaseTransport.h:38
Definition: SerialTransport.h:24
SerialTransport(HardwareSerial &stream)
Definition: SerialTransport.h:26
Base Stream class.
Definition: Wiring/Stream.h:33
Delegate< void(Stream &source, char arrivedChar, uint16_t availableCharsCount)> StreamDataReceivedDelegate
Delegate callback type for serial data reception.
Definition: HardwareSerial.h:46
Definition: Components/Hosted/include/Hosted/Client.h:32