diff --git a/include/leddevice/LedDevice.h b/include/leddevice/LedDevice.h index 7a5a8ba00..fbb7904d8 100644 --- a/include/leddevice/LedDevice.h +++ b/include/leddevice/LedDevice.h @@ -140,7 +140,7 @@ class LedDevice : public QObject /// /// @param[in] params Parameters to address device /// - virtual void identify(const QJsonObject& params) {}; + virtual void identify(const QJsonObject& params) {} /// /// @brief Check, if device is properly initialised @@ -262,7 +262,7 @@ public slots: /// @param[in] numberOfWrites Write Black given number of times /// @return Zero on success else negative /// - virtual int writeBlack(int numberOfWrites=1); + virtual int writeBlack(int numberOfBlack=1); /// /// @brief Switch the LEDs on. diff --git a/libsrc/leddevice/LedDevice.cpp b/libsrc/leddevice/LedDevice.cpp index 7032b6e47..0e76b5810 100644 --- a/libsrc/leddevice/LedDevice.cpp +++ b/libsrc/leddevice/LedDevice.cpp @@ -25,7 +25,6 @@ LedDevice::LedDevice(const QJsonObject& deviceConfig, QObject* parent) , _refreshTimerInterval_ms(0) , _latchTime_ms(0) , _isRestoreOrigState(false) - , _orignalStateValues() , _isEnabled(false) , _isDeviceInitialised(false) , _isDeviceReady(false) @@ -414,7 +413,9 @@ void LedDevice::printLedValues(const std::vector& ledValues) QString LedDevice::uint8_t_to_hex_string(const uint8_t * data, const qint64 size, qint64 number) const { if ( number <= 0 || number > size) + { number = size; + } QByteArray bytes (reinterpret_cast(data), number); #if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) diff --git a/libsrc/leddevice/LedDeviceFactory.cpp b/libsrc/leddevice/LedDeviceFactory.cpp index b4f50aedb..0b0690acb 100644 --- a/libsrc/leddevice/LedDeviceFactory.cpp +++ b/libsrc/leddevice/LedDeviceFactory.cpp @@ -18,7 +18,6 @@ LedDevice * LedDeviceFactory::construct(const QJsonObject & deviceConfig) { Logger * log = Logger::getInstance("LEDDEVICE"); QJsonDocument config(deviceConfig); - QString ss(config.toJson(QJsonDocument::Indented)); QString type = deviceConfig["type"].toString("UNSPECIFIED").toLower(); diff --git a/libsrc/leddevice/LedDeviceTemplate.cpp b/libsrc/leddevice/LedDeviceTemplate.cpp index ad71bbaa7..a462ffa10 100644 --- a/libsrc/leddevice/LedDeviceTemplate.cpp +++ b/libsrc/leddevice/LedDeviceTemplate.cpp @@ -9,10 +9,6 @@ LedDeviceTemplate::LedDeviceTemplate(const QJsonObject &deviceConfig) _activeDeviceType = deviceConfig["type"].toString("UNSPECIFIED").toLower(); } -LedDeviceTemplate::~LedDeviceTemplate() -{ -} - LedDevice* LedDeviceTemplate::construct(const QJsonObject &deviceConfig) { return new LedDeviceTemplate(deviceConfig); diff --git a/libsrc/leddevice/LedDeviceTemplate.h b/libsrc/leddevice/LedDeviceTemplate.h index 68c958f33..6096c30cd 100644 --- a/libsrc/leddevice/LedDeviceTemplate.h +++ b/libsrc/leddevice/LedDeviceTemplate.h @@ -19,11 +19,6 @@ class LedDeviceTemplate : public LedDevice /// explicit LedDeviceTemplate(const QJsonObject &deviceConfig); - /// - /// @brief Destructor of the LedDevice - /// - virtual ~LedDeviceTemplate() override; - /// /// @brief Constructs the LED-device /// diff --git a/libsrc/leddevice/dev_hid/LedDeviceHyperionUsbasp.cpp b/libsrc/leddevice/dev_hid/LedDeviceHyperionUsbasp.cpp index a9a8716f4..8a67db73b 100644 --- a/libsrc/leddevice/dev_hid/LedDeviceHyperionUsbasp.cpp +++ b/libsrc/leddevice/dev_hid/LedDeviceHyperionUsbasp.cpp @@ -182,7 +182,7 @@ int LedDeviceHyperionUsbasp::write(const std::vector &ledValues) { int nbytes = libusb_control_transfer( _deviceHandle, // device handle - LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT, // request type + static_cast( LIBUSB_REQUEST_TYPE_VENDOR | LIBUSB_RECIPIENT_DEVICE | LIBUSB_ENDPOINT_OUT ), // request type _writeLedsCommand, // request 0, // value 0, // index diff --git a/libsrc/leddevice/dev_hid/LedDeviceLightpack.cpp b/libsrc/leddevice/dev_hid/LedDeviceLightpack.cpp index 4faaf4bae..9e2abdb0b 100644 --- a/libsrc/leddevice/dev_hid/LedDeviceLightpack.cpp +++ b/libsrc/leddevice/dev_hid/LedDeviceLightpack.cpp @@ -220,7 +220,7 @@ int LedDeviceLightpack::testAndOpen(libusb_device * device, const QString & requ uint8_t buffer[256]; error = libusb_control_transfer( _deviceHandle, - LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, + static_cast( LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE), 0x01, 0x0100, 0, @@ -283,12 +283,12 @@ int LedDeviceLightpack::testAndOpen(libusb_device * device, const QString & requ int LedDeviceLightpack::write(const std::vector &ledValues) { - return write(ledValues.data(), ledValues.size()); + return write(ledValues.data(), static_cast(ledValues.size())); } int LedDeviceLightpack::write(const ColorRgb * ledValues, int size) { - int count = qMin(_hwLedCount, static_cast( _ledCount)); + int count = qMin(_hwLedCount, static_cast( size )); for (int i = 0; i < count ; ++i) { @@ -331,7 +331,7 @@ int LedDeviceLightpack::writeBytes(uint8_t *data, int size) // std::cout << std::endl; int error = libusb_control_transfer(_deviceHandle, - LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, + static_cast( LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE ), 0x09, (2 << 8), 0x00, @@ -349,7 +349,13 @@ int LedDeviceLightpack::writeBytes(uint8_t *data, int size) int LedDeviceLightpack::disableSmoothing() { unsigned char buf[2] = {CMD_SET_SMOOTH_SLOWDOWN, 0}; - return writeBytes(buf, sizeof(buf)) == sizeof(buf); + + int rc = 0; + if ( writeBytes(buf, sizeof(buf)) == sizeof(buf) ) + { + rc = 1; + } + return rc; } libusb_device_handle * LedDeviceLightpack::openDevice(libusb_device *device) diff --git a/libsrc/leddevice/dev_hid/LedDeviceMultiLightpack.cpp b/libsrc/leddevice/dev_hid/LedDeviceMultiLightpack.cpp index 8bf39b188..fe87612ae 100644 --- a/libsrc/leddevice/dev_hid/LedDeviceMultiLightpack.cpp +++ b/libsrc/leddevice/dev_hid/LedDeviceMultiLightpack.cpp @@ -32,7 +32,9 @@ LedDeviceMultiLightpack::~LedDeviceMultiLightpack() for (LedDeviceLightpack * device : _lightpacks) { if ( device != nullptr) + { delete device; + } } } @@ -55,7 +57,7 @@ bool LedDeviceMultiLightpack::init(const QJsonObject &deviceConfig) std::sort(_lightpacks.begin(), _lightpacks.end(), compareLightpacks); // open each Lightpack device - foreach (auto serial , serialList) + for (auto serial : serialList) { QJsonObject devConfig; devConfig["serial"] = serial; @@ -76,7 +78,7 @@ bool LedDeviceMultiLightpack::init(const QJsonObject &deviceConfig) } } - if (_lightpacks.size() == 0) + if (_lightpacks.empty()) { //Warning(_log, "No Lightpack devices were found"); QString errortext = QString ("No Lightpack devices were found"); @@ -226,7 +228,7 @@ QStringList LedDeviceMultiLightpack::getLightpackSerials() } } - Info(log, "Lightpack device found with serial %s", QSTRING_CSTR(serialNumber));; + Info(log, "Lightpack device found with serial %s", QSTRING_CSTR(serialNumber)); serialList.append(serialNumber); } } diff --git a/libsrc/leddevice/dev_hid/ProviderHID.cpp b/libsrc/leddevice/dev_hid/ProviderHID.cpp index e51f44e37..289a59969 100644 --- a/libsrc/leddevice/dev_hid/ProviderHID.cpp +++ b/libsrc/leddevice/dev_hid/ProviderHID.cpp @@ -196,23 +196,27 @@ QJsonObject ProviderHID::discover() // Discover HID Devices auto devs = hid_enumerate(0x00, 0x00); - auto cur_dev = devs; - while (cur_dev) + + if ( devs != nullptr ) { - QJsonObject deviceInfo; - deviceInfo.insert("manufacturer",QString::fromWCharArray(cur_dev->manufacturer_string)); - deviceInfo.insert("path",cur_dev->path); - deviceInfo.insert("productIdentifier", QString("0x%1").arg(static_cast(cur_dev->product_id),0,16)); - deviceInfo.insert("release_number",QString("0x%1").arg(static_cast(cur_dev->release_number),0,16)); - deviceInfo.insert("serialNumber",QString::fromWCharArray(cur_dev->serial_number)); - deviceInfo.insert("usage_page", QString("0x%1").arg(static_cast(cur_dev->usage_page),0,16)); - deviceInfo.insert("vendorIdentifier", QString("0x%1").arg(static_cast(cur_dev->vendor_id),0,16)); - deviceInfo.insert("interface_number",cur_dev->interface_number); - deviceList.append(deviceInfo); - - cur_dev = cur_dev->next; + auto cur_dev = devs; + while (cur_dev) + { + QJsonObject deviceInfo; + deviceInfo.insert("manufacturer",QString::fromWCharArray(cur_dev->manufacturer_string)); + deviceInfo.insert("path",cur_dev->path); + deviceInfo.insert("productIdentifier", QString("0x%1").arg(static_cast(cur_dev->product_id),0,16)); + deviceInfo.insert("release_number",QString("0x%1").arg(static_cast(cur_dev->release_number),0,16)); + deviceInfo.insert("serialNumber",QString::fromWCharArray(cur_dev->serial_number)); + deviceInfo.insert("usage_page", QString("0x%1").arg(static_cast(cur_dev->usage_page),0,16)); + deviceInfo.insert("vendorIdentifier", QString("0x%1").arg(static_cast(cur_dev->vendor_id),0,16)); + deviceInfo.insert("interface_number",cur_dev->interface_number); + deviceList.append(deviceInfo); + + cur_dev = cur_dev->next; + } + hid_free_enumeration(devs); } - hid_free_enumeration(devs); devicesDiscovered.insert("devices", deviceList); return devicesDiscovered; diff --git a/libsrc/leddevice/dev_net/LedDeviceAtmoOrb.cpp b/libsrc/leddevice/dev_net/LedDeviceAtmoOrb.cpp index 666ecd842..b1209ae8a 100644 --- a/libsrc/leddevice/dev_net/LedDeviceAtmoOrb.cpp +++ b/libsrc/leddevice/dev_net/LedDeviceAtmoOrb.cpp @@ -59,22 +59,28 @@ bool LedDeviceAtmoOrb::init(const QJsonObject &deviceConfig) _orbIds.clear(); - foreach(auto & id_str, orbIds) + for (auto & id_str : orbIds) { bool ok; int id = id_str.toInt(&ok); if (ok) { if ( id < 1 || id > 255 ) + { Warning(_log, "Skip orb id '%d'. IDs must be in range 1-255", id); + } else + { _orbIds.append(id); + } } else + { Error(_log, "orb id '%s' is not a number", QSTRING_CSTR(id_str)); + } } - if ( _orbIds.size() == 0 ) + if ( _orbIds.empty() ) { this->setInError("No valid OrbIds found!"); isInitOK = false; @@ -99,7 +105,7 @@ int LedDeviceAtmoOrb::open() _groupAddress = QHostAddress(_multicastGroup); if ( !_udpSocket->bind(QHostAddress::AnyIPv4, _multiCastGroupPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint) ) { - QString errortext = QString ("(%1) %2, MulticastGroup: (%3)").arg(_udpSocket->error()).arg(_udpSocket->errorString()).arg(_multicastGroup); + QString errortext = QString ("(%1) %2, MulticastGroup: (%3)").arg(_udpSocket->error()).arg(_udpSocket->errorString(), _multicastGroup); this->setInError( errortext ); } else @@ -107,7 +113,7 @@ int LedDeviceAtmoOrb::open() _joinedMulticastgroup = _udpSocket->joinMulticastGroup(_groupAddress); if ( !_joinedMulticastgroup ) { - QString errortext = QString ("(%1) %2, MulticastGroup: (%3)").arg(_udpSocket->error()).arg(_udpSocket->errorString()).arg(_multicastGroup); + QString errortext = QString ("(%1) %2, MulticastGroup: (%3)").arg(_udpSocket->error()).arg(_udpSocket->errorString(), _multicastGroup); this->setInError( errortext ); } else diff --git a/libsrc/leddevice/dev_net/LedDeviceFadeCandy.cpp b/libsrc/leddevice/dev_net/LedDeviceFadeCandy.cpp index 29c90a11f..4d1f5c41a 100644 --- a/libsrc/leddevice/dev_net/LedDeviceFadeCandy.cpp +++ b/libsrc/leddevice/dev_net/LedDeviceFadeCandy.cpp @@ -28,7 +28,7 @@ LedDeviceFadeCandy::LedDeviceFadeCandy(const QJsonObject &deviceConfig) LedDeviceFadeCandy::~LedDeviceFadeCandy() { - if ( _client == nullptr ) + if ( _client != nullptr ) { _client->deleteLater(); } diff --git a/libsrc/leddevice/dev_net/LedDeviceFadeCandy.h b/libsrc/leddevice/dev_net/LedDeviceFadeCandy.h index 85d01fb2b..274b6b6c8 100644 --- a/libsrc/leddevice/dev_net/LedDeviceFadeCandy.h +++ b/libsrc/leddevice/dev_net/LedDeviceFadeCandy.h @@ -45,7 +45,7 @@ class LedDeviceFadeCandy : public LedDevice /// /// @brief Destructor of the LedDevice /// - virtual ~LedDeviceFadeCandy(); + ~LedDeviceFadeCandy() override; /// /// @brief Constructs the LED-device diff --git a/libsrc/leddevice/dev_net/LedDeviceNanoleaf.cpp b/libsrc/leddevice/dev_net/LedDeviceNanoleaf.cpp index e6b6cc28b..44ed2970e 100644 --- a/libsrc/leddevice/dev_net/LedDeviceNanoleaf.cpp +++ b/libsrc/leddevice/dev_net/LedDeviceNanoleaf.cpp @@ -141,16 +141,24 @@ bool LedDeviceNanoleaf::init(const QJsonObject &deviceConfig) // Read panel organisation configuration if ( deviceConfig[ CONFIG_PANEL_ORDER_TOP_DOWN ].isString() ) - _topDown = deviceConfig[ CONFIG_PANEL_ORDER_TOP_DOWN ].toString().toInt() == 0 ? true : false; + { + _topDown = deviceConfig[ CONFIG_PANEL_ORDER_TOP_DOWN ].toString().toInt() == 0; + } else - _topDown = deviceConfig[ CONFIG_PANEL_ORDER_TOP_DOWN ].toInt() == 0 ? true : false; + { + _topDown = deviceConfig[ CONFIG_PANEL_ORDER_TOP_DOWN ].toInt() == 0; + } if ( deviceConfig[ CONFIG_PANEL_ORDER_LEFT_RIGHT ].isString() ) - _leftRight = deviceConfig[ CONFIG_PANEL_ORDER_LEFT_RIGHT ].toString().toInt() == 0 ? true : false; + { + _leftRight = deviceConfig[ CONFIG_PANEL_ORDER_LEFT_RIGHT ].toString().toInt() == 0; + } else - _leftRight = deviceConfig[ CONFIG_PANEL_ORDER_LEFT_RIGHT ].toInt() == 0 ? true : false; + { + _leftRight = deviceConfig[ CONFIG_PANEL_ORDER_LEFT_RIGHT ].toInt() == 0; + } - _startPos = deviceConfig[ CONFIG_PANEL_START_POS ].toInt(0); + _startPos = static_cast( deviceConfig[ CONFIG_PANEL_START_POS ].toInt(0) ); // TODO: Allow to handle port dynamically @@ -224,7 +232,7 @@ bool LedDeviceNanoleaf::initLedsConfiguration() std::map> panelMap; // Loop over all children. - foreach (const QJsonValue & value, positionData) + for (const QJsonValue value : positionData) { QJsonObject panelObj = value.toObject(); @@ -258,9 +266,13 @@ bool LedDeviceNanoleaf::initLedsConfiguration() DebugIf(verbose3, _log, "panelMap[%u][%u]=%u", posY->first, posX->first, posX->second ); if ( _topDown ) + { _panelIds.push_back(posX->second); + } else + { _panelIds.push_front(posX->second); + } } } else @@ -271,9 +283,13 @@ bool LedDeviceNanoleaf::initLedsConfiguration() DebugIf(verbose3, _log, "panelMap[%u][%u]=%u", posY->first, posX->first, posX->second ); if ( _topDown ) + { _panelIds.push_back(posX->second); + } else + { _panelIds.push_front(posX->second); + } } } } @@ -413,9 +429,13 @@ QJsonObject LedDeviceNanoleaf::getProperties(const QJsonObject& params) int apiPort; if ( addressparts.size() > 1) + { apiPort = addressparts[1].toInt(); + } else + { apiPort = API_DEFAULT_PORT; + } initRestAPI(apiHost, apiPort, authToken); _restApi->setPath(filter); @@ -457,9 +477,13 @@ void LedDeviceNanoleaf::identify(const QJsonObject& params) int apiPort; if ( addressparts.size() > 1) + { apiPort = addressparts[1].toInt(); + } else + { apiPort = API_DEFAULT_PORT; + } initRestAPI(apiHost, apiPort, authToken); _restApi->setPath("identify"); diff --git a/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp b/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp index 3b9363a5a..47c6b9793 100644 --- a/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp +++ b/libsrc/leddevice/dev_net/LedDevicePhilipsHue.cpp @@ -60,7 +60,7 @@ static const char API_STREAM_RESPONSE_FORMAT[] = "/%1/%2/%3/%4"; // List of resources static const char API_XY_COORDINATES[] = "xy"; static const char API_BRIGHTNESS[] = "bri"; -static const char API_SATURATION[] = "sat"; +//static const char API_SATURATION[] = "sat"; static const char API_TRANSITIONTIME[] = "transitiontime"; static const char API_MODEID[] = "modelid"; @@ -193,6 +193,7 @@ double CiColor::crossProduct(XYColor p1, XYColor p2) bool CiColor::isPointInLampsReach(CiColor p, const CiColorTriangle &colorSpace) { + bool rc = false; XYColor v1 = { colorSpace.green.x - colorSpace.red.x, colorSpace.green.y - colorSpace.red.y }; XYColor v2 = { colorSpace.blue.x - colorSpace.red.x, colorSpace.blue.y - colorSpace.red.y }; XYColor q = { p.x - colorSpace.red.x, p.y - colorSpace.red.y }; @@ -200,9 +201,9 @@ bool CiColor::isPointInLampsReach(CiColor p, const CiColorTriangle &colorSpace) double t = crossProduct(v1, q) / crossProduct(v1, v2); if ( ( s >= 0.0 ) && ( t >= 0.0 ) && ( s + t <= 1.0 ) ) { - return true; + rc = true; } - return false; + return rc; } XYColor CiColor::getClosestPointToPoint(XYColor a, XYColor b, CiColor p) @@ -430,14 +431,17 @@ bool LedDevicePhilipsHueBridge::initMaps() else { setBridgeConfig( doc ); - if( _useHueEntertainmentAPI ) setGroupMap( doc ); + if( _useHueEntertainmentAPI ) + { + setGroupMap( doc ); + } setLightsMap( doc ); } return isInitOK; } -void LedDevicePhilipsHueBridge::setBridgeConfig(QJsonDocument doc) +void LedDevicePhilipsHueBridge::setBridgeConfig(const QJsonDocument &doc) { QJsonObject jsonConfigInfo = doc.object()[ API_CONFIG ].toObject(); if ( verbose ) @@ -483,7 +487,7 @@ void LedDevicePhilipsHueBridge::setBridgeConfig(QJsonDocument doc) log( "EntertainmentReady", "%d", _isHueEntertainmentReady ); } -void LedDevicePhilipsHueBridge::setLightsMap(QJsonDocument doc) +void LedDevicePhilipsHueBridge::setLightsMap(const QJsonDocument &doc) { QJsonObject jsonLightsInfo = doc.object()[ API_LIGHTS ].toObject(); @@ -510,7 +514,7 @@ void LedDevicePhilipsHueBridge::setLightsMap(QJsonDocument doc) } } -void LedDevicePhilipsHueBridge::setGroupMap(QJsonDocument doc) +void LedDevicePhilipsHueBridge::setGroupMap(const QJsonDocument &doc) { QJsonObject jsonGroupsInfo = doc.object()[ API_GROUPS ].toObject(); @@ -643,7 +647,7 @@ QJsonDocument LedDevicePhilipsHueBridge::getGroupState(const unsigned int groupI QJsonDocument LedDevicePhilipsHueBridge::setGroupState(const 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 ).arg( API_STREAM_ACTIVE ).arg( active ) ); + 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) @@ -916,7 +920,7 @@ bool LedDevicePhilipsHue::setLights() if( !lArray.empty() ) { - for(const auto id : lArray) + for (const auto id : lArray) { unsigned int lightId = id.toString().toUInt(); if( lightId > 0 ) @@ -1209,7 +1213,7 @@ bool LedDevicePhilipsHue::setStreamGroupState(bool state) } else { - QString valueName = QString( API_STREAM_RESPONSE_FORMAT ).arg( API_GROUPS ).arg( _groupId ).arg( API_STREAM ).arg( API_STREAM_ACTIVE ); + QString valueName = QString( API_STREAM_RESPONSE_FORMAT ).arg( API_GROUPS ).arg( _groupId ).arg( API_STREAM, API_STREAM_ACTIVE ); if(!map.value( API_SUCCESS ).toMap().value( valueName ).isValid()) { this->setInError( QString("set stream to %1: Bridge response is not Valid").arg( active ) ); @@ -1457,7 +1461,7 @@ void LedDevicePhilipsHue::setOnOffState(PhilipsHueLight& light, bool on) { light.setOnOffState( on ); QString state = on ? API_STATE_VALUE_TRUE : API_STATE_VALUE_FALSE; - setLightState( light.getId(), QString("{\"%1\": %2 }").arg( API_STATE_ON ).arg( state ) ); + setLightState( light.getId(), QString("{\"%1\": %2 }").arg( API_STATE_ON, state ) ); } } @@ -1497,7 +1501,7 @@ void LedDevicePhilipsHue::setState(PhilipsHueLight& light, bool on, const CiColo { light.setOnOffState( on ); QString state = on ? API_STATE_VALUE_TRUE : API_STATE_VALUE_FALSE; - stateCmd += QString("\"%1\":%2,").arg( API_STATE_ON ).arg( state ); + stateCmd += QString("\"%1\":%2,").arg( API_STATE_ON, state ); } if ( light.getTransitionTime() != _transitionTime ) @@ -1705,8 +1709,8 @@ void LedDevicePhilipsHue::identify(const QJsonObject& params) _restApi->setPath(resource); QString stateCmd; - stateCmd += QString("\"%1\":%2,").arg( API_STATE_ON ).arg( API_STATE_VALUE_TRUE ); - stateCmd += QString("\"%1\":\"%2\"").arg( "alert" ).arg( "select" ); + stateCmd += QString("\"%1\":%2,").arg( API_STATE_ON, API_STATE_VALUE_TRUE ); + stateCmd += QString("\"%1\":\"%2\"").arg( "alert", "select" ); stateCmd = "{" + stateCmd + "}"; // Perform request diff --git a/libsrc/leddevice/dev_net/LedDevicePhilipsHue.h b/libsrc/leddevice/dev_net/LedDevicePhilipsHue.h index b7e3e1bb1..86f2823ea 100644 --- a/libsrc/leddevice/dev_net/LedDevicePhilipsHue.h +++ b/libsrc/leddevice/dev_net/LedDevicePhilipsHue.h @@ -186,7 +186,7 @@ class LedDevicePhilipsHueBridge : public ProviderUdpSSL public: explicit LedDevicePhilipsHueBridge(const QJsonObject &deviceConfig); - ~LedDevicePhilipsHueBridge(); + ~LedDevicePhilipsHueBridge() override; /// /// @brief Initialise the access to the REST-API wrapper @@ -274,9 +274,9 @@ class LedDevicePhilipsHueBridge : public ProviderUdpSSL private: QJsonDocument getAllBridgeInfos(); - void setBridgeConfig( QJsonDocument doc ); - void setLightsMap( QJsonDocument doc ); - void setGroupMap( QJsonDocument doc ); + void setBridgeConfig( const QJsonDocument &doc ); + void setLightsMap( const QJsonDocument &doc ); + void setGroupMap( const QJsonDocument &doc ); //Philips Hue Bridge details QString _deviceModel; diff --git a/libsrc/leddevice/dev_net/LedDeviceUdpRaw.cpp b/libsrc/leddevice/dev_net/LedDeviceUdpRaw.cpp index c7c06d573..0502eb352 100644 --- a/libsrc/leddevice/dev_net/LedDeviceUdpRaw.cpp +++ b/libsrc/leddevice/dev_net/LedDeviceUdpRaw.cpp @@ -29,5 +29,5 @@ int LedDeviceUdpRaw::write(const std::vector &ledValues) { const uint8_t * dataPtr = reinterpret_cast(ledValues.data()); - return writeBytes((unsigned)_ledRGBCount, dataPtr); + return writeBytes(_ledRGBCount, dataPtr); } diff --git a/libsrc/leddevice/dev_net/LedDeviceWled.cpp b/libsrc/leddevice/dev_net/LedDeviceWled.cpp index 2064a6ba1..76f7d787f 100644 --- a/libsrc/leddevice/dev_net/LedDeviceWled.cpp +++ b/libsrc/leddevice/dev_net/LedDeviceWled.cpp @@ -219,9 +219,13 @@ QJsonObject LedDeviceWled::getProperties(const QJsonObject& params) int apiPort; if ( addressparts.size() > 1) + { apiPort = addressparts[1].toInt(); + } else + { apiPort = API_DEFAULT_PORT; + } if ( filter.startsWith("/") ) filter.remove(0,1); @@ -293,5 +297,5 @@ int LedDeviceWled::write(const std::vector &ledValues) { const uint8_t * dataPtr = reinterpret_cast(ledValues.data()); - return writeBytes((unsigned)_ledRGBCount, dataPtr); + return writeBytes( _ledRGBCount, dataPtr); } diff --git a/libsrc/leddevice/dev_net/LedDeviceYeelight.cpp b/libsrc/leddevice/dev_net/LedDeviceYeelight.cpp index 34e3b96eb..4342e6ab8 100644 --- a/libsrc/leddevice/dev_net/LedDeviceYeelight.cpp +++ b/libsrc/leddevice/dev_net/LedDeviceYeelight.cpp @@ -83,7 +83,7 @@ static const char SSDP_FILTER[] = "yeelight(.*)"; static const char SSDP_FILTER_HEADER[] = "Location"; const quint16 SSDP_PORT = 1982; -YeelightLight::YeelightLight( Logger *log, const QString &hostname, int port = API_DEFAULT_PORT) +YeelightLight::YeelightLight( Logger *log, const QString &hostname, quint16 port = API_DEFAULT_PORT) :_log(log) ,_debugLevel(0) ,_isInError(false) @@ -114,11 +114,13 @@ YeelightLight::~YeelightLight() { log (3,"~YeelightLight()","" ); if ( _tcpSocket != nullptr) + { _tcpSocket->deleteLater(); + } log (2,"~YeelightLight()","void" ); } -void YeelightLight::setHostname( const QString &hostname, int port = API_DEFAULT_PORT ) +void YeelightLight::setHostname( const QString &hostname, quint16 port = API_DEFAULT_PORT ) { log (3,"setHostname()","" ); _host = hostname; @@ -207,7 +209,10 @@ int YeelightLight::writeCommand( const QJsonDocument &command ) int YeelightLight::writeCommand( const QJsonDocument &command, QJsonArray &result ) { - log (3,"writeCommand()","isON[%d], isInMusicMode[%d]", _isOn, _isInMusicMode ); + log( 3, + "writeCommand()", + "isON[%d], isInMusicMode[%d]", + static_cast( _isOn ), static_cast( _isInMusicMode ) ); if (_debugLevel >= 2) { QString help = command.toJson(QJsonDocument::Compact); @@ -403,7 +408,7 @@ YeelightResponse YeelightLight::handleResponse(int correlationID, QByteArray con QVariantMap paramsMap = jsonObj[API_COMMAND_PARAMS].toVariant().toMap(); // Loop over all children. - foreach (const QString property, paramsMap.keys()) + for (const QString & property : paramsMap.keys()) { QString value = paramsMap[property].toString(); log ( 3, "Notification ID:", "[%s]:[%s]", QSTRING_CSTR( property ), QSTRING_CSTR( value )); @@ -534,6 +539,7 @@ QJsonObject YeelightLight::getProperties() bool YeelightLight::identify() { log (3,"identify()","" ); + bool rc = true; /* count 6, total number of visible state changing before color flow is stopped @@ -556,9 +562,12 @@ bool YeelightLight::identify() QJsonDocument command = getCommand( API_METHOD_SETSCENE, colorflowParams ); - int rc = writeCommand( command ); + if ( writeCommand( command ) < 0 ) + { + rc= false; + } - log (2,"identify() rc","%d", rc ); + log( 2, "identify() rc","%d", static_cast(rc) ); return rc; } @@ -574,11 +583,13 @@ bool YeelightLight::isInMusicMode( bool deviceCheck) QJsonDocument command = getCommand( API_METHOD_GETPROP, propertylist ); QJsonArray result; - bool rc = writeCommand( command, result ); - if( rc && !result.empty()) + if ( writeCommand( command, result ) >= 0 ) { - inMusicMode = result.at(0).toString() == "1" ? true : false; + if( !result.empty()) + { + inMusicMode = result.at(0).toString() == "1"; + } } } else @@ -599,7 +610,7 @@ bool YeelightLight::isInMusicMode( bool deviceCheck) } _isInMusicMode = inMusicMode; - log (3,"isInMusicMode()","%d", _isInMusicMode ); + log( 3, "isInMusicMode()", "%d", static_cast( _isInMusicMode ) ); return _isInMusicMode; } @@ -617,7 +628,7 @@ void YeelightLight::mapProperties(const QJsonObject &properties) } } _model = properties.value(API_PROP_MODEL).toString(); - _fw_ver = properties.value(API_PROP_FWVER).toString();; + _fw_ver = properties.value(API_PROP_FWVER).toString(); _power = properties.value(API_PROP_POWER).toString(); _colorRgbValue = properties.value(API_PROP_RGB).toString().toInt(); @@ -650,10 +661,13 @@ bool YeelightLight::restoreState() } else { - rc = writeCommand( getCommand( API_METHOD_SETSCENE, paramlist ) ); + if ( writeCommand( getCommand( API_METHOD_SETSCENE, paramlist ) ) >= 0 ) + { + rc =true; + } } - log (2,"restoreState() rc","%d", rc ); + log( 2, "restoreState() rc","%d", static_cast(rc) ); return rc; } @@ -665,13 +679,18 @@ bool YeelightLight::setPower(bool on) bool YeelightLight::setPower(bool on, YeelightLight::API_EFFECT effect, int duration, API_MODE mode) { bool rc = false; - log (3,"setPower()","isON[%d], isInMusicMode[%d]", _isOn, _isInMusicMode ); + log( 3, + "setPower()", + "isON[%d], isInMusicMode[%d]", + static_cast( _isOn), static_cast(_isInMusicMode ) ); // Disable music mode to get power-off command executed if ( !on && _isInMusicMode ) { if ( _tcpStreamSocket != nullptr ) + { _tcpStreamSocket->close(); + } } QString powerParam = on ? API_METHOD_POWER_ON : API_METHOD_POWER_OFF; @@ -683,13 +702,16 @@ bool YeelightLight::setPower(bool on, YeelightLight::API_EFFECT effect, int dura if ( writeCommand( getCommand( API_METHOD_POWER, paramlist ) ) > -1 ) { _isOn = on; - if ( on == false ) + if ( !on ) { _isInMusicMode = false; } rc =true; } - log (2,"setPower() rc","%d, isON[%d], isInMusicMode[%d]", rc, _isOn, _isInMusicMode ); + log( 2, + "setPower() rc", + "%d, isON[%d], isInMusicMode[)%d]", + static_cast(rc), static_cast( _isOn ), static_cast( _isInMusicMode ) ); return rc; } @@ -714,7 +736,11 @@ bool YeelightLight::setColorRGB(const ColorRgb &color) { if ( _isBrightnessSwitchOffMinimum ) { - log ( 2, "Set Color RGB:", "Turn off, brightness [%d] < _brightnessMin [%d], _isBrightnessSwitchOffMinimum [%d]", bri, _brightnessMin, _isBrightnessSwitchOffMinimum ); + log( 2, + "Set Color RGB:", + "Turn off, brightness [%d] < _brightnessMin [%d], " + "_isBrightnessSwitchOffMinimum [%d]", + bri,_brightnessMin, static_cast(_isBrightnessSwitchOffMinimum ) ); // Set brightness to 0 bri = 0; duration = _transitionDuration + _extraTimeDarkness; @@ -722,7 +748,10 @@ bool YeelightLight::setColorRGB(const ColorRgb &color) else { //If not switchOff on MinimumBrightness, avoid switch-off - log ( 2, "Set Color RGB:", "Set brightness[%d] to minimum brightness [%d], if not _isBrightnessSwitchOffMinimum [%d]", bri, _brightnessMin, _isBrightnessSwitchOffMinimum ); + log( 2, + "Set Color RGB:", + "Set brightness[%d] to minimum brightness [%d], if not _isBrightnessSwitchOffMinimum [%d]", + bri, _brightnessMin, static_cast( _isBrightnessSwitchOffMinimum ) ); bri = _brightnessMin; } } @@ -740,14 +769,17 @@ bool YeelightLight::setColorRGB(const ColorRgb &color) paramlist << _transitionEffectParam << duration; } - bool writeOK; + bool writeOK = false; if ( _isInMusicMode ) { writeOK = streamCommand( getCommand( API_METHOD_SETSCENE, paramlist ) ); } else { - writeOK = writeCommand( getCommand( API_METHOD_SETSCENE, paramlist ) ); + if ( writeCommand( getCommand( API_METHOD_SETSCENE, paramlist ) ) >= 0 ) + { + writeOK = true; + } } if ( writeOK ) { @@ -778,7 +810,10 @@ bool YeelightLight::setColorHSV(const ColorRgb &colorRGB) color.getHsv( &hue, &sat, &bri); //Align to Yeelight number ranges (hue: 0-359, sat: 0-100, bri: 0-100) - if ( hue == -1) hue = 0; + if ( hue == -1) + { + hue = 0; + } sat = sat * 100 / 255; bri = bri * 100 / 255; @@ -786,7 +821,13 @@ bool YeelightLight::setColorHSV(const ColorRgb &colorRGB) { if ( _isBrightnessSwitchOffMinimum ) { - log ( 2, "Set Color HSV:", "Turn off, brightness [%d] < _brightnessMin [%d], _isBrightnessSwitchOffMinimum [%d]", bri, _brightnessMin, _isBrightnessSwitchOffMinimum ); + log( 2, + "Set Color HSV:", + "Turn off, brightness [%d] < _brightnessMin [%d], " + "_isBrightnessSwitchOffMinimum [%d]", + bri, + _brightnessMin, + static_cast( _isBrightnessSwitchOffMinimum ) ); // Set brightness to 0 bri = 0; duration = _transitionDuration + _extraTimeDarkness; @@ -794,7 +835,10 @@ bool YeelightLight::setColorHSV(const ColorRgb &colorRGB) else { //If not switchOff on MinimumBrightness, avoid switch-off - log ( 2, "Set Color HSV:", "Set brightness[%d] to minimum brightness [%d], if not _isBrightnessSwitchOffMinimum [%d]", bri, _brightnessMin, _isBrightnessSwitchOffMinimum ); + log( 2, + "Set Color HSV:", + "Set brightness[%d] to minimum brightness [%d], if not _isBrightnessSwitchOffMinimum [%d]", + bri, _brightnessMin, static_cast( _isBrightnessSwitchOffMinimum )); bri = _brightnessMin; } } @@ -811,14 +855,17 @@ bool YeelightLight::setColorHSV(const ColorRgb &colorRGB) paramlist << _transitionEffectParam << duration; } - bool writeOK; + bool writeOK=false; if ( _isInMusicMode ) { writeOK = streamCommand( getCommand( API_METHOD_SETSCENE, paramlist ) ); } else { - writeOK = writeCommand( getCommand( API_METHOD_SETSCENE, paramlist ) ); + if ( writeCommand( getCommand( API_METHOD_SETSCENE, paramlist ) ) >= 0 ) + { + writeOK = true; + } } if ( writeOK ) @@ -840,7 +887,10 @@ bool YeelightLight::setColorHSV(const ColorRgb &colorRGB) { //log ( 3, "setColorHSV", "Skip update. Same Color as before"); } - log (3,"setColorHSV() rc","%d, isON[%d], isInMusicMode[%d]", rc, _isOn, _isInMusicMode ); + log( 3, + "setColorHSV() rc", + "%d, isON[%d], isInMusicMode[%d]", + static_cast( rc ), static_cast( _isOn ), static_cast( _isInMusicMode ) ); return rc; } @@ -888,7 +938,8 @@ bool YeelightLight::setMusicMode(bool on, const QHostAddress &hostAddress, int p rc = true; } - log (2,"setMusicMode() rc","%d, isInMusicMode[%d]", rc, _isInMusicMode ); + log( 2, + "setMusicMode() rc", "%d, isInMusicMode[%d]", static_cast( rc ), static_cast( _isInMusicMode ) ); return rc; } @@ -971,15 +1022,22 @@ bool LedDeviceYeelight::init(const QJsonObject &deviceConfig) bool ok; if ( deviceConfig[ CONFIG_COLOR_MODEL ].isString() ) + { _outputColorModel = deviceConfig[ CONFIG_COLOR_MODEL ].toString().toInt(&ok,MODEL_RGB); + } else + { _outputColorModel = deviceConfig[ CONFIG_COLOR_MODEL ].toInt(MODEL_RGB); - + } if ( deviceConfig[ CONFIG_TRANS_EFFECT ].isString() ) + { _transitionEffect = static_cast( deviceConfig[ CONFIG_TRANS_EFFECT ].toString().toInt(&ok, YeelightLight::API_EFFECT_SMOOTH) ); + } else + { _transitionEffect = static_cast( deviceConfig[ CONFIG_TRANS_EFFECT ].toInt(YeelightLight::API_EFFECT_SMOOTH) ); + } _transitionDuration = deviceConfig[ CONFIG_TRANS_TIME ].toInt(API_PARAM_DURATION); _extraTimeDarkness = _devConfig[CONFIG_EXTRA_TIME_DARKNESS].toInt(0); @@ -990,9 +1048,13 @@ bool LedDeviceYeelight::init(const QJsonObject &deviceConfig) _brightnessFactor = _devConfig[CONFIG_BRIGHTNESSFACTOR].toDouble(1.0); if ( deviceConfig[ CONFIG_DEBUGLEVEL ].isString() ) + { _debuglevel = deviceConfig[ CONFIG_DEBUGLEVEL ].toString().toInt(); + } else + { _debuglevel = deviceConfig[ CONFIG_DEBUGLEVEL ].toInt(0); + } QString outputColorModel = _outputColorModel == MODEL_RGB ? "RGB": "HSV"; QString transitionEffect = _transitionEffect == YeelightLight::API_EFFECT_SMOOTH ? API_PARAM_EFFECT_SMOOTH : API_PARAM_EFFECT_SUDDEN; @@ -1009,7 +1071,7 @@ bool LedDeviceYeelight::init(const QJsonObject &deviceConfig) _isRestoreOrigState = _devConfig[CONFIG_RESTORE_STATE].toBool(false); Debug(_log, "RestoreOrigState : %d", _isRestoreOrigState); - + _waitTimeQuota = _devConfig[CONFIG_QUOTA_WAIT_TIME].toInt(0); Debug(_log, "Wait time (quota) : %d", _waitTimeQuota ); @@ -1017,7 +1079,7 @@ bool LedDeviceYeelight::init(const QJsonObject &deviceConfig) QJsonArray configuredYeelightLights = _devConfig[CONFIG_LIGHTS].toArray(); uint configuredYeelightsCount = 0; - foreach (const QJsonValue & light, configuredYeelightLights) + for (const QJsonValue light : configuredYeelightLights) { QString host = light.toObject().value("host").toString(); int port = light.toObject().value("port").toInt(API_DEFAULT_PORT); @@ -1060,7 +1122,7 @@ bool LedDeviceYeelight::init(const QJsonObject &deviceConfig) #endif QString apiHost = addressparts[0]; - int apiPort = port;; + int apiPort = port; _lightsAddressList.append( {apiHost, apiPort} ); } @@ -1100,7 +1162,7 @@ bool LedDeviceYeelight::startMusicModeServer() // use the first non-localhost IPv4 address for (int i = 0; i < ipAddressesList.size(); ++i) { if (ipAddressesList.at(i) != QHostAddress::LocalHost && - ipAddressesList.at(i).toIPv4Address()) + (ipAddressesList.at(i).toIPv4Address() != 0U)) { _musicModeServerAddress = ipAddressesList.at(i); break; @@ -1216,7 +1278,7 @@ bool LedDeviceYeelight::updateLights(const QVector &list) _lights.reserve( static_cast( _lightsAddressList.size() )); - for(auto yeelightAddress : _lightsAddressList ) + for(auto & yeelightAddress : _lightsAddressList ) { QString host = yeelightAddress.host; @@ -1288,7 +1350,9 @@ bool LedDeviceYeelight::restoreState() { light.restoreState(); if ( !light.wasOriginallyOn() ) + { light.setPower( false, _transitionEffect, API_PARAM_DURATION_POWERONOFF); + } } return rc; } @@ -1324,7 +1388,7 @@ QJsonObject LedDeviceYeelight::getProperties(const QJsonObject& params) QJsonObject properties; QString apiHostname = params["hostname"].toString(""); - int apiPort = params["port"].toInt(API_DEFAULT_PORT); + quint16 apiPort = static_cast( params["port"].toInt(API_DEFAULT_PORT) ); Debug (_log, "apiHost [%s], apiPort [%d]", QSTRING_CSTR(apiHostname), apiPort); if ( !apiHostname.isEmpty() ) @@ -1348,7 +1412,7 @@ void LedDeviceYeelight::identify(const QJsonObject& params) Debug(_log, "params: [%s]", QString(QJsonDocument(params).toJson(QJsonDocument::Compact)).toUtf8().constData() ); QString apiHostname = params["hostname"].toString(""); - int apiPort = params["port"].toInt(API_DEFAULT_PORT); + quint16 apiPort = static_cast( params["port"].toInt(API_DEFAULT_PORT) ); Debug (_log, "apiHost [%s], apiPort [%d]", QSTRING_CSTR(apiHostname), apiPort); if ( !apiHostname.isEmpty() ) diff --git a/libsrc/leddevice/dev_net/LedDeviceYeelight.h b/libsrc/leddevice/dev_net/LedDeviceYeelight.h index 67aafa9f1..aa227c196 100644 --- a/libsrc/leddevice/dev_net/LedDeviceYeelight.h +++ b/libsrc/leddevice/dev_net/LedDeviceYeelight.h @@ -94,12 +94,12 @@ class YeelightLight /// @param[in] hostname or IP-address /// @param[in] port, default port 55443 is used when not provided /// - YeelightLight( Logger *log, const QString &hostname, int port); + YeelightLight( Logger *log, const QString &hostname, quint16 port); /// /// @brief Destructor of the Yeelight light /// - ~YeelightLight(); + virtual ~YeelightLight(); /// /// @brief Set the Yeelight light connectivity parameters @@ -107,7 +107,7 @@ class YeelightLight /// @param[in] hostname or IP-address /// @param[in] port, default port 55443 is used when not provided /// - void setHostname( const QString &hostname, int port); + void setHostname( const QString &hostname, quint16 port); /// /// @brief Set the Yeelight light name @@ -240,10 +240,10 @@ class YeelightLight /// @brief Set the Yeelight light into music-mode /// /// @param[in] on True: music-mode on, False: music-mode off - /// @param[in] ipAddress of the music-mode server + /// @param[in] hostAddress of the music-mode server /// @param[in] port of the music-mode server /// - bool setMusicMode( bool on, const QHostAddress &ipAddress = {} , int port = -1 ); + bool setMusicMode( bool on, const QHostAddress &hostAddress = {} , int port = -1 ); /// /// @brief Set the wait-time between two Yeelight light commands @@ -357,7 +357,7 @@ class YeelightLight /// IP address/port of the Yeelight light QString _host; - int _port; + quint16 _port; /// Yeelight light communication socket QTcpSocket* _tcpSocket; @@ -613,7 +613,7 @@ class LedDeviceYeelight : public LedDevice ///Music mode Server details QHostAddress _musicModeServerAddress; - quint16 _musicModeServerPort; + int _musicModeServerPort; QTcpServer* _tcpMusicModeServer = nullptr; }; diff --git a/libsrc/leddevice/dev_net/ProviderRestApi.h b/libsrc/leddevice/dev_net/ProviderRestApi.h index c146ae0b4..32c267316 100644 --- a/libsrc/leddevice/dev_net/ProviderRestApi.h +++ b/libsrc/leddevice/dev_net/ProviderRestApi.h @@ -182,7 +182,7 @@ class ProviderRestApi /// @param[in] reply Network reply /// @return Response The body of the response in JSON /// - httpResponse getResponse(QNetworkReply* const &response); + httpResponse getResponse(QNetworkReply* const &reply); private: diff --git a/libsrc/leddevice/dev_net/ProviderUdpSSL.cpp b/libsrc/leddevice/dev_net/ProviderUdpSSL.cpp index d072a3e71..ef171f9cf 100644 --- a/libsrc/leddevice/dev_net/ProviderUdpSSL.cpp +++ b/libsrc/leddevice/dev_net/ProviderUdpSSL.cpp @@ -135,7 +135,6 @@ bool ProviderUdpSSL::init(const QJsonObject &deviceConfig) int ProviderUdpSSL::open() { int retval = -1; - QString errortext; _isDeviceReady = false; // TODO: Question: Just checking .... Is this one time initialisation or required with every open request (during switch-off/switch-on)? diff --git a/libsrc/leddevice/dev_other/LedDeviceFile.cpp b/libsrc/leddevice/dev_other/LedDeviceFile.cpp index 66e73e339..afd27aeb2 100644 --- a/libsrc/leddevice/dev_other/LedDeviceFile.cpp +++ b/libsrc/leddevice/dev_other/LedDeviceFile.cpp @@ -58,9 +58,8 @@ int LedDeviceFile::open() Debug(_log, "QIODevice::WriteOnly, %s", QSTRING_CSTR(_fileName)); if ( !_file->open(QIODevice::WriteOnly | QIODevice::Text) ) { - QString errortext = QString ("(%1) %2, file: (%3)").arg(_file->error()).arg(_file->errorString()).arg(_fileName); + QString errortext = QString ("(%1) %2, file: (%3)").arg(_file->error()).arg(_file->errorString(),_fileName); this->setInError( errortext ); - return false; } else { diff --git a/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp b/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp index e207398d8..284a1e681 100644 --- a/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp +++ b/libsrc/leddevice/dev_rpi_pwm/LedDeviceWS281x.cpp @@ -46,7 +46,7 @@ bool LedDeviceWS281x::init(const QJsonObject &deviceConfig) else { memset(&_led_string, 0, sizeof(_led_string)); - _led_string.freq = deviceConfig["freq"].toInt(800000ul); + _led_string.freq = deviceConfig["freq"].toInt(800000UL); _led_string.dmanum = deviceConfig["dma"].toInt(5); _led_string.channel[_channel].gpionum = deviceConfig["gpio"].toInt(18); _led_string.channel[_channel].count = deviceConfig["leds"].toInt(256); diff --git a/libsrc/leddevice/dev_serial/LedDeviceSedu.cpp b/libsrc/leddevice/dev_serial/LedDeviceSedu.cpp index 75c36c4f8..495c78ba3 100644 --- a/libsrc/leddevice/dev_serial/LedDeviceSedu.cpp +++ b/libsrc/leddevice/dev_serial/LedDeviceSedu.cpp @@ -42,7 +42,7 @@ bool LedDeviceSedu::init(const QJsonObject &deviceConfig) } } - if (_ledBuffer.size() == 0) + if (_ledBuffer.empty()) { //Warning(_log, "More rgb-channels required then available"); QString errortext = "More rgb-channels required then available"; diff --git a/libsrc/leddevice/dev_serial/ProviderRs232.cpp b/libsrc/leddevice/dev_serial/ProviderRs232.cpp index cf36e5aaf..5a89c8487 100644 --- a/libsrc/leddevice/dev_serial/ProviderRs232.cpp +++ b/libsrc/leddevice/dev_serial/ProviderRs232.cpp @@ -254,7 +254,7 @@ int ProviderRs232::writeBytes(const qint64 size, const uint8_t *data) QString ProviderRs232::discoverFirst() { // take first available USB serial port - currently no probing! - for (auto port : QSerialPortInfo::availablePorts()) + for (auto const & port : QSerialPortInfo::availablePorts()) { if (!port.isNull() && !port.isBusy()) { diff --git a/libsrc/leddevice/dev_tinker/LedDeviceTinkerforge.cpp b/libsrc/leddevice/dev_tinker/LedDeviceTinkerforge.cpp index 734fa0395..e282f97a1 100644 --- a/libsrc/leddevice/dev_tinker/LedDeviceTinkerforge.cpp +++ b/libsrc/leddevice/dev_tinker/LedDeviceTinkerforge.cpp @@ -71,7 +71,6 @@ bool LedDeviceTinkerforge::init(const QJsonObject &deviceConfig) int LedDeviceTinkerforge::open() { int retval = -1; - QString errortext; _isDeviceReady = false; // Check if connection is already created