c4glteatt 2.0.0.0
c4glteatt.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 C4GLTEATT_H
29#define C4GLTEATT_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 C4GLTEATT_CMD_AT "AT"
74#define C4GLTEATT_CMD_ATI "ATI"
75#define C4GLTEATT_CMD_CGMR "AT+CGMR"
76#define C4GLTEATT_CMD_CFUN "AT+CFUN"
77#define C4GLTEATT_CMD_CREG "AT+CREG"
78#define C4GLTEATT_CMD_CGREG "AT+CGREG"
79#define C4GLTEATT_CMD_CGDCONT "AT+CGDCONT"
80#define C4GLTEATT_CMD_CIMI "AT+CIMI"
81#define C4GLTEATT_CMD_CMEE "AT+CMEE"
82#define C4GLTEATT_CMD_CGATT "AT+CGATT"
83#define C4GLTEATT_CMD_CSQ "AT+CSQ"
84#define C4GLTEATT_CMD_COPS "AT+COPS"
85#define C4GLTEATT_CMD_CMGS "AT+CMGS"
86#define C4GLTEATT_CMD_CMGF "AT+CMGF"
92#define DRV_RX_BUFFER_SIZE 256
93#define DRV_TX_BUFFER_SIZE 256
94
95 // c4glteatt_set
96
111#define C4GLTEATT_MAP_MIKROBUS( cfg, mikrobus ) \
112 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
113 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
114 cfg.sta = MIKROBUS( mikrobus, MIKROBUS_AN ); \
115 cfg.pwk = MIKROBUS( mikrobus, MIKROBUS_RST ); \
116 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
117 cfg.ring = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
118 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_INT );
119
120 // c4glteatt_map
121 // c4glteatt
122
127typedef struct
128{
129 // Output pins
130 digital_out_t pwk;
131 digital_out_t rts;
132
133 // Input pins
134 digital_in_t sta;
135 digital_in_t ring;
136 digital_in_t cts;
137
138 // Modules
139 uart_t uart;
141 // Buffers
142 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
143 char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
146
151typedef struct
152{
153 // Communication gpio pins
154 pin_name_t rx_pin;
155 pin_name_t tx_pin;
157 // Additional gpio pins
158 pin_name_t sta;
159 pin_name_t pwk;
160 pin_name_t rts;
161 pin_name_t ring;
162 pin_name_t cts;
163
164 // Static variable
165 uint32_t baud_rate;
167 uart_data_bits_t data_bit;
168 uart_parity_t parity_bit;
169 uart_stop_bits_t stop_bit;
172
183
200
216
226
240err_t c4glteatt_generic_write ( c4glteatt_t *ctx, char *data_buf, uint16_t len );
241
255err_t c4glteatt_generic_read ( c4glteatt_t *ctx, char *data_buf, uint16_t max_len );
256
257
267void c4glteatt_set_rts_pin ( c4glteatt_t *ctx, uint8_t state );
268
278void c4glteatt_set_pwk_pin ( c4glteatt_t *ctx, uint8_t state );
279
290
301
312
322void c4glteatt_send_cmd ( c4glteatt_t *ctx, char *cmd );
323
334void c4glteatt_send_cmd_with_parameter ( c4glteatt_t *ctx, char *at_cmd_buf, char *param_buf );
335
345void c4glteatt_send_cmd_check ( c4glteatt_t *ctx, char *at_cmd_buf );
346
356void c4glteatt_send_cmd_parameter_check ( c4glteatt_t *ctx, char *at_cmd_buf );
357
367void c4glteatt_set_sim_apn ( c4glteatt_t *ctx, char *sim_apn );
368
379void c4glteatt_send_sms_text ( c4glteatt_t *ctx, char *phone_number, char *sms_text );
380
394err_t c4glteatt_send_sms_pdu ( c4glteatt_t *ctx, char *service_center_number, char *phone_number, char *sms_text );
395
396#ifdef __cplusplus
397}
398#endif
399#endif // C4GLTEATT_H
400
401 // c4glteatt
402
403// ------------------------------------------------------------------------ END
c4glteatt_return_value_t
4G LTE-ATT Click return value data.
Definition c4glteatt.h:178
@ C4GLTEATT_OK
Definition c4glteatt.h:179
@ C4GLTEATT_ERROR
Definition c4glteatt.h:180
#define DRV_RX_BUFFER_SIZE
4G LTE-ATT driver buffer size.
Definition c4glteatt.h:92
#define DRV_TX_BUFFER_SIZE
Definition c4glteatt.h:93
err_t c4glteatt_send_sms_pdu(c4glteatt_t *ctx, char *service_center_number, char *phone_number, char *sms_text)
4G LTE-ATT send SMS in PDU mode.
void c4glteatt_cfg_setup(c4glteatt_cfg_t *cfg)
4G LTE-ATT configuration object setup function.
void c4glteatt_send_sms_text(c4glteatt_t *ctx, char *phone_number, char *sms_text)
4G LTE-ATT send SMS in text mode.
void c4glteatt_set_rts_pin(c4glteatt_t *ctx, uint8_t state)
Sets state of the RTS pin.
uint8_t c4glteatt_get_ring_pin(c4glteatt_t *ctx)
RING Pin Get function.
err_t c4glteatt_init(c4glteatt_t *ctx, c4glteatt_cfg_t *cfg)
4G LTE-ATT initialization function.
void c4glteatt_set_pwk_pin(c4glteatt_t *ctx, uint8_t state)
Sets state of the PWK pin.
uint8_t c4glteatt_get_sta_pin(c4glteatt_t *ctx)
STA Pin Get function.
void c4glteatt_send_cmd(c4glteatt_t *ctx, char *cmd)
Send command function.
void c4glteatt_send_cmd_check(c4glteatt_t *ctx, char *at_cmd_buf)
Check the sent command.
err_t c4glteatt_generic_read(c4glteatt_t *ctx, char *data_buf, uint16_t max_len)
4G LTE-ATT data reading function.
void c4glteatt_module_power_on(c4glteatt_t *ctx)
Power ON the module function.
void c4glteatt_send_cmd_parameter_check(c4glteatt_t *ctx, char *at_cmd_buf)
Check the command parameters.
err_t c4glteatt_generic_write(c4glteatt_t *ctx, char *data_buf, uint16_t len)
4G LTE-ATT data writing function.
void c4glteatt_send_cmd_with_parameter(c4glteatt_t *ctx, char *at_cmd_buf, char *param_buf)
Send command function with parameter.
void c4glteatt_set_sim_apn(c4glteatt_t *ctx, char *sim_apn)
Set sim card APN.
uint8_t c4glteatt_get_cts_pin(c4glteatt_t *ctx)
CTS Pin Get function.
4G LTE-ATT Click configuration object.
Definition c4glteatt.h:152
pin_name_t sta
Definition c4glteatt.h:158
pin_name_t rts
Definition c4glteatt.h:160
uint32_t baud_rate
Definition c4glteatt.h:165
pin_name_t pwk
Definition c4glteatt.h:159
pin_name_t cts
Definition c4glteatt.h:162
pin_name_t ring
Definition c4glteatt.h:161
bool uart_blocking
Definition c4glteatt.h:166
uart_data_bits_t data_bit
Definition c4glteatt.h:167
pin_name_t tx_pin
Definition c4glteatt.h:155
pin_name_t rx_pin
Definition c4glteatt.h:154
uart_stop_bits_t stop_bit
Definition c4glteatt.h:169
uart_parity_t parity_bit
Definition c4glteatt.h:168
4G LTE-ATT Click context object.
Definition c4glteatt.h:128
digital_in_t sta
Definition c4glteatt.h:134
digital_out_t rts
Definition c4glteatt.h:131
uart_t uart
Definition c4glteatt.h:139
digital_in_t cts
Definition c4glteatt.h:136
digital_out_t pwk
Definition c4glteatt.h:130
digital_in_t ring
Definition c4glteatt.h:135