2016-05-30 23:58:31 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// Hyperion includes
|
|
|
|
#include <leddevice/LedDevice.h>
|
2016-06-24 17:46:23 +02:00
|
|
|
#include <utils/Logger.h>
|
2016-05-30 23:58:31 +02:00
|
|
|
|
2018-12-27 23:11:32 +01:00
|
|
|
// qt
|
|
|
|
#include <QHostAddress>
|
|
|
|
|
|
|
|
class QUdpSocket;
|
|
|
|
|
2019-07-12 16:54:26 +02:00
|
|
|
#define MAX_PORT 65535
|
|
|
|
|
2016-05-30 23:58:31 +02:00
|
|
|
///
|
2016-10-08 13:52:22 +02:00
|
|
|
/// The ProviderUdp implements an abstract base-class for LedDevices using UDP packets.
|
2016-05-30 23:58:31 +02:00
|
|
|
///
|
2016-08-28 07:12:48 +02:00
|
|
|
class ProviderUdp : public LedDevice
|
2016-05-30 23:58:31 +02:00
|
|
|
{
|
|
|
|
public:
|
2016-09-22 00:18:46 +02:00
|
|
|
///
|
|
|
|
/// Constructs specific LedDevice
|
|
|
|
///
|
|
|
|
ProviderUdp();
|
2016-05-30 23:58:31 +02:00
|
|
|
|
|
|
|
///
|
|
|
|
/// Destructor of the LedDevice; closes the output device if it is open
|
|
|
|
///
|
2016-08-28 07:12:48 +02:00
|
|
|
virtual ~ProviderUdp();
|
2016-05-30 23:58:31 +02:00
|
|
|
|
2016-08-23 20:07:12 +02:00
|
|
|
///
|
|
|
|
/// Sets configuration
|
|
|
|
///
|
|
|
|
/// @param deviceConfig the json device config
|
|
|
|
/// @return true if success
|
2017-02-11 22:52:47 +01:00
|
|
|
virtual bool init(const QJsonObject &deviceConfig);
|
2016-08-23 20:07:12 +02:00
|
|
|
|
2016-05-30 23:58:31 +02:00
|
|
|
///
|
|
|
|
/// Opens and configures the output device
|
|
|
|
///
|
|
|
|
/// @return Zero on succes else negative
|
|
|
|
///
|
|
|
|
int open();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
///
|
2019-07-02 19:06:36 +02:00
|
|
|
/// Writes the given bytes/bits to the UDP-device and sleeps the latch time to ensure that the
|
2016-05-30 23:58:31 +02:00
|
|
|
/// values are latched.
|
|
|
|
///
|
2016-08-14 10:46:44 +02:00
|
|
|
/// @param[in] size The length of the data
|
2016-05-30 23:58:31 +02:00
|
|
|
/// @param[in] data The data
|
|
|
|
///
|
|
|
|
/// @return Zero on succes else negative
|
|
|
|
///
|
|
|
|
int writeBytes(const unsigned size, const uint8_t *data);
|
|
|
|
|
|
|
|
///
|
2016-08-14 10:46:44 +02:00
|
|
|
QUdpSocket * _udpSocket;
|
2016-05-30 23:58:31 +02:00
|
|
|
QHostAddress _address;
|
2019-07-12 16:54:26 +02:00
|
|
|
ushort _port;
|
2017-02-11 22:52:47 +01:00
|
|
|
QString _defaultHost;
|
2016-05-30 23:58:31 +02:00
|
|
|
};
|