BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
ZWaveSerialProber.h
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include <Poco/Timespan.h>
7 
8 #include "io/SerialPort.h"
9 #include "util/Loggable.h"
10 
11 namespace BeeeOn {
12 
20 public:
22 
36  void probe(const Poco::Timespan &timeout);
37 
42  static void setupPort(SerialPort &port);
43 
44 protected:
49  std::string buildMessage(const std::vector<uint8_t> payload) const;
50 
57  void checkTimeout(const Poco::Timespan &timeout) const;
58 
59  void writeAll(const std::string &s, const Poco::Timespan &timeout);
60  std::string read(size_t max, const Poco::Timespan &timeout);
61 
62  void writeAck(const Poco::Timespan &timeout);
63  void readAck(const Poco::Timespan &timeout);
64  size_t decodeHeader(const std::string &message) const;
65  void writeRequest(const char id, const Poco::Timespan &timeout);
66  std::string readResponse(const Poco::Timespan &timeout);
67 
68  void nack(const Poco::Timespan &timeout);
69  std::string version(const Poco::Timespan &timeout);
70 
71 private:
72  SerialPort &m_port;
73  std::string m_buffer;
74 };
75 
76 }
static void setupPort(SerialPort &port)
Configure the given serial port to settings typical for Z-Wave controllers.
Definition: ZWaveSerialProber.cpp:249
Definition: Loggable.h:19
Definition: SerialPort.h:9
void probe(const Poco::Timespan &timeout)
Probe the configured serial port and try to find a Z-Wave controller on the other side...
Definition: ZWaveSerialProber.cpp:27
void checkTimeout(const Poco::Timespan &timeout) const
Check whether the given timeout is positive. Otherwise, we treate it as expired.
Definition: ZWaveSerialProber.cpp:96
std::string buildMessage(const std::vector< uint8_t > payload) const
Build a message from the given payload. The header with SOF and size are prepended and the checksum i...
Definition: ZWaveSerialProber.cpp:45
ZWaveSerialProber detects whether the device connected to a serial port is a Z-Wave controller...
Definition: ZWaveSerialProber.h:19