|
| 1 | +use ublox_derive::{UbxPacketRecv, UbxPacketSend, UbxDefineSubTypes}; |
| 2 | + |
| 3 | +pub trait UbxPacket { |
| 4 | + const class: u8; |
| 5 | + const id: u8; |
| 6 | + const fixed_length: Option<u16>; |
| 7 | +} |
| 8 | + |
| 9 | + |
| 10 | +#[derive(UbxPacketRecv, UbxDefineSubTypes)] |
| 11 | +#[ubx(class = 1, id = 2, fixed_len = 28)] |
| 12 | +#[repr(packed)] |
| 13 | +/// Geodetic Position Solution |
| 14 | +struct NavPosLLHRaw { |
| 15 | + itow: u32, |
| 16 | + #[ubx(map_type = f64, scale = 1e-7, alias = lon_degrees)] |
| 17 | + lon: i32, |
| 18 | + lat: i32, |
| 19 | + #[ubx(map_type = f64, scale = 1e-3, alias = height_ellipsoid_meters)] |
| 20 | + height_ellipsoid: i32, |
| 21 | + height_msl: i32, |
| 22 | + /// Horizontal Accuracy Estimate |
| 23 | + horizontal_accuracy: u32, |
| 24 | + vertical_accuracy: u32, |
| 25 | +} |
| 26 | + |
| 27 | +#[derive(UbxPacketRecv, UbxDefineSubTypes)] |
| 28 | +#[repr(packed)] |
| 29 | +#[ubx(class = 1, id = 3, fixed_len = 16)] |
| 30 | +struct NavStatusRaw { |
| 31 | + itow: u32, |
| 32 | + #[ubx(enum { |
| 33 | + NoFix = 0, |
| 34 | + DeadReckoningOnly = 1, |
| 35 | + Fix2D = 2, |
| 36 | + Fix3D = 3, |
| 37 | + GpsDeadReckoningCombine = 4, |
| 38 | + TimeOnlyFix = 5, |
| 39 | + })] |
| 40 | + gps_fix: u8, |
| 41 | + #[ubx(bitflags { |
| 42 | + GpsFixOk = bit0, |
| 43 | + DiffSoln = bit1, |
| 44 | + WknSet = bit2, |
| 45 | + TowSet = bit3, |
| 46 | + })] |
| 47 | + flags: u8, |
| 48 | + fix_status: u8, |
| 49 | + flags2: u8, |
| 50 | + time_to_first_fix: u32, |
| 51 | + uptime_ms: u32, |
| 52 | +} |
| 53 | + |
| 54 | +#[derive(UbxPacketSend, UbxDefineSubTypes)] |
| 55 | +#[repr(packed)] |
| 56 | +#[ubx(class = 5, id = 1, fixed_len = 0)] |
| 57 | +struct AckAckRaw {} |
| 58 | + |
| 59 | +#[derive(UbxPacketSend, UbxDefineSubTypes)] |
| 60 | +#[repr(packed)] |
| 61 | +#[ubx(class = 6, id = 4)] |
| 62 | +struct CfgRstRaw { |
| 63 | + #[ubx(bitflags { |
| 64 | + Eph = bit0, |
| 65 | + Alm = bit1, |
| 66 | + Health = bit2, |
| 67 | + /// Klobuchard |
| 68 | + Klob = bit3, |
| 69 | + Pos = bit4, |
| 70 | + Clkd = bit5, |
| 71 | + Osc = bit6, |
| 72 | + Utc = bit7, |
| 73 | + Rtc = bit8, |
| 74 | + HotStart = mask0, |
| 75 | + })] |
| 76 | + nav_bbr_mask: u16, |
| 77 | + #[ubx(enum { |
| 78 | + /// Hardware reset (Watchdog) immediately |
| 79 | + HardwareReset = 0, |
| 80 | + ControlledSoftwareReset = 1, |
| 81 | + })] |
| 82 | + reset_mode: u8, |
| 83 | + reserved1: u8, |
| 84 | +} |
0 commit comments