// Path: FlyverRCApp/IPC/src/main/java/co/flyver/IPC/JSONUtils.java
// public class JSONUtils {
//     private static Gson mGson = new Gson();
//     private static final String TAG = "JSONIPC";
// 
//     /**
//      * Validates if a string is a valid JSON object
//      *
//      * @param json - String to be validated
//      * @return - boolean, true if the string is a valid JSON object
//      */
//     public static boolean validateJson(String json) {
//         try {
//             mGson.fromJson(json, Object.class);
//             return true;
//         } catch (JsonSyntaxException e) {
//             return false;
//         }
//     }
// 
//     private static <T> T fromJSON(String json, Type type) {
// 
//         if (validateJson(json)) {
//             return mGson.fromJson(json, type);
//         } else {
//             return null;
//         }
//     }
// 
//     public static <T> T deserialize(String json, Type type) {
//         T jsonObj;
//         jsonObj = co.flyver.IPC.JSONUtils.fromJSON(json, type);
//         if (jsonObj == null) {
//             throw new NullPointerException("JSON is null");
//         }
//         return jsonObj;
//     }
// 
//     public static <T> String serialize(T t, Type type) {
//         return mGson.toJson(t, type);
//     }
// 
// }
// 
// Path: FlyverRCApp/IPC/src/main/java/co/flyver/IPC/Tuples.java
// public static class Triple<K, A, V> {
// 
//     public K key;
//     public A value1;
//     public V value2;
// 
// 
//     public K getKey() {
//         return key;
//     }
// 
//     public A getValue1() {
//         return value1;
//     }
// 
//     public V getValue2() {
//         return value2;
//     }
// 
//     public Triple() {
//     }
// 
//     public Triple(K key, A value1, V value2) {
//         this.key = key;
//         this.value1 = value1;
//         this.value2 = value2;
//     }
// 
// }
// 
// Path: FlyverRCApp/IPC/src/main/java/co/flyver/IPC/SharedIPCKeys.java
// public class SharedIPCKeys {
//     public static final String COORDINATES = "coordinates";
//     public static final String YAW = "yaw";
//     public static final String THROTTLE = "throttle";
//     public static final String INCREASE = "increase";
//     public static final String DECREASE = "decrease";
//     public static final String EMERGENCY = "emergency";
//     public static final String PIDYAW = "pidy";
//     public static final String PIDPITCH = "pidp";
//     public static final String PIDROLL = "pidr";
//     public static final String PROPORTIONAL = "proportional";
//     public static final String INTEGRAL = "integral";
//     public static final String DERIVATIVE = "derivative";
//     public static final String PICTURE = "picture";
//     public static final String PICREADY = "picready";
//     public static final String HEARTBEAT = "heartbeat";
// }


import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import co.flyver.IPC.JSONUtils;
import static co.flyver.IPC.Tuples.Triple;
import static co.flyver.IPC.SharedIPCKeys.*;
        Triple<String, String, Float> jsonTriple;
        Type type = new TypeToken<Triple<String, String, Float>>() {}.getType();
        switch (change) {
            case INCREASE:
                jsonTriple = new Triple<>(THROTTLE, INCREASE, STEP * steps);
                Client.sendMsg(JSONUtils.serialize(jsonTriple, type));
                jsonIntent.putExtra("json", JSONUtils.serialize(jsonTriple, type));
                context.sendBroadcast(jsonIntent);
                break;
            case DECREASE:
                jsonTriple = new Triple<>(THROTTLE, DECREASE, STEP * steps);
                Client.sendMsg(JSONUtils.serialize(jsonTriple, type));
                jsonIntent.putExtra("json", JSONUtils.serialize(jsonTriple, type));
                context.sendBroadcast(jsonIntent);
                break;
        }
    }

    private void changeYaw(int steps, Change change) {
        Triple<String, String, Float> jsonTriple;
        Type type = new TypeToken<Triple<String, String, Float>>() {}.getType();
        switch (change) {
            case INCREASE:
                jsonTriple = new Triple<>(YAW, INCREASE, STEP * steps);
                Client.sendMsg(JSONUtils.serialize(jsonTriple, type));
                jsonIntent.putExtra("json", JSONUtils.serialize(jsonTriple, type));
                context.sendBroadcast(jsonIntent);
                break;
            case DECREASE:
                jsonTriple = new Triple<>(YAW, DECREASE, STEP * steps);
// Path: FlyverRCApp/IPC/src/main/java/co/flyver/IPC/JSONUtils.java
// public class JSONUtils {
//     private static Gson mGson = new Gson();
//     private static final String TAG = "JSONIPC";
// 
//     /**
//      * Validates if a string is a valid JSON object
//      *
//      * @param json - String to be validated
//      * @return - boolean, true if the string is a valid JSON object
//      */
//     public static boolean validateJson(String json) {
//         try {
//             mGson.fromJson(json, Object.class);
//             return true;
//         } catch (JsonSyntaxException e) {
//             return false;
//         }
//     }
// 
//     private static <T> T fromJSON(String json, Type type) {
// 
//         if (validateJson(json)) {
//             return mGson.fromJson(json, type);
//         } else {
//             return null;
//         }
//     }
// 
//     public static <T> T deserialize(String json, Type type) {
//         T jsonObj;
//         jsonObj = co.flyver.IPC.JSONUtils.fromJSON(json, type);
//         if (jsonObj == null) {
//             throw new NullPointerException("JSON is null");
//         }
//         return jsonObj;
//     }
// 
//     public static <T> String serialize(T t, Type type) {
//         return mGson.toJson(t, type);
//     }
// 
// }
// 
// Path: FlyverRCApp/IPC/src/main/java/co/flyver/IPC/Tuples.java
// public static class Triple<K, A, V> {
// 
//     public K key;
//     public A value1;
//     public V value2;
// 
// 
//     public K getKey() {
//         return key;
//     }
// 
//     public A getValue1() {
//         return value1;
//     }
// 
//     public V getValue2() {
//         return value2;
//     }
// 
//     public Triple() {
//     }
// 
//     public Triple(K key, A value1, V value2) {
//         this.key = key;
//         this.value1 = value1;
//         this.value2 = value2;
//     }
// 
// }
// 
// Path: FlyverRCApp/IPC/src/main/java/co/flyver/IPC/SharedIPCKeys.java
// public class SharedIPCKeys {
//     public static final String COORDINATES = "coordinates";
//     public static final String YAW = "yaw";
//     public static final String THROTTLE = "throttle";
//     public static final String INCREASE = "increase";
//     public static final String DECREASE = "decrease";
//     public static final String EMERGENCY = "emergency";
//     public static final String PIDYAW = "pidy";
//     public static final String PIDPITCH = "pidp";
//     public static final String PIDROLL = "pidr";
//     public static final String PROPORTIONAL = "proportional";
//     public static final String INTEGRAL = "integral";
//     public static final String DERIVATIVE = "derivative";
//     public static final String PICTURE = "picture";
//     public static final String PICREADY = "picready";
//     public static final String HEARTBEAT = "heartbeat";
// }


// Path: FlyverRCApp/Client/src/main/java/co/flyver/Client/JoystickListener.java
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import com.google.gson.reflect.TypeToken;
import java.lang.reflect.Type;
import co.flyver.IPC.JSONUtils;
import static co.flyver.IPC.Tuples.Triple;
import static co.flyver.IPC.SharedIPCKeys.*;

        Triple<String, String, Float> jsonTriple;
        Type type = new TypeToken<Triple<String, String, Float>>() {}.getType();
        switch (change) {
            case INCREASE:
                jsonTriple = new Triple<>(THROTTLE, INCREASE, STEP * steps);
                Client.sendMsg(JSONUtils.serialize(jsonTriple, type));
                jsonIntent.putExtra("json", JSONUtils.serialize(jsonTriple, type));
                context.sendBroadcast(jsonIntent);
                break;
            case DECREASE:
                jsonTriple = new Triple<>(THROTTLE, DECREASE, STEP * steps);
                Client.sendMsg(JSONUtils.serialize(jsonTriple, type));
                jsonIntent.putExtra("json", JSONUtils.serialize(jsonTriple, type));
                context.sendBroadcast(jsonIntent);
                break;
        }
    }

    private void changeYaw(int steps, Change change) {
        Triple<String, String, Float> jsonTriple;
        Type type = new TypeToken<Triple<String, String, Float>>() {}.getType();
        switch (change) {
            case INCREASE:
                jsonTriple = new Triple<>(YAW, INCREASE, STEP * steps);
                Client.sendMsg(JSONUtils.serialize(jsonTriple, type));
                jsonIntent.putExtra("json", JSONUtils.serialize(jsonTriple, type));
                context.sendBroadcast(jsonIntent);
                break;
            case DECREASE:
                jsonTriple = new Triple<>(YAW, DECREASE, STEP * steps);
                Client.sendMsg(JSONUtils.serialize(jsonTriple, type));