lteiot6  2.0.0.0
lteiot6.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 LTEIOT6_H
29 #define LTEIOT6_H
30 
31 #include "drv_digital_out.h"
32 #include "drv_digital_in.h"
33 #include "drv_uart.h"
34 
35 
56 #define LTEIOT6_CMD_AT "AT"
57 #define LTEIOT6_CMD_ATI "ATI"
58 #define LTEIOT6_CMD_CGMR "AT+CGMR"
59 #define LTEIOT6_CMD_CFUN "AT+CFUN"
60 #define LTEIOT6_CMD_CREG "AT+CREG"
61 #define LTEIOT6_CMD_CEREG "AT+CEREG"
62 #define LTEIOT6_CMD_CGDCONT "AT+CGDCONT"
63 #define LTEIOT6_CMD_CIMI "AT+CIMI"
64 #define LTEIOT6_CMD_CGATT "AT+CGATT"
65 #define LTEIOT6_CMD_CSQ "AT+CSQ"
66 #define LTEIOT6_CMD_CESQ "AT+CESQ"
67 #define LTEIOT6_CMD_COPS "AT+COPS"
68 #define LTEIOT6_CMD_CMGF "AT+CMGF"
69 #define LTEIOT6_CMD_CMGS "AT+CMGS"
70 #define LTEIOT6_CMD_CSCA "AT+CSCA"
71 #define LTEIOT6_CMD_SQNLED "AT+SQNLED"
72  // lteiot6_cmd
74 
89 #define LTEIOT6_RSP_OK "OK"
90 #define LTEIOT6_RSP_ERROR "ERROR"
91 #define LTEIOT6_RSP_SYSTART "+SYSSTART"
92 
97 #define DRV_BUFFER_SIZE 400
98  // lteiot6_set
100 
115 #define LTEIOT6_MAP_MIKROBUS( cfg, mikrobus ) \
116  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
117  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
118  cfg.pwr = MIKROBUS( mikrobus, MIKROBUS_AN ); \
119  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
120  cfg.rts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
121  cfg.ri = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
122  cfg.cts = MIKROBUS( mikrobus, MIKROBUS_INT );
123  // lteiot6_map // lteiot6
126 
131 typedef struct
132 {
133  // Output pins
134  digital_out_t pwr;
135  digital_out_t rst;
136  digital_out_t rts;
137 
138  // Input pins
139  digital_in_t ri;
140  digital_in_t cts;
141  digital_in_t rx_pin;
142 
143  // Modules
144 
145  uart_t uart;
146 
147  char uart_rx_buffer[ DRV_BUFFER_SIZE ];
148  char uart_tx_buffer[ DRV_BUFFER_SIZE ];
149 
150 } lteiot6_t;
151 
156 typedef struct
157 {
158  // Communication gpio pins
159  pin_name_t rx_pin;
160  pin_name_t tx_pin;
161 
162  // Additional gpio pins
163  pin_name_t pwr;
164  pin_name_t rst;
165  pin_name_t rts;
166  pin_name_t ri;
167  pin_name_t cts;
168 
169  // static variable
170  uint32_t baud_rate; // Clock speed.
171  bool uart_blocking;
172  uart_data_bits_t data_bit; // Data bits.
173  uart_parity_t parity_bit; // Parity bit.
174  uart_stop_bits_t stop_bit; // Stop bits.
175 
176 } lteiot6_cfg_t;
177 
182 typedef enum
183 {
189 
191 
198 #ifdef __cplusplus
199 extern "C"{
200 #endif
201 
211 void lteiot6_cfg_setup ( lteiot6_cfg_t *cfg );
212 
227 err_t lteiot6_init ( lteiot6_t *ctx, lteiot6_cfg_t *cfg );
228 
242 err_t lteiot6_generic_write ( lteiot6_t *ctx, char *data_buf, uint16_t len );
243 
257 err_t lteiot6_generic_read ( lteiot6_t *ctx, char *data_buf, uint16_t max_len );
258 
266 void lteiot6_power_on ( lteiot6_t *ctx );
267 
275 void lteiot6_reset ( lteiot6_t *ctx );
276 
285 void lteiot6_set_pwr ( lteiot6_t *ctx, uint8_t state );
286 
295 void lteiot6_set_rst ( lteiot6_t *ctx, uint8_t state );
296 
305 void lteiot6_set_rts ( lteiot6_t *ctx, uint8_t state );
306 
315 uint8_t lteiot6_get_ri ( lteiot6_t *ctx );
316 
325 uint8_t lteiot6_get_cts ( lteiot6_t *ctx );
326 
338 void lteiot6_send_cmd ( lteiot6_t *ctx, char *cmd );
339 
352 void lteiot6_send_cmd_with_parameter ( lteiot6_t *ctx, char *at_cmd_buf, char *param_buf );
353 
365 void lteiot6_send_cmd_check ( lteiot6_t *ctx, char *at_cmd_buf );
366 
378 void lteiot6_send_cmd_parameter_check ( lteiot6_t *ctx, char *at_cmd_buf );
379 
391 void lteiot6_set_sim_apn ( lteiot6_t *ctx, char *sim_apn );
392 
405 void lteiot6_send_text_message ( lteiot6_t *ctx, char *phone_number, char *message_content );
406 
420 err_t lteiot6_send_sms_pdu ( lteiot6_t *ctx, char *service_center_number, char *phone_number, char *sms_text );
421 
422 #ifdef __cplusplus
423 }
424 #endif
425 #endif // LTEIOT6_H
426  // lteiot6
428 
429 // ------------------------------------------------------------------------ END
LTEIOT6_ERROR
Definition: lteiot6.h:184
lteiot6_generic_read
err_t lteiot6_generic_read(lteiot6_t *ctx, char *data_buf, uint16_t max_len)
LTE IoT 6 data reading function.
lteiot6_set_sim_apn
void lteiot6_set_sim_apn(lteiot6_t *ctx, char *sim_apn)
Set sim card APN.
lteiot6_init
err_t lteiot6_init(lteiot6_t *ctx, lteiot6_cfg_t *cfg)
LTE IoT 6 initialization function.
LTEIOT6_ERROR_UNKNOWN
Definition: lteiot6.h:187
LTEIOT6_OK
Definition: lteiot6.h:183
lteiot6_send_cmd
void lteiot6_send_cmd(lteiot6_t *ctx, char *cmd)
Send command function.
lteiot6_generic_write
err_t lteiot6_generic_write(lteiot6_t *ctx, char *data_buf, uint16_t len)
LTE IoT 6 data writing function.
lteiot6_cfg_setup
void lteiot6_cfg_setup(lteiot6_cfg_t *cfg)
LTE IoT 6 configuration object setup function.
lteiot6_t
LTE IoT 6 Click context object.
Definition: lteiot6.h:130
lteiot6_set_pwr
void lteiot6_set_pwr(lteiot6_t *ctx, uint8_t state)
Sets state of the PWR pin.
lteiot6_cfg_t
LTE IoT 6 Click configuration object.
Definition: lteiot6.h:155
DRV_BUFFER_SIZE
#define DRV_BUFFER_SIZE
LTE IoT 6 driver buffer size.
Definition: lteiot6.h:96
lteiot6_send_cmd_parameter_check
void lteiot6_send_cmd_parameter_check(lteiot6_t *ctx, char *at_cmd_buf)
Check the command parameters.
lteiot6_get_ri
uint8_t lteiot6_get_ri(lteiot6_t *ctx)
RI Pin Get function.
lteiot6_set_rts
void lteiot6_set_rts(lteiot6_t *ctx, uint8_t state)
Sets state of the RTS pin.
lteiot6_send_cmd_check
void lteiot6_send_cmd_check(lteiot6_t *ctx, char *at_cmd_buf)
Check the sent command.
lteiot8_return_value_t
lteiot8_return_value_t
LTE IoT 6 Click return value data.
Definition: lteiot6.h:181
lteiot6_power_on
void lteiot6_power_on(lteiot6_t *ctx)
LTE IoT 6 power on.
lteiot6_send_text_message
void lteiot6_send_text_message(lteiot6_t *ctx, char *phone_number, char *message_content)
Send SMS message to number in text mode.
LTEIOT6_ERROR_TIMEOUT
Definition: lteiot6.h:185
LTEIOT6_ERROR_CMD
Definition: lteiot6.h:186
lteiot6_send_cmd_with_parameter
void lteiot6_send_cmd_with_parameter(lteiot6_t *ctx, char *at_cmd_buf, char *param_buf)
Send command function with parameter.
lteiot6_get_cts
uint8_t lteiot6_get_cts(lteiot6_t *ctx)
CTS Pin Get function.
lteiot6_reset
void lteiot6_reset(lteiot6_t *ctx)
LTE IoT 6 power on.
lteiot6_send_sms_pdu
err_t lteiot6_send_sms_pdu(lteiot6_t *ctx, char *service_center_number, char *phone_number, char *sms_text)
Send SMS message to number in pdu mode.
lteiot6_set_rst
void lteiot6_set_rst(lteiot6_t *ctx, uint8_t state)
Sets state of the RST pin.