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::Transport
20 {
22 {
23 public:
25  {
26  stream.onDataReceived(StreamDataReceivedDelegate(&SerialTransport::process, this));
27  }
28 
29 private:
30  void process(Stream& source, char arrivedChar, uint16_t availableCharsCount)
31  {
32  handler(source);
33  }
34 };
35 
36 } // namespace Hosted::Transport
Hardware serial class.
Definition: HardwareSerial.h:107
bool onDataReceived(StreamDataReceivedDelegate dataReceivedDelegate)
Set handler for received data.
Definition: HardwareSerial.h:350
Definition: BaseTransport.h:22
DataHandler handler
Definition: BaseTransport.h:36
Definition: SerialTransport.h:22
SerialTransport(HardwareSerial &stream)
Definition: SerialTransport.h:24
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: BaseTransport.h:20