Embedded Wireless Framework
ewf_adapter_mxchip_common.h
Go to the documentation of this file.
1 /************************************************************************/
9 #ifndef __ewf_adapter_mxchip_common__h__included__
10 #define __ewf_adapter_mxchip_common__h__included__
11 
12 #include "ewf_adapter.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /************************************************************************/
25 #define EWF_ADAPTER_MXCHIP_COMMON_TLS_BASIC_ENABLED (0)
26 #define EWF_ADAPTER_MXCHIP_COMMON_MQTT_BASIC_ENABLED (0)
27 
28 #if !defined(EWF_ADAPTER_MXCHIP_COMMON_TLS_ENABLED) && !defined(EWF_ADAPTER_MXCHIP_COMMON_TLS_BASIC_ENABLED)
29 #if 1
30 #define EWF_ADAPTER_MXCHIP_COMMON_TLS_BASIC_ENABLED (1)
31 #define EWF_ADAPTER_MXCHIP_COMMON_TLS_ENABLED (0)
32 #else
33 #define EWF_ADAPTER_MXCHIP_COMMON_TLS_BASIC_ENABLED (0)
34 #define EWF_ADAPTER_MXCHIP_COMMON_TLS_ENABLED (1)
35 #endif
36 #endif
37 
38 #ifndef EWF_ADAPTER_MXCHIP_COMMON_TCP_ENABLED
39 #define EWF_ADAPTER_MXCHIP_COMMON_TCP_ENABLED (1)
40 #endif
41 
42 #ifndef EWF_ADAPTER_MXCHIP_COMMON_UDP_ENABLED
43 #define EWF_ADAPTER_MXCHIP_COMMON_UDP_ENABLED (1)
44 #endif
45 
46 #ifndef EWF_ADAPTER_MXCHIP_COMMON_INTERNET_SOCKET_POOL_SIZE
48 #define EWF_ADAPTER_MXCHIP_COMMON_INTERNET_SOCKET_POOL_SIZE (5)
49 #endif
50 
51 #ifndef EWF_ADAPTER_MXCHIP_COMMON_INTERNET_SOCKET_RECV_BUFFER_SIZE
53 #define EWF_ADAPTER_MXCHIP_COMMON_INTERNET_SOCKET_RECV_BUFFER_SIZE (1500)
54 #endif
55 
56 #ifndef EWF_ADAPTER_MXCHIP_COMMON_INTERNET_SOCKET_INVALID
58 #define EWF_ADAPTER_MXCHIP_COMMON_INTERNET_SOCKET_INVALID (-1)
59 #endif
60 
61 /************************************************************************/
65 /************************************************************************/
71 /************************************************************************/
77 extern ewf_interface_tokenizer_pattern* ewf_adapter_mxchip_common_message_tokenizer_pattern_ptr;
78 extern ewf_interface_tokenizer_pattern* ewf_adapter_mxchip_common_command_response_end_tokenizer_pattern_ptr;
79 static ewf_interface_tokenizer_pattern* ewf_adapter_mxchip_common_command_response_tokenizer_pattern_ptr;
80 extern ewf_interface_tokenizer_pattern* ewf_adapter_mxchip_common_urc_tokenizer_pattern_ptr;
81 
82 /************************************************************************/
86 /************************************************************************/
94 {
95  ewf_adapter_mxchip_common_internet_socket_service_type_not_initialized,
96  ewf_adapter_mxchip_common_internet_socket_service_type_tcp,
97  ewf_adapter_mxchip_common_internet_socket_service_type_udp,
98  ewf_adapter_mxchip_common_internet_socket_service_type_tcp_listener,
99  ewf_adapter_mxchip_common_internet_socket_service_type_udp_listener,
100 
102 
105 {
106  uint32_t id;
107  uint32_t local_port;
109  volatile bool used;
110  volatile bool open;
111  volatile bool open_error;
112  volatile bool conn;
113  volatile bool conn_error;
114  volatile bool recv;
115  ewf_platform_queue* recv_queue_ptr;
116 
118 
121 {
122  volatile bool status_ap;
123  volatile bool status_station;
124 
125  uint32_t ipv4_address;
126  uint32_t ipv4_netmask;
127  uint32_t ipv4_gateway;
128  uint32_t ipv4_dns;
129 
130 #if EWF_ADAPTER_MXCHIP_COMMON_TCP_ENABLED || EWF_ADAPTER_MXCHIP_COMMON_UDP_ENABLED
135 #endif
136 
138 
139 /************************************************************************/
149 extern ewf_adapter_api_control ewf_adapter_mxchip_common_api_control;
150 
151 ewf_result ewf_adapter_mxchip_common_start(ewf_adapter* adapter_ptr);
152 ewf_result ewf_adapter_mxchip_common_stop(ewf_adapter* adapter_ptr);
153 
162 extern ewf_adapter_api_info ewf_adapter_mxchip_common_api_info;
163 
164 ewf_result ewf_adapter_mxchip_common_info(ewf_adapter* adapter_ptr);
165 ewf_result ewf_adapter_mxchip_common_get_ipv4_address(ewf_adapter* adapter_ptr, uint32_t* address_ptr);
166 ewf_result ewf_adapter_mxchip_common_get_ipv4_netmask(ewf_adapter* adapter_ptr, uint32_t* netmask_ptr);
167 ewf_result ewf_adapter_mxchip_common_get_ipv4_gateway(ewf_adapter* adapter_ptr, uint32_t* gateway_ptr);
168 ewf_result ewf_adapter_mxchip_common_get_ipv4_dns(ewf_adapter* adapter_ptr, uint32_t* dns);
169 
178 ewf_result ewf_adapter_mxchip_common_urc_callback(ewf_interface* interface_ptr, uint8_t* buffer_ptr, uint32_t buffer_length);
179 
188 extern ewf_adapter_api_wifi_station ewf_adapter_mxchip_common_api_wifi_station;
189 
190 ewf_result ewf_adapter_mxchip_common_wifi_station_connect(ewf_adapter* adapter_ptr, const char* ssid_str, const char* password_str);
191 ewf_result ewf_adapter_mxchip_common_wifi_station_disconnect(ewf_adapter* adapter_ptr);
192 
201 #if EWF_ADAPTER_MXCHIP_COMMON_TCP_ENABLED || EWF_ADAPTER_MXCHIP_COMMON_UDP_ENABLED
202 
203 ewf_result ewf_adapter_mxchip_common_internet_start(ewf_adapter* adapter_ptr);
204 ewf_result ewf_adapter_mxchip_common_internet_stop(ewf_adapter* adapter_ptr);
205 
206 ewf_result ewf_adapter_mxchip_common_internet_urc_callback(ewf_interface* interface_ptr, uint8_t* buffer_ptr, uint32_t buffer_length);
207 
208 #endif /* EWF_ADAPTER_MXCHIP_COMMON_TCP_ENABLED || EWF_ADAPTER_MXCHIP_COMMON_UDP_ENABLED */
209 
218 #if EWF_ADAPTER_MXCHIP_COMMON_TCP_ENABLED
219 
220 extern ewf_adapter_api_tcp ewf_adapter_mxchip_common_api_tcp;
221 
222 ewf_result ewf_adapter_mxchip_common_tcp_open(ewf_adapter* adapter_ptr, ewf_socket_tcp* socket_ptr);
223 ewf_result ewf_adapter_mxchip_common_tcp_close(ewf_socket_tcp* socket_ptr);
224 ewf_result ewf_adapter_mxchip_common_tcp_control(ewf_socket_tcp* socket_ptr, const char* control_str, const uint8_t* buffer_ptr, uint32_t* buffer_length_ptr);
225 ewf_result ewf_adapter_mxchip_common_tcp_set_tls_configuration(ewf_socket_tcp* socket_ptr, uint32_t tls_configuration_id);
226 ewf_result ewf_adapter_mxchip_common_tcp_bind(ewf_socket_tcp* socket_ptr, uint32_t port);
227 ewf_result ewf_adapter_mxchip_common_tcp_listen(ewf_socket_tcp* socket_ptr);
228 ewf_result ewf_adapter_mxchip_common_tcp_accept(ewf_socket_tcp* socket_ptr, ewf_socket_tcp* socket_new_ptr);
229 ewf_result ewf_adapter_mxchip_common_tcp_connect(ewf_socket_tcp* socket_ptr, const char* const server, uint32_t port);
230 ewf_result ewf_adapter_mxchip_common_tcp_shutdown(ewf_socket_tcp* socket_ptr);
231 ewf_result ewf_adapter_mxchip_common_tcp_send(ewf_socket_tcp* socket_ptr, const uint8_t* buffer_ptr, uint32_t buffer_length);
232 ewf_result ewf_adapter_mxchip_common_tcp_receive(ewf_socket_tcp* socket_ptr, uint8_t* buffer_ptr, uint32_t* buffer_length, bool wait);
233 
234 #endif /* EWF_ADAPTER_MXCHIP_COMMON_TCP_ENABLED */
235 
244 #if EWF_ADAPTER_MXCHIP_COMMON_UDP_ENABLED
245 
246 extern ewf_adapter_api_udp ewf_adapter_mxchip_common_api_udp;
247 
248 ewf_result ewf_adapter_mxchip_common_udp_open(ewf_adapter* adapter_ptr, ewf_socket_udp* socket_ptr);
249 ewf_result ewf_adapter_mxchip_common_udp_close(ewf_socket_udp* socket_ptr);
250 ewf_result ewf_adapter_mxchip_common_udp_control(ewf_socket_udp* socket_ptr, const char* control_str, const uint8_t* buffer_ptr, uint32_t* buffer_length_ptr);
251 ewf_result ewf_adapter_mxchip_common_udp_set_dtls_configuration(ewf_socket_udp* socket_ptr, uint32_t dtls_configuration_id);
252 ewf_result ewf_adapter_mxchip_common_udp_bind(ewf_socket_udp* socket_ptr, uint32_t port);
253 ewf_result ewf_adapter_mxchip_common_udp_shutdown(ewf_socket_udp* socket_ptr);
254 ewf_result ewf_adapter_mxchip_common_udp_send_to(ewf_socket_udp* socket_ptr, const char* remote_address_str, uint32_t remote_port, const uint8_t* buffer_ptr, uint32_t buffer_length);
255 ewf_result ewf_adapter_mxchip_common_udp_receive_from(ewf_socket_udp* socket_ptr, char* remote_address, uint32_t* remote_address_length_ptr, uint32_t* remote_port_ptr, uint8_t* buffer_ptr, uint32_t* buffer_length_ptr, bool wait);
256 
257 #endif /* EWF_ADAPTER_MXCHIP_COMMON_UDP_ENABLED */
258 
261 /************************************************************************/
265 #ifdef __cplusplus
266 }
267 #endif
268 
269 #endif /* __ewf_adapter_mxchip_common__h__included__ */
The Embedded Wireless Framework adapter API implementation.
_ewf_adapter_common_internet_socket_service_type
The socket service type
Definition: ewf_adapter_espressif_common.h:79
enum _ewf_adapter_common_internet_socket_service_type ewf_adapter_mxchip_common_internet_socket_service_type
The socket service type
struct _ewf_adapter_mxchip_common ewf_adapter_mxchip_common
The MX-CHIP common adapter data structure.
struct _ewf_adapter_mxchip_common_internet_socket ewf_adapter_mxchip_common_internet_socket
Internal structure for internet socket status
#define EWF_ADAPTER_MXCHIP_COMMON_INTERNET_SOCKET_POOL_SIZE
The total number of supported internet sockets in the adapter.
Definition: ewf_adapter_mxchip_common.h:48
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
Definition: ewf_adapter_api_info.h:26
The TCP API structure.
Definition: ewf_adapter_api_tcp.h:76
The UDP API type.
Definition: ewf_adapter_api_udp.h:63
Definition: ewf_adapter_api_wifi_station.h:29
Internal structure for internet socket status
Definition: ewf_adapter_mxchip_common.h:105
The MX-CHIP common adapter data structure.
Definition: ewf_adapter_mxchip_common.h:121
uint32_t ipv4_dns
Definition: ewf_adapter_mxchip_common.h:128
bool passive_mode
Definition: ewf_adapter_mxchip_common.h:132
The EWF network adapter control structure definition.
Definition: ewf_adapter.h:50
The interface structure definition.
Definition: ewf_interface.h:66
The platform queue structure.
Definition: ewf_platform_bare_metal.h:74
The TCP socket structure definition.
Definition: ewf_adapter_api_tcp.h:47
The UDP socket structure definition.
Definition: ewf_adapter_api_udp.h:40
The interface tokenizer pattern structure definition.
Definition: ewf_tokenizer.h:27