supla-device
Loading...
Searching...
No Matches
last_state_logger.h
1/*
2 Copyright (C) AC SOFTWARE SP. Z O.O.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 You should have received a copy of the GNU General Public License
13 along with this program; if not, write to the Free Software
14 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15*/
16
17#ifndef SRC_SUPLA_DEVICE_LAST_STATE_LOGGER_H_
18#define SRC_SUPLA_DEVICE_LAST_STATE_LOGGER_H_
19
20#define LAST_STATE_LOGGER_BUFFER_SIZE 500
21
22#include <stddef.h>
23
24namespace Supla {
25class Mutex;
26
27namespace Device {
28class LastStateLogger {
29 public:
30 LastStateLogger();
31 virtual ~LastStateLogger();
32 virtual void log(const char *, int uptimeSec);
33 virtual void clear();
34
35 // getLog locks the mutex on first call and releases it when all messages
36 // have been read, so make sure you call it in a loop until null is returned
37 virtual char *getLog();
38 virtual bool prepareLastStateLog();
39
40 protected:
41 char buffer[LAST_STATE_LOGGER_BUFFER_SIZE] = {};
42 size_t index = 0;
43 Supla::Mutex *mutex = nullptr;
44};
45}; // namespace Device
46}; // namespace Supla
47
48#endif // SRC_SUPLA_DEVICE_LAST_STATE_LOGGER_H_
Definition mutex.h:22