Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
|
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_data * | ubx_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. | |
#define UBX_MSG_CLASS_WILDCARD 0x00 |
#include <infuse/gnss/ubx/modem.h>
#define UBX_MSG_ID_WILDCARD 0x00 |
#include <infuse/gnss/ubx/modem.h>
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.
message_class | UBX message class |
message_id | UBX message ID |
payload | Pointer to message payload |
payload_len | Length of message payload |
user_data | Arbitrary user data |
#include <infuse/gnss/ubx/modem.h>
Enumerator | |
---|---|
UBX_HANDLING_ACK | |
UBX_HANDLING_RSP | |
UBX_HANDLING_RSP_ACK |
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.
message_class | Expected to be UBX_MSG_CLASS_ACK |
message_id | Expected to be either UBX_MSG_ID_ACK_ACK or UBX_MSG_ID_ACK_NAK |
payload | ACK payload |
payload_len | ACK payload length |
user_data | Unused |
0 | If message_id == UBX_MSG_ID_ACK_ACK |
-EINVAL | Otherwise |
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
.
dev | Modem device to reset communications for |
0 | On success |
-errno | Negative error code otherwise |
struct ubx_modem_data * ubx_modem_data_get | ( | const struct device * | dev | ) |
#include <infuse/gnss/ubx/modem.h>
Get modem data structure from device.
dev | Modem device |
void ubx_modem_init | ( | struct ubx_modem_data * | modem, |
struct modem_pipe * | pipe ) |
#include <infuse/gnss/ubx/modem.h>
Initialise UBX modem handler.
modem | Modem data structure |
pipe | Pipe to underlying modem hardware |
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.
modem | Modem data structure |
handler_ctx | Handler context structure |
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.
modem | Modem data structure |
handler_ctx | Handler context structure |
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.
handler_ctx->signal == NULL
, or until after the callback runs otherwise.modem | Modem data structure |
buf | Complete UBX message |
handler_ctx | Handler context object |
wait_tx | Wait for transmission to finish before returning |
0 | if TX was queued |
-errno | Negative error code otherwise |
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.
modem | Modem data structure |
message_class | UBX message class to poll |
message_id | UBX message ID to poll |
buf | Static buffer of at least 8 bytes for request |
handler_ctx | Handler context object |
rc | Returned code from handler on success |
-ETIMEDOUT | On response timeout |
-errno | Negative error code otherwise |
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.
modem | Modem data structure |
buf | Complete UBX message |
flags | Flags for callback (ubx_message_handler_flags) |
handler | Callback function run on message reception |
user_data | Arbitrary user data provided to handler |
timeout | Duration to wait for response |
rc | Returned code from handler on success |
-ETIMEDOUT | On response timeout |
-errno | Negative error code otherwise |
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.
modem | Modem data structure |
buf | Complete UBX message |
timeout | Duration to wait for response |
0 | If modem responded with UBX_MSG_ID_ACK_ACK |
-EINVAL | If modem responded with UBX_MSG_ID_ACK_NAK |
-ETIMEDOUT | If modem did not respond within timeout |
-errno | Negative error code otherwise |
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.
modem | Modem data structure |
message_class | UBX message class to poll |
message_id | UBX message ID to poll |
handler | Callback to handle the poll response |
user_data | Arbitrary user data provided to handler |
timeout | Duration to wait for response |
rc | Returned code from handler on success |
-ETIMEDOUT | On response timeout |
-errno | Negative error code otherwise |
void ubx_modem_software_standby | ( | struct ubx_modem_data * | modem | ) |
#include <infuse/gnss/ubx/modem.h>
Notify UBX modem that hardware is in standby.
modem | Modem data structure |