@@ -623,21 +623,9 @@ const int *LedDevicePhilipsHueBridge::getCiphersuites() const
623623 return SSL_CIPHERSUITES;
624624}
625625
626- void LedDevicePhilipsHueBridge::log (const char * msg, const char *type, ... ) const
626+ void LedDevicePhilipsHueBridge::log (const QString& msg, const QVariant& value ) const
627627{
628- const size_t max_val_length = 1024 ;
629- char val[max_val_length];
630- va_list args;
631- va_start (args, type);
632- vsnprintf (val, max_val_length, type, args);
633- va_end (args);
634- std::string s = msg;
635- size_t max = 30 ;
636- if (max > s.length ())
637- {
638- s.append (max - s.length (), ' ' );
639- }
640- Debug (_log, " %s: %s" , s.c_str (), val);
628+ Debug (_log, " %s: %s" , QSTRING_CSTR (msg.leftJustified (30 , ' ' )), QSTRING_CSTR (value.toString ()));
641629}
642630
643631QJsonDocument LedDevicePhilipsHueBridge::retrieveBridgeDetails ()
@@ -971,15 +959,15 @@ void LedDevicePhilipsHueBridge::setBridgeDetails(const QJsonDocument &doc, bool
971959
972960 if (isLogging)
973961 {
974- log (" Bridge name [ID]" , " %s [%s] " , QSTRING_CSTR (_deviceName), QSTRING_CSTR ( getBridgeId ()));
975- log (" Philips Bridge" , " %s " , _isPhilipsHueBridge ? " Yes" : " No" );
976- log (" DIYHue Bridge" , " %s " , _isDiyHue ? " Yes" : " No" );
977- log (" Model" , " %s " , QSTRING_CSTR ( _deviceModel) );
978- log (" Firmware version" , " %d " , _deviceFirmwareVersion);
979- log (" API-Version" , " %u.%u.%u " , _api_major, _api_minor, _api_patch);
980- log (" API v2 ready" , " %s " , _isAPIv2Ready ? " Yes" : " No" );
981- log (" Entertainment ready" , " %s " , _isHueEntertainmentReady ? " Yes" : " No" );
982- log (" Use Entertainment API" , " %s " , _useEntertainmentAPI ? " Yes" : " No" );
962+ log (" Bridge name [ID]" , QString ( " %1 [%2] " ). arg (_deviceName, getBridgeId ()));
963+ log (" Philips Bridge" , _isPhilipsHueBridge ? " Yes" : " No" );
964+ log (" DIYHue Bridge" , _isDiyHue ? " Yes" : " No" );
965+ log (" Model" , _deviceModel);
966+ log (" Firmware version" , _deviceFirmwareVersion);
967+ log (" API-Version" , QString ( " %1.%2.%3 " ). arg ( _api_major). arg ( _api_minor). arg ( _api_patch) );
968+ log (" API v2 ready" , _isAPIv2Ready ? " Yes" : " No" );
969+ log (" Entertainment ready" , _isHueEntertainmentReady ? " Yes" : " No" );
970+ log (" Use Entertainment API" , _useEntertainmentAPI ? " Yes" : " No" );
983971 }
984972}
985973
@@ -1036,7 +1024,7 @@ void LedDevicePhilipsHueBridge::setLightsMap(const QJsonDocument &doc)
10361024 }
10371025 else
10381026 {
1039- log (" Lights at Bridge found" , " %d " , _lightsCount);
1027+ log (" Lights at Bridge found" , _lightsCount);
10401028 }
10411029}
10421030
@@ -1061,7 +1049,7 @@ void LedDevicePhilipsHueBridge::setGroupMap(const QJsonDocument &doc)
10611049 // Get all available group ids and their values
10621050 QStringList keys = jsonGroupsInfo.keys ();
10631051
1064- int _groupsCount = keys.size ();
1052+ auto _groupsCount = keys.size ();
10651053 for (int i = 0 ; i < _groupsCount; ++i)
10661054 {
10671055 _groupsMap.insert (keys.at (i), jsonGroupsInfo.take (keys.at (i)).toObject ());
@@ -1846,10 +1834,6 @@ LedDevice *LedDevicePhilipsHue::construct(const QJsonObject &deviceConfig)
18461834 return new LedDevicePhilipsHue (deviceConfig);
18471835}
18481836
1849- LedDevicePhilipsHue::~LedDevicePhilipsHue ()
1850- {
1851- }
1852-
18531837bool LedDevicePhilipsHue::init (const QJsonObject &deviceConfig)
18541838{
18551839 bool isInitOK{false };
@@ -1891,19 +1875,19 @@ bool LedDevicePhilipsHue::init(const QJsonObject &deviceConfig)
18911875
18921876 if (LedDevicePhilipsHueBridge::init (_devConfig))
18931877 {
1894- log (" Off on Black" , " %s " , _switchOffOnBlack ? " Yes" : " No" );
1895- log (" Brightness Factor" , " %f " , _brightnessFactor);
1896- log (" Transition Time" , " %d " , _transitionTime);
1897- log (" Restore Original State" , " %s " , _isRestoreOrigState ? " Yes" : " No" );
1898- log (" Use Hue Entertainment API" , " %s " , isUsingEntertainmentApi () ? " Yes" : " No" );
1899- log (" Brightness Threshold" , " %f " , _blackLevel);
1900- log (" CandyGamma" , " %s " , _candyGamma ? " Yes" : " No" );
1901- log (" Time powering off when black" , " %s " , _onBlackTimeToPowerOff ? " Yes" : " No" );
1902- log (" Time powering on when signalled" , " %s " , _onBlackTimeToPowerOn ? " Yes" : " No" );
1878+ log (" Off on Black" , _switchOffOnBlack ? " Yes" : " No" );
1879+ log (" Brightness Factor" , _brightnessFactor);
1880+ log (" Transition Time" , _transitionTime);
1881+ log (" Restore Original State" , _isRestoreOrigState ? " Yes" : " No" );
1882+ log (" Use Hue Entertainment API" , isUsingEntertainmentApi () ? " Yes" : " No" );
1883+ log (" Brightness Threshold" , _blackLevel);
1884+ log (" CandyGamma" , _candyGamma ? " Yes" : " No" );
1885+ log (" Time powering off when black" , _onBlackTimeToPowerOff ? " Yes" : " No" );
1886+ log (" Time powering on when signalled" , _onBlackTimeToPowerOn ? " Yes" : " No" );
19031887
19041888 if (isUsingEntertainmentApi ())
19051889 {
1906- log (" Entertainment API Group-ID" , " %s " , QSTRING_CSTR ( _groupId) );
1890+ log (" Entertainment API Group-ID" , _groupId);
19071891
19081892 if (_groupId.isEmpty ())
19091893 {
0 commit comments