@@ -12,6 +12,15 @@ pub struct NTN<'a, IOM: Write<SevenBitAddress> + Read<SevenBitAddress>, const BS
12
12
note : & ' a mut Notecard < IOM , BS > ,
13
13
}
14
14
15
+ #[ derive( Clone , Copy , defmt:: Format ) ]
16
+ pub enum NtnSetGps {
17
+ /// Use notecard gps on starnote as well
18
+ Notecard ,
19
+
20
+ /// Use starnotes own gps (default).
21
+ Starnote ,
22
+ }
23
+
15
24
impl < ' a , IOM : Write < SevenBitAddress > + Read < SevenBitAddress > , const BS : usize > NTN < ' a , IOM , BS > {
16
25
pub fn from ( note : & mut Notecard < IOM , BS > ) -> NTN < ' _ , IOM , BS > {
17
26
NTN { note }
@@ -22,8 +31,7 @@ impl<'a, IOM: Write<SevenBitAddress> + Read<SevenBitAddress>, const BS: usize> N
22
31
self ,
23
32
delay : & mut impl DelayMs < u16 > ,
24
33
) -> Result < FutureResponse < ' a , res:: Empty , IOM , BS > , NoteError > {
25
- self . note
26
- . request_raw ( delay, b"{\" req\" :\" ntn.reset\" }\n " ) ?;
34
+ self . note . request_raw ( delay, b"{\" req\" :\" ntn.reset\" }\n " ) ?;
27
35
Ok ( FutureResponse :: from ( self . note ) )
28
36
}
29
37
@@ -38,10 +46,38 @@ impl<'a, IOM: Write<SevenBitAddress> + Read<SevenBitAddress>, const BS: usize> N
38
46
39
47
Ok ( FutureResponse :: from ( self . note ) )
40
48
}
49
+
50
+ /// Determines whether a Notecard should override a paired Starnote's GPS/GNSS location with its own GPS/GNSS location. The paired Starnote uses its own GPS/GNSS location by default.
51
+ pub fn gps (
52
+ self ,
53
+ delay : & mut impl DelayMs < u16 > ,
54
+ gps : Option < NtnSetGps > ,
55
+ ) -> Result < FutureResponse < ' a , res:: Gps , IOM , BS > , NoteError > {
56
+ self . note . request (
57
+ delay,
58
+ req:: Gps {
59
+ req : "ntn.gps" ,
60
+ on : gps. map ( |g| matches ! ( g, NtnSetGps :: Notecard ) ) ,
61
+ off : gps. map ( |g| matches ! ( g, NtnSetGps :: Starnote ) ) ,
62
+ } ,
63
+ ) ?;
64
+ Ok ( FutureResponse :: from ( self . note ) )
65
+ }
41
66
}
42
67
43
68
pub mod req {
44
69
use super :: * ;
70
+
71
+ #[ derive( Deserialize , Serialize , defmt:: Format , Default ) ]
72
+ pub struct Gps {
73
+ pub req : & ' static str ,
74
+
75
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
76
+ pub on : Option < bool > ,
77
+
78
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
79
+ pub off : Option < bool > ,
80
+ }
45
81
}
46
82
47
83
pub mod res {
@@ -50,15 +86,23 @@ pub mod res {
50
86
#[ derive( Deserialize , defmt:: Format ) ]
51
87
pub struct Empty { }
52
88
89
+ #[ derive( Deserialize , Serialize , defmt:: Format , Default ) ]
90
+ pub struct Gps {
91
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
92
+ pub on : Option < bool > ,
93
+
94
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
95
+ pub off : Option < bool > ,
96
+ }
97
+
53
98
#[ derive( Deserialize , defmt:: Format ) ]
54
99
pub struct Status {
55
100
pub err : Option < heapless:: String < 120 > > ,
56
101
pub status : Option < heapless:: String < 120 > > ,
57
102
}
58
103
}
59
104
60
- #[ cfg( test) ]
61
- mod tests {
62
- use super :: * ;
63
- }
64
-
105
+ // #[cfg(test)]
106
+ // mod tests {
107
+ // use super::*;
108
+ // }
0 commit comments