Shellminator  V1.1.1
Simple Terminal
Loading...
Searching...
No Matches
Shellminator-IO.hpp
Go to the documentation of this file.
1/*
2 * Created on Aug 10 2020
3 *
4 * Copyright (c) 2020 - Daniel Hajnal
5 * hajnal.daniel96@gmail.com
6 * This file is part of the Shellminator project.
7 * Modified 2022.05.08
8*/
9
10/*
11MIT License
12
13Copyright (c) 2020 Daniel Hajnal
14
15Permission is hereby granted, free of charge, to any person obtaining a copy
16of this software and associated documentation files (the "Software"), to deal
17in the Software without restriction, including without limitation the rights
18to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
19copies of the Software, and to permit persons to whom the Software is
20furnished to do so, subject to the following conditions:
21
22The above copyright notice and this permission notice shall be included in all
23copies or substantial portions of the Software.
24
25THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31SOFTWARE.
32*/
33
34#ifndef SHELLMINATOR_IO_HPP_
35#define SHELLMINATOR_IO_HPP_
36
38
39#ifdef ARDUINO
40#include "Arduino.h"
41#endif
42
43#ifdef SHELLMINATOR_USE_WIFI_CLIENT
44 #ifdef ESP8266
45 #include <ESP8266WiFi.h>
46 #endif
47
48 #ifdef ESP32
49 #include <WiFi.h>
50 #endif
51#endif
52
64
65public:
66
70 virtual int available() { return 0; }
71
75 virtual int read() { return -1; }
76
80 virtual int peek() { return 0; }
81
83 virtual void flush() { return; }
84
89 virtual size_t write( uint8_t b ) { return 0; }
90
95 virtual size_t print( char c ) { return 0; }
96
101 virtual size_t print( uint8_t b ) { return 0; }
102
107 virtual size_t print( char *str ) { return 0; }
108
113 virtual size_t print( const char *str ) { return 0; }
114
115};
116
117#ifdef SHELLMINATOR_USE_ARDUINO_SERIAL
118
121
122public:
123
128 void select( HardwareSerial *serialPort_p );
129
133 int available() override;
134
138 int read() override;
139
143 int peek() override;
144
146 void flush() override;
147
152 size_t write( uint8_t b ) override;
153
158 size_t print( char c ) override;
159
164 size_t print( uint8_t b );
165
170 size_t print( char *str ) override;
171
176 size_t print( const char *str ) override;
177
181 HardwareSerial* getSerialObject();
182
183private:
184 HardwareSerial *serialPort = NULL;
185
186};
187
188#endif
189
190#ifdef SHELLMINATOR_USE_ARDUINO_32U4_SERIAL
191
194
195public:
196
201 void select( Serial_ *serialPort_p );
202
206 int available() override;
207
211 int read() override;
212
216 int peek() override;
217
219 void flush() override;
220
225 size_t write( uint8_t b ) override;
226
231 size_t print( char c ) override;
232
237 size_t print( uint8_t b );
238
243 size_t print( char *str ) override;
244
249 size_t print( const char *str ) override;
250
254 Serial_* getSerialObject();
255
256private:
257 Serial_ *serialPort = NULL;
258
259};
260
261#endif
262
263#ifdef SHELLMINATOR_USE_WIFI_CLIENT
264
266
267public:
268
273 void select( WiFiClient *client_p );
274
278 int available() override;
279
283 int read() override;
284
288 int peek() override;
289
291 void flush() override;
292
297 size_t write( uint8_t b ) override;
298
303 size_t print( char c ) override;
304
309 size_t print( uint8_t b );
310
315 size_t print( char *str ) override;
316
321 size_t print( const char *str ) override;
322
326 WiFiClient* getClientObject();
327
328private:
329 WiFiClient *client = NULL;
330
331};
332
333#endif
334
335#endif
Shellminator channel class for Arduino Serial objects.
size_t print(char c) override
Print one character to the channel.
void select(Serial_ *serialPort_p)
Select Serial Port.
Serial_ * getSerialObject()
Get the address of the chosen Serial Port.
int read() override
Read one byte form the channel.
int peek() override
Peek the firtst byte from the channel.
void flush() override
Flush the channel.
int available() override
Available bytes in the channel.
size_t write(uint8_t b) override
Write one byte to the channel.
Shellminator channel class for Arduino Serial objects.
size_t write(uint8_t b) override
Write one byte to the channel.
int peek() override
Peek the firtst byte from the channel.
int read() override
Read one byte form the channel.
int available() override
Available bytes in the channel.
void select(HardwareSerial *serialPort_p)
Select Serial Port.
HardwareSerial * getSerialObject()
Get the address of the chosen Serial Port.
size_t print(char c) override
Print one character to the channel.
void flush() override
Flush the channel.
Shellminator channel class.
virtual size_t print(uint8_t b)
Print one byte to the channel.
virtual size_t print(char *str)
Print c-string to the channel.
virtual int available()
Available bytes in the channel.
virtual size_t print(const char *str)
Print c-string to the channel.
virtual int read()
Read one byte form the channel.
virtual int peek()
Peek the firtst byte from the channel.
virtual size_t write(uint8_t b)
Write one byte to the channel.
virtual size_t print(char c)
Print one character to the channel.
virtual void flush()
Flush the channel.
size_t print(char c) override
Print one character to the channel.
int available() override
Available bytes in the channel.
void flush() override
Flush the channel.
void select(WiFiClient *client_p)
Select WiFi Client.
size_t write(uint8_t b) override
Write one byte to the channel.
int peek() override
Peek the firtst byte from the channel.
int read() override
Read one byte form the channel.
WiFiClient * getClientObject()
Get the address of the chosen WiFi Client.