Zephyr Project API 3.7.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
cellular.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Bjarki Arge Andreasen
3 * Copyright (c) 2023 Lucas Denefle
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
13#ifndef ZEPHYR_INCLUDE_DRIVERS_CELLULAR_H_
14#define ZEPHYR_INCLUDE_DRIVERS_CELLULAR_H_
15
23#include <zephyr/types.h>
24#include <zephyr/device.h>
25#include <errno.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
42
55
62
78
87
89typedef int (*cellular_api_configure_networks)(const struct device *dev,
90 const struct cellular_network *networks,
92
94typedef int (*cellular_api_get_supported_networks)(const struct device *dev,
95 const struct cellular_network **networks,
96 uint8_t *size);
97
99typedef int (*cellular_api_get_signal)(const struct device *dev,
100 const enum cellular_signal_type type, int16_t *value);
101
103typedef int (*cellular_api_get_modem_info)(const struct device *dev,
104 const enum cellular_modem_info_type type,
105 char *info, size_t size);
106
108typedef int (*cellular_api_get_registration_status)(const struct device *dev,
110 enum cellular_registration_status *status);
111
120
142static inline int cellular_configure_networks(const struct device *dev,
143 const struct cellular_network *networks, uint8_t size)
144{
145 const struct cellular_driver_api *api = (const struct cellular_driver_api *)dev->api;
146
147 if (api->configure_networks == NULL) {
148 return -ENOSYS;
149 }
150
151 return api->configure_networks(dev, networks, size);
152}
153
165static inline int cellular_get_supported_networks(const struct device *dev,
166 const struct cellular_network **networks,
167 uint8_t *size)
168{
169 const struct cellular_driver_api *api = (const struct cellular_driver_api *)dev->api;
170
171 if (api->get_supported_networks == NULL) {
172 return -ENOSYS;
173 }
174
175 return api->get_supported_networks(dev, networks, size);
176}
177
190static inline int cellular_get_signal(const struct device *dev,
191 const enum cellular_signal_type type, int16_t *value)
192{
193 const struct cellular_driver_api *api = (const struct cellular_driver_api *)dev->api;
194
195 if (api->get_signal == NULL) {
196 return -ENOSYS;
197 }
198
199 return api->get_signal(dev, type, value);
200}
201
215static inline int cellular_get_modem_info(const struct device *dev,
216 const enum cellular_modem_info_type type, char *info,
217 size_t size)
218{
219 const struct cellular_driver_api *api = (const struct cellular_driver_api *)dev->api;
220
221 if (api->get_modem_info == NULL) {
222 return -ENOSYS;
223 }
224
225 return api->get_modem_info(dev, type, info, size);
226}
227
240static inline int cellular_get_registration_status(const struct device *dev,
242 enum cellular_registration_status *status)
243{
244 const struct cellular_driver_api *api = (const struct cellular_driver_api *)dev->api;
245
246 if (api->get_registration_status == NULL) {
247 return -ENOSYS;
248 }
249
250 return api->get_registration_status(dev, tech, status);
251}
252
253#ifdef __cplusplus
254}
255#endif
256
261#endif /* ZEPHYR_INCLUDE_DRIVERS_CELLULAR_H_ */
System error numbers.
static int cellular_get_signal(const struct device *dev, const enum cellular_signal_type type, int16_t *value)
Get signal for the device.
Definition cellular.h:190
int(* cellular_api_get_modem_info)(const struct device *dev, const enum cellular_modem_info_type type, char *info, size_t size)
API for getting modem information.
Definition cellular.h:103
int(* cellular_api_get_registration_status)(const struct device *dev, enum cellular_access_technology tech, enum cellular_registration_status *status)
API for getting registration status.
Definition cellular.h:108
cellular_access_technology
Cellular access technologies.
Definition cellular.h:32
int(* cellular_api_get_supported_networks)(const struct device *dev, const struct cellular_network **networks, uint8_t *size)
API for getting supported networks.
Definition cellular.h:94
static int cellular_get_supported_networks(const struct device *dev, const struct cellular_network **networks, uint8_t *size)
Get supported cellular networks for the device.
Definition cellular.h:165
int(* cellular_api_configure_networks)(const struct device *dev, const struct cellular_network *networks, uint8_t size)
API for configuring networks.
Definition cellular.h:89
cellular_registration_status
Definition cellular.h:79
cellular_signal_type
Cellular signal type.
Definition cellular.h:57
static int cellular_get_modem_info(const struct device *dev, const enum cellular_modem_info_type type, char *info, size_t size)
Get modem info for the device.
Definition cellular.h:215
int(* cellular_api_get_signal)(const struct device *dev, const enum cellular_signal_type type, int16_t *value)
API for getting network signal strength.
Definition cellular.h:99
static int cellular_configure_networks(const struct device *dev, const struct cellular_network *networks, uint8_t size)
Configure cellular networks for the device.
Definition cellular.h:142
cellular_modem_info_type
Cellular modem info type.
Definition cellular.h:64
static int cellular_get_registration_status(const struct device *dev, enum cellular_access_technology tech, enum cellular_registration_status *status)
Get network registration status for the device.
Definition cellular.h:240
@ CELLULAR_ACCESS_TECHNOLOGY_LTE
Definition cellular.h:37
@ CELLULAR_ACCESS_TECHNOLOGY_UMTS
Definition cellular.h:35
@ CELLULAR_ACCESS_TECHNOLOGY_NB_IOT
Definition cellular.h:40
@ CELLULAR_ACCESS_TECHNOLOGY_GPRS
Definition cellular.h:34
@ CELLULAR_ACCESS_TECHNOLOGY_LTE_CAT_M2
Definition cellular.h:39
@ CELLULAR_ACCESS_TECHNOLOGY_GSM
Definition cellular.h:33
@ CELLULAR_ACCESS_TECHNOLOGY_EDGE
Definition cellular.h:36
@ CELLULAR_ACCESS_TECHNOLOGY_LTE_CAT_M1
Definition cellular.h:38
@ CELLULAR_REGISTRATION_UNKNOWN
Definition cellular.h:84
@ CELLULAR_REGISTRATION_SEARCHING
Definition cellular.h:82
@ CELLULAR_REGISTRATION_DENIED
Definition cellular.h:83
@ CELLULAR_REGISTRATION_REGISTERED_HOME
Definition cellular.h:81
@ CELLULAR_REGISTRATION_NOT_REGISTERED
Definition cellular.h:80
@ CELLULAR_REGISTRATION_REGISTERED_ROAMING
Definition cellular.h:85
@ CELLULAR_SIGNAL_RSRQ
Definition cellular.h:60
@ CELLULAR_SIGNAL_RSRP
Definition cellular.h:59
@ CELLULAR_SIGNAL_RSSI
Definition cellular.h:58
@ CELLULAR_MODEM_INFO_SIM_IMSI
International Mobile Subscriber Identity.
Definition cellular.h:74
@ CELLULAR_MODEM_INFO_MANUFACTURER
Modem manufacturer.
Definition cellular.h:70
@ CELLULAR_MODEM_INFO_MODEL_ID
Modem model ID.
Definition cellular.h:68
@ CELLULAR_MODEM_INFO_SIM_ICCID
Integrated Circuit Card Identification Number (SIM)
Definition cellular.h:76
@ CELLULAR_MODEM_INFO_FW_VERSION
Modem fw version.
Definition cellular.h:72
@ CELLULAR_MODEM_INFO_IMEI
International Mobile Equipment Identity.
Definition cellular.h:66
#define ENOSYS
Function not implemented.
Definition errno.h:82
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
__INT16_TYPE__ int16_t
Definition stdint.h:73
Cellular driver API.
Definition cellular.h:113
cellular_api_get_supported_networks get_supported_networks
Definition cellular.h:115
cellular_api_get_registration_status get_registration_status
Definition cellular.h:118
cellular_api_get_signal get_signal
Definition cellular.h:116
cellular_api_get_modem_info get_modem_info
Definition cellular.h:117
cellular_api_configure_networks configure_networks
Definition cellular.h:114
Cellular network structure.
Definition cellular.h:44
uint16_t * bands
List of bands, as defined by the specified cellular access technology, to enables.
Definition cellular.h:51
uint16_t size
Size of bands.
Definition cellular.h:53
enum cellular_access_technology technology
Cellular access technology.
Definition cellular.h:46
Runtime device structure (in ROM) per driver instance.
Definition device.h:403
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:409