anynet3gea 2.0.0.0
anynet3gea.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 ANYNET3GEA_H
29#define ANYNET3GEA_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 ANYNET3GEA_CMD_AT "AT"
74#define ANYNET3GEA_CMD_QCCID "AT+QCCID"
75#define ANYNET3GEA_CMD_GSN "AT+GSN"
76#define ANYNET3GEA_CMD_AWSVER "AT+AWSVER"
77#define ANYNET3GEA_CMD_AWSRESET "AT+AWSRESET"
78#define ANYNET3GEA_CMD_AWSSTATE "AT+AWSSTATE"
79#define ANYNET3GEA_CMD_AWSBUTTON "AT+AWSBUTTON"
80#define ANYNET3GEA_CMD_AWSPUBOPEN "AT+AWSPUBOPEN"
81#define ANYNET3GEA_CMD_AWSPUBLISH "AT+AWSPUBLISH"
82#define ANYNET3GEA_CMD_AWSSUBOPEN "AT+AWSSUBOPEN"
83#define ANYNET3GEA_CMD_AWSPUBCLOSE "AT+AWSPUBCLOSE"
84
89#define ANYNET3GEA_RSP_OK "OK"
90#define ANYNET3GEA_RSP_ERROR "ERROR"
91#define ANYNET3GEA_RSP_READY_FOR_SEND ">"
92#define ANYNET3GEA_RSP_SEND_OK "SEND OK"
93#define ANYNET3GEA_RSP_SEND_FAIL "SEND FAIL"
94
100#define ANYNET3GEA_RX_DRV_BUFFER_SIZE 256
101#define ANYNET3GEA_TX_DRV_BUFFER_SIZE 256
102
103 // anynet3gea_set
104
119#define ANYNET3GEA_MAP_MIKROBUS( cfg, mikrobus ) \
120 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
121 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
122 cfg.slp = MIKROBUS( mikrobus, MIKROBUS_RST ); \
123 cfg.dsr = MIKROBUS( mikrobus, MIKROBUS_CS ); \
124 cfg.dtr = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
125 cfg.iot = MIKROBUS( mikrobus, MIKROBUS_INT )
126
127 // anynet3gea_map
128 // anynet3gea
129
134typedef struct
135{
136 // Output pins
137 digital_out_t slp;
138 digital_out_t dtr;
139 digital_out_t iot;
141 // Input pins
142 digital_in_t dsr;
144 // Modules
145 uart_t uart;
147 // Buffers
148 uint8_t uart_rx_buffer[ ANYNET3GEA_RX_DRV_BUFFER_SIZE ];
149 uint8_t uart_tx_buffer[ ANYNET3GEA_TX_DRV_BUFFER_SIZE ];
152
157typedef struct
158{
159 // Communication gpio pins
160 pin_name_t rx_pin;
161 pin_name_t tx_pin;
163 // Additional gpio pins
164 pin_name_t slp;
165 pin_name_t dtr;
166 pin_name_t iot;
167 pin_name_t dsr;
169 // Static variable
170 uint32_t baud_rate;
172 uart_data_bits_t data_bit;
173 uart_parity_t parity_bit;
174 uart_stop_bits_t stop_bit;
177
192
209
224
237err_t anynet3gea_generic_write ( anynet3gea_t *ctx, uint8_t *data_in, uint16_t len );
238
251err_t anynet3gea_generic_read ( anynet3gea_t *ctx, uint8_t *data_out, uint16_t len );
252
262void anynet3gea_set_slp_pin ( anynet3gea_t *ctx, uint8_t state );
263
273void anynet3gea_set_dtr_pin ( anynet3gea_t *ctx, uint8_t state );
274
284void anynet3gea_set_iot_pin ( anynet3gea_t *ctx, uint8_t state );
285
295
305void anynet3gea_send_cmd ( anynet3gea_t *ctx, uint8_t *cmd );
306
317void anynet3gea_send_cmd_with_par ( anynet3gea_t *ctx, uint8_t *at_cmd_buf, uint8_t *param_buf );
318
328void anynet3gea_send_cmd_check ( anynet3gea_t *ctx, uint8_t *at_cmd_buf );
329
339void anynet3gea_send_cmd_par_check ( anynet3gea_t *ctx, uint8_t *at_cmd_buf );
340
341#ifdef __cplusplus
342}
343#endif
344#endif // ANYNET3GEA_H
345
346 // anynet3gea
347
348// ------------------------------------------------------------------------ END
anynet3gea_return_value_t
AnyNet 3G-EA Click return value data.
Definition anynet3gea.h:183
@ ANYNET3GEA_OK
Definition anynet3gea.h:184
@ ANYNET3GEA_ERROR_TIMEOUT
Definition anynet3gea.h:186
@ ANYNET3GEA_ERROR_UNKNOWN
Definition anynet3gea.h:189
@ ANYNET3GEA_ERROR
Definition anynet3gea.h:185
@ ANYNET3GEA_ERROR_SEND
Definition anynet3gea.h:188
@ ANYNET3GEA_ERROR_CMD
Definition anynet3gea.h:187
#define ANYNET3GEA_TX_DRV_BUFFER_SIZE
Definition anynet3gea.h:101
#define ANYNET3GEA_RX_DRV_BUFFER_SIZE
AnyNet 3G-EA driver buffer size.
Definition anynet3gea.h:100
void anynet3gea_set_dtr_pin(anynet3gea_t *ctx, uint8_t state)
AnyNet 3G-EA set dtr pin function.
err_t anynet3gea_init(anynet3gea_t *ctx, anynet3gea_cfg_t *cfg)
AnyNet 3G-EA initialization function.
void anynet3gea_send_cmd_check(anynet3gea_t *ctx, uint8_t *at_cmd_buf)
Check the sent command.
void anynet3gea_set_slp_pin(anynet3gea_t *ctx, uint8_t state)
AnyNet 3G-EA set slp pin function.
void anynet3gea_send_cmd(anynet3gea_t *ctx, uint8_t *cmd)
Send command function.
void anynet3gea_send_cmd_with_par(anynet3gea_t *ctx, uint8_t *at_cmd_buf, uint8_t *param_buf)
Send command function with parameter.
uint8_t anynet3gea_get_dsr_pin(anynet3gea_t *ctx)
AnyNet 3G-EA get dsr pin function.
err_t anynet3gea_generic_write(anynet3gea_t *ctx, uint8_t *data_in, uint16_t len)
AnyNet 3G-EA data writing function.
err_t anynet3gea_generic_read(anynet3gea_t *ctx, uint8_t *data_out, uint16_t len)
AnyNet 3G-EA data reading function.
void anynet3gea_cfg_setup(anynet3gea_cfg_t *cfg)
AnyNet 3G-EA configuration object setup function.
void anynet3gea_set_iot_pin(anynet3gea_t *ctx, uint8_t state)
AnyNet 3G-EA set iot pin function.
void anynet3gea_send_cmd_par_check(anynet3gea_t *ctx, uint8_t *at_cmd_buf)
Check the command parameters.
AnyNet 3G-EA Click configuration object.
Definition anynet3gea.h:158
pin_name_t dtr
Definition anynet3gea.h:165
uint32_t baud_rate
Definition anynet3gea.h:170
pin_name_t iot
Definition anynet3gea.h:166
pin_name_t slp
Definition anynet3gea.h:164
bool uart_blocking
Definition anynet3gea.h:171
uart_data_bits_t data_bit
Definition anynet3gea.h:172
pin_name_t tx_pin
Definition anynet3gea.h:161
pin_name_t rx_pin
Definition anynet3gea.h:160
uart_stop_bits_t stop_bit
Definition anynet3gea.h:174
pin_name_t dsr
Definition anynet3gea.h:167
uart_parity_t parity_bit
Definition anynet3gea.h:173
AnyNet 3G-EA Click context object.
Definition anynet3gea.h:135
digital_out_t slp
Definition anynet3gea.h:137
uart_t uart
Definition anynet3gea.h:145
digital_out_t iot
Definition anynet3gea.h:139
digital_out_t dtr
Definition anynet3gea.h:138
digital_in_t dsr
Definition anynet3gea.h:142