lteiot5 2.0.0.0
lteiot5.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 LTEIOT5_H
29#define LTEIOT5_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// TODO -- dodati makroe koji definisu adrese registara
74
75 // lteiot5_reg
76
91#define LTEIOT5_CMD_AT "AT"
92#define LTEIOT5_CMD_ATI "ATI"
93#define LTEIOT5_CMD_CGMR "AT+CGMR"
94
95#define LTEIOT5_CMD_CFUN "AT+CFUN"
96#define LTEIOT5_CMD_CREG "AT+CREG"
97#define LTEIOT5_CMD_CEREG "AT+CEREG"
98#define LTEIOT5_CMD_CGDCONT "AT+CGDCONT"
99#define LTEIOT5_CMD_CIMI "AT+CIMI"
100#define LTEIOT5_CMD_CGATT "AT+CGATT"
101#define LTEIOT5_CMD_CSQ "AT+CSQ"
102#define LTEIOT5_CMD_CESQ "AT+CESQ"
103#define LTEIOT5_CMD_COPS "AT+COPS"
104#define LTEIOT5_CMD_URAT "AT+URAT"
105#define LTEIOT5_CMD_UBANDMASK "AT+UBANDMASK"
106#define LTEIOT5_CMD_URATCONF "AT+URATCONF"
107#define LTEIOT5_CMD_UAUTHREQ "AT+UAUTHREQ"
108#define LTEIOT5_CMD_UUICC "AT+UUICC"
109#define LTEIOT5_CMD_UCGED "AT+UCGED"
110#define LTEIOT5_CMD_UCELLINFO "AT+UCELLINFO"
111#define LTEIOT5_CMD_UANTR "AT+UANTR"
112
113// "AT+CGMR"
114
120#define DRV_RX_BUFFER_SIZE 500
121#define DRV_TX_BUFFER_SIZE 150
122
123 // lteiot5_set
124
139#define LTEIOT5_MAP_MIKROBUS( cfg, mikrobus ) \
140 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
141 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
142 cfg.pwr = MIKROBUS( mikrobus, MIKROBUS_AN ); \
143 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
144 cfg.rts = MIKROBUS( mikrobus, MIKROBUS_CS ); \
145 cfg.ri = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
146 cfg.cts = MIKROBUS( mikrobus, MIKROBUS_INT );
147
148 // lteiot5_map
149 // lteiot5
150
155typedef struct
156{
157 // Output pins
158
159 digital_out_t pwr;
160 digital_out_t rst;
161 digital_out_t rts;
163 // Input pins
164
165 digital_in_t ri;
166 digital_in_t cts;
168 // Modules
169
170 uart_t uart;
172 // Buffers
173
174 char uart_rx_buffer[ DRV_RX_BUFFER_SIZE ];
175 char uart_tx_buffer[ DRV_TX_BUFFER_SIZE ];
177} lteiot5_t;
178
183typedef struct
184{
185 // Communication gpio pins
186
187 pin_name_t rx_pin;
188 pin_name_t tx_pin;
190 // Additional gpio pins
191
192 pin_name_t pwr;
193 pin_name_t rst;
194 pin_name_t rts;
195 pin_name_t ri;
196 pin_name_t cts;
198 // Static variable
199
200 uint32_t baud_rate;
202 uart_data_bits_t data_bit;
203 uart_parity_t parity_bit;
204 uart_stop_bits_t stop_bit;
207
224
240
255
269err_t lteiot5_generic_write ( lteiot5_t *ctx, char *data_buf, uint16_t len );
270
284err_t lteiot5_generic_read ( lteiot5_t *ctx, char *data_buf, uint16_t max_len );
285
294
303
312void lteiot5_set_pwr ( lteiot5_t *ctx, uint8_t state );
313
322void lteiot5_set_rst ( lteiot5_t *ctx, uint8_t state );
323
332void lteiot5_set_rts ( lteiot5_t *ctx, uint8_t state );
333
342uint8_t lteiot5_get_ri ( lteiot5_t *ctx );
343
352uint8_t lteiot5_get_cts ( lteiot5_t *ctx );
353
363void lteiot5_send_cmd ( lteiot5_t *ctx, char *cmd );
364
375void lteiot5_send_cmd_with_parameter ( lteiot5_t *ctx, char *at_cmd_buf, char *param_buf );
376
386void lteiot5_send_cmd_check ( lteiot5_t *ctx, char *at_cmd_buf );
387
397void lteiot5_send_cmd_parameter_check ( lteiot5_t *ctx, char *at_cmd_buf );
398
408void lteiot5_set_sim_apn ( lteiot5_t *ctx, char *sim_apn );
409
420void lteiot5_send_text_message ( lteiot5_t *ctx, char *phone_number, char *message_context );
421
422#ifdef __cplusplus
423}
424#endif
425#endif // LTEIOT5_H
426
427 // lteiot5
428
429// ------------------------------------------------------------------------ END
#define DRV_RX_BUFFER_SIZE
LTE IoT 5 driver buffer size.
Definition lteiot5.h:120
#define DRV_TX_BUFFER_SIZE
Definition lteiot5.h:121
err_t lteiot5_init(lteiot5_t *ctx, lteiot5_cfg_t *cfg)
LTE IoT 5 initialization function.
uint8_t lteiot5_get_ri(lteiot5_t *ctx)
RI Pin Get function.
err_t lteiot5_generic_read(lteiot5_t *ctx, char *data_buf, uint16_t max_len)
LTE IoT 5 data reading function.
void lteiot5_send_text_message(lteiot5_t *ctx, char *phone_number, char *message_context)
LTE IoT 5 send text message.
err_t lteiot5_generic_write(lteiot5_t *ctx, char *data_buf, uint16_t len)
LTE IoT 5 data writing function.
void lteiot5_send_cmd_check(lteiot5_t *ctx, char *at_cmd_buf)
Check the sent command.
void lteiot5_reset(lteiot5_t *ctx)
LTE IoT 5 power on.
void lteiot5_set_sim_apn(lteiot5_t *ctx, char *sim_apn)
Set sim card APN.
void lteiot5_send_cmd_with_parameter(lteiot5_t *ctx, char *at_cmd_buf, char *param_buf)
Send command function with parameter.
void lteiot5_cfg_setup(lteiot5_cfg_t *cfg)
LTE IoT 5 configuration object setup function.
void lteiot5_send_cmd_parameter_check(lteiot5_t *ctx, char *at_cmd_buf)
Check the command parameters.
uint8_t lteiot5_get_cts(lteiot5_t *ctx)
CTS Pin Get function.
void lteiot5_power_on(lteiot5_t *ctx)
LTE IoT 5 power on.
err_t lteiot5_default_cfg(lteiot5_t *ctx)
LTE IoT 5 default configuration function.
void lteiot5_send_cmd(lteiot5_t *ctx, char *cmd)
Send command function.
void lteiot5_set_rts(lteiot5_t *ctx, uint8_t state)
Sets state of the RTS pin.
void lteiot5_set_pwr(lteiot5_t *ctx, uint8_t state)
Sets state of the PWR pin.
void lteiot5_set_rst(lteiot5_t *ctx, uint8_t state)
Sets state of the RST pin.
LTE IoT 5 Click configuration object.
Definition lteiot5.h:184
pin_name_t rts
Definition lteiot5.h:194
uint32_t baud_rate
Definition lteiot5.h:200
pin_name_t cts
Definition lteiot5.h:196
bool uart_blocking
Definition lteiot5.h:201
pin_name_t ri
Definition lteiot5.h:195
uart_data_bits_t data_bit
Definition lteiot5.h:202
pin_name_t tx_pin
Definition lteiot5.h:188
pin_name_t pwr
Definition lteiot5.h:192
pin_name_t rx_pin
Definition lteiot5.h:187
uart_stop_bits_t stop_bit
Definition lteiot5.h:204
uart_parity_t parity_bit
Definition lteiot5.h:203
pin_name_t rst
Definition lteiot5.h:193
LTE IoT 5 Click context object.
Definition lteiot5.h:156
digital_out_t pwr
Definition lteiot5.h:159
digital_out_t rts
Definition lteiot5.h:161
digital_in_t ri
Definition lteiot5.h:165
uart_t uart
Definition lteiot5.h:170
digital_in_t cts
Definition lteiot5.h:166
digital_out_t rst
Definition lteiot5.h:160