c4glte2voicena 2.1.0.0
c4glte2voicena.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef C4GLTE2VOICENA_H
29#define C4GLTE2VOICENA_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_uart.h"
52
73#define C4GLTE2VOICENA_CMD_AT "AT"
74#define C4GLTE2VOICENA_CMD_ATI "ATI"
75#define C4GLTE2VOICENA_CMD_CGMR "AT+CGMR"
76#define C4GLTE2VOICENA_CMD_CFUN "AT+CFUN"
77#define C4GLTE2VOICENA_CMD_CREG "AT+CREG"
78#define C4GLTE2VOICENA_CMD_CGREG "AT+CGREG"
79#define C4GLTE2VOICENA_CMD_CGDCONT "AT+CGDCONT"
80#define C4GLTE2VOICENA_CMD_CIMI "AT+CIMI"
81#define C4GLTE2VOICENA_CMD_CMEE "AT+CMEE"
82#define C4GLTE2VOICENA_CMD_CGATT "AT+CGATT"
83#define C4GLTE2VOICENA_CMD_CSQ "AT+CSQ"
84#define C4GLTE2VOICENA_CMD_COPS "AT+COPS"
85#define C4GLTE2VOICENA_CMD_CMGS "AT+CMGS"
86#define C4GLTE2VOICENA_CMD_CMGF "AT+CMGF"
87#define C4GLTE2VOICENA_CMD_CGACT "AT+CGACT"
88#define C4GLTE2VOICENA_CMD_USOCR "AT+USOCR"
89#define C4GLTE2VOICENA_CMD_USOCO "AT+USOCO"
90#define C4GLTE2VOICENA_CMD_USOWR "AT+USOWR"
91#define C4GLTE2VOICENA_CMD_USOST "AT+USOST"
92#define C4GLTE2VOICENA_CMD_USORD "AT+USORD"
93#define C4GLTE2VOICENA_CMD_USORF "AT+USORF"
94#define C4GLTE2VOICENA_CMD_USOCL "AT+USOCL"
95#define C4GLTE2VOICENA_CMD_UGPS "AT+UGPS"
96#define C4GLTE2VOICENA_CMD_UGGGA "AT+UGGGA"
97
102#define C4GLTE2VOICENA_RSP_OK "OK"
103#define C4GLTE2VOICENA_RSP_ERROR "ERROR"
104
109#define C4GLTE2VOICENA_POWER_STATE_OFF 0
110#define C4GLTE2VOICENA_POWER_STATE_ON 1
111
117#define C4GLTE2VOICENA_DRV_BUFFER_SIZE 256
118
119 // c4glte2voicena_cmd
120
135#define C4GLTE2VOICENA_MAP_MIKROBUS( cfg, mikrobus ) \
136 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
137 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
138 cfg.sts = MIKROBUS( mikrobus, MIKROBUS_AN ); \
139 cfg.pwr = MIKROBUS( mikrobus, MIKROBUS_RST ); \
140 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
141 cfg.ri = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
142 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_INT );
143
144 // c4glte2voicena_map
145 // c4glte2voicena
146
151typedef struct
152{
153 // Output pins
154 digital_out_t sts;
155 digital_out_t pwr;
156 digital_out_t rts;
158 // Input pins
159 digital_in_t ri;
160 digital_in_t cts;
162 // Modules
163 uart_t uart;
165 // Buffers
166 char uart_rx_buffer[ C4GLTE2VOICENA_DRV_BUFFER_SIZE ];
167 char uart_tx_buffer[ C4GLTE2VOICENA_DRV_BUFFER_SIZE ];
170
175typedef struct
176{
177 // Communication gpio pins
178 pin_name_t rx_pin;
179 pin_name_t tx_pin;
181 // Additional gpio pins
182 pin_name_t sts;
183 pin_name_t pwr;
184 pin_name_t rts;
185 pin_name_t ri;
186 pin_name_t cts;
188 // Static variable
189 uint32_t baud_rate;
191 uart_data_bits_t data_bit;
192 uart_parity_t parity_bit;
193 uart_stop_bits_t stop_bit;
196
210
227
242
255err_t c4glte2voicena_generic_write ( c4glte2voicena_t *ctx, char *data_in, uint16_t len );
256
269err_t c4glte2voicena_generic_read ( c4glte2voicena_t *ctx, char *data_out, uint16_t len );
270
280void c4glte2voicena_set_pwr_pin ( c4glte2voicena_t *ctx, uint8_t state );
281
291void c4glte2voicena_set_sts_pin ( c4glte2voicena_t *ctx, uint8_t state );
292
302void c4glte2voicena_set_rts_pin ( c4glte2voicena_t *ctx, uint8_t state );
303
313
323
335
346
357void c4glte2voicena_send_cmd_par ( c4glte2voicena_t *ctx, char *at_cmd_buf, char *param_buf );
358
368void c4glte2voicena_send_cmd_check ( c4glte2voicena_t *ctx, char *at_cmd_buf );
369
379void c4glte2voicena_set_sim_apn ( c4glte2voicena_t *ctx, char *sim_apn );
380
391void c4glte2voicena_send_sms_text ( c4glte2voicena_t *ctx, char *phone_number, char *sms_text );
392
406err_t c4glte2voicena_send_sms_pdu ( c4glte2voicena_t *ctx, char *service_center_number, char *phone_number, char *sms_text );
407
408#ifdef __cplusplus
409}
410#endif
411#endif // C4GLTE2VOICENA_H
412
413 // c4glte2voicena
414
415// ------------------------------------------------------------------------ END
c4glte2voicena_return_value_t
4G LTE 2 Voice-NA Click return value data.
Definition c4glte2voicena.h:202
@ C4GLTE2VOICENA_OK
Definition c4glte2voicena.h:203
@ C4GLTE2VOICENA_ERROR
Definition c4glte2voicena.h:204
@ C4GLTE2VOICENA_ERROR_CMD
Definition c4glte2voicena.h:206
@ C4GLTE2VOICENA_ERROR_UNKNOWN
Definition c4glte2voicena.h:207
@ C4GLTE2VOICENA_ERROR_TIMEOUT
Definition c4glte2voicena.h:205
#define C4GLTE2VOICENA_DRV_BUFFER_SIZE
4G LTE 2 Voice-NA driver buffer size.
Definition c4glte2voicena.h:117
void c4glte2voicena_set_sim_apn(c4glte2voicena_t *ctx, char *sim_apn)
Set sim card APN.
void c4glte2voicena_set_power_state(c4glte2voicena_t *ctx, uint8_t state)
4G LTE 2 Voice-NA set power state function.
err_t c4glte2voicena_init(c4glte2voicena_t *ctx, c4glte2voicena_cfg_t *cfg)
4G LTE 2 Voice-NA initialization function.
err_t c4glte2voicena_generic_write(c4glte2voicena_t *ctx, char *data_in, uint16_t len)
4G LTE 2 Voice-NA data writing function.
void c4glte2voicena_set_rts_pin(c4glte2voicena_t *ctx, uint8_t state)
4G LTE 2 Voice-NA set RTS pin function.
err_t c4glte2voicena_generic_read(c4glte2voicena_t *ctx, char *data_out, uint16_t len)
4G LTE 2 Voice-NA data reading function.
err_t c4glte2voicena_send_sms_pdu(c4glte2voicena_t *ctx, char *service_center_number, char *phone_number, char *sms_text)
4G LTE 2 Voice-NA send SMS in PDU mode.
void c4glte2voicena_send_cmd_par(c4glte2voicena_t *ctx, char *at_cmd_buf, char *param_buf)
Send command function with parameter.
void c4glte2voicena_send_cmd(c4glte2voicena_t *ctx, char *cmd)
Send command function.
void c4glte2voicena_send_cmd_check(c4glte2voicena_t *ctx, char *at_cmd_buf)
Check the sent command.
void c4glte2voicena_cfg_setup(c4glte2voicena_cfg_t *cfg)
4G LTE 2 Voice-NA configuration object setup function.
void c4glte2voicena_set_sts_pin(c4glte2voicena_t *ctx, uint8_t state)
4G LTE 2 Voice-NA set STS pin function.
uint8_t c4glte2voicena_get_cts_pin(c4glte2voicena_t *ctx)
4G LTE 2 Voice-NA get CTS pin function.
void c4glte2voicena_set_pwr_pin(c4glte2voicena_t *ctx, uint8_t state)
4G LTE 2 Voice-NA set PWR pin function.
void c4glte2voicena_send_sms_text(c4glte2voicena_t *ctx, char *phone_number, char *sms_text)
4G LTE 2 Voice-NA send SMS in text mode.
uint8_t c4glte2voicena_get_ri_pin(c4glte2voicena_t *ctx)
4G LTE 2 Voice-NA get RI pin function.
4G LTE 2 Voice-NA Click configuration object.
Definition c4glte2voicena.h:176
pin_name_t rts
Definition c4glte2voicena.h:184
uint32_t baud_rate
Definition c4glte2voicena.h:189
pin_name_t sts
Definition c4glte2voicena.h:182
pin_name_t cts
Definition c4glte2voicena.h:186
bool uart_blocking
Definition c4glte2voicena.h:190
pin_name_t ri
Definition c4glte2voicena.h:185
uart_data_bits_t data_bit
Definition c4glte2voicena.h:191
pin_name_t tx_pin
Definition c4glte2voicena.h:179
pin_name_t pwr
Definition c4glte2voicena.h:183
pin_name_t rx_pin
Definition c4glte2voicena.h:178
uart_stop_bits_t stop_bit
Definition c4glte2voicena.h:193
uart_parity_t parity_bit
Definition c4glte2voicena.h:192
4G LTE 2 Voice-NA Click context object.
Definition c4glte2voicena.h:152
digital_out_t pwr
Definition c4glte2voicena.h:155
digital_out_t rts
Definition c4glte2voicena.h:156
digital_in_t ri
Definition c4glte2voicena.h:159
uart_t uart
Definition c4glte2voicena.h:163
digital_out_t sts
Definition c4glte2voicena.h:154
digital_in_t cts
Definition c4glte2voicena.h:160