lteiot8  2.0.0.0
lteiot8.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 LTEIOT8_H
29 #define LTEIOT8_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 LTEIOT8_CMD_AT "AT"
60 #define LTEIOT8_CMD_ATI "ATI"
61 #define LTEIOT8_CMD_CGMR "AT+CGMR"
62 #define LTEIOT8_CMD_CFUN "AT+CFUN"
63 #define LTEIOT8_CMD_CREG "AT+CREG"
64 #define LTEIOT8_CMD_CEREG "AT+CEREG"
65 #define LTEIOT8_CMD_CGDCONT "AT+CGDCONT"
66 #define LTEIOT8_CMD_CIMI "AT+CIMI"
67 #define LTEIOT8_CMD_CGATT "AT+CGATT"
68 #define LTEIOT8_CMD_CSQ "AT+CSQ"
69 #define LTEIOT8_CMD_CESQ "AT+CESQ"
70 #define LTEIOT8_CMD_COPS "AT+COPS"
71 #define LTEIOT8_CMD_CMGF "AT+CMGF"
72 #define LTEIOT8_CMD_CMGS "AT+CMGS"
73 #define LTEIOT8_CMD_CSCA "AT+CSCA"
74 #define LTEIOT8_CMD_SQNLED "AT+SQNLED"
75  // lteiot8_cmd
77 
92 #define LTEIOT8_RSP_OK "OK"
93 #define LTEIOT8_RSP_ERROR "ERROR"
94 #define LTEIOT8_RSP_SYSTART "+SYSSTART"
95 
101 #define DRV_TX_BUFFER_SIZE 200
102 #define DRV_RX_BUFFER_SIZE 500
103  // lteiot8_set
105 
120 #define LTEIOT8_MAP_MIKROBUS( cfg, mikrobus ) \
121  cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
122  cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
123  cfg.rng = MIKROBUS( mikrobus, MIKROBUS_AN ); \
124  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
125  cfg.cts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
126  cfg.pst = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
127  cfg.rts = MIKROBUS( mikrobus, MIKROBUS_INT );
128  // lteiot8_map // lteiot8
131 
136 typedef struct
137 {
138  // Output pins
139  digital_out_t rst;
140  digital_out_t cts;
142  // Input pins
143  digital_in_t rng;
144  digital_in_t pst;
145  digital_in_t rts;
147  // Modules
148  uart_t uart;
150  // Buffers
151  char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
152  char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
154 } lteiot8_t;
155 
160 typedef struct
161 {
162  // Communication gpio pins
163  pin_name_t rx_pin;
164  pin_name_t tx_pin;
166  // Additional gpio pins
167  pin_name_t rng;
168  pin_name_t rst;
169  pin_name_t cts;
170  pin_name_t pst;
171  pin_name_t rts;
173  // Static variable
174 
175  uint32_t baud_rate;
176  bool uart_blocking;
177  uart_data_bits_t data_bit;
178  uart_parity_t parity_bit;
179  uart_stop_bits_t stop_bit;
181 } lteiot8_cfg_t;
182 
187 typedef enum
188 {
194 
196 
212 void lteiot8_cfg_setup ( lteiot8_cfg_t *cfg );
213 
228 err_t lteiot8_init ( lteiot8_t *ctx, lteiot8_cfg_t *cfg );
229 
243 err_t lteiot8_default_cfg ( lteiot8_t *ctx );
244 
258 err_t lteiot8_generic_write ( lteiot8_t *ctx, char *data_buf, uint16_t len );
259 
273 err_t lteiot8_generic_read ( lteiot8_t *ctx, char *data_buf, uint16_t max_len );
274 
284 void lteiot8_send_cmd ( lteiot8_t *ctx, char *cmd );
285 
297 void lteiot8_send_cmd_with_parameter ( lteiot8_t *ctx, char *at_cmd_buf, char *param_buf );
298 
308 void lteiot8_send_cmd_check ( lteiot8_t *ctx, char *at_cmd_buf );
309 
319 void lteiot8_send_cmd_syntax_check ( lteiot8_t *ctx, char *at_cmd_buf );
320 
330 void lteiot8_set_sim_apn ( lteiot8_t *ctx, char *sim_apn );
331 
344 void lteiot8_send_text_message ( lteiot8_t *ctx, char *phone_number, char *message_content );
345 
359 err_t lteiot8_send_sms_pdu ( lteiot8_t *ctx, char *service_center_number, char *phone_number, char *sms_text );
360 
361 #ifdef __cplusplus
362 }
363 #endif
364 #endif // LTEIOT8_H
365  // lteiot8
367 
368 // ------------------------------------------------------------------------ END
lteiot8_send_cmd_with_parameter
void lteiot8_send_cmd_with_parameter(lteiot8_t *ctx, char *at_cmd_buf, char *param_buf)
Send command with parameters.
DRV_TX_BUFFER_SIZE
#define DRV_TX_BUFFER_SIZE
LTE IoT 8 driver buffer size.
Definition: lteiot8.h:100
lteiot8_send_cmd
void lteiot8_send_cmd(lteiot8_t *ctx, char *cmd)
Send command function.
LTEIOT8_OK
Definition: lteiot8.h:188
lteiot8_set_sim_apn
void lteiot8_set_sim_apn(lteiot8_t *ctx, char *sim_apn)
Set SIM APN.
lteiot8_send_text_message
void lteiot8_send_text_message(lteiot8_t *ctx, char *phone_number, char *message_content)
Send SMS message to number in text mode.
LTEIOT8_ERROR_TIMEOUT
Definition: lteiot8.h:190
lteiot8_send_cmd_check
void lteiot8_send_cmd_check(lteiot8_t *ctx, char *at_cmd_buf)
Send command to check commands current value.
lteiot8_default_cfg
err_t lteiot8_default_cfg(lteiot8_t *ctx)
LTE IoT 8 default configuration function.
lteiot8_cfg_setup
void lteiot8_cfg_setup(lteiot8_cfg_t *cfg)
LTE IoT 8 configuration object setup function.
LTEIOT8_ERROR_UNKNOWN
Definition: lteiot8.h:192
lteiot8_generic_write
err_t lteiot8_generic_write(lteiot8_t *ctx, char *data_buf, uint16_t len)
LTE IoT 8 data writing function.
lteiot8_cfg_t
LTE IoT 8 Click configuration object.
Definition: lteiot8.h:159
LTEIOT8_ERROR
Definition: lteiot8.h:189
DRV_RX_BUFFER_SIZE
#define DRV_RX_BUFFER_SIZE
Definition: lteiot8.h:101
lteiot8_t
LTE IoT 8 Click context object.
Definition: lteiot8.h:135
lteiot8_return_value_t
lteiot8_return_value_t
LTE IoT 8 Click return value data.
Definition: lteiot8.h:186
lteiot8_send_cmd_syntax_check
void lteiot8_send_cmd_syntax_check(lteiot8_t *ctx, char *at_cmd_buf)
Send command to check commands available parameters.
lteiot8_init
err_t lteiot8_init(lteiot8_t *ctx, lteiot8_cfg_t *cfg)
LTE IoT 8 initialization function.
lteiot8_send_sms_pdu
err_t lteiot8_send_sms_pdu(lteiot8_t *ctx, char *service_center_number, char *phone_number, char *sms_text)
Send SMS message to number in pdu mode.
lteiot8_generic_read
err_t lteiot8_generic_read(lteiot8_t *ctx, char *data_buf, uint16_t max_len)
LTE IoT 8 data reading function.
LTEIOT8_ERROR_CMD
Definition: lteiot8.h:191