// Path: common/src/main/java/com/github/jbarr21/goproremote/common/utils/GoProStateParser.java
// public class GoProStateParser {
//     public static GoProState from(byte[] bytes) {
//         if (bytes.length > 30) {
//             // Camera is On
//             return GoProState.builder()
//                     .rawState(bytes)
//                     .currentMode(GoProMode.values()[bytes[1]])
//                     .startupMode(GoProMode.values()[bytes[3]])
//                     .recordingMinutes(bytes[13])
//                     .recordingSeconds(bytes[14])
//                     .beepVolume(bytes[16])
//                     .ledState(LedState.values()[bytes[17]])
//                     .orientation(Orientation.UP) // TODO: figure out how to get this
//                     .batteryPercent(bytes[19])
//                     .photosAvailable(toInt(bytes[21], bytes[22]))
//                     .photoCount(toInt(bytes[23], bytes[24]))
//                     .videoAvailableMinutes(toInt(bytes[25], bytes[26]))
//                     .videoCount(toInt(bytes[27], bytes[28]))
//                     .recording(bytes[29] > 0)
//                     .build();
//         } else {
//             // Camera is OFF
//             return GoProState.CAMERA_OFF;
//         }
//     }
// 
//     public static GoProState cameraOff() {
//         return GoProState.builder()
//                 .rawState(new byte[0])
//                 .currentMode(GoProMode.VIDEO)
//                 .startupMode(GoProMode.VIDEO)
//                 .recordingMinutes(0)
//                 .recordingSeconds(0)
//                 .beepVolume(0)
//                 .ledState(LedState.NONE)
//                 .orientation(Orientation.UP)
//                 .batteryPercent(0)
//                 .photosAvailable(0)
//                 .photoCount(0)
//                 .videoAvailableMinutes(0)
//                 .videoCount(0)
//                 .recording(false)
//                 .build();
//     }
// 
//     static int toInt(byte highByte, byte lowByte) {
//         return highByte << 8 | lowByte;
//     }
// }


import com.github.jbarr21.goproremote.common.utils.GoProStateParser;
import com.google.auto.value.AutoValue;
import java.util.Arrays;
package com.github.jbarr21.goproremote.common.data;



/**
 * Legend: https://github.com/KonradIT/goprowifihack/blob/master/ByteStates.md
 *
 * b# | value
 * ---|--------
 * 0 | ?
 * 1 | Current mode. 0-4 matches set CM. 7 - in menu.
 * 2 | ?
 * 3 | Start up mode : 0 = video - 1 = photo - 2 = burst - 3 = timelapse
 * 4 | Spot meter : 0 = Off - 1 = On
 * 5 | Current timelapse interval
 * 6 | Automatic power off : 0 = never - 1 = 60sec - 2 = 120sec - 3 = 300sec
 * 7 | Current view angle
 * 8 | Current photo mode
 * 9 | Current video mode
 * 10 | ?
 * 11 | ?
 * 12 | ?
 * 13 | Recording minutes
 * 14 | Recording seconds
 * 15 | ?
 * 16 | Current beep volume
 * 17 | 2 = 4 LEDS - 1 = 2 LEDS - 0 = LEDS off
 * 18 | bit 1 : 1 = preview on - 0 = preview off / bit 2 : ? / bit 3 : 0 = up - 1 = down / bit 4 : 1 = one button on - 0 = one button off / bit 5 : 1 = OSD on - 0 = OSD off / bit 6 : 0 = NTSC - 1 = PAL / bit 7 : 1 = Locate(beeping) / bit 8 : ?
 * 19 | Battery %
 * 20 | ?
 * 21 | Photos available (hi byte) or 255 = no SD Card
 * 22 | Photos available (lo byte)
 * 23 | Photo count (hi byte)
 * 24 | Photo count (lo byte)
 * 25 | Video Time Remaining in minutes (hi byte)
 * 26 | Video Time Left (lo byte)
 * 27 | Video count (hi byte)
 * 28 | Video count (lo byte)
 * 29 | Recording
 * 30 | ?
 */
@AutoValue
public abstract class GoProState {

    public static final GoProState CAMERA_OFF = GoProStateParser.cameraOff();

    private static final int NO_SD_CARD = 255;

    public abstract byte[] rawState();
    public abstract GoProMode currentMode();
    public abstract GoProMode startupMode();
    public abstract int recordingMinutes();
    public abstract int recordingSeconds();
    public abstract int beepVolume();
    public abstract LedState ledState();
    //public abstract boolean previewEnabled();
    public abstract Orientation orientation();
    public abstract int batteryPercent(); // 99 for 99%
    public abstract int photosAvailable();
    public abstract int photoCount();
    public abstract int videoAvailableMinutes();
// Path: common/src/main/java/com/github/jbarr21/goproremote/common/utils/GoProStateParser.java
// public class GoProStateParser {
//     public static GoProState from(byte[] bytes) {
//         if (bytes.length > 30) {
//             // Camera is On
//             return GoProState.builder()
//                     .rawState(bytes)
//                     .currentMode(GoProMode.values()[bytes[1]])
//                     .startupMode(GoProMode.values()[bytes[3]])
//                     .recordingMinutes(bytes[13])
//                     .recordingSeconds(bytes[14])
//                     .beepVolume(bytes[16])
//                     .ledState(LedState.values()[bytes[17]])
//                     .orientation(Orientation.UP) // TODO: figure out how to get this
//                     .batteryPercent(bytes[19])
//                     .photosAvailable(toInt(bytes[21], bytes[22]))
//                     .photoCount(toInt(bytes[23], bytes[24]))
//                     .videoAvailableMinutes(toInt(bytes[25], bytes[26]))
//                     .videoCount(toInt(bytes[27], bytes[28]))
//                     .recording(bytes[29] > 0)
//                     .build();
//         } else {
//             // Camera is OFF
//             return GoProState.CAMERA_OFF;
//         }
//     }
// 
//     public static GoProState cameraOff() {
//         return GoProState.builder()
//                 .rawState(new byte[0])
//                 .currentMode(GoProMode.VIDEO)
//                 .startupMode(GoProMode.VIDEO)
//                 .recordingMinutes(0)
//                 .recordingSeconds(0)
//                 .beepVolume(0)
//                 .ledState(LedState.NONE)
//                 .orientation(Orientation.UP)
//                 .batteryPercent(0)
//                 .photosAvailable(0)
//                 .photoCount(0)
//                 .videoAvailableMinutes(0)
//                 .videoCount(0)
//                 .recording(false)
//                 .build();
//     }
// 
//     static int toInt(byte highByte, byte lowByte) {
//         return highByte << 8 | lowByte;
//     }
// }


// Path: common/src/main/java/com/github/jbarr21/goproremote/common/data/GoProState.java
import com.github.jbarr21.goproremote.common.utils.GoProStateParser;
import com.google.auto.value.AutoValue;
import java.util.Arrays;

package com.github.jbarr21.goproremote.common.data;



/**
 * Legend: https://github.com/KonradIT/goprowifihack/blob/master/ByteStates.md
 *
 * b# | value
 * ---|--------
 * 0 | ?
 * 1 | Current mode. 0-4 matches set CM. 7 - in menu.
 * 2 | ?
 * 3 | Start up mode : 0 = video - 1 = photo - 2 = burst - 3 = timelapse
 * 4 | Spot meter : 0 = Off - 1 = On
 * 5 | Current timelapse interval
 * 6 | Automatic power off : 0 = never - 1 = 60sec - 2 = 120sec - 3 = 300sec
 * 7 | Current view angle
 * 8 | Current photo mode
 * 9 | Current video mode
 * 10 | ?
 * 11 | ?
 * 12 | ?
 * 13 | Recording minutes
 * 14 | Recording seconds
 * 15 | ?
 * 16 | Current beep volume
 * 17 | 2 = 4 LEDS - 1 = 2 LEDS - 0 = LEDS off
 * 18 | bit 1 : 1 = preview on - 0 = preview off / bit 2 : ? / bit 3 : 0 = up - 1 = down / bit 4 : 1 = one button on - 0 = one button off / bit 5 : 1 = OSD on - 0 = OSD off / bit 6 : 0 = NTSC - 1 = PAL / bit 7 : 1 = Locate(beeping) / bit 8 : ?
 * 19 | Battery %
 * 20 | ?
 * 21 | Photos available (hi byte) or 255 = no SD Card
 * 22 | Photos available (lo byte)
 * 23 | Photo count (hi byte)
 * 24 | Photo count (lo byte)
 * 25 | Video Time Remaining in minutes (hi byte)
 * 26 | Video Time Left (lo byte)
 * 27 | Video count (hi byte)
 * 28 | Video count (lo byte)
 * 29 | Recording
 * 30 | ?
 */
@AutoValue
public abstract class GoProState {

    public static final GoProState CAMERA_OFF = GoProStateParser.cameraOff();

    private static final int NO_SD_CARD = 255;

    public abstract byte[] rawState();
    public abstract GoProMode currentMode();
    public abstract GoProMode startupMode();
    public abstract int recordingMinutes();
    public abstract int recordingSeconds();
    public abstract int beepVolume();
    public abstract LedState ledState();
    //public abstract boolean previewEnabled();
    public abstract Orientation orientation();
    public abstract int batteryPercent(); // 99 for 99%
    public abstract int photosAvailable();
    public abstract int photoCount();
    public abstract int videoAvailableMinutes();
    public abstract int videoCount();