2016-08-23 20:07:12 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// STL includes
|
|
|
|
#include <string>
|
|
|
|
|
2016-09-04 09:07:10 +02:00
|
|
|
// hyperion includes
|
|
|
|
#include "ProviderUdp.h"
|
|
|
|
|
|
|
|
#define TPM2_DEFAULT_PORT 65506
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Implementation of the LedDevice interface for sending led colors via udp/E1.31 packets
|
2016-08-23 20:07:12 +02:00
|
|
|
///
|
2016-09-04 09:07:10 +02:00
|
|
|
class LedDeviceTpm2net : public ProviderUdp
|
2016-08-23 20:07:12 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
///
|
|
|
|
/// Constructs specific LedDevice
|
|
|
|
///
|
|
|
|
/// @param deviceConfig json device config
|
|
|
|
///
|
|
|
|
LedDeviceTpm2net(const Json::Value &deviceConfig);
|
|
|
|
|
|
|
|
///
|
|
|
|
/// Sets configuration
|
|
|
|
///
|
|
|
|
/// @param deviceConfig the json device config
|
|
|
|
/// @return true if success
|
|
|
|
bool setConfig(const Json::Value &deviceConfig);
|
|
|
|
|
|
|
|
/// constructs leddevice
|
|
|
|
static LedDevice* construct(const Json::Value &deviceConfig);
|
|
|
|
|
2016-09-04 09:07:10 +02:00
|
|
|
|
2016-08-23 20:07:12 +02:00
|
|
|
///
|
2016-09-04 09:07:10 +02:00
|
|
|
/// Writes the led color values to the led-device
|
2016-08-23 20:07:12 +02:00
|
|
|
///
|
|
|
|
/// @param ledValues The color-value per led
|
2016-09-04 09:07:10 +02:00
|
|
|
/// @return Zero on succes else negative
|
2016-08-23 20:07:12 +02:00
|
|
|
///
|
2016-09-04 09:07:10 +02:00
|
|
|
virtual int write(const std::vector<ColorRgb> &ledValues);
|
2016-08-23 20:07:12 +02:00
|
|
|
|
|
|
|
/// Switch the leds off
|
|
|
|
virtual int switchOff();
|
|
|
|
|
|
|
|
private:
|
2016-09-04 09:07:10 +02:00
|
|
|
int _tpm2_max;
|
|
|
|
int _tpm2ByteCount;
|
|
|
|
int _tpm2TotalPackets;
|
|
|
|
int _tpm2ThisPacket;
|
2016-08-23 20:07:12 +02:00
|
|
|
};
|