wifiesp 2.0.0.0
wifiesp.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef WIFIESP_H
36#define WIFIESP_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_uart.h"
55#include "log.h"
56
57
58// -------------------------------------------------------------- PUBLIC MACROS
68#define WIFIESP_MAP_MIKROBUS( cfg, mikrobus ) \
69 cfg.tx_pin = MIKROBUS( mikrobus, MIKROBUS_TX ); \
70 cfg.rx_pin = MIKROBUS( mikrobus, MIKROBUS_RX ); \
71 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
72 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS )
79#define WIFIESP_DRV_RX_BUFFER_SIZE 610
80#define WIFIESP_DRV_TX_BUFFER_SIZE 150
87#define WIFIESP_CHECK "AT"
88#define WIFIESP_RESTORE "AT+RESTORE"
89#define WIFIESP_RST "AT+RST"
90#define WIFIESP_CHECK_FIRMWARE "AT+GMR"
91#define WIFIESP_SET_MODE "AT+CWMODE"
92#define WIFIESP_CONNECT "AT+CWJAP"
93#define WIFIESP_LIST_AP "AT+CWLAP"
94#define WIFIESP_QUIT_AP "AT+CWQAP"
95#define WIFIESP_SET_AP_PARAMETERS "AT+CWSAP"
96#define WIFIESP_JOIN_DEV_IP "AT+CWLIF"
97#define WIFIESP_CONNESTION_STATUS "AT+CIPSTATUS"
98#define WIFIESP_START "AT+CIPSTART"
99#define WIFIESP_MODE "AT+CIPMODE"
100#define WIFIESP_SEND "AT+CIPSEND"
101#define WIFIESP_CLOSE "AT+CIPCLOSE"
102#define WIFIESP_GET_IP "AT+CIFSR"
103#define WIFIESP_SET_MULTIPLE_CONNECTION "AT+CIPMUX"
104#define WIFIESP_SET_AS_SERVER "AT+CIPSERVER"
105#define WIFIESP_CHECK_SERVER_TIMEOUT "AT+CIPSTO?"
106#define WIFIESP_RECEIVE "+IPD"
113#define WIFIESP_RSP_OK "OK"
114#define WIFIESP_RSP_READY_FOR_SEND ">"
115#define WIFIESP_RSP_SEND_OK "SEND OK"
116#define WIFIESP_RSP_ERROR "ERROR"
117#define WIFIESP_RSP_CONNECT "CONNECT"
120 // End group macro
121// --------------------------------------------------------------- PUBLIC TYPES
130typedef struct
131{
132 // Output pins
133 digital_out_t rst;
134 digital_out_t cs;
135
136 // Modules
137 uart_t uart;
138
139 char uart_rx_buffer[ WIFIESP_DRV_RX_BUFFER_SIZE ];
140 char uart_tx_buffer[ WIFIESP_DRV_TX_BUFFER_SIZE ];
141
142} wifiesp_t;
143
147typedef struct
148{
149 // Communication gpio pins
150 pin_name_t rx_pin;
151 pin_name_t tx_pin;
152
153 // Additional gpio pins
154 pin_name_t rst;
155 pin_name_t cs;
156
157 // static variable
158 uint32_t baud_rate; // Clock speed.
160 uart_data_bits_t data_bit; // Data bits.
161 uart_parity_t parity_bit; // Parity bit.
162 uart_stop_bits_t stop_bit; // Stop bits.
163
165
179
180 // End types group
181// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
182
188#ifdef __cplusplus
189extern "C"{
190#endif
191
201
210
219
226void wifiesp_generic_write ( wifiesp_t *ctx, char *data_buf, uint16_t len );
227
235int32_t wifiesp_generic_read ( wifiesp_t *ctx, char *data_buf, int32_t max_len );
236
245void wifiesp_send_cmd( wifiesp_t* ctx, uint8_t* cmd, uint8_t* args );
246
247#ifdef __cplusplus
248}
249#endif
250#endif // _WIFIESP_H_
251
252 // End public_function group
254
255// ------------------------------------------------------------------------- END
#define WIFIESP_DRV_TX_BUFFER_SIZE
Definition wifiesp.h:80
#define WIFIESP_DRV_RX_BUFFER_SIZE
Definition wifiesp.h:79
void wifiesp_cfg_setup(wifiesp_cfg_t *cfg)
Config Object Initialization function.
void wifiesp_default_cfg(wifiesp_t *ctx)
Click Default Configuration function.
int32_t wifiesp_generic_read(wifiesp_t *ctx, char *data_buf, int32_t max_len)
Generic read function.
void wifiesp_send_cmd(wifiesp_t *ctx, uint8_t *cmd, uint8_t *args)
Sends AT command to the module.
void wifiesp_generic_write(wifiesp_t *ctx, char *data_buf, uint16_t len)
Generic write function.
err_t wifiesp_init(wifiesp_t *ctx, wifiesp_cfg_t *cfg)
Initialization function.
wifiesp_return_value_t
WiFi ESP Click return value data.
Definition wifiesp.h:171
@ WIFIESP_ERROR_UNKNOWN
Definition wifiesp.h:176
@ WIFIESP_ERROR
Definition wifiesp.h:173
@ WIFIESP_ERROR_TIMEOUT
Definition wifiesp.h:174
@ WIFIESP_ERROR_CMD
Definition wifiesp.h:175
@ WIFIESP_OK
Definition wifiesp.h:172
Click configuration structure definition.
Definition wifiesp.h:148
uint32_t baud_rate
Definition wifiesp.h:158
bool uart_blocking
Definition wifiesp.h:159
uart_data_bits_t data_bit
Definition wifiesp.h:160
pin_name_t tx_pin
Definition wifiesp.h:151
pin_name_t rx_pin
Definition wifiesp.h:150
uart_stop_bits_t stop_bit
Definition wifiesp.h:162
uart_parity_t parity_bit
Definition wifiesp.h:161
pin_name_t rst
Definition wifiesp.h:154
pin_name_t cs
Definition wifiesp.h:155
Click ctx object definition.
Definition wifiesp.h:131
digital_out_t cs
Definition wifiesp.h:134
uart_t uart
Definition wifiesp.h:137
digital_out_t rst
Definition wifiesp.h:133