]> git.basschouten.com Git - openhab-addons.git/commitdiff
- Introduced more output for debugging (w/ log level debug) (#15070)
authorGuenther Schreiner <gs4711@users.noreply.github.com>
Sun, 11 Jun 2023 19:10:53 +0000 (21:10 +0200)
committerGitHub <noreply@github.com>
Sun, 11 Jun 2023 19:10:53 +0000 (21:10 +0200)
- Fixed support for MB-LAN (=KM200, version 1.0) by avoiding query of an unsupported attribute.
- BEFORE this fix: The MBLAN does not support the /gateway/registrations attribute and returns an invalid answer:
*   [b.binding.km200.internal.KM200Device] - /gateway/registrations: trying to query information.
*   [b.binding.km200.internal.KM200Device] - /gateway/registrations: trying to decode: [B@4de25f6.
*   [binding.km200.internal.KM200Cryption] - Length of message is 11.
*   [binding.km200.internal.KM200Cryption] - Did NOT decrypt message
*   [binding.km200.internal.KM200Cryption] - Exception on encoding

Logging of detailed error message.

Signed-off-by: guenther.schreiner@smile.de
bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/KM200Cryption.java
bundles/org.openhab.binding.km200/src/main/java/org/openhab/binding/km200/internal/KM200Device.java

index 6490c0c428286530714f5618afebdbed4ed9b6cd..a2c000b50648297e5a4ff1ebe9de224f78163fde 100644 (file)
@@ -83,9 +83,10 @@ public class KM200Cryption {
         try {
             /* Check whether the length of the decryptData is NOT multiplies of 16 */
             if ((decodedB64.length & 0xF) != 0) {
+                logger.debug("Length of message is {}.", decodedB64.length);
                 /* Return the data */
                 retString = new String(decodedB64, remoteDevice.getCharSet());
-                logger.debug("Did NOT decrypt message");
+                logger.debug("Did NOT decrypt message, returning {}.", retString);
                 return retString;
             }
             // --- create cipher
@@ -95,7 +96,7 @@ public class KM200Cryption {
             byte[] decryptedDataWOZP = removeZeroPadding(decryptedData);
             return (new String(decryptedDataWOZP, remoteDevice.getCharSet()));
         } catch (UnsupportedEncodingException | GeneralSecurityException e) {
-            logger.warn("Exception on encoding", e);
+            logger.warn("Exception on encoding ({})", e.getMessage());
             return null;
         }
     }
@@ -119,7 +120,7 @@ public class KM200Cryption {
                 logger.debug("Base64encoding not possible: {}", e.getMessage());
             }
         } catch (UnsupportedEncodingException | GeneralSecurityException e) {
-            logger.warn("Exception on encoding", e);
+            logger.warn("Exception on encoding ({})", e.getMessage());
         }
         return null;
     }
index 19b2a1325a5320926b941a1ebbf032a18b82958f..408816dbcf5ac498aa96098ae63553307da1be84 100644 (file)
@@ -75,6 +75,7 @@ public class KM200Device {
     public KM200Device(HttpClient httpClient) {
         serviceTreeMap = new HashMap<>();
         getBlacklistMap().add("/gateway/firmware");
+        getBlacklistMap().add("/gateway/registrations");
         virtualList = new ArrayList<>();
         comCryption = new KM200Cryption(this);
         deviceCommunicator = new KM200Comm<>(this, httpClient);
@@ -330,6 +331,7 @@ public class KM200Device {
     public @Nullable JsonObject getServiceNode(String service) {
         String decodedData = null;
         JsonObject nodeRoot = null;
+        logger.debug("{}: trying to query information.", service);
         byte[] recData = deviceCommunicator.getDataFromService(service.toString());
         try {
             if (recData == null) {
@@ -347,6 +349,7 @@ public class KM200Device {
                 decodedData = "";
                 return nodeRoot;
             } else {
+                logger.debug("{}: trying to decode: {}.", service, recData.toString());
                 decodedData = comCryption.decodeMessage(recData);
                 if (decodedData == null) {
                     logger.warn("Decoding of the KM200 message is not possible!");
@@ -355,9 +358,10 @@ public class KM200Device {
             }
             if (decodedData.length() > 0) {
                 if ("SERVICE NOT AVAILABLE".equals(decodedData)) {
-                    logger.debug("{}: SERVICE NOT AVAILABLE", service);
+                    logger.warn("{}: SERVICE NOT AVAILABLE", service);
                     return null;
                 } else {
+                    logger.debug("{}: trying to parse {}", service, decodedData.toString());
                     nodeRoot = (JsonObject) JsonParser.parseString(decodedData);
                 }
             } else {