Commander-API  V2.1.0
Simple Command Parser
Loading...
Searching...
No Matches
Commander-IO.hpp
Go to the documentation of this file.
1/*
2 * Created on June 18 2020
3 *
4 * Copyright (c) 2020 - Daniel Hajnal
5 * hajnal.daniel96@gmail.com
6 * This file is part of the Commander-API project.
7 * Modified 2022.02.06
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
35#ifndef COMMANDER_API_SRC_COMMANDER_IO_HPP_
36#define COMMANDER_API_SRC_COMMANDER_IO_HPP_
37
38#include <stdint.h>
39#include <stddef.h>
40
42
43#include "Stream.h"
44
45#ifdef ARDUINO
46#include "Arduino.h"
47#endif
48
49#ifdef COMMANDER_USE_WIFI_CLIENT_RESPONSE
50 #ifdef ESP8266
51 #include <ESP8266WiFi.h>
52 #endif
53
54 #ifdef ESP32
55 #include <WiFi.h>
56 #endif
57#endif
58
72class commandResponse : public Stream{
73
74public:
75
79 int available() { return 0; }
80
84 int read() { return -1; }
85
89 int peek() { return 0; }
90
92 void flush() { return; }
93
98 size_t write( uint8_t b ) { return 0; }
99
100};
101
102class commanderPipeChannel : public Stream{
103
104public:
105
109 int available() override;
110
114 int read() override;
115
119 int peek() override;
120
122 void flush() override;
123
128 size_t write( uint8_t b ) override;
129
130 size_t write( const uint8_t *buffer, size_t size ) override;
131
132private:
134 uint32_t readPointer = 0;
135 uint32_t writePointer = 0;
136
137};
138
139
140#endif /* COMMANDER_API_SRC_COMMANDER_IO_HPP_ */
#define COMMANDER_MAX_COMMAND_SIZE
Default response class.
size_t write(uint8_t b)
Write one byte to the channel.
void flush()
Flush the channel.
int peek()
Peek the firtst byte from the channel.
int available()
Available bytes in the channel.
int read()
Read one byte form the channel.
void flush() override
Flush the channel.
size_t write(uint8_t b) override
Write one byte to the channel.
uint8_t buffer[COMMANDER_MAX_COMMAND_SIZE]
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.