1#[allow(unused_imports)]
15use crate::{
16 base58::Uid, byte_converter::*, converting_receiver::BrickletRecvTimeoutError, device::*, error::TinkerforgeError,
17 ip_connection::async_io::AsyncIpConnection, low_level_traits::LowLevelRead,
18};
19#[allow(unused_imports)]
20use futures_core::Stream;
21#[allow(unused_imports)]
22use tokio_stream::StreamExt;
23pub enum GpsV3BrickletFunction {
24 GetCoordinates,
25 GetStatus,
26 GetAltitude,
27 GetMotion,
28 GetDateTime,
29 Restart,
30 GetSatelliteSystemStatusLowLevel,
31 GetSatelliteStatus,
32 SetFixLedConfig,
33 GetFixLedConfig,
34 SetCoordinatesCallbackPeriod,
35 GetCoordinatesCallbackPeriod,
36 SetStatusCallbackPeriod,
37 GetStatusCallbackPeriod,
38 SetAltitudeCallbackPeriod,
39 GetAltitudeCallbackPeriod,
40 SetMotionCallbackPeriod,
41 GetMotionCallbackPeriod,
42 SetDateTimeCallbackPeriod,
43 GetDateTimeCallbackPeriod,
44 SetSbasConfig,
45 GetSbasConfig,
46 GetSpitfpErrorCount,
47 SetBootloaderMode,
48 GetBootloaderMode,
49 SetWriteFirmwarePointer,
50 WriteFirmware,
51 SetStatusLedConfig,
52 GetStatusLedConfig,
53 GetChipTemperature,
54 Reset,
55 WriteUid,
56 ReadUid,
57 GetIdentity,
58 CallbackPulsePerSecond,
59 CallbackCoordinates,
60 CallbackStatus,
61 CallbackAltitude,
62 CallbackMotion,
63 CallbackDateTime,
64}
65impl From<GpsV3BrickletFunction> for u8 {
66 fn from(fun: GpsV3BrickletFunction) -> Self {
67 match fun {
68 GpsV3BrickletFunction::GetCoordinates => 1,
69 GpsV3BrickletFunction::GetStatus => 2,
70 GpsV3BrickletFunction::GetAltitude => 3,
71 GpsV3BrickletFunction::GetMotion => 4,
72 GpsV3BrickletFunction::GetDateTime => 5,
73 GpsV3BrickletFunction::Restart => 6,
74 GpsV3BrickletFunction::GetSatelliteSystemStatusLowLevel => 7,
75 GpsV3BrickletFunction::GetSatelliteStatus => 8,
76 GpsV3BrickletFunction::SetFixLedConfig => 9,
77 GpsV3BrickletFunction::GetFixLedConfig => 10,
78 GpsV3BrickletFunction::SetCoordinatesCallbackPeriod => 11,
79 GpsV3BrickletFunction::GetCoordinatesCallbackPeriod => 12,
80 GpsV3BrickletFunction::SetStatusCallbackPeriod => 13,
81 GpsV3BrickletFunction::GetStatusCallbackPeriod => 14,
82 GpsV3BrickletFunction::SetAltitudeCallbackPeriod => 15,
83 GpsV3BrickletFunction::GetAltitudeCallbackPeriod => 16,
84 GpsV3BrickletFunction::SetMotionCallbackPeriod => 17,
85 GpsV3BrickletFunction::GetMotionCallbackPeriod => 18,
86 GpsV3BrickletFunction::SetDateTimeCallbackPeriod => 19,
87 GpsV3BrickletFunction::GetDateTimeCallbackPeriod => 20,
88 GpsV3BrickletFunction::SetSbasConfig => 27,
89 GpsV3BrickletFunction::GetSbasConfig => 28,
90 GpsV3BrickletFunction::GetSpitfpErrorCount => 234,
91 GpsV3BrickletFunction::SetBootloaderMode => 235,
92 GpsV3BrickletFunction::GetBootloaderMode => 236,
93 GpsV3BrickletFunction::SetWriteFirmwarePointer => 237,
94 GpsV3BrickletFunction::WriteFirmware => 238,
95 GpsV3BrickletFunction::SetStatusLedConfig => 239,
96 GpsV3BrickletFunction::GetStatusLedConfig => 240,
97 GpsV3BrickletFunction::GetChipTemperature => 242,
98 GpsV3BrickletFunction::Reset => 243,
99 GpsV3BrickletFunction::WriteUid => 248,
100 GpsV3BrickletFunction::ReadUid => 249,
101 GpsV3BrickletFunction::GetIdentity => 255,
102 GpsV3BrickletFunction::CallbackPulsePerSecond => 21,
103 GpsV3BrickletFunction::CallbackCoordinates => 22,
104 GpsV3BrickletFunction::CallbackStatus => 23,
105 GpsV3BrickletFunction::CallbackAltitude => 24,
106 GpsV3BrickletFunction::CallbackMotion => 25,
107 GpsV3BrickletFunction::CallbackDateTime => 26,
108 }
109 }
110}
111pub const GPS_V3_BRICKLET_RESTART_TYPE_HOT_START: u8 = 0;
112pub const GPS_V3_BRICKLET_RESTART_TYPE_WARM_START: u8 = 1;
113pub const GPS_V3_BRICKLET_RESTART_TYPE_COLD_START: u8 = 2;
114pub const GPS_V3_BRICKLET_RESTART_TYPE_FACTORY_RESET: u8 = 3;
115pub const GPS_V3_BRICKLET_SATELLITE_SYSTEM_GPS: u8 = 0;
116pub const GPS_V3_BRICKLET_SATELLITE_SYSTEM_GLONASS: u8 = 1;
117pub const GPS_V3_BRICKLET_SATELLITE_SYSTEM_GALILEO: u8 = 2;
118pub const GPS_V3_BRICKLET_FIX_NO_FIX: u8 = 1;
119pub const GPS_V3_BRICKLET_FIX_2D_FIX: u8 = 2;
120pub const GPS_V3_BRICKLET_FIX_3D_FIX: u8 = 3;
121pub const GPS_V3_BRICKLET_FIX_LED_CONFIG_OFF: u8 = 0;
122pub const GPS_V3_BRICKLET_FIX_LED_CONFIG_ON: u8 = 1;
123pub const GPS_V3_BRICKLET_FIX_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
124pub const GPS_V3_BRICKLET_FIX_LED_CONFIG_SHOW_FIX: u8 = 3;
125pub const GPS_V3_BRICKLET_FIX_LED_CONFIG_SHOW_PPS: u8 = 4;
126pub const GPS_V3_BRICKLET_SBAS_ENABLED: u8 = 0;
127pub const GPS_V3_BRICKLET_SBAS_DISABLED: u8 = 1;
128pub const GPS_V3_BRICKLET_BOOTLOADER_MODE_BOOTLOADER: u8 = 0;
129pub const GPS_V3_BRICKLET_BOOTLOADER_MODE_FIRMWARE: u8 = 1;
130pub const GPS_V3_BRICKLET_BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT: u8 = 2;
131pub const GPS_V3_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT: u8 = 3;
132pub const GPS_V3_BRICKLET_BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT: u8 = 4;
133pub const GPS_V3_BRICKLET_BOOTLOADER_STATUS_OK: u8 = 0;
134pub const GPS_V3_BRICKLET_BOOTLOADER_STATUS_INVALID_MODE: u8 = 1;
135pub const GPS_V3_BRICKLET_BOOTLOADER_STATUS_NO_CHANGE: u8 = 2;
136pub const GPS_V3_BRICKLET_BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT: u8 = 3;
137pub const GPS_V3_BRICKLET_BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT: u8 = 4;
138pub const GPS_V3_BRICKLET_BOOTLOADER_STATUS_CRC_MISMATCH: u8 = 5;
139pub const GPS_V3_BRICKLET_STATUS_LED_CONFIG_OFF: u8 = 0;
140pub const GPS_V3_BRICKLET_STATUS_LED_CONFIG_ON: u8 = 1;
141pub const GPS_V3_BRICKLET_STATUS_LED_CONFIG_SHOW_HEARTBEAT: u8 = 2;
142pub const GPS_V3_BRICKLET_STATUS_LED_CONFIG_SHOW_STATUS: u8 = 3;
143
144#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
145pub struct Coordinates {
146 pub latitude: u32,
147 pub ns: char,
148 pub longitude: u32,
149 pub ew: char,
150}
151impl FromByteSlice for Coordinates {
152 fn bytes_expected() -> usize {
153 10
154 }
155 fn from_le_byte_slice(bytes: &[u8]) -> Coordinates {
156 Coordinates {
157 latitude: <u32>::from_le_byte_slice(&bytes[0..4]),
158 ns: <char>::from_le_byte_slice(&bytes[4..5]),
159 longitude: <u32>::from_le_byte_slice(&bytes[5..9]),
160 ew: <char>::from_le_byte_slice(&bytes[9..10]),
161 }
162 }
163}
164
165#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
166pub struct Status {
167 pub has_fix: bool,
168 pub satellites_view: u8,
169}
170impl FromByteSlice for Status {
171 fn bytes_expected() -> usize {
172 2
173 }
174 fn from_le_byte_slice(bytes: &[u8]) -> Status {
175 Status { has_fix: <bool>::from_le_byte_slice(&bytes[0..1]), satellites_view: <u8>::from_le_byte_slice(&bytes[1..2]) }
176 }
177}
178
179#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
180pub struct Altitude {
181 pub altitude: i32,
182 pub geoidal_separation: i32,
183}
184impl FromByteSlice for Altitude {
185 fn bytes_expected() -> usize {
186 8
187 }
188 fn from_le_byte_slice(bytes: &[u8]) -> Altitude {
189 Altitude { altitude: <i32>::from_le_byte_slice(&bytes[0..4]), geoidal_separation: <i32>::from_le_byte_slice(&bytes[4..8]) }
190 }
191}
192
193#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
194pub struct Motion {
195 pub course: u32,
196 pub speed: u32,
197}
198impl FromByteSlice for Motion {
199 fn bytes_expected() -> usize {
200 8
201 }
202 fn from_le_byte_slice(bytes: &[u8]) -> Motion {
203 Motion { course: <u32>::from_le_byte_slice(&bytes[0..4]), speed: <u32>::from_le_byte_slice(&bytes[4..8]) }
204 }
205}
206
207#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
208pub struct DateTime {
209 pub date: u32,
210 pub time: u32,
211}
212impl FromByteSlice for DateTime {
213 fn bytes_expected() -> usize {
214 8
215 }
216 fn from_le_byte_slice(bytes: &[u8]) -> DateTime {
217 DateTime { date: <u32>::from_le_byte_slice(&bytes[0..4]), time: <u32>::from_le_byte_slice(&bytes[4..8]) }
218 }
219}
220
221#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
222pub struct SatelliteSystemStatusLowLevel {
223 pub satellite_numbers_length: u8,
224 pub satellite_numbers_data: [u8; 12],
225 pub fix: u8,
226 pub pdop: u16,
227 pub hdop: u16,
228 pub vdop: u16,
229}
230impl FromByteSlice for SatelliteSystemStatusLowLevel {
231 fn bytes_expected() -> usize {
232 20
233 }
234 fn from_le_byte_slice(bytes: &[u8]) -> SatelliteSystemStatusLowLevel {
235 SatelliteSystemStatusLowLevel {
236 satellite_numbers_length: <u8>::from_le_byte_slice(&bytes[0..1]),
237 satellite_numbers_data: <[u8; 12]>::from_le_byte_slice(&bytes[1..13]),
238 fix: <u8>::from_le_byte_slice(&bytes[13..14]),
239 pdop: <u16>::from_le_byte_slice(&bytes[14..16]),
240 hdop: <u16>::from_le_byte_slice(&bytes[16..18]),
241 vdop: <u16>::from_le_byte_slice(&bytes[18..20]),
242 }
243 }
244}
245impl LowLevelRead<u8, SatelliteSystemStatusResult> for SatelliteSystemStatusLowLevel {
246 fn ll_message_length(&self) -> usize {
247 self.satellite_numbers_length as usize
248 }
249
250 fn ll_message_chunk_offset(&self) -> usize {
251 0
252 }
253
254 fn ll_message_chunk_data(&self) -> &[u8] {
255 &self.satellite_numbers_data
256 }
257
258 fn get_result(&self) -> SatelliteSystemStatusResult {
259 SatelliteSystemStatusResult { fix: self.fix, pdop: self.pdop, hdop: self.hdop, vdop: self.vdop }
260 }
261}
262
263#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
264pub struct SatelliteStatus {
265 pub elevation: i16,
266 pub azimuth: i16,
267 pub snr: i16,
268}
269impl FromByteSlice for SatelliteStatus {
270 fn bytes_expected() -> usize {
271 6
272 }
273 fn from_le_byte_slice(bytes: &[u8]) -> SatelliteStatus {
274 SatelliteStatus {
275 elevation: <i16>::from_le_byte_slice(&bytes[0..2]),
276 azimuth: <i16>::from_le_byte_slice(&bytes[2..4]),
277 snr: <i16>::from_le_byte_slice(&bytes[4..6]),
278 }
279 }
280}
281
282#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
283pub struct CoordinatesEvent {
284 pub latitude: u32,
285 pub ns: char,
286 pub longitude: u32,
287 pub ew: char,
288}
289impl FromByteSlice for CoordinatesEvent {
290 fn bytes_expected() -> usize {
291 10
292 }
293 fn from_le_byte_slice(bytes: &[u8]) -> CoordinatesEvent {
294 CoordinatesEvent {
295 latitude: <u32>::from_le_byte_slice(&bytes[0..4]),
296 ns: <char>::from_le_byte_slice(&bytes[4..5]),
297 longitude: <u32>::from_le_byte_slice(&bytes[5..9]),
298 ew: <char>::from_le_byte_slice(&bytes[9..10]),
299 }
300 }
301}
302
303#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
304pub struct StatusEvent {
305 pub has_fix: bool,
306 pub satellites_view: u8,
307}
308impl FromByteSlice for StatusEvent {
309 fn bytes_expected() -> usize {
310 2
311 }
312 fn from_le_byte_slice(bytes: &[u8]) -> StatusEvent {
313 StatusEvent { has_fix: <bool>::from_le_byte_slice(&bytes[0..1]), satellites_view: <u8>::from_le_byte_slice(&bytes[1..2]) }
314 }
315}
316
317#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
318pub struct AltitudeEvent {
319 pub altitude: i32,
320 pub geoidal_separation: i32,
321}
322impl FromByteSlice for AltitudeEvent {
323 fn bytes_expected() -> usize {
324 8
325 }
326 fn from_le_byte_slice(bytes: &[u8]) -> AltitudeEvent {
327 AltitudeEvent { altitude: <i32>::from_le_byte_slice(&bytes[0..4]), geoidal_separation: <i32>::from_le_byte_slice(&bytes[4..8]) }
328 }
329}
330
331#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
332pub struct MotionEvent {
333 pub course: u32,
334 pub speed: u32,
335}
336impl FromByteSlice for MotionEvent {
337 fn bytes_expected() -> usize {
338 8
339 }
340 fn from_le_byte_slice(bytes: &[u8]) -> MotionEvent {
341 MotionEvent { course: <u32>::from_le_byte_slice(&bytes[0..4]), speed: <u32>::from_le_byte_slice(&bytes[4..8]) }
342 }
343}
344
345#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
346pub struct DateTimeEvent {
347 pub date: u32,
348 pub time: u32,
349}
350impl FromByteSlice for DateTimeEvent {
351 fn bytes_expected() -> usize {
352 8
353 }
354 fn from_le_byte_slice(bytes: &[u8]) -> DateTimeEvent {
355 DateTimeEvent { date: <u32>::from_le_byte_slice(&bytes[0..4]), time: <u32>::from_le_byte_slice(&bytes[4..8]) }
356 }
357}
358
359#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
360pub struct SpitfpErrorCount {
361 pub error_count_ack_checksum: u32,
362 pub error_count_message_checksum: u32,
363 pub error_count_frame: u32,
364 pub error_count_overflow: u32,
365}
366impl FromByteSlice for SpitfpErrorCount {
367 fn bytes_expected() -> usize {
368 16
369 }
370 fn from_le_byte_slice(bytes: &[u8]) -> SpitfpErrorCount {
371 SpitfpErrorCount {
372 error_count_ack_checksum: <u32>::from_le_byte_slice(&bytes[0..4]),
373 error_count_message_checksum: <u32>::from_le_byte_slice(&bytes[4..8]),
374 error_count_frame: <u32>::from_le_byte_slice(&bytes[8..12]),
375 error_count_overflow: <u32>::from_le_byte_slice(&bytes[12..16]),
376 }
377 }
378}
379
380#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
381pub struct Identity {
382 pub uid: String,
383 pub connected_uid: String,
384 pub position: char,
385 pub hardware_version: [u8; 3],
386 pub firmware_version: [u8; 3],
387 pub device_identifier: u16,
388}
389impl FromByteSlice for Identity {
390 fn bytes_expected() -> usize {
391 25
392 }
393 fn from_le_byte_slice(bytes: &[u8]) -> Identity {
394 Identity {
395 uid: <String>::from_le_byte_slice(&bytes[0..8]),
396 connected_uid: <String>::from_le_byte_slice(&bytes[8..16]),
397 position: <char>::from_le_byte_slice(&bytes[16..17]),
398 hardware_version: <[u8; 3]>::from_le_byte_slice(&bytes[17..20]),
399 firmware_version: <[u8; 3]>::from_le_byte_slice(&bytes[20..23]),
400 device_identifier: <u16>::from_le_byte_slice(&bytes[23..25]),
401 }
402 }
403}
404
405#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)]
406pub struct SatelliteSystemStatusResult {
407 pub fix: u8,
408 pub pdop: u16,
409 pub hdop: u16,
410 pub vdop: u16,
411}
412
413#[derive(Clone)]
415pub struct GpsV3Bricklet {
416 device: Device,
417}
418impl GpsV3Bricklet {
419 pub const DEVICE_IDENTIFIER: u16 = 2171;
420 pub const DEVICE_DISPLAY_NAME: &'static str = "GPS Bricklet 3.0";
421 pub fn new(uid: Uid, connection: AsyncIpConnection) -> GpsV3Bricklet {
423 let mut result = GpsV3Bricklet { device: Device::new([2, 0, 10], uid, connection, Self::DEVICE_DISPLAY_NAME) };
424 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetCoordinates) as usize] = ResponseExpectedFlag::AlwaysTrue;
425 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetStatus) as usize] = ResponseExpectedFlag::AlwaysTrue;
426 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetAltitude) as usize] = ResponseExpectedFlag::AlwaysTrue;
427 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetMotion) as usize] = ResponseExpectedFlag::AlwaysTrue;
428 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetDateTime) as usize] = ResponseExpectedFlag::AlwaysTrue;
429 result.device.response_expected[u8::from(GpsV3BrickletFunction::Restart) as usize] = ResponseExpectedFlag::False;
430 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetSatelliteSystemStatusLowLevel) as usize] =
431 ResponseExpectedFlag::AlwaysTrue;
432 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetSatelliteStatus) as usize] = ResponseExpectedFlag::AlwaysTrue;
433 result.device.response_expected[u8::from(GpsV3BrickletFunction::SetFixLedConfig) as usize] = ResponseExpectedFlag::False;
434 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetFixLedConfig) as usize] = ResponseExpectedFlag::AlwaysTrue;
435 result.device.response_expected[u8::from(GpsV3BrickletFunction::SetCoordinatesCallbackPeriod) as usize] =
436 ResponseExpectedFlag::True;
437 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetCoordinatesCallbackPeriod) as usize] =
438 ResponseExpectedFlag::AlwaysTrue;
439 result.device.response_expected[u8::from(GpsV3BrickletFunction::SetStatusCallbackPeriod) as usize] = ResponseExpectedFlag::True;
440 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetStatusCallbackPeriod) as usize] =
441 ResponseExpectedFlag::AlwaysTrue;
442 result.device.response_expected[u8::from(GpsV3BrickletFunction::SetAltitudeCallbackPeriod) as usize] = ResponseExpectedFlag::True;
443 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetAltitudeCallbackPeriod) as usize] =
444 ResponseExpectedFlag::AlwaysTrue;
445 result.device.response_expected[u8::from(GpsV3BrickletFunction::SetMotionCallbackPeriod) as usize] = ResponseExpectedFlag::True;
446 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetMotionCallbackPeriod) as usize] =
447 ResponseExpectedFlag::AlwaysTrue;
448 result.device.response_expected[u8::from(GpsV3BrickletFunction::SetDateTimeCallbackPeriod) as usize] = ResponseExpectedFlag::True;
449 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetDateTimeCallbackPeriod) as usize] =
450 ResponseExpectedFlag::AlwaysTrue;
451 result.device.response_expected[u8::from(GpsV3BrickletFunction::SetSbasConfig) as usize] = ResponseExpectedFlag::False;
452 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetSbasConfig) as usize] = ResponseExpectedFlag::AlwaysTrue;
453 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetSpitfpErrorCount) as usize] = ResponseExpectedFlag::AlwaysTrue;
454 result.device.response_expected[u8::from(GpsV3BrickletFunction::SetBootloaderMode) as usize] = ResponseExpectedFlag::AlwaysTrue;
455 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetBootloaderMode) as usize] = ResponseExpectedFlag::AlwaysTrue;
456 result.device.response_expected[u8::from(GpsV3BrickletFunction::SetWriteFirmwarePointer) as usize] = ResponseExpectedFlag::False;
457 result.device.response_expected[u8::from(GpsV3BrickletFunction::WriteFirmware) as usize] = ResponseExpectedFlag::AlwaysTrue;
458 result.device.response_expected[u8::from(GpsV3BrickletFunction::SetStatusLedConfig) as usize] = ResponseExpectedFlag::False;
459 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetStatusLedConfig) as usize] = ResponseExpectedFlag::AlwaysTrue;
460 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetChipTemperature) as usize] = ResponseExpectedFlag::AlwaysTrue;
461 result.device.response_expected[u8::from(GpsV3BrickletFunction::Reset) as usize] = ResponseExpectedFlag::False;
462 result.device.response_expected[u8::from(GpsV3BrickletFunction::WriteUid) as usize] = ResponseExpectedFlag::False;
463 result.device.response_expected[u8::from(GpsV3BrickletFunction::ReadUid) as usize] = ResponseExpectedFlag::AlwaysTrue;
464 result.device.response_expected[u8::from(GpsV3BrickletFunction::GetIdentity) as usize] = ResponseExpectedFlag::AlwaysTrue;
465 result
466 }
467
468 pub fn get_response_expected(&mut self, fun: GpsV3BrickletFunction) -> Result<bool, GetResponseExpectedError> {
483 self.device.get_response_expected(u8::from(fun))
484 }
485
486 pub fn set_response_expected(&mut self, fun: GpsV3BrickletFunction, response_expected: bool) -> Result<(), SetResponseExpectedError> {
495 self.device.set_response_expected(u8::from(fun), response_expected)
496 }
497
498 pub fn set_response_expected_all(&mut self, response_expected: bool) {
500 self.device.set_response_expected_all(response_expected)
501 }
502
503 pub fn get_api_version(&self) -> [u8; 3] {
506 self.device.api_version
507 }
508
509 pub async fn get_pulse_per_second_callback_receiver(&mut self) -> impl Stream<Item = ()> {
517 self.device.get_callback_receiver(u8::from(GpsV3BrickletFunction::CallbackPulsePerSecond)).await.map(|_p| ())
518 }
519
520 pub async fn get_coordinates_callback_receiver(&mut self) -> impl Stream<Item = CoordinatesEvent> {
528 self.device
529 .get_callback_receiver(u8::from(GpsV3BrickletFunction::CallbackCoordinates))
530 .await
531 .map(|p| CoordinatesEvent::from_le_byte_slice(p.body()))
532 }
533
534 pub async fn get_status_callback_receiver(&mut self) -> impl Stream<Item = StatusEvent> {
541 self.device
542 .get_callback_receiver(u8::from(GpsV3BrickletFunction::CallbackStatus))
543 .await
544 .map(|p| StatusEvent::from_le_byte_slice(p.body()))
545 }
546
547 pub async fn get_altitude_callback_receiver(&mut self) -> impl Stream<Item = AltitudeEvent> {
555 self.device
556 .get_callback_receiver(u8::from(GpsV3BrickletFunction::CallbackAltitude))
557 .await
558 .map(|p| AltitudeEvent::from_le_byte_slice(p.body()))
559 }
560
561 pub async fn get_motion_callback_receiver(&mut self) -> impl Stream<Item = MotionEvent> {
569 self.device
570 .get_callback_receiver(u8::from(GpsV3BrickletFunction::CallbackMotion))
571 .await
572 .map(|p| MotionEvent::from_le_byte_slice(p.body()))
573 }
574
575 pub async fn get_date_time_callback_receiver(&mut self) -> impl Stream<Item = DateTimeEvent> {
582 self.device
583 .get_callback_receiver(u8::from(GpsV3BrickletFunction::CallbackDateTime))
584 .await
585 .map(|p| DateTimeEvent::from_le_byte_slice(p.body()))
586 }
587
588 pub async fn get_coordinates(&mut self) -> Result<Coordinates, TinkerforgeError> {
597 let payload = [0; 0];
598
599 #[allow(unused_variables)]
600 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetCoordinates), &payload).await?;
601 Ok(Coordinates::from_le_byte_slice(result.body()))
602 }
603
604 pub async fn get_status(&mut self) -> Result<Status, TinkerforgeError> {
610 let payload = [0; 0];
611
612 #[allow(unused_variables)]
613 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetStatus), &payload).await?;
614 Ok(Status::from_le_byte_slice(result.body()))
615 }
616
617 pub async fn get_altitude(&mut self) -> Result<Altitude, TinkerforgeError> {
622 let payload = [0; 0];
623
624 #[allow(unused_variables)]
625 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetAltitude), &payload).await?;
626 Ok(Altitude::from_le_byte_slice(result.body()))
627 }
628
629 pub async fn get_motion(&mut self) -> Result<Motion, TinkerforgeError> {
638 let payload = [0; 0];
639
640 #[allow(unused_variables)]
641 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetMotion), &payload).await?;
642 Ok(Motion::from_le_byte_slice(result.body()))
643 }
644
645 pub async fn get_date_time(&mut self) -> Result<DateTime, TinkerforgeError> {
650 let payload = [0; 0];
651
652 #[allow(unused_variables)]
653 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetDateTime), &payload).await?;
654 Ok(DateTime::from_le_byte_slice(result.body()))
655 }
656
657 pub async fn restart(&mut self, restart_type: u8) -> Result<(), TinkerforgeError> {
672 let mut payload = [0; 1];
673 restart_type.write_to_slice(&mut payload[0..1]);
674
675 #[allow(unused_variables)]
676 let result = self.device.set(u8::from(GpsV3BrickletFunction::Restart), &payload).await?;
677 Ok(())
678 }
679
680 pub async fn get_satellite_system_status_low_level(
703 &mut self,
704 satellite_system: u8,
705 ) -> Result<SatelliteSystemStatusLowLevel, TinkerforgeError> {
706 let mut payload = [0; 1];
707 satellite_system.write_to_slice(&mut payload[0..1]);
708
709 #[allow(unused_variables)]
710 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetSatelliteSystemStatusLowLevel), &payload).await?;
711 Ok(SatelliteSystemStatusLowLevel::from_le_byte_slice(result.body()))
712 }
713
714 pub async fn get_satellite_status(&mut self, satellite_system: u8, satellite_number: u8) -> Result<SatelliteStatus, TinkerforgeError> {
727 let mut payload = [0; 2];
728 satellite_system.write_to_slice(&mut payload[0..1]);
729 satellite_number.write_to_slice(&mut payload[1..2]);
730
731 #[allow(unused_variables)]
732 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetSatelliteStatus), &payload).await?;
733 Ok(SatelliteStatus::from_le_byte_slice(result.body()))
734 }
735
736 pub async fn set_fix_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
752 let mut payload = [0; 1];
753 config.write_to_slice(&mut payload[0..1]);
754
755 #[allow(unused_variables)]
756 let result = self.device.set(u8::from(GpsV3BrickletFunction::SetFixLedConfig), &payload).await?;
757 Ok(())
758 }
759
760 pub async fn get_fix_led_config(&mut self) -> Result<u8, TinkerforgeError> {
769 let payload = [0; 0];
770
771 #[allow(unused_variables)]
772 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetFixLedConfig), &payload).await?;
773 Ok(u8::from_le_byte_slice(result.body()))
774 }
775
776 pub async fn set_coordinates_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
782 let mut payload = [0; 4];
783 period.write_to_slice(&mut payload[0..4]);
784
785 #[allow(unused_variables)]
786 let result = self.device.set(u8::from(GpsV3BrickletFunction::SetCoordinatesCallbackPeriod), &payload).await?;
787 Ok(())
788 }
789
790 pub async fn get_coordinates_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
792 let payload = [0; 0];
793
794 #[allow(unused_variables)]
795 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetCoordinatesCallbackPeriod), &payload).await?;
796 Ok(u32::from_le_byte_slice(result.body()))
797 }
798
799 pub async fn set_status_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
805 let mut payload = [0; 4];
806 period.write_to_slice(&mut payload[0..4]);
807
808 #[allow(unused_variables)]
809 let result = self.device.set(u8::from(GpsV3BrickletFunction::SetStatusCallbackPeriod), &payload).await?;
810 Ok(())
811 }
812
813 pub async fn get_status_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
815 let payload = [0; 0];
816
817 #[allow(unused_variables)]
818 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetStatusCallbackPeriod), &payload).await?;
819 Ok(u32::from_le_byte_slice(result.body()))
820 }
821
822 pub async fn set_altitude_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
828 let mut payload = [0; 4];
829 period.write_to_slice(&mut payload[0..4]);
830
831 #[allow(unused_variables)]
832 let result = self.device.set(u8::from(GpsV3BrickletFunction::SetAltitudeCallbackPeriod), &payload).await?;
833 Ok(())
834 }
835
836 pub async fn get_altitude_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
838 let payload = [0; 0];
839
840 #[allow(unused_variables)]
841 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetAltitudeCallbackPeriod), &payload).await?;
842 Ok(u32::from_le_byte_slice(result.body()))
843 }
844
845 pub async fn set_motion_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
851 let mut payload = [0; 4];
852 period.write_to_slice(&mut payload[0..4]);
853
854 #[allow(unused_variables)]
855 let result = self.device.set(u8::from(GpsV3BrickletFunction::SetMotionCallbackPeriod), &payload).await?;
856 Ok(())
857 }
858
859 pub async fn get_motion_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
861 let payload = [0; 0];
862
863 #[allow(unused_variables)]
864 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetMotionCallbackPeriod), &payload).await?;
865 Ok(u32::from_le_byte_slice(result.body()))
866 }
867
868 pub async fn set_date_time_callback_period(&mut self, period: u32) -> Result<(), TinkerforgeError> {
874 let mut payload = [0; 4];
875 period.write_to_slice(&mut payload[0..4]);
876
877 #[allow(unused_variables)]
878 let result = self.device.set(u8::from(GpsV3BrickletFunction::SetDateTimeCallbackPeriod), &payload).await?;
879 Ok(())
880 }
881
882 pub async fn get_date_time_callback_period(&mut self) -> Result<u32, TinkerforgeError> {
884 let payload = [0; 0];
885
886 #[allow(unused_variables)]
887 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetDateTimeCallbackPeriod), &payload).await?;
888 Ok(u32::from_le_byte_slice(result.body()))
889 }
890
891 pub async fn set_sbas_config(&mut self, sbas_config: u8) -> Result<(), TinkerforgeError> {
899 let mut payload = [0; 1];
900 sbas_config.write_to_slice(&mut payload[0..1]);
901
902 #[allow(unused_variables)]
903 let result = self.device.set(u8::from(GpsV3BrickletFunction::SetSbasConfig), &payload).await?;
904 Ok(())
905 }
906
907 pub async fn get_sbas_config(&mut self) -> Result<u8, TinkerforgeError> {
913 let payload = [0; 0];
914
915 #[allow(unused_variables)]
916 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetSbasConfig), &payload).await?;
917 Ok(u8::from_le_byte_slice(result.body()))
918 }
919
920 pub async fn get_spitfp_error_count(&mut self) -> Result<SpitfpErrorCount, TinkerforgeError> {
932 let payload = [0; 0];
933
934 #[allow(unused_variables)]
935 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetSpitfpErrorCount), &payload).await?;
936 Ok(SpitfpErrorCount::from_le_byte_slice(result.body()))
937 }
938
939 pub async fn set_bootloader_mode(&mut self, mode: u8) -> Result<u8, TinkerforgeError> {
962 let mut payload = [0; 1];
963 mode.write_to_slice(&mut payload[0..1]);
964
965 #[allow(unused_variables)]
966 let result = self.device.get(u8::from(GpsV3BrickletFunction::SetBootloaderMode), &payload).await?;
967 Ok(u8::from_le_byte_slice(result.body()))
968 }
969
970 pub async fn get_bootloader_mode(&mut self) -> Result<u8, TinkerforgeError> {
979 let payload = [0; 0];
980
981 #[allow(unused_variables)]
982 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetBootloaderMode), &payload).await?;
983 Ok(u8::from_le_byte_slice(result.body()))
984 }
985
986 pub async fn set_write_firmware_pointer(&mut self, pointer: u32) -> Result<(), TinkerforgeError> {
993 let mut payload = [0; 4];
994 pointer.write_to_slice(&mut payload[0..4]);
995
996 #[allow(unused_variables)]
997 let result = self.device.set(u8::from(GpsV3BrickletFunction::SetWriteFirmwarePointer), &payload).await?;
998 Ok(())
999 }
1000
1001 pub async fn write_firmware(&mut self, data: &[u8; 64]) -> Result<u8, TinkerforgeError> {
1010 let mut payload = [0; 64];
1011 data.write_to_slice(&mut payload[0..64]);
1012
1013 #[allow(unused_variables)]
1014 let result = self.device.get(u8::from(GpsV3BrickletFunction::WriteFirmware), &payload).await?;
1015 Ok(u8::from_le_byte_slice(result.body()))
1016 }
1017
1018 pub async fn set_status_led_config(&mut self, config: u8) -> Result<(), TinkerforgeError> {
1032 let mut payload = [0; 1];
1033 config.write_to_slice(&mut payload[0..1]);
1034
1035 #[allow(unused_variables)]
1036 let result = self.device.set(u8::from(GpsV3BrickletFunction::SetStatusLedConfig), &payload).await?;
1037 Ok(())
1038 }
1039
1040 pub async fn get_status_led_config(&mut self) -> Result<u8, TinkerforgeError> {
1048 let payload = [0; 0];
1049
1050 #[allow(unused_variables)]
1051 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetStatusLedConfig), &payload).await?;
1052 Ok(u8::from_le_byte_slice(result.body()))
1053 }
1054
1055 pub async fn get_chip_temperature(&mut self) -> Result<i16, TinkerforgeError> {
1062 let payload = [0; 0];
1063
1064 #[allow(unused_variables)]
1065 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetChipTemperature), &payload).await?;
1066 Ok(i16::from_le_byte_slice(result.body()))
1067 }
1068
1069 pub async fn reset(&mut self) -> Result<(), TinkerforgeError> {
1076 let payload = [0; 0];
1077
1078 #[allow(unused_variables)]
1079 let result = self.device.set(u8::from(GpsV3BrickletFunction::Reset), &payload).await?;
1080 Ok(())
1081 }
1082
1083 pub async fn write_uid(&mut self, uid: u32) -> Result<(), TinkerforgeError> {
1089 let mut payload = [0; 4];
1090 uid.write_to_slice(&mut payload[0..4]);
1091
1092 #[allow(unused_variables)]
1093 let result = self.device.set(u8::from(GpsV3BrickletFunction::WriteUid), &payload).await?;
1094 Ok(())
1095 }
1096
1097 pub async fn read_uid(&mut self) -> Result<u32, TinkerforgeError> {
1100 let payload = [0; 0];
1101
1102 #[allow(unused_variables)]
1103 let result = self.device.get(u8::from(GpsV3BrickletFunction::ReadUid), &payload).await?;
1104 Ok(u32::from_le_byte_slice(result.body()))
1105 }
1106
1107 pub async fn get_identity(&mut self) -> Result<Identity, TinkerforgeError> {
1118 let payload = [0; 0];
1119
1120 #[allow(unused_variables)]
1121 let result = self.device.get(u8::from(GpsV3BrickletFunction::GetIdentity), &payload).await?;
1122 Ok(Identity::from_le_byte_slice(result.body()))
1123 }
1124}