2018-08-02 04:01:00 +08:00
|
|
|
/** @file
|
|
|
|
* @brief Modem receiver header file.
|
|
|
|
*
|
|
|
|
* A modem receiver driver allowing application to handle all
|
|
|
|
* aspects of received protocol data.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 Foundries.io
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#ifndef ZEPHYR_INCLUDE_DRIVERS_MODEM_MODEM_RECEIVER_H_
|
|
|
|
#define ZEPHYR_INCLUDE_DRIVERS_MODEM_MODEM_RECEIVER_H_
|
2018-08-02 04:01:00 +08:00
|
|
|
|
|
|
|
#include <kernel.h>
|
2019-06-26 03:57:18 +08:00
|
|
|
#include <sys/ring_buffer.h>
|
2018-08-02 04:01:00 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct mdm_receiver_context {
|
2020-05-01 02:33:38 +08:00
|
|
|
const struct device *uart_dev;
|
2018-08-02 04:01:00 +08:00
|
|
|
|
|
|
|
/* rx data */
|
2019-02-14 05:48:46 +08:00
|
|
|
struct ring_buf rx_rb;
|
2018-08-02 04:01:00 +08:00
|
|
|
struct k_sem rx_sem;
|
|
|
|
|
|
|
|
/* modem data */
|
|
|
|
char *data_manufacturer;
|
|
|
|
char *data_model;
|
|
|
|
char *data_revision;
|
2020-04-20 19:51:45 +08:00
|
|
|
#if defined(CONFIG_MODEM_SIM_NUMBERS)
|
2018-08-02 04:01:00 +08:00
|
|
|
char *data_imei;
|
2020-04-20 19:51:45 +08:00
|
|
|
char *data_imsi;
|
|
|
|
#endif
|
|
|
|
char *data_iccid;
|
2021-11-05 03:56:13 +08:00
|
|
|
int *data_rssi;
|
2018-08-02 04:01:00 +08:00
|
|
|
};
|
|
|
|
|
2019-02-14 05:59:17 +08:00
|
|
|
/**
|
|
|
|
* @brief Gets receiver context by id.
|
|
|
|
*
|
|
|
|
* @param id: receiver context id.
|
|
|
|
*
|
|
|
|
* @retval Receiver context or NULL.
|
|
|
|
*/
|
2018-08-02 04:01:00 +08:00
|
|
|
struct mdm_receiver_context *mdm_receiver_context_from_id(int id);
|
|
|
|
|
2019-02-14 05:59:17 +08:00
|
|
|
/**
|
|
|
|
* @brief Get received data.
|
|
|
|
*
|
|
|
|
* @param *ctx: receiver context.
|
|
|
|
* @param *buf: buffer to copy the received data to.
|
|
|
|
* @param size: buffer size.
|
|
|
|
* @param *bytes_read: amount of received bytes
|
|
|
|
*
|
|
|
|
* @retval 0 if ok, < 0 if error.
|
|
|
|
*/
|
2018-08-02 04:01:00 +08:00
|
|
|
int mdm_receiver_recv(struct mdm_receiver_context *ctx,
|
2020-05-28 00:26:57 +08:00
|
|
|
uint8_t *buf, size_t size, size_t *bytes_read);
|
2019-02-14 05:59:17 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Sends the data over specified receiver context.
|
|
|
|
*
|
|
|
|
* @param *ctx: receiver context.
|
|
|
|
* @param *buf: buffer with the data to send.
|
|
|
|
* @param size: the amount of data to send.
|
|
|
|
*
|
|
|
|
* @retval 0 if ok, < 0 if error.
|
|
|
|
*/
|
2018-08-02 04:01:00 +08:00
|
|
|
int mdm_receiver_send(struct mdm_receiver_context *ctx,
|
2020-05-28 00:26:57 +08:00
|
|
|
const uint8_t *buf, size_t size);
|
2019-02-14 05:59:17 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Registers receiver context.
|
|
|
|
*
|
2019-03-27 23:43:42 +08:00
|
|
|
* @note Acquires receivers device, and prepares the context to be used.
|
2019-02-14 05:59:17 +08:00
|
|
|
*
|
|
|
|
* @param *ctx: receiver context to register.
|
2021-06-29 21:11:22 +08:00
|
|
|
* @param *uart_dev: communication device for the receiver context.
|
2019-02-14 05:59:17 +08:00
|
|
|
* @param *buf: rx buffer to use for received data.
|
|
|
|
* @param size: rx buffer size.
|
|
|
|
*
|
|
|
|
* @retval 0 if ok, < 0 if error.
|
|
|
|
*/
|
2018-08-02 04:01:00 +08:00
|
|
|
int mdm_receiver_register(struct mdm_receiver_context *ctx,
|
2021-06-29 21:11:22 +08:00
|
|
|
const struct device *uart_dev,
|
2020-05-28 00:26:57 +08:00
|
|
|
uint8_t *buf, size_t size);
|
2018-08-02 04:01:00 +08:00
|
|
|
|
2019-06-07 23:51:30 +08:00
|
|
|
int mdm_receiver_sleep(struct mdm_receiver_context *ctx);
|
|
|
|
|
|
|
|
int mdm_receiver_wake(struct mdm_receiver_context *ctx);
|
|
|
|
|
2018-08-02 04:01:00 +08:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-09-15 01:43:44 +08:00
|
|
|
#endif /* ZEPHYR_INCLUDE_DRIVERS_MODEM_MODEM_RECEIVER_H_ */
|