mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
implemented bare providerudp constructor and made h801 use it
This commit is contained in:
parent
37130f9c9b
commit
ad785b9eba
@ -9,7 +9,7 @@
|
|||||||
#include "LedDeviceUdpH801.h"
|
#include "LedDeviceUdpH801.h"
|
||||||
|
|
||||||
LedDeviceUdpH801::LedDeviceUdpH801(const Json::Value &deviceConfig)
|
LedDeviceUdpH801::LedDeviceUdpH801(const Json::Value &deviceConfig)
|
||||||
: ProviderUdp(deviceConfig)
|
: ProviderUdp()
|
||||||
{
|
{
|
||||||
setConfig(deviceConfig);
|
setConfig(deviceConfig);
|
||||||
}
|
}
|
||||||
@ -18,6 +18,7 @@ bool LedDeviceUdpH801::setConfig(const Json::Value &deviceConfig)
|
|||||||
{
|
{
|
||||||
/* The H801 port is fixed */
|
/* The H801 port is fixed */
|
||||||
ProviderUdp::setConfig(deviceConfig, 30977, "255.255.255.255");
|
ProviderUdp::setConfig(deviceConfig, 30977, "255.255.255.255");
|
||||||
|
|
||||||
/* 10ms seems to be a safe default for the wait time */
|
/* 10ms seems to be a safe default for the wait time */
|
||||||
_LatchTime_ns = deviceConfig.get("latchtime", 10000000).asInt();
|
_LatchTime_ns = deviceConfig.get("latchtime", 10000000).asInt();
|
||||||
|
|
||||||
@ -54,7 +55,7 @@ int LedDeviceUdpH801::write(const std::vector<ColorRgb> &ledValues)
|
|||||||
_message[_prefix_size + 1] = color.green;
|
_message[_prefix_size + 1] = color.green;
|
||||||
_message[_prefix_size + 2] = color.blue;
|
_message[_prefix_size + 2] = color.blue;
|
||||||
|
|
||||||
writeBytes(_message.size(), reinterpret_cast<const uint8_t*>(_message.data()));
|
return writeBytes(_message.size(), reinterpret_cast<const uint8_t*>(_message.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
int LedDeviceUdpH801::switchOff()
|
int LedDeviceUdpH801::switchOff()
|
||||||
|
@ -16,11 +16,16 @@
|
|||||||
#include "ProviderUdp.h"
|
#include "ProviderUdp.h"
|
||||||
|
|
||||||
ProviderUdp::ProviderUdp(const Json::Value &deviceConfig)
|
ProviderUdp::ProviderUdp(const Json::Value &deviceConfig)
|
||||||
|
: ProviderUdp()
|
||||||
|
{
|
||||||
|
setConfig(deviceConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProviderUdp::ProviderUdp()
|
||||||
: LedDevice()
|
: LedDevice()
|
||||||
, _LatchTime_ns(-1)
|
, _LatchTime_ns(-1)
|
||||||
, _port(0)
|
, _port(0)
|
||||||
{
|
{
|
||||||
setConfig(deviceConfig);
|
|
||||||
_udpSocket = new QUdpSocket();
|
_udpSocket = new QUdpSocket();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +54,7 @@ bool ProviderUdp::setConfig(const Json::Value &deviceConfig, int defaultPort, st
|
|||||||
Debug( _log, "Successfully parsed %s as a hostname.", deviceConfig["host"].asString().c_str());
|
Debug( _log, "Successfully parsed %s as a hostname.", deviceConfig["host"].asString().c_str());
|
||||||
_address = info.addresses().first();
|
_address = info.addresses().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
_port = deviceConfig.get("port", defaultPort).asUInt();
|
_port = deviceConfig.get("port", defaultPort).asUInt();
|
||||||
if ( _port<=0 || _port > 65535)
|
if ( _port<=0 || _port > 65535)
|
||||||
{
|
{
|
||||||
|
@ -19,6 +19,11 @@ public:
|
|||||||
///
|
///
|
||||||
ProviderUdp(const Json::Value &deviceConfig);
|
ProviderUdp(const Json::Value &deviceConfig);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Constructs specific LedDevice
|
||||||
|
///
|
||||||
|
ProviderUdp();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Destructor of the LedDevice; closes the output device if it is open
|
/// Destructor of the LedDevice; closes the output device if it is open
|
||||||
///
|
///
|
||||||
|
Loading…
x
Reference in New Issue
Block a user