GlobalCovfefe
GlobalCovfefe.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2018 Bengt Martensson.
3 
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or (at
7 your option) any later version.
8 
9 This program is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License along with
15 this program. If not, see http://www.gnu.org/licenses/.
16 */
17 
18 #pragma once
19 
20 #include <IrSender.h>
21 
28 public:
35  GlobalCovfefe(IrSender *irSender, int commandLed = invalidPin, int transmitLed = invalidPin);
36 
41  GlobalCovfefe(const GlobalCovfefe& orig);
42  virtual ~GlobalCovfefe();
43 
48  void readProcessCommand(Stream &stream) const;
49 
54  void getdevices(Stream &stream) const;
55 
60  void getversion(Stream &stream) const;
61 
67  void sendir(Stream &stream, char *buf) const;
68 
74  virtual void blink(unsigned int count = blinkCount, milliseconds_t delay = blinkDelay) const;
75 
79  static const char *version;
80 
84  static const uint16_t tcpPort = 4998U;
85 
89  static const char eolChar = '\r';
90 
91  static const int invalidPin = -1;
92 
96  static const size_t bufSize = 300U;
97 
98  static const unsigned int blinkCount = 3;
99 
100  static const milliseconds_t blinkDelay = 200;
101 
102 private:
103  IrSender *irSender;
104  int commandLed;
105  int transmitLed;
106 
107 protected:
114  virtual void processCommand(Stream &stream, char *buf) const;
115 
116  void initLed(int pin) const;
117  void turnOnLed(int pin) const;
118  void turnOffLed(int pin) const;
119 
125  void turnOnOffLed(int pin, milliseconds_t delay) const;
126 };
static const int invalidPin
Definition: GlobalCovfefe.h:91
void initLed(int pin) const
static const milliseconds_t blinkDelay
void getversion(Stream &stream) const
Implements the getversion command.
virtual ~GlobalCovfefe()
static const uint16_t tcpPort
The GlobalCache standard TCP command port.
Definition: GlobalCovfefe.h:84
void turnOnOffLed(int pin, milliseconds_t delay) const
Turns on the pin as the first argument, waits delay milli seconds, then turns off the pin...
void turnOnLed(int pin) const
static const size_t bufSize
Max length on input line.
Definition: GlobalCovfefe.h:96
This class emulates the IR sending of a GlobalCache device.
Definition: GlobalCovfefe.h:27
static const char eolChar
GlobalCache uses CR as line terminator.
Definition: GlobalCovfefe.h:89
GlobalCovfefe(IrSender *irSender, int commandLed=invalidPin, int transmitLed=invalidPin)
Main constructor.
void getdevices(Stream &stream) const
Implements the getdevices command.
virtual void processCommand(Stream &stream, char *buf) const
Processes one command from the supplied Stream argument.
void turnOffLed(int pin) const
virtual void blink(unsigned int count=blinkCount, milliseconds_t delay=blinkDelay) const
Implements the blink command (found in GC-100)
void sendir(Stream &stream, char *buf) const
Implements the sendir command.
static const char * version
Version of the present program.
Definition: GlobalCovfefe.h:79
void readProcessCommand(Stream &stream) const
Reads and processes one command from the supplied Stream argument.
static const unsigned int blinkCount
Definition: GlobalCovfefe.h:98