lteiot9 2.0.0.0
lteiot9.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 LTEIOT9_H
29#define LTEIOT9_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 LTEIOT9_CMD_AT "AT"
74#define LTEIOT9_CMD_ATI "ATI"
75#define LTEIOT9_CMD_CGMR "AT+CGMR"
76#define LTEIOT9_CMD_CFUN "AT+CFUN"
77#define LTEIOT9_CMD_CREG "AT+CREG"
78#define LTEIOT9_CMD_CEREG "AT+CEREG"
79#define LTEIOT9_CMD_CGDCONT "AT+CGDCONT"
80#define LTEIOT9_CMD_CIMI "AT+CIMI"
81#define LTEIOT9_CMD_CGATT "AT+CGATT"
82#define LTEIOT9_CMD_CSQ "AT+CSQ"
83#define LTEIOT9_CMD_CESQ "AT+CESQ"
84#define LTEIOT9_CMD_COPS "AT+COPS"
85#define LTEIOT9_CMD_URAT "AT+URAT"
86#define LTEIOT9_CMD_UBANDMASK "AT+UBANDMASK"
87#define LTEIOT9_CMD_URATCONF "AT+URATCONF"
88#define LTEIOT9_CMD_UAUTHREQ "AT+UAUTHREQ"
89#define LTEIOT9_CMD_UUICC "AT+UUICC"
90#define LTEIOT9_CMD_UCGED "AT+UCGED"
91#define LTEIOT9_CMD_UCELLINFO "AT+UCELLINFO"
92#define LTEIOT9_CMD_UANTR "AT+UANTR"
93#define LTEIOT9_CMD_CMGF "AT+CMGF"
94
95
96 // lteiot9_reg
97
112#define LTEIOT9_GNSS_GPGGA "GPGGA"
113#define LTEIOT9_GNSS_START '$'
114#define LTEIOT9_GNSS_SEPARATOR ','
115
120#define LTEIOT9_GPGGA_LATITUDE 2
121#define LTEIOT9_GPGGA_LONGITUDE 4
122#define LTEIOT9_GPGGA_ALTITUDE 9
123
128#define LTEIOT9_SYSSTART "^SYSSTART"
129
134#define LTEIOT9_RSP_OK "OK"
135#define LTEIOT9_RSP_ERROR "ERROR"
136
142#define DRV_TX_BUFFER_SIZE 200
143#define DRV_RX_BUFFER_SIZE 500
144
145 // lteiot9_set
146
161#define LTEIOT9_MAP_MIKROBUS( cfg, mikrobus ) \
162 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
163 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
164 cfg.smi = MIKROBUS( mikrobus, MIKROBUS_AN ); \
165 cfg.on = MIKROBUS( mikrobus, MIKROBUS_RST ); \
166 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
167 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_INT );
168
169 // lteiot9_map
170 // lteiot9
171
176typedef struct
177{
178 // Output pins
179 digital_out_t smi;
180 digital_out_t on;
181 digital_out_t rts;
183 // Input pins
184 digital_in_t cts;
186 // Modules
187 uart_t uart;
189 // Buffers
190 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
191 char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
193} lteiot9_t;
194
199typedef struct
200{
201 // Communication gpio pins
202 pin_name_t rx_pin;
203 pin_name_t tx_pin;
205 // Additional gpio pins
206 pin_name_t smi;
207 pin_name_t on;
208 pin_name_t cts;
209 pin_name_t rts;
211 // Static variable
212 uint32_t baud_rate;
214 uart_data_bits_t data_bit;
215 uart_parity_t parity_bit;
216 uart_stop_bits_t stop_bit;
219
232
249
265
280
294err_t lteiot9_generic_write ( lteiot9_t *ctx, char *data_buf, uint16_t len );
295
309err_t lteiot9_generic_read ( lteiot9_t *ctx, char *data_buf, uint16_t max_len );
310
320void lteiot9_set_pin_on ( lteiot9_t *ctx, uint8_t state );
321
331void lteiot9_send_cmd ( lteiot9_t *ctx, char *cmd );
332
343void lteiot9_send_cmd_with_parameter ( lteiot9_t *ctx, char *at_cmd_buf, char *param_buf );
344
354void lteiot9_send_cmd_check ( lteiot9_t *ctx, char *at_cmd_buf );
355
365void lteiot9_send_cmd_parameter_check ( lteiot9_t *ctx, char *at_cmd_buf );
366
376void lteiot9_set_sim_apn ( lteiot9_t *ctx, char *sim_apn );
377
388void lteiot9_send_text_message ( lteiot9_t *ctx, char *phone_number, char *message_context );
389
390
391#ifdef __cplusplus
392}
393#endif
394#endif // LTEIOT9_H
395
396 // lteiot9
397
398// ------------------------------------------------------------------------ END
#define DRV_RX_BUFFER_SIZE
Definition lteiot9.h:143
#define DRV_TX_BUFFER_SIZE
LTE IoT 9 driver buffer size.
Definition lteiot9.h:142
void lteiot9_send_cmd_check(lteiot9_t *ctx, char *at_cmd_buf)
Check the sent command.
void lteiot9_set_pin_on(lteiot9_t *ctx, uint8_t state)
Set ON pin state.
void lteiot9_cfg_setup(lteiot9_cfg_t *cfg)
LTE IoT 9 configuration object setup function.
err_t lteiot9_generic_read(lteiot9_t *ctx, char *data_buf, uint16_t max_len)
LTE IoT 9 data reading function.
void lteiot9_send_text_message(lteiot9_t *ctx, char *phone_number, char *message_context)
LTE IoT 9 send text message.
void lteiot9_send_cmd(lteiot9_t *ctx, char *cmd)
Send command function.
err_t lteiot9_init(lteiot9_t *ctx, lteiot9_cfg_t *cfg)
LTE IoT 9 initialization function.
void lteiot9_send_cmd_with_parameter(lteiot9_t *ctx, char *at_cmd_buf, char *param_buf)
Send command function with parameter.
err_t lteiot9_default_cfg(lteiot9_t *ctx)
LTE IoT 9 default configuration function.
void lteiot9_send_cmd_parameter_check(lteiot9_t *ctx, char *at_cmd_buf)
Check the command parameters.
void lteiot9_set_sim_apn(lteiot9_t *ctx, char *sim_apn)
Set sim card APN.
err_t lteiot9_generic_write(lteiot9_t *ctx, char *data_buf, uint16_t len)
LTE IoT 9 data writing function.
lteiot9_return_value_t
LTE IoT 9 Click return value data.
Definition lteiot9.h:225
@ LTEIOT9_ERROR_OVERFLOW
Definition lteiot9.h:228
@ LTEIOT9_OK
Definition lteiot9.h:226
@ LTEIOT9_ERROR_TIMEOUT
Definition lteiot9.h:229
@ LTEIOT9_ERROR
Definition lteiot9.h:227
LTE IoT 9 Click configuration object.
Definition lteiot9.h:200
pin_name_t rts
Definition lteiot9.h:209
uint32_t baud_rate
Definition lteiot9.h:212
pin_name_t cts
Definition lteiot9.h:208
bool uart_blocking
Definition lteiot9.h:213
pin_name_t smi
Definition lteiot9.h:206
uart_data_bits_t data_bit
Definition lteiot9.h:214
pin_name_t on
Definition lteiot9.h:207
pin_name_t tx_pin
Definition lteiot9.h:203
pin_name_t rx_pin
Definition lteiot9.h:202
uart_stop_bits_t stop_bit
Definition lteiot9.h:216
uart_parity_t parity_bit
Definition lteiot9.h:215
LTE IoT 9 Click context object.
Definition lteiot9.h:177
digital_out_t on
Definition lteiot9.h:180
digital_out_t rts
Definition lteiot9.h:181
uart_t uart
Definition lteiot9.h:187
digital_in_t cts
Definition lteiot9.h:184
digital_out_t smi
Definition lteiot9.h:179