Skip to content

Commit

Permalink
Added Debug and Trace logging for Status Update responses
Browse files Browse the repository at this point in the history
  • Loading branch information
jllcunha authored Feb 1, 2018
1 parent 351f698 commit f67d237
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.List;
import java.util.Objects;

import org.openhab.binding.greeair.handler.GreeAirHandler;
import org.openhab.binding.greeair.internal.encryption.CryptoUtil;
import org.openhab.binding.greeair.internal.gson.GreeBindRequest4Gson;
import org.openhab.binding.greeair.internal.gson.GreeBindRequestPack4Gson;
Expand All @@ -33,6 +34,8 @@
import org.openhab.binding.greeair.internal.gson.GreeScanResponse4Gson;
import org.openhab.binding.greeair.internal.gson.GreeStatusResponse4Gson;
import org.openhab.binding.greeair.internal.gson.GreeStatusResponsePack4Gson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.Gson;
import com.google.gson.stream.JsonReader;
Expand All @@ -54,6 +57,7 @@ public class GreeDevice {
private GreeBindResponse4Gson bindResponseGson = null;
private GreeStatusResponse4Gson statusResponseGson = null;
private GreeStatusResponsePack4Gson prevStatusResponsePackGson = null;
private final Logger logger = LoggerFactory.getLogger(GreeAirHandler.class);

public Boolean getIsBound() {
return mIsBound;
Expand Down Expand Up @@ -530,9 +534,12 @@ public void getDeviceStatus(DatagramSocket clientSocket) throws Exception {
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, getAddress(), getPort());
clientSocket.send(sendPacket);

logger.trace("Sending Status request packet to device");

// Recieve a response
DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length);
clientSocket.receive(receivePacket);
logger.trace("Status request packet received from device");
String modifiedSentence = new String(receivePacket.getData());

// Keep a copy of the old response to be used to check if values have changed
Expand All @@ -546,6 +553,8 @@ public void getDeviceStatus(DatagramSocket clientSocket) throws Exception {
statusResponseGson = gson.fromJson(new JsonReader(stringReader), GreeStatusResponse4Gson.class);
statusResponseGson.decryptedPack = CryptoUtil.decryptPack(this.getKey().getBytes(), statusResponseGson.pack);

logger.trace("Response from device: {}", statusResponseGson.decryptedPack);

// Create the JSON to hold the response values
stringReader = new StringReader(statusResponseGson.decryptedPack);

Expand Down

0 comments on commit f67d237

Please sign in to comment.