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 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_uart.h"
48 
69 #define LTECAT43_CMD_AT "AT"
70 #define LTECAT43_CMD_ATI "ATI"
71 #define LTECAT43_CMD_CGMR "AT+CGMR"
72 #define LTECAT43_CMD_CFUN "AT+CFUN"
73 #define LTECAT43_CMD_CREG "AT+CREG"
74 #define LTECAT43_CMD_CGREG "AT+CGREG"
75 #define LTECAT43_CMD_CGDCONT "AT+CGDCONT"
76 #define LTECAT43_CMD_CIMI "AT+CIMI"
77 #define LTECAT43_CMD_CMEE "AT+CMEE"
78 #define LTECAT43_CMD_CGATT "AT+CGATT"
79 #define LTECAT43_CMD_CSQ "AT+CSQ"
80 #define LTECAT43_CMD_COPS "AT+COPS"
81 #define LTECAT43_CMD_CMGS "AT+CMGS"
82 #define LTECAT43_CMD_CMGF "AT+CMGF"
83 #define LTECAT43_CMD_CGACT "AT+CGACT"
84 #define LTECAT43_CMD_USOCR "AT+USOCR"
85 #define LTECAT43_CMD_USOCO "AT+USOCO"
86 #define LTECAT43_CMD_USOWR "AT+USOWR"
87 #define LTECAT43_CMD_USOST "AT+USOST"
88 #define LTECAT43_CMD_USORD "AT+USORD"
89 #define LTECAT43_CMD_USORF "AT+USORF"
90 #define LTECAT43_CMD_USOCL "AT+USOCL"
91 #define LTECAT43_CMD_UGPS "AT+UGPS"
92 #define LTECAT43_CMD_UGGGA "AT+UGGGA"
93 
98 #define LTECAT43_RSP_OK "OK"
99 #define LTECAT43_RSP_ERROR "ERROR"
100 
105 #define LTECAT43_POWER_STATE_OFF 0
106 #define LTECAT43_POWER_STATE_ON 1
107 
113 #define LTECAT43_TX_DRV_BUFFER_SIZE 256
114 #define LTECAT43_RX_DRV_BUFFER_SIZE 256
115  // ltecat43_cmd
117 
132 #define LTECAT43_MAP_MIKROBUS( cfg, mikrobus ) \
133  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
134  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
135  cfg.sts = MIKROBUS( mikrobus, MIKROBUS_AN ); \
136  cfg.pwr = MIKROBUS( mikrobus, MIKROBUS_RST ); \
137  cfg.rts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
138  cfg.ri = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
139  cfg.cts = MIKROBUS( mikrobus, MIKROBUS_INT );
140  // ltecat43_map // ltecat43
143 
148 typedef struct
149 {
150  // Output pins
151  digital_out_t sts;
152  digital_out_t pwr;
153  digital_out_t rts;
155  // Input pins
156  digital_in_t ri;
157  digital_in_t cts;
159  // Modules
160  uart_t uart;
162  // Buffers
163  uint8_t uart_rx_buffer[ LTECAT43_TX_DRV_BUFFER_SIZE ];
164  uint8_t uart_tx_buffer[ LTECAT43_RX_DRV_BUFFER_SIZE ];
166 } ltecat43_t;
167 
172 typedef struct
173 {
174  // Communication gpio pins
175  pin_name_t rx_pin;
176  pin_name_t tx_pin;
178  // Additional gpio pins
179  pin_name_t sts;
180  pin_name_t pwr;
181  pin_name_t rts;
182  pin_name_t ri;
183  pin_name_t cts;
185  // Static variable
186  uint32_t baud_rate;
188  uart_data_bits_t data_bit;
189  uart_parity_t parity_bit;
190  uart_stop_bits_t stop_bit;
193 
198 typedef enum
199 {
205 
207 
224 
239 
252 err_t ltecat43_generic_write ( ltecat43_t *ctx, uint8_t *data_in, uint16_t len );
253 
266 err_t ltecat43_generic_read ( ltecat43_t *ctx, uint8_t *data_out, uint16_t len );
267 
277 void ltecat43_set_pwr_pin ( ltecat43_t *ctx, uint8_t state );
278 
288 void ltecat43_set_sts_pin ( ltecat43_t *ctx, uint8_t state );
289 
299 void ltecat43_set_rts_pin ( ltecat43_t *ctx, uint8_t state );
300 
310 
320 
331 void ltecat43_set_power_state ( ltecat43_t *ctx, uint8_t state );
332 
342 void ltecat43_send_cmd ( ltecat43_t *ctx, uint8_t *cmd );
343 
354 void ltecat43_send_cmd_par ( ltecat43_t *ctx, uint8_t *at_cmd_buf, uint8_t *param_buf );
355 
365 void ltecat43_send_cmd_check ( ltecat43_t *ctx, uint8_t *at_cmd_buf );
366 
376 void ltecat43_set_sim_apn ( ltecat43_t *ctx, uint8_t *sim_apn );
377 
388 void ltecat43_send_sms_text ( ltecat43_t *ctx, uint8_t *phone_number, uint8_t *sms_text );
389 
403 err_t ltecat43_send_sms_pdu ( ltecat43_t *ctx, uint8_t *service_center_number, uint8_t *phone_number, uint8_t *sms_text );
404 
405 #ifdef __cplusplus
406 }
407 #endif
408 #endif // LTECAT43_H
409  // ltecat43
411 
412 // ------------------------------------------------------------------------ END
ltecat43_cfg_t::rx_pin
pin_name_t rx_pin
Definition: ltecat43.h:175
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:201
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:149
ltecat43_cfg_t::tx_pin
pin_name_t tx_pin
Definition: ltecat43.h:176
LTECAT43_ERROR_TIMEOUT
@ LTECAT43_ERROR_TIMEOUT
Definition: ltecat43.h:202
ltecat43_cfg_t::ri
pin_name_t ri
Definition: ltecat43.h:182
ltecat43_t::cts
digital_in_t cts
Definition: ltecat43.h:157
ltecat43_t::pwr
digital_out_t pwr
Definition: ltecat43.h:152
ltecat43_cfg_t::pwr
pin_name_t pwr
Definition: ltecat43.h:180
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:181
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:188
LTECAT43_OK
@ LTECAT43_OK
Definition: ltecat43.h:200
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:114
ltecat43_t::rts
digital_out_t rts
Definition: ltecat43.h:153
ltecat43_return_value_t
ltecat43_return_value_t
LTE Cat.4 3 Click return value data.
Definition: ltecat43.h:199
ltecat43_cfg_t::cts
pin_name_t cts
Definition: ltecat43.h:183
ltecat43_t::sts
digital_out_t sts
Definition: ltecat43.h:151
ltecat43_cfg_t::stop_bit
uart_stop_bits_t stop_bit
Definition: ltecat43.h:190
ltecat43_cfg_t::parity_bit
uart_parity_t parity_bit
Definition: ltecat43.h:189
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:186
LTECAT43_ERROR_UNKNOWN
@ LTECAT43_ERROR_UNKNOWN
Definition: ltecat43.h:204
ltecat43_cfg_t
LTE Cat.4 3 Click configuration object.
Definition: ltecat43.h:173
LTECAT43_TX_DRV_BUFFER_SIZE
#define LTECAT43_TX_DRV_BUFFER_SIZE
LTE Cat.4 3 driver buffer size.
Definition: ltecat43.h:113
ltecat43_t::uart
uart_t uart
Definition: ltecat43.h:160
ltecat43_cfg_t::sts
pin_name_t sts
Definition: ltecat43.h:179
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:156
LTECAT43_ERROR_CMD
@ LTECAT43_ERROR_CMD
Definition: ltecat43.h:203
ltecat43_cfg_t::uart_blocking
bool uart_blocking
Definition: ltecat43.h:187
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.