gopro_controller/
services.rs1use uuid::Uuid;
2
3macro_rules! gp_uuid {
6 ($x:expr) => {{
7 let full_uuid = format!("b5f9{}-aa8d-11e3-9046-0002a5d5c51b", $x);
9 Uuid::parse_str(&full_uuid).expect("Invalid UUID")
10 }};
11}
12
13#[test]
14fn test_macro() {
15 let uuid = gp_uuid!("0072");
16 assert_eq!(uuid, gp_uuid!("0072"));
17}
18
19pub trait ToUUID {
21 fn to_uuid(&self) -> Uuid;
22}
23
24pub trait Sendable {
26 fn as_bytes(&self) -> &'static [u8];
27 fn response_value_bytes(&self) -> &'static [u8];
28}
29
30pub enum GoProServices {
32 #[cfg(feature = "wifi")]
33 GoProWiFiAp,
34 #[cfg(feature = "wifi")]
35 GoProCamManagement,
36 ControlAndQuery,
37}
38
39impl ToUUID for GoProServices {
40 fn to_uuid(&self) -> Uuid {
41 match self {
42 #[cfg(feature = "wifi")]
43 GoProServices::GoProWiFiAp => gp_uuid!("0001"),
44 #[cfg(feature = "wifi")]
45 GoProServices::GoProCamManagement => gp_uuid!("0090"),
46 GoProServices::ControlAndQuery => gp_uuid!("FEA6"),
47 }
48 }
49}
50
51#[cfg(feature = "wifi")]
55pub enum GoProWifiApCharacteristics {
56 SSID,
57 Password,
58 Power,
59 State,
60}
61
62#[cfg(feature = "wifi")]
63use GoProWifiApCharacteristics as GPWAC; #[cfg(feature = "wifi")]
66impl ToUUID for GoProWifiApCharacteristics {
67 fn to_uuid(&self) -> Uuid {
68 match self {
69 GPWAC::SSID => gp_uuid!("0002"),
70 GPWAC::Password => gp_uuid!("0003"),
71 GPWAC::Power => gp_uuid!("0004"),
72 GPWAC::State => gp_uuid!("0005"),
73 }
74 }
75}
76
77#[cfg(feature = "wifi")]
81pub enum GoProManagementCharacteristics {
82 NetworkManagementCommand,
83 NetworkManagementResponse,
84}
85
86#[cfg(feature = "wifi")]
87use GoProManagementCharacteristics as GPMC; #[cfg(feature = "wifi")]
89impl ToUUID for GoProManagementCharacteristics {
90 fn to_uuid(&self) -> Uuid {
91 match self {
92 GPMC::NetworkManagementCommand => gp_uuid!("0091"),
93 GPMC::NetworkManagementResponse => gp_uuid!("0092"),
94 }
95 }
96}
97
98pub enum GoProControlAndQueryCharacteristics {
100 Command,
101 CommandResponse,
102 Settings,
103 SettingsResponse,
104 Query,
105 QueryResponse,
106}
107
108use GoProControlAndQueryCharacteristics as GPCAQ; impl ToUUID for GoProControlAndQueryCharacteristics {
110 fn to_uuid(&self) -> Uuid {
111 match self {
112 GPCAQ::Command => gp_uuid!("0072"),
113 GPCAQ::CommandResponse => gp_uuid!("0073"),
114 GPCAQ::Settings => gp_uuid!("0074"),
115 GPCAQ::SettingsResponse => gp_uuid!("0075"),
116 GPCAQ::Query => gp_uuid!("0076"),
117 GPCAQ::QueryResponse => gp_uuid!("0077"),
118 }
119 }
120}