Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
UBX Modem Communications

Data Structures

struct  ubx_message_handler_ctx
 Context around a ubx_message_handler_t. More...
 
struct  ubx_modem_data
 UBX modem state. More...
 

Macros

#define UBX_MSG_CLASS_WILDCARD   0x00
 
#define UBX_MSG_ID_WILDCARD   0x00
 

Typedefs

typedef 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.
 

Enumerations

enum  ubx_message_handler_flags { UBX_HANDLING_ACK = BIT(0) , UBX_HANDLING_RSP = BIT(1) , UBX_HANDLING_RSP_ACK = BIT(2) }
 

Functions

struct ubx_modem_dataubx_modem_data_get (const struct device *dev)
 Get modem data structure from device.
 
void ubx_modem_init (struct ubx_modem_data *modem, struct modem_pipe *pipe)
 Initialise UBX modem handler.
 
int ubx_modem_comms_reset (const struct device *dev)
 Reset communications with the UBX modem.
 
void ubx_modem_software_standby (struct ubx_modem_data *modem)
 Notify UBX modem that hardware is in standby.
 
void ubx_modem_msg_subscribe (struct ubx_modem_data *modem, struct ubx_message_handler_ctx *handler_ctx)
 Subscribe to messages from the UBX 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_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_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_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.
 
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_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.
 
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.
 

Detailed Description

Macro Definition Documentation

◆ UBX_MSG_CLASS_WILDCARD

#define UBX_MSG_CLASS_WILDCARD   0x00

◆ UBX_MSG_ID_WILDCARD

#define UBX_MSG_ID_WILDCARD   0x00

Typedef Documentation

◆ ubx_message_handler_t

typedef int(* ubx_message_handler_t) (uint8_t message_class, uint8_t message_id, const void *payload, size_t payload_len, void *user_data)

#include <infuse/gnss/ubx/modem.h>

UBX Message handler callback.

Parameters
message_classUBX message class
message_idUBX message ID
payloadPointer to message payload
payload_lenLength of message payload
user_dataArbitrary user data

Enumeration Type Documentation

◆ ubx_message_handler_flags

#include <infuse/gnss/ubx/modem.h>

Enumerator
UBX_HANDLING_ACK 
UBX_HANDLING_RSP 
UBX_HANDLING_RSP_ACK 

Function Documentation

◆ ubx_modem_ack_handler()

int ubx_modem_ack_handler ( uint8_t message_class,
uint8_t message_id,
const void * payload,
size_t payload_len,
void * user_data )

#include <infuse/gnss/ubx/modem.h>

Common ACK handler for messages.

Parameters
message_classExpected to be UBX_MSG_CLASS_ACK
message_idExpected to be either UBX_MSG_ID_ACK_ACK or UBX_MSG_ID_ACK_NAK
payloadACK payload
payload_lenACK payload length
user_dataUnused
Return values
0If message_id == UBX_MSG_ID_ACK_ACK
-EINVALOtherwise

◆ ubx_modem_comms_reset()

int ubx_modem_comms_reset ( const struct device * dev)

#include <infuse/gnss/ubx/modem.h>

Reset communications with the UBX modem.

Depends on the modem being in PM_DEVICE_STATE_SUSPENDED.

Parameters
devModem device to reset communications for
Return values
0On success
-errnoNegative error code otherwise

◆ ubx_modem_data_get()

struct ubx_modem_data * ubx_modem_data_get ( const struct device * dev)

#include <infuse/gnss/ubx/modem.h>

Get modem data structure from device.

Parameters
devModem device
Returns
Pointer to underlying modem state

◆ ubx_modem_init()

void ubx_modem_init ( struct ubx_modem_data * modem,
struct modem_pipe * pipe )

#include <infuse/gnss/ubx/modem.h>

Initialise UBX modem handler.

Parameters
modemModem data structure
pipePipe to underlying modem hardware

◆ ubx_modem_msg_subscribe()

void ubx_modem_msg_subscribe ( struct ubx_modem_data * modem,
struct ubx_message_handler_ctx * handler_ctx )

#include <infuse/gnss/ubx/modem.h>

Subscribe to messages from the UBX modem.

Parameters
modemModem data structure
handler_ctxHandler context structure

◆ ubx_modem_msg_unsubscribe()

void ubx_modem_msg_unsubscribe ( struct ubx_modem_data * modem,
struct ubx_message_handler_ctx * handler_ctx )

#include <infuse/gnss/ubx/modem.h>

Unsubscribe from messages from the UBX modem.

Parameters
modemModem data structure
handler_ctxHandler context structure

◆ ubx_modem_send_async()

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 )

#include <infuse/gnss/ubx/modem.h>

Send a message to the modem without waiting for a response.

Note
handler_ctx MUST remain valid memory until the callback has executed if handler_ctx->signal == NULL, or until after the callback runs otherwise.
Parameters
modemModem data structure
bufComplete UBX message
handler_ctxHandler context object
wait_txWait for transmission to finish before returning
Return values
0if TX was queued
-errnoNegative error code otherwise

◆ ubx_modem_send_async_poll()

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 )

#include <infuse/gnss/ubx/modem.h>

Request a poll response from the modem.

It is expected that handler_ctx has its message_cb and user_data fields populated before calling this function.

Parameters
modemModem data structure
message_classUBX message class to poll
message_idUBX message ID to poll
bufStatic buffer of at least 8 bytes for request
handler_ctxHandler context object
Return values
rcReturned code from handler on success
-ETIMEDOUTOn response timeout
-errnoNegative error code otherwise

◆ ubx_modem_send_sync()

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 )

#include <infuse/gnss/ubx/modem.h>

Send a message to the modem and wait for the response.

Note
This is unlikely to be the function you want, see ubx_modem_send_sync_acked and ubx_modem_send_sync_poll
Parameters
modemModem data structure
bufComplete UBX message
flagsFlags for callback (ubx_message_handler_flags)
handlerCallback function run on message reception
user_dataArbitrary user data provided to handler
timeoutDuration to wait for response
Return values
rcReturned code from handler on success
-ETIMEDOUTOn response timeout
-errnoNegative error code otherwise

◆ ubx_modem_send_sync_acked()

int ubx_modem_send_sync_acked ( struct ubx_modem_data * modem,
struct net_buf_simple * buf,
k_timeout_t timeout )

#include <infuse/gnss/ubx/modem.h>

Send a message to the modem and wait for the UBX_MSG_CLASS_ACK response.

Parameters
modemModem data structure
bufComplete UBX message
timeoutDuration to wait for response
Return values
0If modem responded with UBX_MSG_ID_ACK_ACK
-EINVALIf modem responded with UBX_MSG_ID_ACK_NAK
-ETIMEDOUTIf modem did not respond within timeout
-errnoNegative error code otherwise

◆ ubx_modem_send_sync_poll()

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 )

#include <infuse/gnss/ubx/modem.h>

Request a poll response from the modem and wait for the response.

Parameters
modemModem data structure
message_classUBX message class to poll
message_idUBX message ID to poll
handlerCallback to handle the poll response
user_dataArbitrary user data provided to handler
timeoutDuration to wait for response
Return values
rcReturned code from handler on success
-ETIMEDOUTOn response timeout
-errnoNegative error code otherwise

◆ ubx_modem_software_standby()

void ubx_modem_software_standby ( struct ubx_modem_data * modem)

#include <infuse/gnss/ubx/modem.h>

Notify UBX modem that hardware is in standby.

Parameters
modemModem data structure