Embedded Wireless Framework
ewf_adapter_thales_common.h
Go to the documentation of this file.
1 /************************************************************************/
9 #ifndef __ewf_adapter_thales_common__h__included__
10 #define __ewf_adapter_thales_common__h__included__
11 
12 #include "ewf_adapter.h"
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /************************************************************************/
25 #ifndef EWF_ADAPTER_THALES_COMMON_DEFAULT_TIMEOUT
26 #define EWF_ADAPTER_THALES_COMMON_DEFAULT_TIMEOUT (EWF_PLATFORM_TICKS_PER_SECOND * 10)
27 #endif
28 
29 #ifndef EWF_ADAPTER_THALES_COMMON_FFS_ENABLED
30 #define EWF_ADAPTER_THALES_COMMON_FFS_ENABLED (1)
31 #endif
32 
33 #if !defined(EWF_ADAPTER_THALES_COMMON_TLS_ENABLED) && !defined(EWF_ADAPTER_THALES_COMMON_TLS_BASIC_ENABLED)
34 #if 1
35 #define EWF_ADAPTER_THALES_COMMON_TLS_BASIC_ENABLED (1)
36 #define EWF_ADAPTER_THALES_COMMON_TLS_ENABLED (0)
37 #else
38 #define EWF_ADAPTER_THALES_COMMON_TLS_BASIC_ENABLED (0)
39 #define EWF_ADAPTER_THALES_COMMON_TLS_ENABLED (1)
40 #endif
41 #endif
42 
43 #ifndef EWF_ADAPTER_THALES_COMMON_TCP_ENABLED
44 #define EWF_ADAPTER_THALES_COMMON_TCP_ENABLED (1)
45 #endif
46 
47 #ifndef EWF_ADAPTER_THALES_COMMON_UDP_ENABLED
48 #define EWF_ADAPTER_THALES_COMMON_UDP_ENABLED (1)
49 #endif
50 
51 #if !defined(EWF_ADAPTER_THALES_COMMON_MQTT_ENABLED) && !defined(EWF_ADAPTER_THALES_COMMON_MQTT_BASIC_ENABLED)
52 #if 1
53 #define EWF_ADAPTER_THALES_COMMON_MQTT_BASIC_ENABLED (1)
54 #define EWF_ADAPTER_THALES_COMMON_MQTT_ENABLED (0)
55 #else
56 #define EWF_ADAPTER_THALES_COMMON_MQTT_BASIC_ENABLED (0)
57 #define EWF_ADAPTER_THALES_COMMON_MQTT_ENABLED (1)
58 #endif
59 #endif
60 
61 #ifndef EWF_ADAPTER_THALES_COMMON_INTERNET_SOCKET_POOL_SIZE
63 #define EWF_ADAPTER_THALES_COMMON_INTERNET_SOCKET_POOL_SIZE (12)
64 #endif
65 
66 #ifndef EWF_ADAPTER_THALES_COMMON_INTERNET_SOCKET_INVALID
68 #define EWF_ADAPTER_THALES_COMMON_INTERNET_SOCKET_INVALID (-1)
69 #endif
70 
71 #ifndef EWF_ADAPTER_THALES_COMMON_MQTT_SOCKET_POOL_SIZE
73 #define EWF_ADAPTER_THALES_COMMON_MQTT_SOCKET_POOL_SIZE (12)
74 #endif
75 
76 #ifndef EWF_ADAPTER_THALES_COMMON_MQTT_SOCKET_INVALID
78 #define EWF_ADAPTER_THALES_COMMON_MQTT_SOCKET_INVALID (-1)
79 #endif
80 
81 /************************************************************************/
85 /************************************************************************/
92 /************************************************************************/
98 extern ewf_interface_tokenizer_pattern* ewf_adapter_thales_common_message_tokenizer_pattern_ptr;
99 extern ewf_interface_tokenizer_pattern* ewf_adapter_thales_common_command_response_end_tokenizer_pattern_ptr;
100 static ewf_interface_tokenizer_pattern* ewf_adapter_thales_common_command_response_tokenizer_pattern_ptr;
101 extern ewf_interface_tokenizer_pattern* ewf_adapter_thales_common_urc_tokenizer_pattern_ptr;
102 
103 /************************************************************************/
107 /************************************************************************/
115 {
116  ewf_adapter_thales_common_internet_socket_service_type_not_initialized,
117  ewf_adapter_thales_common_internet_socket_service_type_tcp,
118  ewf_adapter_thales_common_internet_socket_service_type_udp,
119  ewf_adapter_thales_common_internet_socket_service_type_tcp_listener,
120  ewf_adapter_thales_common_internet_socket_service_type_udp_listener,
121 
123 
126 {
127  void* socket_ptr;
128  uint32_t id;
129  uint16_t local_port;
131  volatile bool used : 1;
132  volatile bool open : 1;
133  volatile bool open_error : 1;
134  volatile bool conn : 1;
135  volatile bool conn_error : 1;
136 
138 
141 {
142  volatile bool open : 1;
143  volatile bool open_error : 1;
144  volatile bool conn : 1;
145  volatile bool conn_error : 1;
146 
148 
151 {
152  uint32_t default_timeout;
153 
154 #if EWF_ADAPTER_THALES_COMMON_TCP_ENABLED || EWF_ADAPTER_THALES_COMMON_UDP_ENABLED
157 #endif
158 
159 #if EWF_ADAPTER_THALES_COMMON_MQTT_BASIC_ENABLED
161  volatile bool mqtt_basic_open : 1;
162  volatile bool mqtt_basic_open_error : 1;
163  volatile bool mqtt_basic_conn : 1;
164  volatile bool mqtt_basic_conn_error : 1;
165  volatile bool mqtt_basic_publish : 1;
166  volatile bool mqtt_basic_subscribe : 1;
167 #endif /* EWF_ADAPTER_THALES_COMMON_MQTT_BASIC_ENABLED */
168 
169 #if EWF_ADAPTER_THALES_COMMON_MQTT_ENABLED
172 
174  ewf_adapter_mqtt_message_callback mqtt_message_callback;
175 #endif /* EWF_ADAPTER_THALES_COMMON_MQTT_ENABLED */
176 
178 
179 /************************************************************************/
183 /************************************************************************/
200 
206 
211 ewf_result ewf_adapter_thales_common_context_configure(ewf_adapter* adapter_ptr, uint32_t ctx, uint32_t type, const char* apn, const char* username, const char* password, uint32_t authentication);
212 
217 ewf_result ewf_adapter_thales_common_context_configure_dns(ewf_adapter* adapter_ptr, uint32_t ctx, const char* primary_dns, const char* secondary_dns);
218 
227 ewf_result ewf_adapter_thales_common_ufs_start(ewf_adapter* adapter_ptr);
228 ewf_result ewf_adapter_thales_common_ufs_stop(ewf_adapter* adapter_ptr);
229 
230 ewf_result ewf_adapter_thales_common_ufs_urc_callback(ewf_interface* interface_ptr, uint8_t* buffer_ptr, uint32_t buffer_length);
231 
237 
243 ewf_result ewf_adapter_thales_common_ufs_delete(ewf_adapter* adapter_ptr, const char* filename_str);
244 
252 ewf_result ewf_adapter_thales_common_ufs_upload(ewf_adapter* adapter_ptr, const char* filename_str, const uint8_t* buffer_ptr, uint32_t buffer_length);
253 
262 extern ewf_adapter_api_control ewf_adapter_thales_common_api_control;
263 
264 ewf_result ewf_adapter_thales_common_start(ewf_adapter* adapter_ptr);
265 ewf_result ewf_adapter_thales_common_stop(ewf_adapter* adapter_ptr);
266 
275 extern ewf_adapter_api_info ewf_adapter_thales_common_api_info;
276 
277 ewf_result ewf_adapter_thales_common_info(ewf_adapter* adapter_ptr);
278 ewf_result ewf_adapter_thales_common_get_ipv4_address(ewf_adapter* adapter_ptr, uint32_t* address_ptr);
279 ewf_result ewf_adapter_thales_common_get_ipv4_netmask(ewf_adapter* adapter_ptr, uint32_t* netmask_ptr);
280 ewf_result ewf_adapter_thales_common_get_ipv4_gateway(ewf_adapter* adapter_ptr, uint32_t* gateway_ptr);
281 ewf_result ewf_adapter_thales_common_get_ipv4_dns(ewf_adapter* adapter_ptr, uint32_t* dns);
282 
291 ewf_result ewf_adapter_thales_common_urc_callback(ewf_interface* interface_ptr, uint8_t* buffer_ptr, uint32_t buffer_length);
292 
301 #if EWF_ADAPTER_THALES_COMMON_TCP_ENABLED || EWF_ADAPTER_THALES_COMMON_UDP_ENABLED
302 
303 ewf_result ewf_adapter_thales_common_internet_start(ewf_adapter* adapter_ptr);
304 ewf_result ewf_adapter_thales_common_internet_stop(ewf_adapter* adapter_ptr);
305 
306 ewf_result ewf_adapter_thales_common_internet_urc_callback(ewf_interface* interface_ptr, uint8_t* buffer_ptr, uint32_t buffer_length);
307 
308 #endif /* EWF_ADAPTER_THALES_COMMON_TCP_ENABLED || EWF_ADAPTER_THALES_COMMON_UDP_ENABLED */
309 
318 #if EWF_ADAPTER_THALES_COMMON_TCP_ENABLED
319 
320 extern ewf_adapter_api_tcp ewf_adapter_thales_common_api_tcp;
321 
322 ewf_result ewf_adapter_thales_common_tcp_open(ewf_adapter* adapter_ptr, ewf_socket_tcp* socket_ptr);
323 ewf_result ewf_adapter_thales_common_tcp_close(ewf_socket_tcp* socket_ptr);
324 ewf_result ewf_adapter_thales_common_tcp_control(ewf_socket_tcp* socket_ptr, const char* control_str, const uint8_t* buffer_ptr, uint32_t* buffer_length_ptr);
325 ewf_result ewf_adapter_thales_common_tcp_set_tls_configuration(ewf_socket_tcp* socket_ptr, uint32_t tls_configuration_id);
326 ewf_result ewf_adapter_thales_common_tcp_bind(ewf_socket_tcp* socket_ptr, uint32_t local_port);
327 ewf_result ewf_adapter_thales_common_tcp_listen(ewf_socket_tcp* socket_ptr);
328 ewf_result ewf_adapter_thales_common_tcp_accept(ewf_socket_tcp* socket_ptr, ewf_socket_tcp* socket_new_ptr);
329 ewf_result ewf_adapter_thales_common_tcp_connect(ewf_socket_tcp* socket_ptr, const char* const server, uint32_t port);
330 ewf_result ewf_adapter_thales_common_tcp_shutdown(ewf_socket_tcp* socket_ptr);
331 ewf_result ewf_adapter_thales_common_tcp_send(ewf_socket_tcp* socket_ptr, const uint8_t* buffer_ptr, uint32_t buffer_length);
332 ewf_result ewf_adapter_thales_common_tcp_receive(ewf_socket_tcp* socket_ptr, uint8_t* buffer_ptr, uint32_t* buffer_length, bool wait);
333 
334 #endif /* EWF_ADAPTER_THALES_COMMON_TCP_ENABLED */
335 
344 #if EWF_ADAPTER_THALES_COMMON_UDP_ENABLED
345 
346 extern ewf_adapter_api_udp ewf_adapter_thales_common_api_udp;
347 
348 ewf_result ewf_adapter_thales_common_udp_open(ewf_adapter* adapter_ptr, ewf_socket_udp* socket_ptr);
349 ewf_result ewf_adapter_thales_common_udp_close(ewf_socket_udp* socket_ptr);
350 ewf_result ewf_adapter_thales_common_udp_control(ewf_socket_udp* socket_ptr, const char* control_str, const uint8_t* buffer_ptr, uint32_t* buffer_length_ptr);
351 ewf_result ewf_adapter_thales_common_udp_set_dtls_configuration(ewf_socket_udp* socket_ptr, uint32_t dtls_configuration_id);
352 ewf_result ewf_adapter_thales_common_udp_bind(ewf_socket_udp* socket_ptr, uint32_t port);
353 ewf_result ewf_adapter_thales_common_udp_shutdown(ewf_socket_udp* socket_ptr);
354 ewf_result ewf_adapter_thales_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);
355 ewf_result ewf_adapter_thales_common_udp_receive_from(ewf_socket_udp* socket_ptr, char* remote_address, uint32_t* remote_address_length_ptr, uint32_t* remote_port_ptr, char* buffer_ptr, uint32_t* buffer_length_ptr, bool wait);
356 
357 #endif /* EWF_ADAPTER_THALES_COMMON_UDP_ENABLED */
358 
367 #if EWF_ADAPTER_THALES_COMMON_TLS_BASIC_ENABLED
368 
369 extern ewf_adapter_api_tls_basic ewf_adapter_thales_common_api_tls_basic;
370 
371 ewf_result ewf_adapter_thales_common_tls_basic_start(ewf_adapter* adapter_ptr);
372 ewf_result ewf_adapter_thales_common_tls_basic_stop(ewf_adapter* adapter_ptr);
373 
374 ewf_result ewf_adapter_thales_common_tls_basic_urc_callback(ewf_interface* interface_ptr, uint8_t* buffer_ptr, uint32_t buffer_length);
375 
376 ewf_result ewf_adapter_thales_common_tls_basic_init(ewf_adapter* adapter_ptr);
377 ewf_result ewf_adapter_thales_common_tls_basic_clean(ewf_adapter* adapter_ptr);
378 
379 #endif /* EWF_ADAPTER_THALES_COMMON_TLS_BASIC_ENABLED */
380 
389 #if EWF_ADAPTER_THALES_COMMON_MQTT_BASIC_ENABLED
390 
391 extern ewf_adapter_api_mqtt_basic ewf_adapter_thales_common_api_mqtt_basic;
392 
393 ewf_result ewf_adapter_thales_common_mqtt_basic_start(ewf_adapter* adapter_ptr);
394 ewf_result ewf_adapter_thales_common_mqtt_basic_stop(ewf_adapter* adapter_ptr);
395 
396 ewf_result ewf_adapter_thales_common_mqtt_basic_urc_callback(ewf_interface* interface_ptr, uint8_t* buffer_ptr, uint32_t buffer_length);
397 
398 ewf_result ewf_adapter_thales_common_mqtt_basic_default_state_callback(ewf_adapter* adapter_ptr, const char* state_cstr, const char* param_cstr);
399 ewf_result ewf_adapter_thales_common_mqtt_basic_default_message_callback(ewf_adapter* adapter_ptr, const char* topic_cstr, const char* payload_cstr);
400 
401 ewf_result ewf_adapter_thales_common_mqtt_basic_connect(ewf_adapter* adapter_ptr, char const* server_str, uint32_t port, char const* clientid, char const* username, char const* password);
402 ewf_result ewf_adapter_thales_common_mqtt_basic_disconnect(ewf_adapter* adapter_ptr);
403 ewf_result ewf_adapter_thales_common_mqtt_basic_subscribe(ewf_adapter* adapter_ptr, char const* topic);
404 ewf_result ewf_adapter_thales_common_mqtt_basic_unsubscribe(ewf_adapter* adapter_ptr, char const* topic);
405 ewf_result ewf_adapter_thales_common_mqtt_basic_publish(ewf_adapter* adapter_ptr, const char* topic, const char* msg_cstr);
406 
407 #endif /* EWF_ADAPTER_THALES_COMMON_MQTT_BASIC_ENABLED */
408 
411 /************************************************************************/
415 /************************************************************************/
419 #ifdef __cplusplus
420 }
421 #endif
422 
423 #endif /* __ewf_adapter_thales_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
ewf_result(* ewf_adapter_mqtt_message_callback)(ewf_socket_mqtt *socket_ptr, const char *topic_str, ewf_adapter_mqtt_message *message_ptr)
A function pointer type for MQTT message callbacks.
Definition: ewf_adapter_api_mqtt.h:50
ewf_result ewf_adapter_thales_common_context_configure_dns(ewf_adapter *adapter_ptr, uint32_t ctx, const char *primary_dns, const char *secondary_dns)
Configure a context DNS.
Definition: ewf_adapter_thales_common_context.c:140
ewf_result ewf_adapter_thales_common_context_activate(ewf_adapter *adapter_ptr, uint32_t ctx)
Activate a context.
Definition: ewf_adapter_thales_common_context.c:13
ewf_result ewf_adapter_thales_common_context_configure(ewf_adapter *adapter_ptr, uint32_t ctx, uint32_t type, const char *apn, const char *username, const char *password, uint32_t authentication)
Configure a context.
Definition: ewf_adapter_thales_common_context.c:79
ewf_result ewf_adapter_thales_common_context_deactivate(ewf_adapter *adapter_ptr, uint32_t ctx)
Deactivate a context.
Definition: ewf_adapter_thales_common_context.c:46
enum _ewf_adapter_common_internet_socket_service_type ewf_adapter_thales_common_internet_socket_service_type
The socket service type
struct _ewf_adapter_thales_common ewf_adapter_thales_common
The Thales common adapter data structure.
struct _ewf_adapter_thales_common_internet_socket ewf_adapter_thales_common_internet_socket
Internal structure for internet socket status
struct _ewf_adapter_thales_common_mqtt_socket ewf_adapter_thales_common_mqtt_socket
Internal structure for MQTT socket status
ewf_result ewf_adapter_thales_common_ufs_list(ewf_adapter *adapter_ptr)
List the files in the user file system.
ewf_result ewf_adapter_thales_common_ufs_upload(ewf_adapter *adapter_ptr, const char *filename_str, const uint8_t *buffer_ptr, uint32_t buffer_length)
Upload a file to the user file system.
ewf_result ewf_adapter_thales_common_ufs_delete(ewf_adapter *adapter_ptr, const char *filename_str)
Delete a file from the user file system.
#define EWF_ADAPTER_THALES_COMMON_INTERNET_SOCKET_POOL_SIZE
The total number of supported internet sockets in the adapter.
Definition: ewf_adapter_thales_common.h:63
#define EWF_ADAPTER_THALES_COMMON_MQTT_SOCKET_POOL_SIZE
The total number of supported MQTT sockets in the adapter.
Definition: ewf_adapter_thales_common.h:73
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
Definition: ewf_adapter_api_mqtt_basic.h:55
The TCP API structure.
Definition: ewf_adapter_api_tcp.h:76
The TLS basic API structure.
Definition: ewf_adapter_api_tls_basic.h:29
The UDP API type.
Definition: ewf_adapter_api_udp.h:63
Internal structure for internet socket status
Definition: ewf_adapter_thales_common.h:126
Internal structure for MQTT socket status
Definition: ewf_adapter_thales_common.h:141
The Thales common adapter data structure.
Definition: ewf_adapter_thales_common.h:151
volatile bool mqtt_basic_open
Internal MQTT basic API socket 0 status
Definition: ewf_adapter_thales_common.h:161
uint32_t default_timeout
Definition: ewf_adapter_thales_common.h:152
The EWF network adapter control structure definition.
Definition: ewf_adapter.h:50
The interface structure definition.
Definition: ewf_interface.h:66
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