General tidy up

This commit is contained in:
Murat
2020-08-08 00:21:19 +02:00
parent 13205a9d11
commit dd2d5e4b40
62 changed files with 117 additions and 296 deletions

View File

@@ -9,7 +9,7 @@ const quint16 MULTICAST_GROUPL_DEFAULT_PORT = 49692;
const int LEDS_DEFAULT_NUMBER = 24;
LedDeviceAtmoOrb::LedDeviceAtmoOrb(const QJsonObject &deviceConfig)
: LedDevice()
: LedDevice(deviceConfig)
, _udpSocket (nullptr)
, _multiCastGroupPort (MULTICAST_GROUPL_DEFAULT_PORT)
, _joinedMulticastgroup (false)
@@ -19,10 +19,6 @@ LedDeviceAtmoOrb::LedDeviceAtmoOrb(const QJsonObject &deviceConfig)
, _numLeds (LEDS_DEFAULT_NUMBER)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceAtmoOrb::construct(const QJsonObject &deviceConfig)
@@ -32,10 +28,7 @@ LedDevice* LedDeviceAtmoOrb::construct(const QJsonObject &deviceConfig)
LedDeviceAtmoOrb::~LedDeviceAtmoOrb()
{
if ( _udpSocket != nullptr )
{
delete _udpSocket;
}
delete _udpSocket;
}
bool LedDeviceAtmoOrb::init(const QJsonObject &deviceConfig)
@@ -241,6 +234,5 @@ void LedDeviceAtmoOrb::setColor(int orbId, const ColorRgb &color, int commandTyp
void LedDeviceAtmoOrb::sendCommand(const QByteArray &bytes)
{
QByteArray datagram = bytes;
_udpSocket->writeDatagram(datagram.data(), datagram.size(), _groupAddress, _multiCastGroupPort);
_udpSocket->writeDatagram(bytes.data(), bytes.size(), _groupAddress, _multiCastGroupPort);
}

View File

@@ -127,7 +127,6 @@ private:
QMap<int, int> lastColorRedMap;
QMap<int, int> lastColorGreenMap;
QMap<int, int> lastColorBlueMap;
};
#endif // LEDEVICEATMOORB_H

View File

@@ -20,23 +20,16 @@ const unsigned OPC_HEADER_SIZE = 4; // OPC header size
const quint16 STREAM_DEFAULT_PORT = 7890;
LedDeviceFadeCandy::LedDeviceFadeCandy(const QJsonObject &deviceConfig)
: LedDevice()
: LedDevice(deviceConfig)
, _client(nullptr)
,_host()
,_port(STREAM_DEFAULT_PORT)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDeviceFadeCandy::~LedDeviceFadeCandy()
{
if ( _client != nullptr )
{
delete _client;
}
delete _client;
}
LedDevice* LedDeviceFadeCandy::construct(const QJsonObject &deviceConfig)

View File

@@ -35,7 +35,7 @@ public:
/// "interpolation" : false,
/// "manualLed" : false,
/// "ledOn" : false
/// },
/// },
///@endcode
///
/// @param deviceConfig Device's configuration as JSON-Object
@@ -114,7 +114,7 @@ private:
/// @return amount of transferred bytes. -1 error while transferring, -2 error while connecting
///
int transferData();
///
/// @brief Send system exclusive commands
///

View File

@@ -90,7 +90,7 @@ enum EXTCONTROLVERSIONS {
};
LedDeviceNanoleaf::LedDeviceNanoleaf(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
,_restApi(nullptr)
,_apiPort(API_DEFAULT_PORT)
,_topDown(true)
@@ -100,10 +100,6 @@ LedDeviceNanoleaf::LedDeviceNanoleaf(const QJsonObject &deviceConfig)
,_extControlVersion (EXTCTRLVER_V2),
_panelLedCount(0)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceNanoleaf::construct(const QJsonObject &deviceConfig)
@@ -113,11 +109,8 @@ LedDevice* LedDeviceNanoleaf::construct(const QJsonObject &deviceConfig)
LedDeviceNanoleaf::~LedDeviceNanoleaf()
{
if ( _restApi != nullptr )
{
delete _restApi;
_restApi = nullptr;
}
delete _restApi;
_restApi = nullptr;
}
bool LedDeviceNanoleaf::init(const QJsonObject &deviceConfig)

View File

@@ -264,7 +264,7 @@ double CiColor::getDistanceBetweenTwoPoints(CiColor p1, XYColor p2)
}
LedDevicePhilipsHueBridge::LedDevicePhilipsHueBridge(const QJsonObject &deviceConfig)
: ProviderUdpSSL()
: ProviderUdpSSL(deviceConfig)
, _restApi(nullptr)
, _apiPort(API_DEFAULT_PORT)
, _useHueEntertainmentAPI(false)
@@ -273,17 +273,12 @@ LedDevicePhilipsHueBridge::LedDevicePhilipsHueBridge(const QJsonObject &deviceCo
, _api_patch(0)
, _isHueEntertainmentReady(false)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
}
LedDevicePhilipsHueBridge::~LedDevicePhilipsHueBridge()
{
if ( _restApi != nullptr )
{
delete _restApi;
_restApi = nullptr;
}
delete _restApi;
_restApi = nullptr;
}
bool LedDevicePhilipsHueBridge::init(const QJsonObject &deviceConfig)
@@ -828,10 +823,6 @@ LedDevicePhilipsHue::LedDevicePhilipsHue(const QJsonObject& deviceConfig)
, start_retry_left(3)
, stop_retry_left(3)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDevicePhilipsHue::construct(const QJsonObject &deviceConfig)

View File

@@ -3,12 +3,8 @@
const ushort TPM2_DEFAULT_PORT = 65506;
LedDeviceTpm2net::LedDeviceTpm2net(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceTpm2net::construct(const QJsonObject &deviceConfig)

View File

@@ -12,15 +12,10 @@
const ushort ARTNET_DEFAULT_PORT = 6454;
LedDeviceUdpArtNet::LedDeviceUdpArtNet(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceUdpArtNet::construct(const QJsonObject &deviceConfig)
{
return new LedDeviceUdpArtNet(deviceConfig);

View File

@@ -25,12 +25,8 @@ const uint32_t VECTOR_E131_DATA_PACKET = 0x00000002;
const int DMX_MAX = 512; // 512 usable slots
LedDeviceUdpE131::LedDeviceUdpE131(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceUdpE131::construct(const QJsonObject &deviceConfig)

View File

@@ -9,12 +9,8 @@ const char H801_DEFAULT_HOST[] = "255.255.255.255";
} //End of constants
LedDeviceUdpH801::LedDeviceUdpH801(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceUdpH801::construct(const QJsonObject &deviceConfig)

View File

@@ -3,12 +3,8 @@
const ushort RAW_DEFAULT_PORT=5568;
LedDeviceUdpRaw::LedDeviceUdpRaw(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDevice* LedDeviceUdpRaw::construct(const QJsonObject &deviceConfig)

View File

@@ -34,23 +34,16 @@ const char SSDP_FILTER_HEADER[] = "ST";
} //End of constants
LedDeviceWled::LedDeviceWled(const QJsonObject &deviceConfig)
: ProviderUdp()
: ProviderUdp(deviceConfig)
,_restApi(nullptr)
,_apiPort(API_DEFAULT_PORT)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDeviceWled::~LedDeviceWled()
{
if ( _restApi != nullptr )
{
delete _restApi;
_restApi = nullptr;
}
delete _restApi;
_restApi = nullptr;
}
LedDevice* LedDeviceWled::construct(const QJsonObject &deviceConfig)

View File

@@ -117,10 +117,7 @@ YeelightLight::YeelightLight( Logger *log, const QString &hostname, quint16 port
YeelightLight::~YeelightLight()
{
log (3,"~YeelightLight()","" );
if ( _tcpSocket != nullptr)
{
delete _tcpSocket;
}
delete _tcpSocket;
log (2,"~YeelightLight()","void" );
}
@@ -968,7 +965,7 @@ void YeelightLight::log(const int logLevel, const char* msg, const char* type, .
//---------------------------------------------------------------------------------
LedDeviceYeelight::LedDeviceYeelight(const QJsonObject &deviceConfig)
: LedDevice()
: LedDevice(deviceConfig)
,_lightsCount (0)
,_outputColorModel(0)
,_transitionEffect(YeelightLight::API_EFFECT_SMOOTH)
@@ -982,10 +979,6 @@ LedDeviceYeelight::LedDeviceYeelight(const QJsonObject &deviceConfig)
,_debuglevel(0)
,_musicModeServerPort(-1)
{
_devConfig = deviceConfig;
_isDeviceReady = false;
_activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower();
}
LedDeviceYeelight::~LedDeviceYeelight()

View File

@@ -16,10 +16,9 @@
class httpResponse
{
public:
httpResponse() = default;
explicit httpResponse() {}
bool error() { return _hasError;}
bool error() const { return _hasError;}
void setError(const bool hasError) { _hasError = hasError; }
QJsonDocument getBody() const { return _responseBody; }
@@ -70,7 +69,7 @@ public:
///
/// @brief Constructor of the REST-API wrapper
///
explicit ProviderRestApi();
ProviderRestApi();
///
/// @brief Constructor of the REST-API wrapper

View File

@@ -16,22 +16,18 @@
const ushort MAX_PORT = 65535;
ProviderUdp::ProviderUdp()
: LedDevice()
ProviderUdp::ProviderUdp(const QJsonObject &deviceConfig)
: LedDevice(deviceConfig)
, _udpSocket (nullptr)
, _port(1)
, _defaultHost("127.0.0.1")
{
_isDeviceReady = false;
_latchTime_ms = 1;
}
ProviderUdp::~ProviderUdp()
{
if ( _udpSocket != nullptr )
{
delete _udpSocket;
}
delete _udpSocket;
}
bool ProviderUdp::init(const QJsonObject &deviceConfig)

View File

@@ -21,7 +21,7 @@ public:
///
/// @brief Constructs an UDP LED-device
///
ProviderUdp();
ProviderUdp(const QJsonObject &deviceConfig);
///
/// @brief Destructor of the UDP LED-device

View File

@@ -15,8 +15,8 @@
const int MAX_RETRY = 5;
const ushort MAX_PORT_SSL = 65535;
ProviderUdpSSL::ProviderUdpSSL()
: LedDevice()
ProviderUdpSSL::ProviderUdpSSL(const QJsonObject &deviceConfig)
: LedDevice(deviceConfig)
, client_fd()
, entropy()
, ssl()
@@ -41,7 +41,6 @@ ProviderUdpSSL::ProviderUdpSSL()
, _debugStreamer(false)
, _debugLevel(0)
{
_isDeviceReady = false;
_latchTime_ms = 1;
}

View File

@@ -61,7 +61,7 @@ public:
///
/// @brief Constructs an UDP SSL LED-device
///
ProviderUdpSSL();
ProviderUdpSSL(const QJsonObject &deviceConfig);
///
/// @brief Destructor of the LED-device