ltecat43  2.1.0.0
ltecat43.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 LTECAT43_H
29 #define LTECAT43_H
30 
31 #ifdef __cplusplus
32 extern "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 LTECAT43_CMD_AT "AT"
74 #define LTECAT43_CMD_ATI "ATI"
75 #define LTECAT43_CMD_CGMR "AT+CGMR"
76 #define LTECAT43_CMD_CFUN "AT+CFUN"
77 #define LTECAT43_CMD_CREG "AT+CREG"
78 #define LTECAT43_CMD_CGREG "AT+CGREG"
79 #define LTECAT43_CMD_CGDCONT "AT+CGDCONT"
80 #define LTECAT43_CMD_CIMI "AT+CIMI"
81 #define LTECAT43_CMD_CMEE "AT+CMEE"
82 #define LTECAT43_CMD_CGATT "AT+CGATT"
83 #define LTECAT43_CMD_CSQ "AT+CSQ"
84 #define LTECAT43_CMD_COPS "AT+COPS"
85 #define LTECAT43_CMD_CMGS "AT+CMGS"
86 #define LTECAT43_CMD_CMGF "AT+CMGF"
87 #define LTECAT43_CMD_CGACT "AT+CGACT"
88 #define LTECAT43_CMD_USOCR "AT+USOCR"
89 #define LTECAT43_CMD_USOCO "AT+USOCO"
90 #define LTECAT43_CMD_USOWR "AT+USOWR"
91 #define LTECAT43_CMD_USOST "AT+USOST"
92 #define LTECAT43_CMD_USORD "AT+USORD"
93 #define LTECAT43_CMD_USORF "AT+USORF"
94 #define LTECAT43_CMD_USOCL "AT+USOCL"
95 #define LTECAT43_CMD_UGPS "AT+UGPS"
96 #define LTECAT43_CMD_UGGGA "AT+UGGGA"
97 
102 #define LTECAT43_RSP_OK "OK"
103 #define LTECAT43_RSP_ERROR "ERROR"
104 
109 #define LTECAT43_POWER_STATE_OFF 0
110 #define LTECAT43_POWER_STATE_ON 1
111 
117 #define LTECAT43_TX_DRV_BUFFER_SIZE 256
118 #define LTECAT43_RX_DRV_BUFFER_SIZE 256
119  // ltecat43_cmd
121 
136 #define LTECAT43_MAP_MIKROBUS( cfg, mikrobus ) \
137  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
138  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
139  cfg.sts = MIKROBUS( mikrobus, MIKROBUS_AN ); \
140  cfg.pwr = MIKROBUS( mikrobus, MIKROBUS_RST ); \
141  cfg.rts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
142  cfg.ri = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
143  cfg.cts = MIKROBUS( mikrobus, MIKROBUS_INT );
144  // ltecat43_map // ltecat43
147 
152 typedef struct
153 {
154  // Output pins
155  digital_out_t sts;
156  digital_out_t pwr;
157  digital_out_t rts;
159  // Input pins
160  digital_in_t ri;
161  digital_in_t cts;
163  // Modules
164  uart_t uart;
166  // Buffers
167  uint8_t uart_rx_buffer[ LTECAT43_TX_DRV_BUFFER_SIZE ];
168  uint8_t uart_tx_buffer[ LTECAT43_RX_DRV_BUFFER_SIZE ];
170 } ltecat43_t;
171 
176 typedef struct
177 {
178  // Communication gpio pins
179  pin_name_t rx_pin;
180  pin_name_t tx_pin;
182  // Additional gpio pins
183  pin_name_t sts;
184  pin_name_t pwr;
185  pin_name_t rts;
186  pin_name_t ri;
187  pin_name_t cts;
189  // Static variable
190  uint32_t baud_rate;
192  uart_data_bits_t data_bit;
193  uart_parity_t parity_bit;
194  uart_stop_bits_t stop_bit;
197 
202 typedef enum
203 {
209 
211 
228 
243 
256 err_t ltecat43_generic_write ( ltecat43_t *ctx, uint8_t *data_in, uint16_t len );
257 
270 err_t ltecat43_generic_read ( ltecat43_t *ctx, uint8_t *data_out, uint16_t len );
271 
281 void ltecat43_set_pwr_pin ( ltecat43_t *ctx, uint8_t state );
282 
292 void ltecat43_set_sts_pin ( ltecat43_t *ctx, uint8_t state );
293 
303 void ltecat43_set_rts_pin ( ltecat43_t *ctx, uint8_t state );
304 
314 
324 
335 void ltecat43_set_power_state ( ltecat43_t *ctx, uint8_t state );
336 
346 void ltecat43_send_cmd ( ltecat43_t *ctx, uint8_t *cmd );
347 
358 void ltecat43_send_cmd_par ( ltecat43_t *ctx, uint8_t *at_cmd_buf, uint8_t *param_buf );
359 
369 void ltecat43_send_cmd_check ( ltecat43_t *ctx, uint8_t *at_cmd_buf );
370 
380 void ltecat43_set_sim_apn ( ltecat43_t *ctx, uint8_t *sim_apn );
381 
392 void ltecat43_send_sms_text ( ltecat43_t *ctx, uint8_t *phone_number, uint8_t *sms_text );
393 
407 err_t ltecat43_send_sms_pdu ( ltecat43_t *ctx, uint8_t *service_center_number, uint8_t *phone_number, uint8_t *sms_text );
408 
409 #ifdef __cplusplus
410 }
411 #endif
412 #endif // LTECAT43_H
413  // ltecat43
415 
416 // ------------------------------------------------------------------------ END
ltecat43_cfg_t::rx_pin
pin_name_t rx_pin
Definition: ltecat43.h:179
ltecat43_set_sts_pin
void ltecat43_set_sts_pin(ltecat43_t *ctx, uint8_t state)
LTE Cat.4 3 set STS pin function.
ltecat43_send_cmd_check
void ltecat43_send_cmd_check(ltecat43_t *ctx, uint8_t *at_cmd_buf)
Check the sent command.
LTECAT43_ERROR
@ LTECAT43_ERROR
Definition: ltecat43.h:205
ltecat43_cfg_setup
void ltecat43_cfg_setup(ltecat43_cfg_t *cfg)
LTE Cat.4 3 configuration object setup function.
ltecat43_send_sms_pdu
err_t ltecat43_send_sms_pdu(ltecat43_t *ctx, uint8_t *service_center_number, uint8_t *phone_number, uint8_t *sms_text)
LTE Cat.4 3 send SMS in PDU mode.
ltecat43_t
LTE Cat.4 3 Click context object.
Definition: ltecat43.h:153
ltecat43_cfg_t::tx_pin
pin_name_t tx_pin
Definition: ltecat43.h:180
LTECAT43_ERROR_TIMEOUT
@ LTECAT43_ERROR_TIMEOUT
Definition: ltecat43.h:206
ltecat43_cfg_t::ri
pin_name_t ri
Definition: ltecat43.h:186
ltecat43_t::cts
digital_in_t cts
Definition: ltecat43.h:161
ltecat43_t::pwr
digital_out_t pwr
Definition: ltecat43.h:156
ltecat43_cfg_t::pwr
pin_name_t pwr
Definition: ltecat43.h:184
ltecat43_send_sms_text
void ltecat43_send_sms_text(ltecat43_t *ctx, uint8_t *phone_number, uint8_t *sms_text)
LTE Cat.4 3 send SMS in text mode.
ltecat43_send_cmd
void ltecat43_send_cmd(ltecat43_t *ctx, uint8_t *cmd)
Send command function.
ltecat43_cfg_t::rts
pin_name_t rts
Definition: ltecat43.h:185
ltecat43_init
err_t ltecat43_init(ltecat43_t *ctx, ltecat43_cfg_t *cfg)
LTE Cat.4 3 initialization function.
ltecat43_get_ri_pin
uint8_t ltecat43_get_ri_pin(ltecat43_t *ctx)
LTE Cat.4 3 get RI pin function.
ltecat43_generic_write
err_t ltecat43_generic_write(ltecat43_t *ctx, uint8_t *data_in, uint16_t len)
LTE Cat.4 3 data writing function.
ltecat43_cfg_t::data_bit
uart_data_bits_t data_bit
Definition: ltecat43.h:192
LTECAT43_OK
@ LTECAT43_OK
Definition: ltecat43.h:204
ltecat43_set_power_state
void ltecat43_set_power_state(ltecat43_t *ctx, uint8_t state)
LTE Cat.4 3 set power state function.
ltecat43_set_pwr_pin
void ltecat43_set_pwr_pin(ltecat43_t *ctx, uint8_t state)
LTE Cat.4 3 set PWR pin function.
ltecat43_send_cmd_par
void ltecat43_send_cmd_par(ltecat43_t *ctx, uint8_t *at_cmd_buf, uint8_t *param_buf)
Send command function with parameter.
LTECAT43_RX_DRV_BUFFER_SIZE
#define LTECAT43_RX_DRV_BUFFER_SIZE
Definition: ltecat43.h:118
ltecat43_t::rts
digital_out_t rts
Definition: ltecat43.h:157
ltecat43_return_value_t
ltecat43_return_value_t
LTE Cat.4 3 Click return value data.
Definition: ltecat43.h:203
ltecat43_cfg_t::cts
pin_name_t cts
Definition: ltecat43.h:187
ltecat43_t::sts
digital_out_t sts
Definition: ltecat43.h:155
ltecat43_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: ltecat43.h:194
ltecat43_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: ltecat43.h:193
ltecat43_generic_read
err_t ltecat43_generic_read(ltecat43_t *ctx, uint8_t *data_out, uint16_t len)
LTE Cat.4 3 data reading function.
ltecat43_cfg_t::baud_rate
uint32_t baud_rate
Definition: ltecat43.h:190
LTECAT43_ERROR_UNKNOWN
@ LTECAT43_ERROR_UNKNOWN
Definition: ltecat43.h:208
ltecat43_cfg_t
LTE Cat.4 3 Click configuration object.
Definition: ltecat43.h:177
LTECAT43_TX_DRV_BUFFER_SIZE
#define LTECAT43_TX_DRV_BUFFER_SIZE
LTE Cat.4 3 driver buffer size.
Definition: ltecat43.h:117
ltecat43_t::uart
uart_t uart
Definition: ltecat43.h:164
ltecat43_cfg_t::sts
pin_name_t sts
Definition: ltecat43.h:183
ltecat43_set_sim_apn
void ltecat43_set_sim_apn(ltecat43_t *ctx, uint8_t *sim_apn)
Set sim card APN.
ltecat43_t::ri
digital_in_t ri
Definition: ltecat43.h:160
LTECAT43_ERROR_CMD
@ LTECAT43_ERROR_CMD
Definition: ltecat43.h:207
ltecat43_cfg_t::uart_blocking
bool uart_blocking
Definition: ltecat43.h:191
ltecat43_get_cts_pin
uint8_t ltecat43_get_cts_pin(ltecat43_t *ctx)
LTE Cat.4 3 get CTS pin function.
ltecat43_set_rts_pin
void ltecat43_set_rts_pin(ltecat43_t *ctx, uint8_t state)
LTE Cat.4 3 set RTS pin function.