supla-device
Loading...
Searching...
No Matches
debug_log_tcp_server.h
1// SPDX-FileCopyrightText: AC SOFTWARE SP. Z O.O.
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#ifndef SRC_SUPLA_DEBUG_DEBUG_LOG_TCP_SERVER_H_
5#define SRC_SUPLA_DEBUG_DEBUG_LOG_TCP_SERVER_H_
6
7#include <stdint.h>
8
9#include <supla/debug/debug_config.h>
10#include <supla/debug/debug_log.h>
11
12namespace Supla {
13namespace Debug {
14
15class DebugLogTcpServer : public LogSink {
16 public:
17 explicit DebugLogTcpServer(uint16_t port = 7778);
18 ~DebugLogTcpServer() override;
19
20 bool begin();
21 void end();
22 void iterate();
23 void writeLog(int priority, const char *message) override;
24
25 private:
26 void writeLine(int priority, const char *message);
27 bool writeBytes(const char *data, unsigned int size);
28
29 uint16_t port = 7778;
30
31#if SUPLA_INSECURE_DEBUG_INTERFACE && defined(SUPLA_LINUX)
32 int listenSocket = -1;
33 int clientSocket = -1;
34 bool openListenSocket();
35 void acceptClient();
36 void closeListenSocket();
37 void closeClient();
38#elif SUPLA_INSECURE_DEBUG_INTERFACE && defined(ESP_PLATFORM) && \
39 !defined(ARDUINO)
40 int listenSocket = -1;
41 int clientSocket = -1;
42 bool openListenSocket();
43 void acceptClient();
44 void closeListenSocket();
45 void closeClient();
46#elif SUPLA_INSECURE_DEBUG_INTERFACE && defined(ARDUINO) && \
47 (defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32))
48 class Impl;
49 Impl *impl = nullptr;
50#endif
51};
52
53} // namespace Debug
54} // namespace Supla
55
56#endif // SRC_SUPLA_DEBUG_DEBUG_LOG_TCP_SERVER_H_
Definition debug_log_tcp_server.h:15