2016-05-30 23:58:31 +02:00
|
|
|
#include "LedDeviceUdpRaw.h"
|
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
const ushort RAW_DEFAULT_PORT=5568;
|
|
|
|
|
2016-10-13 21:59:58 +02:00
|
|
|
LedDeviceUdpRaw::LedDeviceUdpRaw(const QJsonObject &deviceConfig)
|
2016-09-22 09:19:31 +02:00
|
|
|
: ProviderUdp()
|
2016-05-30 23:58:31 +02:00
|
|
|
{
|
2020-02-10 15:21:58 +01:00
|
|
|
_devConfig = deviceConfig;
|
2020-07-12 20:27:56 +02:00
|
|
|
_isDeviceReady = false;
|
|
|
|
|
|
|
|
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
|
2016-08-23 20:07:12 +02:00
|
|
|
}
|
|
|
|
|
2016-10-13 21:59:58 +02:00
|
|
|
LedDevice* LedDeviceUdpRaw::construct(const QJsonObject &deviceConfig)
|
2016-08-23 20:07:12 +02:00
|
|
|
{
|
|
|
|
return new LedDeviceUdpRaw(deviceConfig);
|
2016-05-30 23:58:31 +02:00
|
|
|
}
|
|
|
|
|
2020-02-10 15:21:58 +01:00
|
|
|
bool LedDeviceUdpRaw::init(const QJsonObject &deviceConfig)
|
|
|
|
{
|
|
|
|
_port = RAW_DEFAULT_PORT;
|
2020-07-12 20:27:56 +02:00
|
|
|
|
|
|
|
// Initialise sub-class
|
2020-02-10 15:21:58 +01:00
|
|
|
bool isInitOK = ProviderUdp::init(deviceConfig);
|
|
|
|
return isInitOK;
|
|
|
|
}
|
|
|
|
|
2016-05-30 23:58:31 +02:00
|
|
|
int LedDeviceUdpRaw::write(const std::vector<ColorRgb> &ledValues)
|
|
|
|
{
|
|
|
|
const uint8_t * dataPtr = reinterpret_cast<const uint8_t *>(ledValues.data());
|
|
|
|
|
2020-07-12 20:27:56 +02:00
|
|
|
return writeBytes(_ledRGBCount, dataPtr);
|
2016-05-30 23:58:31 +02:00
|
|
|
}
|