CTRE Phoenix C++ 5.33.1
GadgeteerUartClient.h
Go to the documentation of this file.
1/* Copyright (C) Cross The Road Electronics 2024 */
2#ifndef GadgeteerUartClient_h_
3#define GadgeteerUartClient_h_
4#include <stdint.h>
5#include <string>
6
7/**
8 * Interface for uart gadgeteer devices
9 */
11{
12public:
15
16 /**
17 * Device connected to gadgeteer
18 */
20 {
21 /**
22 * General Gadgeteer Proxy
23 */
25 /**
26 * Pigeon connected to gadgeteer
27 */
28 Pigeon = 1,
29 /**
30 * HERO connected to gadgeteer
31 */
33 };
34 /**
35 * Method of connection to gadgeteer
36 */
38 {
39 /**
40 * Device not connected
41 */
43 /**
44 * Device in process of connecting
45 */
47 /**
48 * Device is connected
49 */
51 };
52 /**
53 * The status of the gadgeteer device
54 */
56 /** Type of gadgeteer */
58 /** Connection status */
60 /** Bitrate of connection */
61 uint32_t bitrate;
62 /** Number of resets that have happened */
63 uint32_t resetCount;
64 };
65
66 /**
67 * Gets gadgeteer status
68 * @param status status object to fill
69 * @return ErrorCode
70 */
71 virtual int GetGadgeteerStatus(GadgeteerUartStatus & status) = 0;
72
73 /**
74 * Gets the string representation of GadgeteerProxyType
75 * @param gpt GadgeteerProxyType to get the string of
76 * @return strnig representation of GadgeteerProxyType
77 */
79 std::string retval;
80 switch(gpt) {
81 case General: retval = "General"; break;
82 case Pigeon : retval = "Pigeon"; break;
83 case PC_HERO: retval = "PC_HERO"; break;
84 }
85 return retval;
86 }
87 /**
88 * Gets the string representation of GadgeteerConnection
89 * @param gc GadgeteerConnection to get the string of
90 * @return strnig representation of GadgeteerConnection
91 */
93 std::string retval;
94 switch(gc) {
95 case NotConnected: retval = "NotConnected"; break;
96 case Connecting : retval = "Connecting"; break;
97 case Connected: retval = "Connected"; break;
98 }
99 return retval;
100 }
101
102protected:
103};
104#endif
Interface for uart gadgeteer devices.
Definition: GadgeteerUartClient.h:11
virtual int GetGadgeteerStatus(GadgeteerUartStatus &status)=0
Gets gadgeteer status.
static std::string ToString(IGadgeteerUartClient::GadgeteerProxyType gpt)
Gets the string representation of GadgeteerProxyType.
Definition: GadgeteerUartClient.h:78
GadgeteerProxyType
Device connected to gadgeteer.
Definition: GadgeteerUartClient.h:20
@ PC_HERO
HERO connected to gadgeteer.
Definition: GadgeteerUartClient.h:32
@ Pigeon
Pigeon connected to gadgeteer.
Definition: GadgeteerUartClient.h:28
@ General
General Gadgeteer Proxy.
Definition: GadgeteerUartClient.h:24
virtual ~IGadgeteerUartClient()
Definition: GadgeteerUartClient.h:14
IGadgeteerUartClient()
Definition: GadgeteerUartClient.h:13
GadgeteerConnection
Method of connection to gadgeteer.
Definition: GadgeteerUartClient.h:38
@ NotConnected
Device not connected.
Definition: GadgeteerUartClient.h:42
@ Connecting
Device in process of connecting.
Definition: GadgeteerUartClient.h:46
@ Connected
Device is connected.
Definition: GadgeteerUartClient.h:50
static std::string ToString(IGadgeteerUartClient::GadgeteerConnection gc)
Gets the string representation of GadgeteerConnection.
Definition: GadgeteerUartClient.h:92
The status of the gadgeteer device.
Definition: GadgeteerUartClient.h:55
uint32_t resetCount
Number of resets that have happened.
Definition: GadgeteerUartClient.h:63
GadgeteerConnection conn
Connection status.
Definition: GadgeteerUartClient.h:59
GadgeteerProxyType type
Type of gadgeteer.
Definition: GadgeteerUartClient.h:57
uint32_t bitrate
Bitrate of connection.
Definition: GadgeteerUartClient.h:61