23#ifndef PROTOCORE_UBX_H
24#define PROTOCORE_UBX_H
28#if PROTOCORE_ENABLE_UBX
32#define PROTOCORE_UBX_SYNC1 0xB5u
33#define PROTOCORE_UBX_SYNC2 0x62u
41 const uint8_t *payload;
48void protocore_ubx_checksum(
const uint8_t *body,
size_t len, uint8_t *ck_a, uint8_t *ck_b);
55size_t protocore_ubx_build(uint8_t *buf,
size_t cap, uint8_t cls, uint8_t
id,
const uint8_t *payload, uint16_t len);
58size_t protocore_ubx_build_poll(uint8_t *buf,
size_t cap, uint8_t cls, uint8_t
id);
65proto_bool protocore_ubx_parse(
const uint8_t *s,
size_t len, protocore_ubx *out);
72int protocore_ubx_ack(
const protocore_ubx *m, uint8_t *acked_cls, uint8_t *acked_id);
75uint16_t protocore_ubx_u16(
const uint8_t *p,
size_t off);
76uint32_t protocore_ubx_u32(
const uint8_t *p,
size_t off);
77int16_t protocore_ubx_i16(
const uint8_t *p,
size_t off);
78int32_t protocore_ubx_i32(
const uint8_t *p,
size_t off);
82#define PROTOCORE_UBX_CLASS_NAV 0x01
83#define PROTOCORE_UBX_NAV_PVT 0x07
84#define PROTOCORE_UBX_NAV_PVT_LEN 92
85#define PROTOCORE_UBX_PVT_FIX_OK 0x01u
88enum protocore_ubx_fix_type
90 PROTOCORE_UBX_FIX_NONE = 0,
91 PROTOCORE_UBX_FIX_DR = 1,
92 PROTOCORE_UBX_FIX_2D = 2,
93 PROTOCORE_UBX_FIX_3D = 3,
94 PROTOCORE_UBX_FIX_GNSS_DR = 4,
95 PROTOCORE_UBX_FIX_TIME = 5
111 uint32_t time_acc_ns;
125 int32_t head_mot_1e5;
127 uint32_t head_acc_1e5;
129} protocore_ubx_nav_pvt;
136proto_bool protocore_ubx_parse_nav_pvt(
const protocore_ubx *m, protocore_ubx_nav_pvt *out);
140#define PROTOCORE_UBX_NAV_SAT 0x35
141#define PROTOCORE_UBX_NAV_SAT_HDR_LEN 8
142#define PROTOCORE_UBX_NAV_SAT_ENTRY_LEN 12
143#define PROTOCORE_UBX_SAT_QUALITY_MASK 0x07u
144#define PROTOCORE_UBX_SAT_USED 0x08u
152} protocore_ubx_nav_sat_hdr;
172proto_bool protocore_ubx_parse_nav_sat(
const protocore_ubx *m, protocore_ubx_nav_sat_hdr *out);
178proto_bool protocore_ubx_nav_sat_get(
const protocore_ubx *m, uint8_t index, protocore_ubx_sat *out);
182#define PROTOCORE_UBX_NAV_TIMEUTC 0x21
183#define PROTOCORE_UBX_NAV_TIMEUTC_LEN 20
184#define PROTOCORE_UBX_TIMEUTC_VALID_TOW 0x01u
185#define PROTOCORE_UBX_TIMEUTC_VALID_WKN 0x02u
186#define PROTOCORE_UBX_TIMEUTC_VALID_UTC 0x04u
192 uint32_t time_acc_ns;
202} protocore_ubx_nav_time_utc;
208proto_bool protocore_ubx_parse_nav_timeutc(
const protocore_ubx *m, protocore_ubx_nav_time_utc *out);
212#define PROTOCORE_UBX_CLASS_CFG 0x06
213#define PROTOCORE_UBX_CFG_MSG 0x01
214#define PROTOCORE_UBX_CFG_RATE 0x08
215#define PROTOCORE_UBX_TIME_REF_UTC 0
216#define PROTOCORE_UBX_TIME_REF_GPS 1
225size_t protocore_ubx_build_cfg_msg(uint8_t *buf,
size_t cap, uint8_t cls, uint8_t
id, uint8_t rate);
234size_t protocore_ubx_build_cfg_rate(uint8_t *buf,
size_t cap, uint16_t meas_rate_ms, uint16_t nav_rate,
238enum protocore_ubx_feed
240 PROTOCORE_UBX_NONE = 0,
241 PROTOCORE_UBX_FRAME = 1,
242 PROTOCORE_UBX_PASSTHROUGH = 2,
243 PROTOCORE_UBX_OVERFLOW = 3
258 uint8_t buf[PROTOCORE_UBX_MAX_PAYLOAD];
259} protocore_ubx_stream;
262void protocore_ubx_stream_init(protocore_ubx_stream *st);
270int protocore_ubx_stream_feed(protocore_ubx_stream *st, uint8_t b, protocore_ubx *out, uint8_t *passthrough);
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS