// Path: GreeRemoteAndroid/app/src/main/java/tomikaa/greeremote/Gree/Packs/DatPack.java
// public class DatPack extends Pack {
//     public static String TYPE = "dat";
// 
//     @SerializedName("r")
//     public int resultCode;
// 
//     @SerializedName("cols")
//     public String[] keys;
// 
//     @SerializedName("dat")
//     public Integer[] values;
// 
//     public DatPack() {
//         type = TYPE;
//     }
// }
// 
// Path: GreeRemoteAndroid/app/src/main/java/tomikaa/greeremote/Gree/Packs/DevicePack.java
// public class DevicePack extends Pack {
//     public static String TYPE = "dev";
// 
//     public String cid;
//     public String bc;
//     public String brand;
//     public String catalog;
//     public String mid;
//     public String model;
//     public String name;
//     public String series;
//     public String ver;
//     public Integer lock;
// 
//     @SerializedName("vender")
//     public String vendor;
// 
//     public DevicePack() {
//         type = TYPE;
//     }
// }
// 
// Path: GreeRemoteAndroid/app/src/main/java/tomikaa/greeremote/Gree/Packs/ResultPack.java
// public class ResultPack extends Pack {
//     public static String TYPE = "res";
// 
//     @SerializedName("r")
//     public int resultCode;
// 
//     @SerializedName("opt")
//     public String[] keys;
// 
//     @SerializedName("p")
//     public Integer[] values;
// 
//     public ResultPack() {
//         type = TYPE;
//     }
// }
// 
// Path: GreeRemoteAndroid/app/src/main/java/tomikaa/greeremote/Gree/Utils.java
// public class Utils {
// 
//     public static class Unzipped {
//         public final String[] keys;
//         public final Integer[] values;
// 
//         public Unzipped(String[] keys, Integer[] values) {
//             this.keys = keys;
//             this.values = values;
//         }
//     }
// 
//     public static Map<String, Integer> zip(String[] keys, Integer[] values) throws IllegalArgumentException {
//         if (keys.length != values.length)
//             throw new IllegalArgumentException("Length of keys and values must match");
// 
//         Map<String, Integer> zipped = new HashMap<>();
//         for (int i = 0; i < keys.length; i++) {
//             zipped.put(keys[i], values[i]);
//         }
// 
//         return zipped;
//     }
// 
//     public static Unzipped unzip(Map<String, Integer> map) {
//         return new Unzipped(map.keySet().toArray(new String[0]), map.values().toArray(new Integer[0]));
//     }
// 
//     public static Map<String, Integer> getValues(DatPack pack) {
//         return zip(pack.keys, pack.values);
//     }
// 
//     public static String serializePacket(Packet packet, DeviceKeyChain deviceKeyChain) {
//         GsonBuilder gsonBuilder = new GsonBuilder();
//         Gson gson = gsonBuilder.create();
// 
//         if (packet.pack != null) {
//             String key = getKey(deviceKeyChain, packet);
//             String plainPack = gson.toJson(packet.pack);
//             packet.encryptedPack = tomikaa.greeremote.Gree.Crypto.encrypt(plainPack, key);
//         }
// 
//         return gson.toJson(packet);
//     }
// 
//     public static Packet deserializePacket(String jsonString, DeviceKeyChain deviceKeyChain) {
//         GsonBuilder gsonBuilder = new GsonBuilder();
//         gsonBuilder.registerTypeAdapter(Pack.class, new PackDeserializer());
// 
//         Gson gson = gsonBuilder.create();
// 
//         Packet packet = gson.fromJson(jsonString, Packet.class);
// 
//         if (packet.encryptedPack != null) {
//             String key = getKey(deviceKeyChain, packet);
//             String plainPack = Crypto.decrypt(packet.encryptedPack, key);
//             packet.pack = gson.fromJson(plainPack, Pack.class);
//         }
// 
//         return packet;
//     }
// 
//     private static String getKey(DeviceKeyChain keyChain, Packet packet) {
//         String key = Crypto.GENERIC_KEY;
// 
//         Log.i("getKey", String.format("packet.cid: %s, packet.tcid: %s", packet.cid, packet.tcid));
// 
//         if (keyChain != null) {
//             if (keyChain.containsKey(packet.cid)) {
//                 key = keyChain.getKey(packet.cid);
//             } else if (keyChain.containsKey(packet.tcid)) {
//                 key = keyChain.getKey(packet.tcid);
//             }
//         }
// 
//         return key;
//     }
// }


import android.util.Log;
import java.util.Map;
import tomikaa.greeremote.Gree.Packs.DatPack;
import tomikaa.greeremote.Gree.Packs.DevicePack;
import tomikaa.greeremote.Gree.Packs.ResultPack;
import tomikaa.greeremote.Gree.Utils;
        @Override
        public String toString() {
            return mParam;
        }
    }

    private String mName = "";
    private Mode mMode = Mode.AUTO;
    private FanSpeed mFanSpeed = FanSpeed.AUTO;
    private int mTemperature = 0;
    private TemperatureUnit mTemperatureUnit = TemperatureUnit.CELSIUS;
    private boolean mPoweredOn;
    private boolean mLightEnabled;
    private boolean mQuietModeEnabled;
    private boolean mTurboModeEnabled;
    private boolean mHealthModeEnabled;
    private boolean mAirModeEnabled;
    private boolean mXfanModeEnabled;
    private boolean mSavingModeEnabled;
    private boolean mSleepModeEnabled;
    private VerticalSwingMode mVerticalSwingMode = VerticalSwingMode.DEFAULT;

    public DeviceImpl(String deviceId, DeviceManager deviceManager) {
        mDeviceId = deviceId;
        mDeviceManager = deviceManager;
        mLogTag = String.format("DeviceImpl(%s)", deviceId);

        Log.i(mLogTag, "Created");
    }

// Path: GreeRemoteAndroid/app/src/main/java/tomikaa/greeremote/Gree/Packs/DatPack.java
// public class DatPack extends Pack {
//     public static String TYPE = "dat";
// 
//     @SerializedName("r")
//     public int resultCode;
// 
//     @SerializedName("cols")
//     public String[] keys;
// 
//     @SerializedName("dat")
//     public Integer[] values;
// 
//     public DatPack() {
//         type = TYPE;
//     }
// }
// 
// Path: GreeRemoteAndroid/app/src/main/java/tomikaa/greeremote/Gree/Packs/DevicePack.java
// public class DevicePack extends Pack {
//     public static String TYPE = "dev";
// 
//     public String cid;
//     public String bc;
//     public String brand;
//     public String catalog;
//     public String mid;
//     public String model;
//     public String name;
//     public String series;
//     public String ver;
//     public Integer lock;
// 
//     @SerializedName("vender")
//     public String vendor;
// 
//     public DevicePack() {
//         type = TYPE;
//     }
// }
// 
// Path: GreeRemoteAndroid/app/src/main/java/tomikaa/greeremote/Gree/Packs/ResultPack.java
// public class ResultPack extends Pack {
//     public static String TYPE = "res";
// 
//     @SerializedName("r")
//     public int resultCode;
// 
//     @SerializedName("opt")
//     public String[] keys;
// 
//     @SerializedName("p")
//     public Integer[] values;
// 
//     public ResultPack() {
//         type = TYPE;
//     }
// }
// 
// Path: GreeRemoteAndroid/app/src/main/java/tomikaa/greeremote/Gree/Utils.java
// public class Utils {
// 
//     public static class Unzipped {
//         public final String[] keys;
//         public final Integer[] values;
// 
//         public Unzipped(String[] keys, Integer[] values) {
//             this.keys = keys;
//             this.values = values;
//         }
//     }
// 
//     public static Map<String, Integer> zip(String[] keys, Integer[] values) throws IllegalArgumentException {
//         if (keys.length != values.length)
//             throw new IllegalArgumentException("Length of keys and values must match");
// 
//         Map<String, Integer> zipped = new HashMap<>();
//         for (int i = 0; i < keys.length; i++) {
//             zipped.put(keys[i], values[i]);
//         }
// 
//         return zipped;
//     }
// 
//     public static Unzipped unzip(Map<String, Integer> map) {
//         return new Unzipped(map.keySet().toArray(new String[0]), map.values().toArray(new Integer[0]));
//     }
// 
//     public static Map<String, Integer> getValues(DatPack pack) {
//         return zip(pack.keys, pack.values);
//     }
// 
//     public static String serializePacket(Packet packet, DeviceKeyChain deviceKeyChain) {
//         GsonBuilder gsonBuilder = new GsonBuilder();
//         Gson gson = gsonBuilder.create();
// 
//         if (packet.pack != null) {
//             String key = getKey(deviceKeyChain, packet);
//             String plainPack = gson.toJson(packet.pack);
//             packet.encryptedPack = tomikaa.greeremote.Gree.Crypto.encrypt(plainPack, key);
//         }
// 
//         return gson.toJson(packet);
//     }
// 
//     public static Packet deserializePacket(String jsonString, DeviceKeyChain deviceKeyChain) {
//         GsonBuilder gsonBuilder = new GsonBuilder();
//         gsonBuilder.registerTypeAdapter(Pack.class, new PackDeserializer());
// 
//         Gson gson = gsonBuilder.create();
// 
//         Packet packet = gson.fromJson(jsonString, Packet.class);
// 
//         if (packet.encryptedPack != null) {
//             String key = getKey(deviceKeyChain, packet);
//             String plainPack = Crypto.decrypt(packet.encryptedPack, key);
//             packet.pack = gson.fromJson(plainPack, Pack.class);
//         }
// 
//         return packet;
//     }
// 
//     private static String getKey(DeviceKeyChain keyChain, Packet packet) {
//         String key = Crypto.GENERIC_KEY;
// 
//         Log.i("getKey", String.format("packet.cid: %s, packet.tcid: %s", packet.cid, packet.tcid));
// 
//         if (keyChain != null) {
//             if (keyChain.containsKey(packet.cid)) {
//                 key = keyChain.getKey(packet.cid);
//             } else if (keyChain.containsKey(packet.tcid)) {
//                 key = keyChain.getKey(packet.tcid);
//             }
//         }
// 
//         return key;
//     }
// }


// Path: GreeRemoteAndroid/app/src/main/java/tomikaa/greeremote/Gree/Device/DeviceImpl.java
import android.util.Log;
import java.util.Map;
import tomikaa.greeremote.Gree.Packs.DatPack;
import tomikaa.greeremote.Gree.Packs.DevicePack;
import tomikaa.greeremote.Gree.Packs.ResultPack;
import tomikaa.greeremote.Gree.Utils;

        @Override
        public String toString() {
            return mParam;
        }
    }

    private String mName = "";
    private Mode mMode = Mode.AUTO;
    private FanSpeed mFanSpeed = FanSpeed.AUTO;
    private int mTemperature = 0;
    private TemperatureUnit mTemperatureUnit = TemperatureUnit.CELSIUS;
    private boolean mPoweredOn;
    private boolean mLightEnabled;
    private boolean mQuietModeEnabled;
    private boolean mTurboModeEnabled;
    private boolean mHealthModeEnabled;
    private boolean mAirModeEnabled;
    private boolean mXfanModeEnabled;
    private boolean mSavingModeEnabled;
    private boolean mSleepModeEnabled;
    private VerticalSwingMode mVerticalSwingMode = VerticalSwingMode.DEFAULT;

    public DeviceImpl(String deviceId, DeviceManager deviceManager) {
        mDeviceId = deviceId;
        mDeviceManager = deviceManager;
        mLogTag = String.format("DeviceImpl(%s)", deviceId);

        Log.i(mLogTag, "Created");
    }

    public void updateWithDatPack(DatPack pack) {