-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSerialManager.h
66 lines (59 loc) · 1.76 KB
/
SerialManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef SERIAL_MANAGER_H
#define SERIAL_MANAGER_H
#include <timeLib.h>
#define LIBCALL_DEEP_SLEEP_SCHEDULER
#include <DeepSleepScheduler.h> // https://github.com/PRosenb/DeepSleepScheduler
#include "WaterManager.h"
#define SERIAL_SLEEP_TIMEOUT_MS_DEFAULT 120000
#define UNDEFINED 255
class SerialManager: public Runnable {
public:
/**
@param bluetoothEnablePin the PIN where the bluetooth module can be enabled/disabled on or UNDEFINED if not used
*/
SerialManager(byte bluetoothEnablePin);
virtual ~SerialManager() {};
/**
set waterManager to forward commands to it from console
@param waterManager the waterManager, must be set, cannot be null
*/
void setWaterManager(WaterManager *waterManager);
/**
start serial communication.
*/
void startSerial();
/**
returns the amount of free ram in bytes.
*/
int freeRam();
/**
do not call from external, used internaly to interact with the serial interface.
*/
void run();
private:
WaterManager *waterManager;
const byte bluetoothEnablePin;
unsigned long serialLastActiveMillis = 0;
boolean aquiredWakeLock = false;
time_t startupTime;
void printTime(time_t time);
void handleSetDateTime();
/**
sets the alarm1 time.
*/
void handleSetAlarmTime();
#ifdef RTC_SUPPORTS_READ_ALARM
/**
@param alarmNumber identifier of the alarm to print, can be 1 or 2.
*/
void handleGetAlarmTime(byte alarmNumber);
#endif // RTC_SUPPORTS_READ_ALARM
void handleWrite();
void handleStatus();
void handleSerialInput();
// helper methods
void readSerial(char inData[], int inDataLength);
int serialReadInt(int length);
void printTwoDigits(unsigned int value);
};
#endif