9#ifndef INFUSE_SDK_DRIVERS_GNSS_UBX_MODEM_H_
10#define INFUSE_SDK_DRIVERS_GNSS_UBX_MODEM_H_
14#include <zephyr/kernel.h>
15#include <zephyr/net_buf.h>
16#include <zephyr/modem/pipe.h>
17#include <zephyr/sys/ring_buffer.h>
40 size_t payload_len,
void *user_data);
42#define UBX_MSG_CLASS_WILDCARD 0x00
43#define UBX_MSG_ID_WILDCARD 0x00
161 size_t payload_len,
void *user_data);
213 k_timeout_t timeout);
231 k_timeout_t timeout);
250 uint8_t message_id, uint8_t buf[8],
253#ifdef CONFIG_GNSS_UBX_RAW_FRAME_HANDLER
264void ubx_modem_raw_frame_handler(
struct ubx_frame *frame, uint16_t total_len);
int ubx_modem_send_sync_acked(struct ubx_modem_data *modem, struct net_buf_simple *buf, k_timeout_t timeout)
Send a message to the modem and wait for the UBX_MSG_CLASS_ACK response.
int ubx_modem_send_async(struct ubx_modem_data *modem, struct net_buf_simple *buf, struct ubx_message_handler_ctx *handler_ctx, bool wait_tx)
Send a message to the modem without waiting for a response.
int ubx_modem_comms_reset(const struct device *dev)
Reset communications with the UBX modem.
struct ubx_modem_data * ubx_modem_data_get(const struct device *dev)
Get modem data structure from device.
void ubx_modem_msg_subscribe(struct ubx_modem_data *modem, struct ubx_message_handler_ctx *handler_ctx)
Subscribe to messages from the UBX modem.
int ubx_modem_send_async_poll(struct ubx_modem_data *modem, uint8_t message_class, uint8_t message_id, uint8_t buf[8], struct ubx_message_handler_ctx *handler_ctx)
Request a poll response from the modem.
void ubx_modem_msg_unsubscribe(struct ubx_modem_data *modem, struct ubx_message_handler_ctx *handler_ctx)
Unsubscribe from messages from the UBX modem.
int(* ubx_message_handler_t)(uint8_t message_class, uint8_t message_id, const void *payload, size_t payload_len, void *user_data)
UBX Message handler callback.
Definition modem.h:39
int ubx_modem_ack_handler(uint8_t message_class, uint8_t message_id, const void *payload, size_t payload_len, void *user_data)
Common ACK handler for messages.
int ubx_modem_send_sync(struct ubx_modem_data *modem, struct net_buf_simple *buf, uint8_t flags, ubx_message_handler_t handler, void *user_data, k_timeout_t timeout)
Send a message to the modem and wait for the response.
void ubx_modem_software_standby(struct ubx_modem_data *modem)
Notify UBX modem that hardware is in standby.
ubx_message_handler_flags
Definition modem.h:45
void ubx_modem_init(struct ubx_modem_data *modem, struct modem_pipe *pipe)
Initialise UBX modem handler.
int ubx_modem_send_sync_poll(struct ubx_modem_data *modem, uint8_t message_class, uint8_t message_id, ubx_message_handler_t handler, void *user_data, k_timeout_t timeout)
Request a poll response from the modem and wait for the response.
@ UBX_HANDLING_ACK
Definition modem.h:47
@ UBX_HANDLING_RSP_ACK
Definition modem.h:51
@ UBX_HANDLING_RSP
Definition modem.h:49
UBX Message Frame.
Definition protocol.h:32
Context around a ubx_message_handler_t.
Definition modem.h:57
struct k_poll_signal * signal
Signal raise after callback run.
Definition modem.h:61
ubx_message_handler_t message_cb
Callback to run.
Definition modem.h:63
uint8_t message_id
Message ID callback should be run on (or UBX_MSG_ID_WILDCARD)
Definition modem.h:69
void * user_data
Arbitrary user data, provided to message_cb.
Definition modem.h:65
uint8_t flags
Flags for callback (ubx_message_handler_flags)
Definition modem.h:71
uint8_t message_class
Message class callback should be run on (or UBX_MSG_CLASS_WILDCARD)
Definition modem.h:67
UBX modem state.
Definition modem.h:77
sys_slist_t handlers
Definition modem.h:85
struct modem_pipe * pipe
Definition modem.h:79
uint8_t rx_buffer[CONFIG_GNSS_U_BLOX_MAX_MSG_SIZE]
Definition modem.h:89
uint16_t rx_buffer_pending
Definition modem.h:91
struct k_work fifo_read_worker
Definition modem.h:81
struct k_poll_signal tx_done
Definition modem.h:83
struct k_sem handlers_sem
Definition modem.h:87