13#ifndef ZEPHYR_MODEM_UBX_
14#define ZEPHYR_MODEM_UBX_
27#define UBX_FRM_HEADER_SZ 6
28#define UBX_FRM_FOOTER_SZ 2
29#define UBX_FRM_SZ_WITHOUT_PAYLOAD (UBX_FRM_HEADER_SZ + UBX_FRM_FOOTER_SZ)
30#define UBX_FRM_SZ(payload_size) (payload_size + UBX_FRM_SZ_WITHOUT_PAYLOAD)
32#define UBX_PREAMBLE_SYNC_CHAR_1 0xB5
33#define UBX_PREAMBLE_SYNC_CHAR_2 0x62
35#define UBX_FRM_PREAMBLE_SYNC_CHAR_1_IDX 0
36#define UBX_FRM_PREAMBLE_SYNC_CHAR_2_IDX 1
37#define UBX_FRM_MSG_CLASS_IDX 2
38#define UBX_FRM_MSG_ID_IDX 3
39#define UBX_FRM_PAYLOAD_SZ_L_IDX 4
40#define UBX_FRM_PAYLOAD_SZ_H_IDX 5
41#define UBX_FRM_PAYLOAD_IDX 6
42#define UBX_FRM_CHECKSUM_START_IDX 2
43#define UBX_FRM_CHECKSUM_STOP_IDX(frame_len) (frame_len - 2)
45#define UBX_PAYLOAD_SZ_MAX 256
46#define UBX_FRM_SZ_MAX UBX_FRM_SZ(UBX_PAYLOAD_SZ_MAX)
long atomic_t
Definition atomic_types.h:15
int modem_ubx_run_script(struct modem_ubx *ubx, const struct modem_ubx_script *script)
Writes the ubx frame in script.request and reads back its response (if available)
int modem_ubx_attach(struct modem_ubx *ubx, struct modem_pipe *pipe)
Attach pipe to Modem Ubx.
int modem_ubx_create_frame(uint8_t *ubx_frame, uint16_t ubx_frame_size, uint8_t msg_cls, uint8_t msg_id, const void *payload, uint16_t payload_size)
Initialize ubx frame.
void modem_ubx_release(struct modem_ubx *ubx)
Release pipe from Modem Ubx instance.
int modem_ubx_init(struct modem_ubx *ubx, const struct modem_ubx_config *config)
Initialize Modem Ubx instance.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Kernel timeout type.
Definition sys_clock.h:65
A structure used to submit work.
Definition kernel.h:3957
uint8_t * work_buf
Definition ubx.h:95
uint16_t receive_buf_size
Definition ubx.h:94
uint8_t * receive_buf
Definition ubx.h:93
uint16_t work_buf_size
Definition ubx.h:96
void * user_data
Definition ubx.h:91
k_timeout_t timeout
Definition ubx.h:64
uint16_t retry_count
Definition ubx.h:63
struct ubx_frame * response
Definition ubx.h:60
struct ubx_frame * request
Definition ubx.h:59
struct ubx_frame * match
Definition ubx.h:61
struct k_sem script_running_sem
Definition ubx.h:87
uint8_t * receive_buf
Definition ubx.h:72
struct modem_pipe * pipe
Definition ubx.h:82
uint16_t work_buf_size
Definition ubx.h:76
uint16_t receive_buf_size
Definition ubx.h:73
atomic_t state
Definition ubx.h:70
bool ubx_preamble_sync_chars_received
Definition ubx.h:78
uint16_t work_buf_len
Definition ubx.h:77
const struct modem_ubx_script * script
Definition ubx.h:80
uint8_t * work_buf
Definition ubx.h:75
void * user_data
Definition ubx.h:68
struct k_work process_work
Definition ubx.h:85
struct k_sem script_stopped_sem
Definition ubx.h:86
struct k_work send_work
Definition ubx.h:84
uint8_t payload_size_high
Definition ubx.h:54
uint8_t payload_and_checksum[]
Definition ubx.h:55
uint8_t payload_size_low
Definition ubx.h:53
uint8_t message_class
Definition ubx.h:51
uint8_t preamble_sync_char_2
Definition ubx.h:50
uint8_t message_id
Definition ubx.h:52
uint8_t preamble_sync_char_1
Definition ubx.h:49