Embedded Wireless Framework
ewf_adapter_espressif_esp8266.h
Go to the documentation of this file.
1 /************************************************************************/
9 #ifndef __ewf_adapter_espressif_esp8266__h__included__
10 #define __ewf_adapter_espressif_esp8266__h__included__
11 
12 #include "ewf_adapter.h"
13 #include "ewf_allocator.h"
14 #include "ewf_interface.h"
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 /************************************************************************/
27 #define EWF_ADAPTER_ESPRESSIF_ESP8266_TLS_BASIC_ENABLED (0)
28 #define EWF_ADAPTER_ESPRESSIF_ESP8266_MQTT_BASIC_ENABLED (0)
29 
30 #if !defined(EWF_ADAPTER_ESPRESSIF_ESP8266_TLS_ENABLED) && !defined(EWF_ADAPTER_ESPRESSIF_ESP8266_TLS_BASIC_ENABLED)
31 #if 1
32 #define EWF_ADAPTER_ESPRESSIF_ESP8266_TLS_BASIC_ENABLED (1)
33 #define EWF_ADAPTER_ESPRESSIF_ESP8266_TLS_ENABLED (0)
34 #else
35 #define EWF_ADAPTER_ESPRESSIF_ESP8266_TLS_BASIC_ENABLED (0)
36 #define EWF_ADAPTER_ESPRESSIF_ESP8266_TLS_ENABLED (1)
37 #endif
38 #endif
39 
40 #ifndef EWF_ADAPTER_ESPRESSIF_ESP8266_TCP_ENABLED
41 #define EWF_ADAPTER_ESPRESSIF_ESP8266_TCP_ENABLED (1)
42 #endif
43 
44 #ifndef EWF_ADAPTER_ESPRESSIF_ESP8266_UDP_ENABLED
45 #define EWF_ADAPTER_ESPRESSIF_ESP8266_UDP_ENABLED (1)
46 #endif
47 
48 #if !defined(EWF_ADAPTER_ESPRESSIF_ESP8266_MQTT_ENABLED) && !defined(EWF_ADAPTER_ESPRESSIF_ESP8266_MQTT_BASIC_ENABLED)
49 #if 1
50 #define EWF_ADAPTER_ESPRESSIF_ESP8266_MQTT_BASIC_ENABLED (1)
51 #define EWF_ADAPTER_ESPRESSIF_ESP8266_MQTT_ENABLED (0)
52 #else
53 #define EWF_ADAPTER_ESPRESSIF_ESP8266_MQTT_BASIC_ENABLED (0)
54 #define EWF_ADAPTER_ESPRESSIF_ESP8266_MQTT_ENABLED (1)
55 #endif
56 #endif
57 
58 /************************************************************************/
62 /* Include the ESPRESSIF common header here, to take the above configuration macros into account */
64 
65 /************************************************************************/
77 extern ewf_adapter_api_control ewf_adapter_espressif_esp8266_api_control;
78 
79 ewf_result ewf_adapter_espressif_esp8266_start(ewf_adapter* adapter_ptr);
80 ewf_result ewf_adapter_espressif_esp8266_stop(ewf_adapter* adapter_ptr);
81 
90 ewf_result ewf_adapter_espressif_esp8266_urc_callback(ewf_interface* interface_ptr, uint8_t* buffer_ptr, uint32_t buffer_length);
91 
100 #define ewf_adapter_espressif_esp8266_info ewf_adapter_espressif_common_info
101 #define ewf_adapter_espressif_esp8266_get_ipv4_address ewf_adapter_espressif_common_get_ipv4_address
102 #define ewf_adapter_espressif_esp8266_get_ipv4_netmask ewf_adapter_espressif_common_get_ipv4_netmask
103 #define ewf_adapter_espressif_esp8266_get_ipv4_gateway ewf_adapter_espressif_common_get_ipv4_gateway
104 #define ewf_adapter_espressif_esp8266_get_ipv4_dns ewf_adapter_espressif_common_get_ipv4_dns
105 
114 #define ewf_adapter_espressif_esp8266_wifi_station_connect ewf_adapter_espressif_common_wifi_station_connect
115 #define ewf_adapter_espressif_esp8266_wifi_station_disconnect ewf_adapter_espressif_common_wifi_station_disconnect
116 
125 #define ewf_adapter_espressif_esp8266_internet_start ewf_adapter_espressif_common_internet_start
126 #define ewf_adapter_espressif_esp8266_internet_stop ewf_adapter_espressif_common_internet_stop
127 
128 #define ewf_adapter_espressif_esp8266_internet_urc_callback ewf_adapter_espressif_common_internet_urc_callback
129 
138 #if EWF_ADAPTER_ESPRESSIF_ESP8266_TCP_ENABLED
139 
140 #define ewf_adapter_espressif_esp8266_tcp_open ewf_adapter_espressif_common_tcp_open
141 #define ewf_adapter_espressif_esp8266_tcp_close ewf_adapter_espressif_common_tcp_close
142 #define ewf_adapter_espressif_esp8266_tcp_control ewf_adapter_espressif_common_tcp_control
143 #define ewf_adapter_espressif_esp8266_tcp_set_tls_configuration ewf_adapter_espressif_common_tcp_set_tls_configuration
144 #define ewf_adapter_espressif_esp8266_tcp_bind ewf_adapter_espressif_common_tcp_bind
145 #define ewf_adapter_espressif_esp8266_tcp_listen ewf_adapter_espressif_common_tcp_listen
146 #define ewf_adapter_espressif_esp8266_tcp_accept ewf_adapter_espressif_common_tcp_accept
147 #define ewf_adapter_espressif_esp8266_tcp_connect ewf_adapter_espressif_common_tcp_connect
148 #define ewf_adapter_espressif_esp8266_tcp_shutdown ewf_adapter_espressif_common_tcp_shutdown
149 #define ewf_adapter_espressif_esp8266_tcp_send ewf_adapter_espressif_common_tcp_send
150 #define ewf_adapter_espressif_esp8266_tcp_receive ewf_adapter_espressif_common_tcp_receive
151 
152 #endif /* EWF_ADAPTER_ESPRESSIF_ESP8266_TCP_ENABLED */
153 
162 #if EWF_ADAPTER_ESPRESSIF_ESP8266_UDP_ENABLED
163 
164 #define ewf_adapter_espressif_esp8266_udp_open ewf_adapter_espressif_common_udp_open
165 #define ewf_adapter_espressif_esp8266_udp_close ewf_adapter_espressif_common_udp_close
166 #define ewf_adapter_espressif_esp8266_udp_control ewf_adapter_espressif_common_udp_control
167 #define ewf_adapter_espressif_esp8266_udp_set_dtls_configuration ewf_adapter_espressif_common_udp_set_dtls_configuration
168 #define ewf_adapter_espressif_esp8266_udp_bind ewf_adapter_espressif_common_udp_bind
169 #define ewf_adapter_espressif_esp8266_udp_send_to ewf_adapter_espressif_common_udp_send_to
170 #define ewf_adapter_espressif_esp8266_udp_receive_from ewf_adapter_espressif_common_udp_receive_from
171 
172 #endif /* EWF_ADAPTER_ESPRESSIF_ESP8266_UDP_ENABLED */
173 
176 /******************************************************************************
177  *
178  * Internal data
179  *
180  ******************************************************************************/
181 
190 {
193 
195 
204 #ifdef EWF_PARAMETER_CHECKING
205 #define EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_HEADER(adapter_ptr) \
206 do { \
207 (adapter_ptr)->struct_magic = EWF_ADAPTER_STRUCT_MAGIC; \
208 (adapter_ptr)->struct_size = EWF_ADAPTER_STRUCT_SIZE; \
209 (adapter_ptr)->struct_version = EWF_ADAPTER_VERSION; \
210 (adapter_ptr)->struct_type = EWF_ADAPTER_TYPE_ESPRESSIF_ESP8266; \
211 } while(0)
212 #else
213 #define EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_HEADER(adapter_ptr)
214 #endif /* EWF_PARAMETER_CHECKING */
215 
216 #if EWF_ADAPTER_ESPRESSIF_ESP8266_TCP_ENABLED
217 #define EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_TCP_API(adapter_ptr) \
218 do { \
219 adapter_ptr->tcp_api_ptr = &ewf_adapter_espressif_common_api_tcp; \
220 } while(0)
221 #else
222 #define EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_TCP_API(adapter_ptr)
223 #endif /* EWF_ADAPTER_ESPRESSIF_ESP8266_TCP_ENABLED */
224 
225 #if EWF_ADAPTER_ESPRESSIF_ESP8266_UDP_ENABLED
226 #define EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_UDP_API(adapter_ptr) \
227 do { \
228 adapter_ptr->udp_api_ptr = &ewf_adapter_espressif_common_api_udp; \
229 } while(0)
230 #else
231 #define EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_UDP_API(adapter_ptr)
232 #endif /* EWF_ADAPTER_ESPRESSIF_ESP8266_UDP_ENABLED */
233 
234 #if EWF_ADAPTER_ESPRESSIF_ESP8266_TLS_BASIC_ENABLED
235 #define EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_TLS_BASIC_API(adapter_ptr) \
236 do { \
237 adapter_ptr->tls_basic_api_ptr = &ewf_adapter_espressif_common_api_tls_basic; \
238 } while(0)
239 #else
240 #define EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_TLS_BASIC_API(adapter_ptr)
241 #endif /* EWF_ADAPTER_ESPRESSIF_ESP8266_TLS_BASIC_ENABLED */
242 
243 #if EWF_ADAPTER_ESPRESSIF_ESP8266_MQTT_BASIC_ENABLED
244 #define EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_MQTT_BASIC_API(adapter_ptr) \
245 do { \
246 adapter_ptr->mqtt_basic_api_ptr = &ewf_adapter_espressif_common_api_mqtt_basic; \
247 } while(0)
248 #else
249 #define EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_MQTT_BASIC_API(adapter_ptr)
250 #endif /* EWF_ADAPTER_ESPRESSIF_ESP8266_MQTT_BASIC_ENABLED */
251 
260 #define EWF_ADAPTER_ESPRESSIF_ESP8266_STATIC_DECLARE(adapter_ptr, adapter_name_symb, message_allocator_ptr_param, data_allocator_ptr_param, interface_ptr_param) \
261 do { \
262 static ewf_adapter_espressif_esp8266 ewf_adapter_espressif_esp8266__implementation__##adapter_name_symb = {0}; \
263 static ewf_adapter ewf_adapter_espressif_esp8266__##adapter_name_symb = {0}; \
264 interface_ptr_param->message_allocator_ptr = message_allocator_ptr_param; \
265 interface_ptr_param->data_allocator_ptr = data_allocator_ptr_param; \
266 interface_ptr_param->urc_callback = ewf_adapter_espressif_esp8266_urc_callback; \
267 ewf_adapter_espressif_esp8266__##adapter_name_symb.interface_ptr = interface_ptr_param; \
268 ewf_adapter_espressif_esp8266__##adapter_name_symb.implementation_ptr = &(ewf_adapter_espressif_esp8266__implementation__##adapter_name_symb); \
269 adapter_ptr = &(ewf_adapter_espressif_esp8266__##adapter_name_symb); \
270 interface_ptr_param->adapter_ptr = adapter_ptr; \
271 EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_HEADER(adapter_ptr); \
272 ewf_adapter_espressif_esp8266__##adapter_name_symb.control_api_ptr = &ewf_adapter_espressif_esp8266_api_control; \
273 ewf_adapter_espressif_esp8266__##adapter_name_symb.wifi_station_api_ptr = &ewf_adapter_espressif_common_api_wifi_station; \
274 ewf_adapter_espressif_esp8266__##adapter_name_symb.info_api_ptr = &ewf_adapter_espressif_common_api_info; \
275 EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_TCP_API(adapter_ptr); \
276 EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_UDP_API(adapter_ptr); \
277 EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_TLS_BASIC_API(adapter_ptr); \
278 EWF_ADAPTER_ESPRESSIF_ESP8266_INITIALIZE_MQTT_BASIC_API(adapter_ptr); \
279 } while(0)
280 
283 /************************************************************************/
287 #ifdef __cplusplus
288 }
289 #endif
290 
291 #endif /* __ewf_adapter_espressif_esp8266__h__included__ */
The Embedded Wireless Framework adapter API implementation.
The Embedded Wireless Framework Espressif common adapter API.
The Embedded Wireless Framework host interface API.
struct _ewf_adapter_espressif_esp8266 ewf_adapter_espressif_esp8266
The ESPRESSIF 8266 adapter driver data structure.
enum _ewf_result ewf_result
Success and error result codes specific to the EWF API.
The adapter control API type.
Definition: ewf_adapter_api_control.h:28
The ESPRESSIF common adapter data structure.
Definition: ewf_adapter_espressif_common.h:106
The ESPRESSIF 8266 adapter driver data structure.
Definition: ewf_adapter_espressif_esp8266.h:190
ewf_adapter_espressif_common common_implementation_data
Definition: ewf_adapter_espressif_esp8266.h:192
The EWF network adapter control structure definition.
Definition: ewf_adapter.h:50
The interface structure definition.
Definition: ewf_interface.h:66