BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Public Member Functions | Static Public Member Functions | Protected Member Functions
BeeeOn::ZWaveSerialProber Class Reference

ZWaveSerialProber detects whether the device connected to a serial port is a Z-Wave controller. We try to obtain its version (and report it). If the version cannot be obtained an exception is thrown. More...

#include <ZWaveSerialProber.h>

Inheritance diagram for BeeeOn::ZWaveSerialProber:
BeeeOn::Loggable

Public Member Functions

 ZWaveSerialProber (SerialPort &port)
 
void probe (const Poco::Timespan &timeout)
 Probe the configured serial port and try to find a Z-Wave controller on the other side. We send NACK and then the version request. More...
 

Static Public Member Functions

static void setupPort (SerialPort &port)
 Configure the given serial port to settings typical for Z-Wave controllers.
 

Protected Member Functions

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 is computed and appended.
 
void checkTimeout (const Poco::Timespan &timeout) const
 Check whether the given timeout is positive. Otherwise, we treate it as expired. More...
 
void writeAll (const std::string &s, const Poco::Timespan &timeout)
 
std::string read (size_t max, const Poco::Timespan &timeout)
 
void writeAck (const Poco::Timespan &timeout)
 
void readAck (const Poco::Timespan &timeout)
 
size_t decodeHeader (const std::string &message) const
 
void writeRequest (const char id, const Poco::Timespan &timeout)
 
std::string readResponse (const Poco::Timespan &timeout)
 
void nack (const Poco::Timespan &timeout)
 
std::string version (const Poco::Timespan &timeout)
 

Detailed Description

ZWaveSerialProber detects whether the device connected to a serial port is a Z-Wave controller. We try to obtain its version (and report it). If the version cannot be obtained an exception is thrown.

Member Function Documentation

void ZWaveSerialProber::checkTimeout ( const Poco::Timespan &  timeout) const
protected

Check whether the given timeout is positive. Otherwise, we treate it as expired.

Exceptions
Poco::TimeoutException
void ZWaveSerialProber::probe ( const Poco::Timespan &  timeout)

Probe the configured serial port and try to find a Z-Wave controller on the other side. We send NACK and then the version request.

The whole probing process must fit into the given timeout. to prevent infinite waiting. The timeout must be a positive value.

Exceptions
Poco::InvalidArgumentException- when timeout is invalid
Poco::TimeoutException- when timeout exceeds while probing
Poco::ProtocolException- when the remote device gives unexpected results

The documentation for this class was generated from the following files: