c4gltee  2.0.0.0
c4gltee.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 C4GLTEE_H
29 #define C4GLTEE_H
30 
31 #ifdef __cplusplus
32 extern "C"{
33 #endif
34 
35 #include "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_uart.h"
38 
59 #define C4GLTEE_CMD_AT "AT"
60 #define C4GLTEE_CMD_ATI "ATI"
61 #define C4GLTEE_CMD_CGMR "AT+CGMR"
62 #define C4GLTEE_CMD_CFUN "AT+CFUN"
63 #define C4GLTEE_CMD_CREG "AT+CREG"
64 #define C4GLTEE_CMD_CGREG "AT+CGREG"
65 #define C4GLTEE_CMD_CGDCONT "AT+CGDCONT"
66 #define C4GLTEE_CMD_CIMI "AT+CIMI"
67 #define C4GLTEE_CMD_CMEE "AT+CMEE"
68 #define C4GLTEE_CMD_CGATT "AT+CGATT"
69 #define C4GLTEE_CMD_CSQ "AT+CSQ"
70 #define C4GLTEE_CMD_COPS "AT+COPS"
71 #define C4GLTEE_CMD_CMGS "AT+CMGS"
72 #define C4GLTEE_CMD_CMGF "AT+CMGF"
73 
78 #define DRV_RX_BUFFER_SIZE 256
79 #define DRV_TX_BUFFER_SIZE 256
80  // c4gltee_set
82 
97 #define C4GLTEE_MAP_MIKROBUS( cfg, mikrobus ) \
98  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
99  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
100  cfg.sta = MIKROBUS( mikrobus, MIKROBUS_AN ); \
101  cfg.pwk = MIKROBUS( mikrobus, MIKROBUS_RST ); \
102  cfg.rts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
103  cfg.ring = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
104  cfg.cts = MIKROBUS( mikrobus, MIKROBUS_INT );
105  // c4gltee_map // c4gltee
108 
113 typedef struct
114 {
115  // Output pins
116  digital_out_t pwk;
117  digital_out_t rts;
118 
119  // Input pins
120  digital_in_t sta;
121  digital_in_t ring;
122  digital_in_t cts;
123 
124  // Modules
125  uart_t uart;
127  // Buffers
128  char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
129  char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
131 } c4gltee_t;
132 
137 typedef struct
138 {
139  // Communication gpio pins
140  pin_name_t rx_pin;
141  pin_name_t tx_pin;
143  // Additional gpio pins
144  pin_name_t sta;
145  pin_name_t pwk;
146  pin_name_t rts;
147  pin_name_t ring;
148  pin_name_t cts;
149 
150  // Static variable
151  uint32_t baud_rate;
153  uart_data_bits_t data_bit;
154  uart_parity_t parity_bit;
155  uart_stop_bits_t stop_bit;
157 } c4gltee_cfg_t;
158 
163 typedef enum
164 {
166  C4GLTEE_ERROR = -1
167 
169 
186 
201 err_t c4gltee_init ( c4gltee_t *ctx, c4gltee_cfg_t *cfg );
202 
212 
226 err_t c4gltee_generic_write ( c4gltee_t *ctx, char *data_buf, uint16_t len );
227 
241 err_t c4gltee_generic_read ( c4gltee_t *ctx, char *data_buf, uint16_t max_len );
242 
243 
253 void c4gltee_set_rts_pin ( c4gltee_t *ctx, uint8_t state );
254 
264 void c4gltee_set_pwk_pin ( c4gltee_t *ctx, uint8_t state );
265 
276 
287 
298 
308 void c4gltee_send_cmd ( c4gltee_t *ctx, char *cmd );
309 
320 void c4gltee_send_cmd_with_parameter ( c4gltee_t *ctx, char *at_cmd_buf, char *param_buf );
321 
331 void c4gltee_send_cmd_check ( c4gltee_t *ctx, char *at_cmd_buf );
332 
342 void c4gltee_send_cmd_parameter_check ( c4gltee_t *ctx, char *at_cmd_buf );
343 
353 void c4gltee_set_sim_apn ( c4gltee_t *ctx, char *sim_apn );
354 
365 void c4gltee_send_sms_text ( c4gltee_t *ctx, char *phone_number, char *sms_text );
366 
380 err_t c4gltee_send_sms_pdu ( c4gltee_t *ctx, char *service_center_number, char *phone_number, char *sms_text );
381 
382 #ifdef __cplusplus
383 }
384 #endif
385 #endif // C4GLTEE_H
386  // c4gltee
388 
389 // ------------------------------------------------------------------------ END
c4gltee_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: c4gltee.h:154
DRV_TX_BUFFER_SIZE
#define DRV_TX_BUFFER_SIZE
Definition: c4gltee.h:79
DRV_RX_BUFFER_SIZE
#define DRV_RX_BUFFER_SIZE
4G LTE-E driver buffer size.
Definition: c4gltee.h:78
c4gltee_send_cmd_with_parameter
void c4gltee_send_cmd_with_parameter(c4gltee_t *ctx, char *at_cmd_buf, char *param_buf)
Send command function with parameter.
c4gltee_set_pwk_pin
void c4gltee_set_pwk_pin(c4gltee_t *ctx, uint8_t state)
Sets state of the PWK pin.
C4GLTEE_ERROR
@ C4GLTEE_ERROR
Definition: c4gltee.h:166
c4gltee_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: c4gltee.h:155
c4gltee_generic_write
err_t c4gltee_generic_write(c4gltee_t *ctx, char *data_buf, uint16_t len)
4G LTE-E data writing function.
c4gltee_module_power_on
void c4gltee_module_power_on(c4gltee_t *ctx)
Power ON the module function.
c4gltee_cfg_t::sta
pin_name_t sta
Definition: c4gltee.h:144
c4gltee_cfg_t::baud_rate
uint32_t baud_rate
Definition: c4gltee.h:151
c4gltee_cfg_t::uart_blocking
bool uart_blocking
Definition: c4gltee.h:152
c4gltee_cfg_t::ring
pin_name_t ring
Definition: c4gltee.h:147
c4gltee_send_cmd_parameter_check
void c4gltee_send_cmd_parameter_check(c4gltee_t *ctx, char *at_cmd_buf)
Check the command parameters.
c4gltee_t::rts
digital_out_t rts
Definition: c4gltee.h:117
c4gltee_cfg_t
4G LTE-E Click configuration object.
Definition: c4gltee.h:138
c4gltee_get_cts_pin
uint8_t c4gltee_get_cts_pin(c4gltee_t *ctx)
CTS Pin Get function.
c4gltee_send_cmd
void c4gltee_send_cmd(c4gltee_t *ctx, char *cmd)
Send command function.
c4gltee_get_ring_pin
uint8_t c4gltee_get_ring_pin(c4gltee_t *ctx)
RING Pin Get function.
c4gltee_t::cts
digital_in_t cts
Definition: c4gltee.h:122
C4GLTEE_OK
@ C4GLTEE_OK
Definition: c4gltee.h:165
c4gltee_t::uart
uart_t uart
Definition: c4gltee.h:125
c4gltee_cfg_setup
void c4gltee_cfg_setup(c4gltee_cfg_t *cfg)
4G LTE-E configuration object setup function.
c4gltee_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: c4gltee.h:153
c4gltee_t::ring
digital_in_t ring
Definition: c4gltee.h:121
c4gltee_set_rts_pin
void c4gltee_set_rts_pin(c4gltee_t *ctx, uint8_t state)
Sets state of the RTS pin.
c4gltee_cfg_t::pwk
pin_name_t pwk
Definition: c4gltee.h:145
c4gltee_send_sms_pdu
err_t c4gltee_send_sms_pdu(c4gltee_t *ctx, char *service_center_number, char *phone_number, char *sms_text)
4G LTE-E send SMS in PDU mode.
c4gltee_cfg_t::cts
pin_name_t cts
Definition: c4gltee.h:148
c4gltee_t
4G LTE-E Click context object.
Definition: c4gltee.h:114
c4gltee_t::pwk
digital_out_t pwk
Definition: c4gltee.h:116
c4gltee_return_value_t
c4gltee_return_value_t
4G LTE-E Click return value data.
Definition: c4gltee.h:164
c4gltee_cfg_t::tx_pin
pin_name_t tx_pin
Definition: c4gltee.h:141
c4gltee_cfg_t::rts
pin_name_t rts
Definition: c4gltee.h:146
c4gltee_set_sim_apn
void c4gltee_set_sim_apn(c4gltee_t *ctx, char *sim_apn)
Set sim card APN.
c4gltee_cfg_t::rx_pin
pin_name_t rx_pin
Definition: c4gltee.h:140
c4gltee_init
err_t c4gltee_init(c4gltee_t *ctx, c4gltee_cfg_t *cfg)
4G LTE-E initialization function.
c4gltee_t::sta
digital_in_t sta
Definition: c4gltee.h:120
c4gltee_send_sms_text
void c4gltee_send_sms_text(c4gltee_t *ctx, char *phone_number, char *sms_text)
4G LTE-E send SMS in text mode.
c4gltee_generic_read
err_t c4gltee_generic_read(c4gltee_t *ctx, char *data_buf, uint16_t max_len)
4G LTE-E data reading function.
c4gltee_get_sta_pin
uint8_t c4gltee_get_sta_pin(c4gltee_t *ctx)
STA Pin Get function.
c4gltee_send_cmd_check
void c4gltee_send_cmd_check(c4gltee_t *ctx, char *at_cmd_buf)
Check the sent command.