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
32extern "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 LTEIOT8_CMD_AT "AT"
74#define LTEIOT8_CMD_ATI "ATI"
75#define LTEIOT8_CMD_CGMR "AT+CGMR"
76#define LTEIOT8_CMD_CFUN "AT+CFUN"
77#define LTEIOT8_CMD_CREG "AT+CREG"
78#define LTEIOT8_CMD_CEREG "AT+CEREG"
79#define LTEIOT8_CMD_CGDCONT "AT+CGDCONT"
80#define LTEIOT8_CMD_CIMI "AT+CIMI"
81#define LTEIOT8_CMD_CGATT "AT+CGATT"
82#define LTEIOT8_CMD_CSQ "AT+CSQ"
83#define LTEIOT8_CMD_CESQ "AT+CESQ"
84#define LTEIOT8_CMD_COPS "AT+COPS"
85#define LTEIOT8_CMD_CMGF "AT+CMGF"
86#define LTEIOT8_CMD_CMGS "AT+CMGS"
87#define LTEIOT8_CMD_CSCA "AT+CSCA"
88#define LTEIOT8_CMD_SQNLED "AT+SQNLED"
89
90 // lteiot8_cmd
91
106#define LTEIOT8_RSP_OK "OK"
107#define LTEIOT8_RSP_ERROR "ERROR"
108#define LTEIOT8_RSP_SYSTART "+SYSSTART"
109
115#define DRV_TX_BUFFER_SIZE 200
116#define DRV_RX_BUFFER_SIZE 500
117
118 // lteiot8_set
119
134#define LTEIOT8_MAP_MIKROBUS( cfg, mikrobus ) \
135 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
136 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
137 cfg.rng = MIKROBUS( mikrobus, MIKROBUS_AN ); \
138 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
139 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
140 cfg.pst = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
141 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_INT );
142
143 // lteiot8_map
144 // lteiot8
145
150typedef struct
151{
152 // Output pins
153 digital_out_t rst;
154 digital_out_t cts;
156 // Input pins
157 digital_in_t rng;
158 digital_in_t pst;
159 digital_in_t rts;
161 // Modules
162 uart_t uart;
164 // Buffers
165 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
166 char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
168} lteiot8_t;
169
174typedef struct
175{
176 // Communication gpio pins
177 pin_name_t rx_pin;
178 pin_name_t tx_pin;
180 // Additional gpio pins
181 pin_name_t rng;
182 pin_name_t rst;
183 pin_name_t cts;
184 pin_name_t pst;
185 pin_name_t rts;
187 // Static variable
188
189 uint32_t baud_rate;
191 uart_data_bits_t data_bit;
192 uart_parity_t parity_bit;
193 uart_stop_bits_t stop_bit;
196
210
227
243
258
272err_t lteiot8_generic_write ( lteiot8_t *ctx, char *data_buf, uint16_t len );
273
287err_t lteiot8_generic_read ( lteiot8_t *ctx, char *data_buf, uint16_t max_len );
288
298void lteiot8_send_cmd ( lteiot8_t *ctx, char *cmd );
299
311void lteiot8_send_cmd_with_parameter ( lteiot8_t *ctx, char *at_cmd_buf, char *param_buf );
312
322void lteiot8_send_cmd_check ( lteiot8_t *ctx, char *at_cmd_buf );
323
333void lteiot8_send_cmd_syntax_check ( lteiot8_t *ctx, char *at_cmd_buf );
334
344void lteiot8_set_sim_apn ( lteiot8_t *ctx, char *sim_apn );
345
358void lteiot8_send_text_message ( lteiot8_t *ctx, char *phone_number, char *message_content );
359
373err_t lteiot8_send_sms_pdu ( lteiot8_t *ctx, char *service_center_number, char *phone_number, char *sms_text );
374
375#ifdef __cplusplus
376}
377#endif
378#endif // LTEIOT8_H
379
380 // lteiot8
381
382// ------------------------------------------------------------------------ END
#define DRV_RX_BUFFER_SIZE
Definition lteiot8.h:116
#define DRV_TX_BUFFER_SIZE
LTE IoT 8 driver buffer size.
Definition lteiot8.h:115
void lteiot8_cfg_setup(lteiot8_cfg_t *cfg)
LTE IoT 8 configuration object setup function.
err_t lteiot8_init(lteiot8_t *ctx, lteiot8_cfg_t *cfg)
LTE IoT 8 initialization function.
void lteiot8_set_sim_apn(lteiot8_t *ctx, char *sim_apn)
Set SIM APN.
err_t lteiot8_generic_write(lteiot8_t *ctx, char *data_buf, uint16_t len)
LTE IoT 8 data writing function.
err_t lteiot8_generic_read(lteiot8_t *ctx, char *data_buf, uint16_t max_len)
LTE IoT 8 data reading function.
void lteiot8_send_cmd_syntax_check(lteiot8_t *ctx, char *at_cmd_buf)
Send command to check commands available parameters.
void lteiot8_send_cmd_check(lteiot8_t *ctx, char *at_cmd_buf)
Send command to check commands current value.
err_t lteiot8_default_cfg(lteiot8_t *ctx)
LTE IoT 8 default configuration function.
void lteiot8_send_text_message(lteiot8_t *ctx, char *phone_number, char *message_content)
Send SMS message to number in text mode.
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.
void lteiot8_send_cmd_with_parameter(lteiot8_t *ctx, char *at_cmd_buf, char *param_buf)
Send command with parameters.
void lteiot8_send_cmd(lteiot8_t *ctx, char *cmd)
Send command function.
lteiot8_return_value_t
LTE IoT 8 Click return value data.
Definition lteiot8.h:202
@ LTEIOT8_OK
Definition lteiot8.h:203
@ LTEIOT8_ERROR
Definition lteiot8.h:204
@ LTEIOT8_ERROR_UNKNOWN
Definition lteiot8.h:207
@ LTEIOT8_ERROR_CMD
Definition lteiot8.h:206
@ LTEIOT8_ERROR_TIMEOUT
Definition lteiot8.h:205
LTE IoT 8 Click configuration object.
Definition lteiot8.h:175
pin_name_t rts
Definition lteiot8.h:185
uint32_t baud_rate
Definition lteiot8.h:189
pin_name_t pst
Definition lteiot8.h:184
pin_name_t cts
Definition lteiot8.h:183
bool uart_blocking
Definition lteiot8.h:190
uart_data_bits_t data_bit
Definition lteiot8.h:191
pin_name_t tx_pin
Definition lteiot8.h:178
pin_name_t rng
Definition lteiot8.h:181
pin_name_t rx_pin
Definition lteiot8.h:177
uart_stop_bits_t stop_bit
Definition lteiot8.h:193
uart_parity_t parity_bit
Definition lteiot8.h:192
pin_name_t rst
Definition lteiot8.h:182
LTE IoT 8 Click context object.
Definition lteiot8.h:151
digital_in_t rng
Definition lteiot8.h:157
digital_in_t pst
Definition lteiot8.h:158
uart_t uart
Definition lteiot8.h:162
digital_in_t rts
Definition lteiot8.h:159
digital_out_t rst
Definition lteiot8.h:153
digital_out_t cts
Definition lteiot8.h:154