Merge branch 'master' into refactor/led_device

This commit is contained in:
Murat Seker
2020-08-23 21:02:25 +02:00
committed by GitHub
272 changed files with 1711 additions and 1738 deletions

View File

@@ -33,7 +33,7 @@ public:
///
/// @brief Destructor of the LedDevice
///
virtual ~LedDeviceAtmoOrb() override;
~LedDeviceAtmoOrb() override;
///
/// @brief Constructs the LED-device
@@ -51,21 +51,21 @@ protected:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Opens the output device.
///
/// @return Zero on success (i.e. device is ready), else negative
///
virtual int open() override;
int open() override;
///
/// @brief Closes the output device.
///
/// @return Zero on success (i.e. device is closed), else negative
///
virtual int close() override;
int close() override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -73,7 +73,7 @@ protected:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb> & ledValues) override;
int write(const std::vector<ColorRgb> & ledValues) override;
private:

View File

@@ -144,7 +144,7 @@ int LedDeviceFadeCandy::close()
return retval;
}
bool LedDeviceFadeCandy::isConnected()
bool LedDeviceFadeCandy::isConnected() const
{
bool connected = false;
if ( _client != nullptr )
@@ -197,7 +197,7 @@ int LedDeviceFadeCandy::transferData()
return -2;
}
int LedDeviceFadeCandy::sendSysEx(uint8_t systemId, uint8_t commandId, QByteArray msg)
int LedDeviceFadeCandy::sendSysEx(uint8_t systemId, uint8_t commandId, const QByteArray& msg)
{
if ( isConnected() )
{

View File

@@ -62,21 +62,21 @@ protected:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Opens the output device.
///
/// @return Zero on success (i.e. device is ready), else negative
///
virtual int open() override;
int open() override;
///
/// @brief Closes the output device.
///
/// @return Zero on success (i.e. device is closed), else negative
///
virtual int close() override;
int close() override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -84,7 +84,7 @@ protected:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb> & ledValues) override;
int write(const std::vector<ColorRgb> & ledValues) override;
private:
@@ -106,7 +106,7 @@ private:
///
/// @return True, if connection established
///
bool isConnected();
bool isConnected() const;
///
/// @brief Transfer current opc_data buffer to opc server
@@ -122,7 +122,7 @@ private:
/// @param[in] commandId id of command
/// @param[in] msg the sysEx message
/// @return amount bytes written, -1 if failed
int sendSysEx(uint8_t systemId, uint8_t commandId, QByteArray msg);
int sendSysEx(uint8_t systemId, uint8_t commandId, const QByteArray& msg);
///
/// @brief Sends the configuration to fadecandy cserver

View File

@@ -335,7 +335,7 @@ bool LedDeviceNanoleaf::initLedsConfiguration()
return isInitOK;
}
bool LedDeviceNanoleaf::initRestAPI(const QString &hostname, const int port, const QString &token )
bool LedDeviceNanoleaf::initRestAPI(const QString &hostname, int port, const QString &token )
{
bool isInitOK = false;
@@ -506,7 +506,7 @@ bool LedDeviceNanoleaf::powerOff()
return true;
}
QString LedDeviceNanoleaf::getOnOffRequest (bool isOn ) const
QString LedDeviceNanoleaf::getOnOffRequest(bool isOn) const
{
QString state = isOn ? STATE_VALUE_TRUE : STATE_VALUE_FALSE;
return QString( "{\"%1\":{\"%2\":%3}}" ).arg(STATE_ON, STATE_ONOFF_VALUE, state);
@@ -607,7 +607,7 @@ int LedDeviceNanoleaf::write(const std::vector<ColorRgb> & ledValues)
return retVal;
}
std::string LedDeviceNanoleaf:: uint8_vector_to_hex_string( const std::vector<uint8_t>& buffer ) const
std::string LedDeviceNanoleaf::uint8_vector_to_hex_string(const std::vector<uint8_t>& buffer) const
{
std::stringstream ss;
ss << std::hex << std::setfill('0');

View File

@@ -37,7 +37,7 @@ public:
///
/// @brief Destructor of the LED-device
///
virtual ~LedDeviceNanoleaf() override;
~LedDeviceNanoleaf() override;
///
/// @brief Constructs the LED-device
@@ -51,7 +51,7 @@ public:
///
/// @return A JSON structure holding a list of devices found
///
virtual QJsonObject discover() override;
QJsonObject discover() override;
///
/// @brief Get the Nanoleaf device's resource properties
@@ -68,7 +68,7 @@ public:
/// @param[in] params Parameters to query device
/// @return A JSON structure holding the device's properties
///
virtual QJsonObject getProperties(const QJsonObject& params) override;
QJsonObject getProperties(const QJsonObject& params) override;
///
/// @brief Send an update to the Nanoleaf device to identify it.
@@ -83,7 +83,7 @@ public:
///
/// @param[in] params Parameters to address device
///
virtual void identify(const QJsonObject& params) override;
void identify(const QJsonObject& params) override;
protected:
@@ -100,7 +100,7 @@ protected:
///
/// @return Zero on success (i.e. device is ready), else negative
///
virtual int open() override;
int open() override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -108,21 +108,21 @@ protected:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
//////
virtual int write(const std::vector<ColorRgb> & ledValues) override;
int write(const std::vector<ColorRgb> & ledValues) override;
///
/// @brief Power-/turn on the Nanoleaf device.
///
/// @brief Store the device's original state.
///
virtual bool powerOn() override;
bool powerOn() override;
///
/// @brief Power-/turn off the Nanoleaf device.
///
/// @return True if success
///
virtual bool powerOff() override;
bool powerOff() override;
private:
@@ -135,7 +135,7 @@ private:
///
/// @return True, if success
///
bool initRestAPI(const QString &hostname, const int port, const QString &token );
bool initRestAPI(const QString &hostname, int port, const QString &token );
///
/// @brief Get Nanoleaf device details and configuration

View File

@@ -342,7 +342,7 @@ bool LedDevicePhilipsHueBridge::init(const QJsonObject &deviceConfig)
return isInitOK;
}
bool LedDevicePhilipsHueBridge::initRestAPI(const QString &hostname, const int port, const QString &token )
bool LedDevicePhilipsHueBridge::initRestAPI(const QString &hostname, int port, const QString &token)
{
bool isInitOK = false;
@@ -398,12 +398,12 @@ int LedDevicePhilipsHueBridge::close()
return retval;
}
const int *LedDevicePhilipsHueBridge::getCiphersuites()
const int *LedDevicePhilipsHueBridge::getCiphersuites() const
{
return SSL_CIPHERSUITES;
}
void LedDevicePhilipsHueBridge::log(const char* msg, const char* type, ...)
void LedDevicePhilipsHueBridge::log(const char* msg, const char* type, ...) const
{
const size_t max_val_length = 1024;
char val[max_val_length];
@@ -539,17 +539,17 @@ void LedDevicePhilipsHueBridge::setGroupMap(const QJsonDocument &doc)
}
}
const QMap<quint16,QJsonObject>& LedDevicePhilipsHueBridge::getLightMap(void)
QMap<quint16,QJsonObject> LedDevicePhilipsHueBridge::getLightMap() const
{
return _lightsMap;
}
const QMap<quint16,QJsonObject>& LedDevicePhilipsHueBridge::getGroupMap(void)
QMap<quint16,QJsonObject> LedDevicePhilipsHueBridge::getGroupMap() const
{
return _groupsMap;
}
QString LedDevicePhilipsHueBridge::getGroupName(quint16 groupId)
QString LedDevicePhilipsHueBridge::getGroupName(quint16 groupId) const
{
QString groupName;
if( _groupsMap.contains( groupId ) )
@@ -564,7 +564,7 @@ QString LedDevicePhilipsHueBridge::getGroupName(quint16 groupId)
return groupName;
}
QJsonArray LedDevicePhilipsHueBridge::getGroupLights(quint16 groupId)
QJsonArray LedDevicePhilipsHueBridge::getGroupLights(quint16 groupId) const
{
QJsonArray groupLights;
// search user groupid inside _groupsMap and create light if found
@@ -594,13 +594,13 @@ QJsonArray LedDevicePhilipsHueBridge::getGroupLights(quint16 groupId)
return groupLights;
}
bool LedDevicePhilipsHueBridge::checkApiError(const QJsonDocument &response )
bool LedDevicePhilipsHueBridge::checkApiError(const QJsonDocument &response)
{
bool apiError = false;
QString errorReason;
QString strJson(response.toJson(QJsonDocument::Compact));
DebugIf(verbose, _log, "Reply: [%s]", strJson.toUtf8().constData() );
DebugIf(verbose, _log, "Reply: [%s]", strJson.toUtf8().constData());
QVariantList rspList = response.toVariant().toList();
if ( !rspList.isEmpty() )
@@ -637,13 +637,13 @@ QJsonDocument LedDevicePhilipsHueBridge::post(const QString& route, const QStrin
return response.getBody();
}
void LedDevicePhilipsHueBridge::setLightState(const unsigned int lightId, const QString &state)
void LedDevicePhilipsHueBridge::setLightState(unsigned int lightId, const QString &state)
{
DebugIf( verbose, _log, "SetLightState [%u]: %s", lightId, QSTRING_CSTR(state) );
post( QString("%1/%2/%3").arg( API_LIGHTS ).arg( lightId ).arg( API_STATE ), state );
}
QJsonDocument LedDevicePhilipsHueBridge::getGroupState(const unsigned int groupId)
QJsonDocument LedDevicePhilipsHueBridge::getGroupState(unsigned int groupId)
{
_restApi->setPath( QString("%1/%2").arg( API_GROUPS ).arg( groupId ) );
httpResponse response = _restApi->get();
@@ -651,13 +651,13 @@ QJsonDocument LedDevicePhilipsHueBridge::getGroupState(const unsigned int groupI
return response.getBody();
}
QJsonDocument LedDevicePhilipsHueBridge::setGroupState(const unsigned int groupId, bool state)
QJsonDocument LedDevicePhilipsHueBridge::setGroupState(unsigned int groupId, bool state)
{
QString active = state ? API_STREAM_ACTIVE_VALUE_TRUE : API_STREAM_ACTIVE_VALUE_FALSE;
return post( QString("%1/%2").arg( API_GROUPS ).arg( groupId ), QString("{\"%1\":{\"%2\":%3}}").arg( API_STREAM, API_STREAM_ACTIVE, active ) );
}
bool LedDevicePhilipsHueBridge::isStreamOwner(const QString &streamOwner)
bool LedDevicePhilipsHueBridge::isStreamOwner(const QString &streamOwner) const
{
return ( streamOwner != "" && streamOwner == _username );
}
@@ -1245,13 +1245,13 @@ bool LedDevicePhilipsHue::setStreamGroupState(bool state)
return false;
}
QByteArray LedDevicePhilipsHue::prepareStreamData()
QByteArray LedDevicePhilipsHue::prepareStreamData() const
{
QByteArray msg;
msg.reserve(static_cast<int>(sizeof(HEADER) + sizeof(PAYLOAD_PER_LIGHT) * _lights.size()));
msg.append((const char*)HEADER, sizeof(HEADER));
for (PhilipsHueLight& light : _lights)
for (const PhilipsHueLight& light : _lights)
{
CiColor lightC = light.getColor();
quint64 R = lightC.x * 0xffff;

View File

@@ -197,7 +197,7 @@ public:
///
/// @return True, if success
///
bool initRestAPI(const QString &hostname, const int port, const QString &token );
bool initRestAPI(const QString &hostname, int port, const QString &token );
///
/// @param route the route of the POST request.
@@ -208,13 +208,13 @@ public:
void setLightState(unsigned int lightId = 0, const QString &state = "");
const QMap<quint16,QJsonObject>& getLightMap();
QMap<quint16,QJsonObject> getLightMap() const;
const QMap<quint16,QJsonObject>& getGroupMap();
QMap<quint16,QJsonObject> getGroupMap() const;
QString getGroupName(quint16 groupId = 0);
QString getGroupName(quint16 groupId = 0) const;
QJsonArray getGroupLights(quint16 groupId = 0);
QJsonArray getGroupLights(quint16 groupId = 0) const;
@@ -226,21 +226,21 @@ protected:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Opens the Hue-Bridge device and its SSL-connection
///
/// @return Zero on success (i.e. device is ready), else negative
///
virtual int open(void) override;
int open() override;
///
/// @brief Closes the Hue-Bridge device and its SSL-connection
///
/// @return Zero on success (i.e. device is closed), else negative
///
virtual int close() override;
int close() override;
///
/// @brief Check, if Hue API response indicate error
@@ -264,12 +264,12 @@ protected:
QJsonDocument getGroupState( unsigned int groupId );
QJsonDocument setGroupState( unsigned int groupId, bool state);
bool isStreamOwner(const QString &streamOwner);
bool isStreamOwner(const QString &streamOwner) const;
bool initMaps();
void log(const char* msg, const char* type, ...);
void log(const char* msg, const char* type, ...) const;
const int * getCiphersuites() override;
const int * getCiphersuites() const override;
private:
@@ -316,7 +316,7 @@ public:
///
/// @brief Destructor of the LED-device
///
virtual ~LedDevicePhilipsHue();
~LedDevicePhilipsHue();
///
/// @brief Constructs the LED-device
@@ -331,7 +331,7 @@ public:
///
/// @return A JSON structure holding a list of devices found
///
virtual QJsonObject discover() override;
QJsonObject discover() override;
///
/// @brief Get the Hue Bridge device's resource properties
@@ -348,7 +348,7 @@ public:
/// @param[in] params Parameters to query device
/// @return A JSON structure holding the device's properties
///
virtual QJsonObject getProperties(const QJsonObject& params) override;
QJsonObject getProperties(const QJsonObject& params) override;
///
/// @brief Send an update to the device to identify it.
@@ -357,7 +357,7 @@ public:
///
/// @param[in] params Parameters to address device
///
virtual void identify(const QJsonObject& params) override;
void identify(const QJsonObject& params) override;
///
/// @brief Get the number of LEDs supported by the device.
@@ -378,7 +378,7 @@ public slots:
///
/// Includes switching-off the device and stopping refreshes.
///
virtual void stop() override;
void stop() override;
protected:
@@ -388,21 +388,21 @@ protected:
/// @param deviceConfig Device's configuration in JSON
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Opens the output device
///
/// @return Zero on success (i.e. device is ready), else negative
///
virtual int open() override;
int open() override;
///
/// @brief Closes the output device.
///
/// @return Zero on success (i.e. device is closed), else negative
///
virtual int close() override;
int close() override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -410,7 +410,7 @@ protected:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb>& ledValues) override;
int write(const std::vector<ColorRgb>& ledValues) override;
///
/// @brief Switch the LEDs on.
@@ -421,7 +421,7 @@ protected:
///
/// @return True if success
///
//virtual bool switchOn() override;
//bool switchOn() override;
///
/// @brief Switch the LEDs off.
@@ -432,7 +432,7 @@ protected:
///
/// @return True, if success
///
virtual bool switchOff() override;
bool switchOff() override;
///
/// @brief Power-/turn on the LED-device.
@@ -441,7 +441,7 @@ protected:
///
/// @return True, if success
///
virtual bool powerOn() override;
bool powerOn() override;
///
/// @brief Power-/turn off the LED-device.
@@ -451,7 +451,7 @@ protected:
///
/// @return True, if success
///
virtual bool powerOff() override;
bool powerOff() override;
///
/// @brief Store the device's original state.
@@ -460,7 +460,7 @@ protected:
///
/// @return True if success
///
virtual bool storeState() override;
bool storeState() override;
///
/// @brief Restore the device's original state.
@@ -470,7 +470,7 @@ protected:
///
/// @return True, if success
///
virtual bool restoreState() override;
bool restoreState() override;
private slots:
@@ -515,7 +515,7 @@ private:
void stopBlackTimeoutTimer();
QByteArray prepareStreamData();
QByteArray prepareStreamData() const;
///
bool _switchOffOnBlack;

View File

@@ -34,7 +34,7 @@ private:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -42,7 +42,7 @@ private:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb> & ledValues) override;
int write(const std::vector<ColorRgb> & ledValues) override;
int _tpm2_max;
int _tpm2ByteCount;

View File

@@ -39,7 +39,7 @@ bool LedDeviceUdpArtNet::init(const QJsonObject &deviceConfig)
}
// populates the headers
void LedDeviceUdpArtNet::prepare(const unsigned this_universe, const unsigned this_sequence, unsigned this_dmxChannelCount)
void LedDeviceUdpArtNet::prepare(unsigned this_universe, unsigned this_sequence, unsigned this_dmxChannelCount)
{
// WTF? why do the specs say:
// "This value should be an even number in the range 2 512. "

View File

@@ -67,7 +67,7 @@ private:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -75,12 +75,12 @@ private:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb> & ledValues) override;
int write(const std::vector<ColorRgb> & ledValues) override;
///
/// @brief Generate Art-Net communication header
///
void prepare(const unsigned this_universe, const unsigned this_sequence, const unsigned this_dmxChannelCount);
void prepare(unsigned this_universe, unsigned this_sequence, unsigned this_dmxChannelCount);
artnet_packet_t artnet_packet;
uint8_t _artnet_seq = 1;

View File

@@ -71,7 +71,7 @@ bool LedDeviceUdpE131::init(const QJsonObject &deviceConfig)
}
// populates the headers
void LedDeviceUdpE131::prepare(const unsigned this_universe, const unsigned this_dmxChannelCount)
void LedDeviceUdpE131::prepare(unsigned this_universe, unsigned this_dmxChannelCount)
{
memset(e131_packet.raw, 0, sizeof(e131_packet.raw));

View File

@@ -112,7 +112,7 @@ private:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -120,12 +120,12 @@ private:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb> & ledValues) override;
int write(const std::vector<ColorRgb> & ledValues) override;
///
/// @brief Generate E1.31 communication header
///
void prepare(const unsigned this_universe, const unsigned this_dmxChannelCount);
void prepare(unsigned this_universe, unsigned this_dmxChannelCount);
e131_packet_t e131_packet;
uint8_t _e131_seq = 0;

View File

@@ -35,7 +35,7 @@ private:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -43,7 +43,7 @@ private:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb> & ledValues) override;
int write(const std::vector<ColorRgb> & ledValues) override;
QList<int> _ids;
QByteArray _message;

View File

@@ -34,7 +34,7 @@ protected:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -42,7 +42,7 @@ protected:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb> & ledValues) override;
int write(const std::vector<ColorRgb> & ledValues) override;
};
#endif // LEDEVICEUDPRAW_H

View File

@@ -104,7 +104,7 @@ bool LedDeviceWled::init(const QJsonObject &deviceConfig)
return isInitOK;
}
bool LedDeviceWled::initRestAPI(const QString &hostname, const int port )
bool LedDeviceWled::initRestAPI(const QString &hostname, int port)
{
Debug(_log, "");
bool isInitOK = false;
@@ -121,7 +121,7 @@ bool LedDeviceWled::initRestAPI(const QString &hostname, const int port )
return isInitOK;
}
QString LedDeviceWled::getOnOffRequest (bool isOn ) const
QString LedDeviceWled::getOnOffRequest(bool isOn) const
{
QString state = isOn ? STATE_VALUE_TRUE : STATE_VALUE_FALSE;
return QString( "{\"%1\":%2}" ).arg( STATE_ON, state);

View File

@@ -25,7 +25,7 @@ public:
///
/// @brief Destructor of the WLED-device
///
virtual ~LedDeviceWled() override;
~LedDeviceWled() override;
///
/// @brief Constructs the WLED-device
@@ -39,7 +39,7 @@ public:
///
/// @return A JSON structure holding a list of devices found
///
virtual QJsonObject discover() override;
QJsonObject discover() override;
///
/// @brief Get the WLED device's resource properties
@@ -55,7 +55,7 @@ public:
/// @param[in] params Parameters to query device
/// @return A JSON structure holding the device's properties
///
virtual QJsonObject getProperties(const QJsonObject& params) override;
QJsonObject getProperties(const QJsonObject& params) override;
///
/// @brief Send an update to the WLED device to identify it.
@@ -69,7 +69,7 @@ public:
///
/// @param[in] params Parameters to address device
///
virtual void identify(const QJsonObject& params) override;
void identify(const QJsonObject& params) override;
protected:
@@ -79,7 +79,7 @@ protected:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -87,21 +87,21 @@ protected:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb> & ledValues) override;
int write(const std::vector<ColorRgb> & ledValues) override;
///
/// @brief Power-/turn on the WLED device.
///
/// @brief Store the device's original state.
///
virtual bool powerOn() override;
bool powerOn() override;
///
/// @brief Power-/turn off the WLED device.
///
/// @return True if success
///
virtual bool powerOff() override;
bool powerOff() override;
private:
@@ -112,7 +112,7 @@ private:
/// @param[in] port
/// @return True, if success
///
bool initRestAPI(const QString &hostname, const int port );
bool initRestAPI(const QString &hostname, int port );
///
/// @brief Get command to power WLED-device on or off

View File

@@ -234,12 +234,12 @@ int YeelightLight::writeCommand( const QJsonDocument &command, QJsonArray &resul
if ( ! _tcpSocket->waitForBytesWritten(WRITE_TIMEOUT.count()) )
{
QString errorReason = QString ("(%1) %2").arg(_tcpSocket->error()).arg( _tcpSocket->errorString());
log ( 2, "Error:", "bytesWritten: [%d], %s", bytesWritten, QSTRING_CSTR(errorReason));
log ( 2, "Error:", "bytesWritten: [%ll], %s", bytesWritten, QSTRING_CSTR(errorReason));
this->setInError ( errorReason );
}
else
{
log ( 3, "Success:", "Bytes written [%d]", bytesWritten );
log ( 3, "Success:", "Bytes written [%ll]", bytesWritten );
// Avoid to overrun the Yeelight Command Quota
qint64 elapsedTime = QDateTime::currentMSecsSinceEpoch() - _lastWriteTime;
@@ -247,7 +247,7 @@ int YeelightLight::writeCommand( const QJsonDocument &command, QJsonArray &resul
if ( elapsedTime < _waitTimeQuota )
{
int waitTime = _waitTimeQuota;
log ( 1, "writeCommand():", "Wait %dms, elapsedTime: %dms < quotaTime: %dms", waitTime, elapsedTime, _waitTimeQuota);
log ( 1, "writeCommand():", "Wait %dms, elapsedTime: %llms < quotaTime: %dms", waitTime, elapsedTime, _waitTimeQuota);
// Wait time (in ms) before doing next write to not overrun Yeelight command quota
std::this_thread::sleep_for(std::chrono::milliseconds(_waitTimeQuota));
@@ -258,7 +258,7 @@ int YeelightLight::writeCommand( const QJsonDocument &command, QJsonArray &resul
{
do
{
log ( 3, "Reading:", "Bytes available [%d]", _tcpSocket->bytesAvailable() );
log ( 3, "Reading:", "Bytes available [%ll]", _tcpSocket->bytesAvailable() );
while ( _tcpSocket->canReadLine() )
{
QByteArray response = _tcpSocket->readLine();
@@ -338,7 +338,7 @@ bool YeelightLight::streamCommand( const QJsonDocument &command )
{
int error = _tcpStreamSocket->error();
QString errorReason = QString ("(%1) %2").arg(error).arg( _tcpStreamSocket->errorString());
log ( 1, "Error:", "bytesWritten: [%d], %s", bytesWritten, QSTRING_CSTR(errorReason));
log ( 1, "Error:", "bytesWritten: [%ll], %s", bytesWritten, QSTRING_CSTR(errorReason));
if ( error == QAbstractSocket::RemoteHostClosedError )
{
@@ -353,7 +353,7 @@ bool YeelightLight::streamCommand( const QJsonDocument &command )
}
else
{
log ( 3, "Success:", "Bytes written [%d]", bytesWritten );
log ( 3, "Success:", "Bytes written [%ll]", bytesWritten );
rc = true;
}
}
@@ -572,7 +572,7 @@ bool YeelightLight::identify()
return rc;
}
bool YeelightLight::isInMusicMode( bool deviceCheck)
bool YeelightLight::isInMusicMode(bool deviceCheck)
{
bool inMusicMode = false;
@@ -896,7 +896,7 @@ bool YeelightLight::setColorHSV(const ColorRgb &colorRGB)
}
void YeelightLight::setTransitionEffect ( YeelightLight::API_EFFECT effect ,int duration )
void YeelightLight::setTransitionEffect(YeelightLight::API_EFFECT effect, int duration)
{
if( effect != _transitionEffect )
{
@@ -911,7 +911,7 @@ void YeelightLight::setTransitionEffect ( YeelightLight::API_EFFECT effect ,int
}
void YeelightLight::setBrightnessConfig (int min, int max, bool switchoff, int extraTime, double factor )
void YeelightLight::setBrightnessConfig(int min, int max, bool switchoff, int extraTime, double factor)
{
_brightnessMin = min;
_isBrightnessSwitchOffMinimum = switchoff;
@@ -944,7 +944,7 @@ bool YeelightLight::setMusicMode(bool on, const QHostAddress &hostAddress, int p
return rc;
}
void YeelightLight::log(const int logLevel, const char* msg, const char* type, ...)
void YeelightLight::log(int logLevel, const char* msg, const char* type, ...)
{
if ( logLevel <= _debugLevel)
{

View File

@@ -49,16 +49,14 @@ public:
API_NOTIFICATION,
};
explicit YeelightResponse() {}
API_REPLY error() { return _error;}
API_REPLY error() const { return _error;}
void setError(const YeelightResponse::API_REPLY replyType) { _error = replyType; }
QJsonArray getResult() const { return _resultArray; }
void setResult(const QJsonArray &result) { _resultArray = result; }
int getErrorCode() const { return _errorCode; }
void setErrorCode(const int &errorCode) { _errorCode = errorCode; _error = API_ERROR;}
void setErrorCode(int errorCode) { _errorCode = errorCode; _error = API_ERROR;}
QString getErrorReason() const { return _errorReason; }
void setErrorReason(const QString &errorReason) { _errorReason = errorReason; }
@@ -79,7 +77,6 @@ class YeelightLight
{
public:
enum API_EFFECT{
API_EFFECT_SMOOTH,
API_EFFECT_SUDDEN
@@ -281,7 +278,7 @@ public:
///
/// @return True, if success
///
virtual bool restoreState();
bool restoreState();
///
/// @brief Check, if light was originally powered on before hyperion color streaming started..
@@ -353,7 +350,7 @@ private:
/// @param[in] type log message text
/// @param[in] ... variable input to log message text
/// ///
void log(const int logLevel,const char* msg, const char* type, ...);
void log(int logLevel,const char* msg, const char* type, ...);
Logger* _log;
int _debugLevel;
@@ -428,7 +425,7 @@ public:
///
/// @brief Destructor of the LedDevice
///
virtual ~LedDeviceYeelight() override;
~LedDeviceYeelight() override;
///
/// @brief Constructs the LED-device
@@ -443,7 +440,7 @@ public:
///
/// @return A JSON structure holding a list of devices found
///
virtual QJsonObject discover() override;
QJsonObject discover() override;
///
/// @brief Get a Yeelight device's resource properties
@@ -459,7 +456,7 @@ public:
/// @param[in] params Parameters to query device
/// @return A JSON structure holding the device's properties
///
virtual QJsonObject getProperties(const QJsonObject& params) override;
QJsonObject getProperties(const QJsonObject& params) override;
///
/// @brief Send an update to the Yeelight device to identify it.
@@ -474,7 +471,7 @@ public:
///
/// @param[in] params Parameters to address device
///
virtual void identify(const QJsonObject& params) override;
void identify(const QJsonObject& params) override;
protected:
@@ -484,21 +481,21 @@ protected:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Opens the output device.
///
/// @return Zero on success (i.e. device is ready), else negative
///
virtual int open() override;
int open() override;
///
/// @brief Closes the output device.
///
/// @return Zero on success (i.e. device is closed), else negative
///
virtual int close() override;
int close() override;
///
/// @brief Writes the RGB-Color values to the LEDs.
@@ -506,21 +503,21 @@ protected:
/// @param[in] ledValues The RGB-color per LED
/// @return Zero on success, else negative
///
virtual int write(const std::vector<ColorRgb> & ledValues) override;
int write(const std::vector<ColorRgb> & ledValues) override;
///
/// @brief Power-/turn on the Nanoleaf device.
///
/// @brief Store the device's original state.
///
virtual bool powerOn() override;
bool powerOn() override;
///
/// @brief Power-/turn off the Nanoleaf device.
///
/// @return True if success
///
virtual bool powerOff() override;
bool powerOff() override;
///
/// @brief Store the device's original state.
@@ -529,7 +526,7 @@ protected:
///
/// @return True if success
///
virtual bool storeState() override;
bool storeState() override;
///
/// @brief Restore the device's original state.
@@ -539,7 +536,7 @@ protected:
///
/// @return True, if success
///
virtual bool restoreState() override;
bool restoreState() override;
private:

View File

@@ -16,7 +16,7 @@ const QChar ONE_SLASH = '/';
} //End of constants
ProviderRestApi::ProviderRestApi(const QString &host, const int &port, const QString &basePath)
ProviderRestApi::ProviderRestApi(const QString &host, int port, const QString &basePath)
:_log(Logger::getInstance("LEDDEVICE"))
,_networkManager(nullptr)
,_scheme("http")
@@ -31,7 +31,7 @@ ProviderRestApi::ProviderRestApi(const QString &host, const int &port, const QSt
_basePath = basePath;
}
ProviderRestApi::ProviderRestApi(const QString &host, const int &port)
ProviderRestApi::ProviderRestApi(const QString &host, int port)
: ProviderRestApi(host, port, "") {}
ProviderRestApi::ProviderRestApi()

View File

@@ -28,7 +28,7 @@ public:
void setErrorReason(const QString &errorReason) { _errorReason = errorReason; }
int getHttpStatusCode() const { return _httpStatusCode; }
void setHttpStatusCode(const int httpStatusCode) { _httpStatusCode = httpStatusCode; }
void setHttpStatusCode(int httpStatusCode) { _httpStatusCode = httpStatusCode; }
QNetworkReply::NetworkError getNetworkReplyError() const { return _networkReplyError; }
void setNetworkReplyError (const QNetworkReply::NetworkError networkReplyError) { _networkReplyError = networkReplyError; }
@@ -77,7 +77,7 @@ public:
/// @param[in] host
/// @param[in] port
///
explicit ProviderRestApi(const QString &host, const int &port);
explicit ProviderRestApi(const QString &host, int port);
///
/// @brief Constructor of the REST-API wrapper
@@ -86,7 +86,7 @@ public:
/// @param[in] port
/// @param[in] API base-path
///
explicit ProviderRestApi(const QString &host, const int &port, const QString &basePath);
explicit ProviderRestApi(const QString &host, int port, const QString &basePath);
///
/// @brief Destructor of the REST-API wrapper

View File

@@ -125,7 +125,7 @@ int ProviderUdp::close()
return retval;
}
int ProviderUdp::writeBytes(const unsigned size, const uint8_t * data)
int ProviderUdp::writeBytes(unsigned size, const uint8_t * data)
{
qint64 retVal = _udpSocket->writeDatagram((const char *)data,size,_address,_port);

View File

@@ -26,7 +26,7 @@ public:
///
/// @brief Destructor of the UDP LED-device
///
virtual ~ProviderUdp() override;
~ProviderUdp() override;
protected:
@@ -36,21 +36,21 @@ protected:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Opens the output device.
///
/// @return Zero on success (i.e. device is ready), else negative
///
virtual int open() override;
int open() override;
///
/// @brief Closes the UDP device.
///
/// @return Zero on success (i.e. device is closed), else negative
///
virtual int close() override;
int close() override;
///
/// @brief Writes the given bytes/bits to the UDP-device and sleeps the latch time to ensure that the
@@ -61,7 +61,7 @@ protected:
///
/// @return Zero on success, else negative
///
int writeBytes(const unsigned size, const uint8_t *data);
int writeBytes(unsigned size, const uint8_t *data);
///
QUdpSocket * _udpSocket;

View File

@@ -181,7 +181,7 @@ void ProviderUdpSSL::closeSSLConnection()
}
}
const int *ProviderUdpSSL::getCiphersuites()
const int *ProviderUdpSSL::getCiphersuites() const
{
return mbedtls_ssl_list_ciphersuites();
}
@@ -456,7 +456,7 @@ void ProviderUdpSSL::freeSSLConnection()
}
}
void ProviderUdpSSL::writeBytes(const unsigned size, const unsigned char * data)
void ProviderUdpSSL::writeBytes(unsigned size, const unsigned char * data)
{
if( _stopConnection ) return;

View File

@@ -66,7 +66,7 @@ public:
///
/// @brief Destructor of the LED-device
///
virtual ~ProviderUdpSSL() override;
~ProviderUdpSSL() override;
protected:
@@ -76,21 +76,21 @@ protected:
/// @param[in] deviceConfig the JSON device configuration
/// @return True, if success#endif // PROVIDERUDP_H
///
virtual bool init(const QJsonObject &deviceConfig) override;
bool init(const QJsonObject &deviceConfig) override;
///
/// @brief Opens the output device.
///
/// @return Zero on success (i.e. device is ready), else negative
///
virtual int open() override;
int open() override;
///
/// @brief Closes the output device.
///
/// @return Zero on success (i.e. device is closed), else negative
///
virtual int close() override;
int close() override;
///
/// @brief Initialise device's network details
@@ -106,14 +106,14 @@ protected:
/// @param[in] size The length of the data
/// @param[in] data The data
///
void writeBytes(const unsigned size, const uint8_t *data);
void writeBytes(unsigned size, const uint8_t *data);
///
/// get ciphersuites list from mbedtls_ssl_list_ciphersuites
///
/// @return const int * array
///
virtual const int * getCiphersuites();
virtual const int * getCiphersuites() const;
void sslLog(const QString &msg, const char* errorType = "debug");
void sslLog(const char* msg, const char* errorType = "debug");