9 #ifndef __ewf_interface__h__included__
10 #define __ewf_interface__h__included__
67 #ifdef EWF_PARAMETER_CHECKING
68 uint32_t struct_magic;
70 uint32_t struct_version;
74 #ifdef EWF_PLATFORM_HAS_THREADING
76 ewf_platform_mutex global_mutex;
83 volatile bool sync_urc_processing;
161 #define EWF_INTERFACE_STRUCT_MAGIC (0x017eface)
162 #define EWF_INTERFACE_STRUCT_SIZE (sizeof(struct _ewf_interface))
163 #define EWF_INTERFACE_VERSION (EWF_DEVELOPER_MICROSOFT | 0x0001)
165 #ifdef EWF_PARAMETER_CHECKING
166 #define EWF_INTERFACE_VALIDATE_POINTER(interface_ptr) \
168 if ((interface_ptr == NULL) || \
169 (interface_ptr->struct_magic != EWF_INTERFACE_STRUCT_MAGIC) || \
170 (interface_ptr->struct_size != EWF_INTERFACE_STRUCT_SIZE) || \
171 (interface_ptr->struct_version != EWF_INTERFACE_VERSION) || \
172 (interface_ptr->implementation_ptr == NULL)) \
174 EWF_LOG_ERROR("The interface pointer is invalid."); \
175 return EWF_RESULT_INVALID_FUNCTION_ARGUMENT; \
179 #define EWF_INTERFACE_VALIDATE_POINTER(interface_ptr) \
181 if ((interface_ptr == NULL) || \
182 (interface_ptr->implementation_ptr == NULL)) \
184 EWF_LOG_ERROR("The interface pointer is invalid."); \
185 return EWF_RESULT_INVALID_FUNCTION_ARGUMENT; \
190 #ifdef EWF_PARAMETER_CHECKING
191 #define EWF_INTERFACE_VALIDATE_POINTER_TYPE(interface_ptr, interface_type) \
193 if ((interface_ptr == NULL) || \
194 (interface_ptr->struct_type != interface_type) || \
195 (interface_ptr->implementation_ptr == NULL)) \
197 EWF_LOG_ERROR("The interface type is invalid."); \
198 return EWF_RESULT_INVALID_FUNCTION_ARGUMENT; \
202 #define EWF_INTERFACE_VALIDATE_POINTER_TYPE(interface_ptr, interface_type)
The Embedded Wireless Framework.
enum _ewf_result ewf_result
Success and error result codes specific to the EWF API.
ewf_result ewf_interface_set_user_urc_callback(ewf_interface *interface_ptr, ewf_interface_urc_callback callback)
register a user callback for URC
Definition: ewf_interface.c:963
ewf_result ewf_interface_set_urc_callback(ewf_interface *interface_ptr, ewf_interface_urc_callback callback)
register a callback for URC
Definition: ewf_interface.c:954
ewf_result ewf_interface_set_response_callback(ewf_interface *interface_ptr, ewf_interface_response_callback callback)
register a user callback for responses
Definition: ewf_interface.c:945
ewf_result ewf_interface_stop(ewf_interface *interface_ptr)
Stops the interface.
Definition: ewf_interface.c:147
ewf_result ewf_interface_release(ewf_interface *interface_ptr, void *buffer_ptr)
Release a message buffer returned by the interface.
Definition: ewf_interface.c:313
ewf_result ewf_interface_receive_response(ewf_interface *interface_ptr, uint8_t **buffer_ptr_ptr, uint32_t *buffer_length_ptr, uint32_t wait_time)
Read a response message from the interface.
Definition: ewf_interface.c:287
ewf_result ewf_interface_message_allocator_set(ewf_interface *interface_ptr, ewf_allocator *allocator_ptr)
Set the interface message allocator.
Definition: ewf_interface.c:299
ewf_result ewf_interface_clean(ewf_interface *interface_ptr)
Cleanup the interface This is called after the interface has been stopped It releases resources used ...
Definition: ewf_interface.c:65
ewf_result ewf_interface_release_data(ewf_interface *interface_ptr, void *buffer_ptr)
Release a data buffer returned by the interface.
Definition: ewf_interface.c:320
ewf_result ewf_interface_start(ewf_interface *interface_ptr)
Starts the interface.
Definition: ewf_interface.c:82
ewf_result ewf_interface_send(ewf_interface *interface_ptr, const uint8_t *buffer_ptr, uint32_t buffer_length)
Sends data to the interface.
Definition: ewf_interface.c:187
ewf_result ewf_interface_receive_urc(ewf_interface *interface_ptr, uint8_t **buffer, uint32_t *buffer_length_ptr, uint32_t wait_time)
Receive a message from the URC queue.
Definition: ewf_interface.c:293
ewf_result ewf_interface_data_allocator_set(ewf_interface *interface_ptr, ewf_allocator *allocator_ptr)
Set the interface data allocator.
Definition: ewf_interface.c:306
ewf_result ewf_interface_init(ewf_interface *interface_ptr)
Initialize the interface This initializes the internal status of the control structure This doesn't s...
Definition: ewf_interface.c:34
ewf_result ewf_interface_process_byte(ewf_interface *interface_ptr, uint8_t b)
Called by the hardware code to process an incoming byte When the hardware interface receives a byte i...
Definition: ewf_interface.c:698
ewf_result ewf_interface_process_buffer(ewf_interface *interface_ptr, uint8_t *buffer_ptr, uint32_t buffer_length)
Called by the hardware code to process a buffer When the hardware interface receives a byte it used t...
ewf_result ewf_interface_send_command(ewf_interface *interface_ptr, const char *command_str)
Send a command.
Definition: ewf_interface.c:978
ewf_result ewf_interface_send_commands(ewf_interface *interface_ptr, const char *command_str,...)
Send a command.
Definition: ewf_interface.c:987
ewf_result ewf_interface_verify_response_ends_with(ewf_interface *interface_ptr, const char *expected_end_str)
Verify if interface response starts with expected string.
Definition: ewf_interface.c:1190
ewf_result ewf_interface_verify_response(ewf_interface *interface_ptr, const char *expected_str)
Verify an interface response, compare against a string.
Definition: ewf_interface.c:1079
ewf_result ewf_interface_verify_responses(ewf_interface *interface_ptr, uint32_t response_count, const char **expected_str_arr)
Verify an interface response, compare agains an array of strings.
Definition: ewf_interface.c:1116
ewf_result ewf_interface_get_response(ewf_interface *interface_ptr, uint8_t **response_out)
Get a response from the interface.
Definition: ewf_interface.c:1052
ewf_result ewf_interface_verify_response_starts_with(ewf_interface *interface_ptr, const char *expected_start_str)
Verify if interface response starts with expected string.
Definition: ewf_interface.c:1153
ewf_result ewf_interface_drop_all_responses(ewf_interface *interface_ptr)
Drop all responses from the interface.
Definition: ewf_interface.c:1009
ewf_result ewf_interface_drop_response(ewf_interface *interface_ptr)
Drop a single response from the interface.
Definition: ewf_interface.c:1026
ewf_result ewf_interface_poll(ewf_interface *interface_ptr)
Definition: ewf_interface.c:876
ewf_result ewf_interface_default_timeout_get(ewf_interface *interface_ptr, uint32_t *timeout_ptr)
Get the current interface default timeout value.
Definition: ewf_interface.c:334
ewf_result ewf_interface_default_timeout_set(ewf_interface *interface_ptr, uint32_t timeout)
Set the interface default timeout value.
Definition: ewf_interface.c:327
ewf_result ewf_interface_tokenizer_command_response_end_pattern_get(ewf_interface *interface_ptr, ewf_interface_tokenizer_pattern **tokenizer_patter_ptr_ptr)
Get the interface command response end tokenizer pattern.
Definition: ewf_interface.c:402
ewf_result ewf_interface_tokenizer_message_pattern_get(ewf_interface *interface_ptr, ewf_interface_tokenizer_pattern **tokenizer_patter_ptr_ptr)
Get the interface message tokenizer pattern.
Definition: ewf_interface.c:368
ewf_result ewf_interface_tokenizer_command_response_pattern_set(ewf_interface *interface_ptr, ewf_interface_tokenizer_pattern *tokenizer_patter_ptr)
Set the interface command response tokenizer pattern.
Definition: ewf_interface.c:410
ewf_result ewf_interface_tokenizer_urc_pattern_get(ewf_interface *interface_ptr, ewf_interface_tokenizer_pattern **tokenizer_patter_ptr_ptr)
Get the interface URC tokenizer pattern.
Definition: ewf_interface.c:470
ewf_result ewf_interface_tokenizer_command_response_pattern_get(ewf_interface *interface_ptr, ewf_interface_tokenizer_pattern **tokenizer_patter_ptr_ptr)
Get the interface command response tokenizer pattern.
Definition: ewf_interface.c:436
ewf_result ewf_interface_tokenizer_message_pattern_set(ewf_interface *interface_ptr, ewf_interface_tokenizer_pattern *tokenizer_patter_ptr)
Set the interface message tokenizer pattern.
Definition: ewf_interface.c:342
ewf_result ewf_interface_tokenizer_urc_pattern_set(ewf_interface *interface_ptr, ewf_interface_tokenizer_pattern *tokenizer_patter_ptr)
Set the interface URC tokenizer pattern.
Definition: ewf_interface.c:444
ewf_result ewf_interface_tokenizer_command_response_end_pattern_set(ewf_interface *interface_ptr, ewf_interface_tokenizer_pattern *tokenizer_patter_ptr)
Set the interface command response end tokenizer pattern.
Definition: ewf_interface.c:376
ewf_result ewf_interface_urc_process_message(ewf_interface *interface_ptr, uint8_t *buffer_ptr, uint32_t buffer_length)
Process a URC message.
Definition: ewf_interface.c:605
ewf_result ewf_interface_urc_processing(ewf_interface *interface_ptr)
Call periodically to process URCs This is called internally by the URC thread. Call manually if there...
Definition: ewf_interface.c:567
ewf_result(* ewf_interface_response_callback)(ewf_interface *interface_ptr, uint8_t *buffer_ptr, uint32_t length)
a function pointer type for response callbacks
Definition: ewf_interface.h:57
ewf_tokenizer_pattern ewf_interface_tokenizer_pattern
Legacy type for tokenizer patters.
Definition: ewf_interface.h:52
ewf_result(* ewf_interface_urc_callback)(ewf_interface *interface_ptr, uint8_t *buffer_ptr, uint32_t length)
a function pointer type for URC callbacks
Definition: ewf_interface.h:62
ewf_message ewf_interface_message
Legacy type for messages.
Definition: ewf_interface.h:47
The EWF network adapter control structure definition.
Definition: ewf_adapter.h:50
ewf_interface * interface_ptr
Definition: ewf_adapter.h:73
The allocator structure definition.
Definition: ewf_allocator.h:27
The interface structure definition.
Definition: ewf_interface.h:66
ewf_result(* hardware_send)(ewf_interface *interface_ptr, const uint8_t *buffer_ptr, uint32_t buffer_length)
Definition: ewf_interface.h:155
ewf_result(* hardware_stop)(ewf_interface *interface_ptr)
Definition: ewf_interface.h:152
volatile bool command_mode
Definition: ewf_interface.h:80
ewf_platform_queue * response_queue_ptr
Definition: ewf_interface.h:122
struct _ewf_adapter * adapter_ptr
Definition: ewf_interface.h:88
void * implementation_ptr
Definition: ewf_interface.h:91
ewf_allocator * message_allocator_ptr
Definition: ewf_interface.h:114
ewf_interface_response_callback response_callback
Definition: ewf_interface.h:103
volatile uint32_t default_timeout
Definition: ewf_interface.h:130
ewf_interface_urc_callback urc_callback
Definition: ewf_interface.h:106
ewf_interface_tokenizer_pattern * message_tokenizer_pattern_ptr
Definition: ewf_interface.h:135
ewf_interface_tokenizer_pattern * command_response_tokenizer_pattern_ptr
Definition: ewf_interface.h:141
ewf_interface_tokenizer_pattern * command_response_end_tokenizer_pattern_ptr
Definition: ewf_interface.h:138
ewf_result(* hardware_start)(ewf_interface *interface_ptr)
Definition: ewf_interface.h:149
The interface message structure definition.
Definition: ewf_message.h:27
The interface tokenizer pattern structure definition.
Definition: ewf_tokenizer.h:27