001/* Copyright (C) Cross The Road Electronics 2024 */
002package com.ctre.phoenix;
003
004/**
005 * Interface for uart gadgeteer devices
006 */
007public interface GadgeteerUartClient
008{
009        /**
010         * Device connected to gadgeteer
011         */
012        public enum GadgeteerProxyType{
013                /**
014                 * General Gadgeteer Proxy
015                 */
016                General(0), 
017                /**
018                 * Pigeon connected to gadgeteer
019                 */
020                Pigeon(1), 
021                /**
022                 * HERO connected to gadgeteer
023                 */
024                PC_HERO(2),
025                /**
026                 * Device unknown
027                 */
028                Unknown(-1);
029
030                private int value; 
031                private GadgeteerProxyType(int value) { this.value = value; }
032                
033                /**
034                 * Get GadgeteerProxyType of specified value
035                 * @param value Value of GadgeteerProxyType
036                 * @return GadgeteerProxyType of specified value
037                 */
038                public static GadgeteerProxyType valueOf(int value) {
039                        for (GadgeteerProxyType e : GadgeteerProxyType.values()) {
040                                if (e.value == value) {
041                                        return e;
042                                }
043                        }
044                        return Unknown;
045                }
046        };
047
048        /**
049         * Method of connection to gadgeteer
050         */
051        public enum GadgeteerConnection {
052                /**
053                 * Device not connected
054                 */
055                NotConnected (0),
056                /**
057                 * Device in process of connecting
058                 */
059                Connecting (1),
060                /**
061                 * Device is connected
062                 */
063                Connected (2),
064                /**
065                 * Device unknown
066                 */
067                Unknown(-1);
068                
069                private int value; 
070                private GadgeteerConnection(int value) { this.value = value; } 
071
072                /**
073                 * Get GadgeteerConnection of specified value
074                 * @param value Value of GadgeteerConnection
075                 * @return GadgeteerConnection of specified value
076                 */
077                public static GadgeteerConnection valueOf(int value) {
078                        for (GadgeteerConnection e : GadgeteerConnection.values()) {
079                                if (e.value == value) {
080                                        return e;
081                                }
082                        }
083                        return Unknown;
084                }
085        };
086
087        /**
088         * The status of the gadgeteer device
089         */
090        public static class GadgeteerUartStatus {
091                /** Type of gadgeteer */
092                public GadgeteerProxyType type;
093                /** Connection status */
094                public GadgeteerConnection conn;
095                /** Bitrate of connection */
096                public int bitrate;
097                /** Number of resets that have happened */
098                public int resetCount;
099        };
100
101        /**
102         * Gets gadgeteer status
103         * @param status status object to fill
104         * @return ErrorCode
105         */
106    int getGadgeteerStatus(GadgeteerUartStatus status);
107};
108