21 #include "platform/mbed_retarget.h" 22 #include "platform/mbed_chrono.h" 24 #include "events/EventQueue.h" 25 #include "netsocket/nsapi_types.h" 28 #include "rtos/Kernel.h" 32 #include "drivers/BufferedSerial.h" 40 #define AT_HANDLER_MUTEX 42 #if defined AT_HANDLER_MUTEX && defined MBED_CONF_RTOS_PRESENT 43 #include "rtos/ConditionVariable.h" 50 extern const char *OK;
51 extern const char *CRLF;
54 enum DeviceErrorType {
55 DeviceErrorTypeNoError = 0,
57 DeviceErrorTypeErrorCMS,
58 DeviceErrorTypeErrorCME
63 DeviceErrorType errType;
89 ATHandler(
FileHandle *fh,
events::EventQueue &queue, mbed::chrono::milliseconds_u32 timeout,
const char *output_delimiter, std::chrono::duration<uint16_t, std::milli> send_delay = std::chrono::milliseconds(0));
137 void set_at_timeout(uint32_t timeout_milliseconds,
bool default_timeout =
false);
144 void set_at_timeout(mbed::chrono::milliseconds_u32 timeout,
bool default_timeout =
false);
148 void restore_at_timeout();
168 void set_is_filehandle_usable(
bool usable);
175 bool sync(
int timeout_ms);
182 bool sync(std::chrono::duration<int, std::milli> timeout);
188 void set_send_delay(uint16_t send_delay);
194 void set_baud(
int baud_rate);
201 void cmd_start(
const char *cmd);
213 void cmd_start_stop(
const char *cmd,
const char *cmd_chr,
const char *format =
"", ...);
225 nsapi_error_t at_cmd_str(
const char *cmd,
const char *cmd_chr,
char *resp_buf,
size_t resp_buf_size,
const char *format =
"", ...);
236 nsapi_error_t at_cmd_int(
const char *cmd,
const char *cmd_chr,
int &resp,
const char *format =
"", ...);
246 nsapi_error_t at_cmd_discard(
const char *cmd,
const char *cmd_chr,
const char *format =
"", ...);
253 void write_int(int32_t param);
262 void write_string(
const char *param,
bool useQuotations =
true);
271 void cmd_stop_read_resp();
281 size_t write_bytes(
const uint8_t *data,
size_t len);
289 void set_stop_tag(
const char *stop_tag_seq);
296 void set_delimiter(
char delimiter);
300 void set_default_delimiter();
306 void use_delimiter(
bool use_delimiter);
312 void skip_param(uint32_t count = 1);
319 void skip_param(ssize_t len, uint32_t count);
327 ssize_t read_bytes(uint8_t *buf,
size_t len);
337 ssize_t read_string(
char *str,
size_t size,
bool read_even_stop_tag =
false);
348 ssize_t read_hex_string(
char *str,
size_t size);
357 void write_hex_string(
const char *str,
size_t size,
bool quote_string =
true);
373 void resp_start(
const char *prefix = NULL,
bool stop =
false);
403 bool info_elem(
char start_tag);
409 bool consume_to_stop_tag();
414 int get_3gpp_error();
426 void set_debug(
bool debug_on);
433 bool get_debug()
const;
468 void inc_ref_count();
474 void dec_ref_count();
486 void remove_urc_handler(
const char *prefix);
491 void handle_args(
const char *format, std::va_list
list);
494 void handle_start(
const char *cmd,
const char *cmd_chr);
497 bool ok_to_proceed();
506 void rewind_buffer();
509 int poll_timeout(
bool wait_for_timeout =
true);
512 bool fill_buffer(
bool wait_for_timeout =
true);
514 void set_tag(tag_t *tag_dest,
const char *tag_seq);
517 bool match(
const char *str,
size_t size);
526 bool consume_char(
char ch);
529 bool consume_to_tag(
const char *tag,
bool consume_tag);
531 void resp(
const char *prefix,
bool check_urc);
533 void set_scope(ScopeType scope_type);
535 ScopeType get_scope();
538 void information_response_stop();
540 void information_response_element_stop();
543 void at_error(
bool error_code, DeviceErrorType error_type);
549 void set_3gpp_error(
int err, DeviceErrorType error_type);
551 bool check_cmd_send();
552 size_t write(
const void *data,
size_t len);
563 const char *mem_str(
const char *dest,
size_t dest_len,
const char *src,
size_t src_len);
566 bool find_urc_handler(
const char *prefix);
575 void debug_print(
const char *p,
int len, ATType type);
579 #if defined AT_HANDLER_MUTEX && defined MBED_CONF_RTOS_PRESENT 587 int _last_3gpp_error;
589 uint16_t _oob_string_max_length;
590 char *_output_delimiter;
593 mbed::chrono::milliseconds_u32 _at_timeout;
594 mbed::chrono::milliseconds_u32 _previous_at_timeout;
596 std::chrono::duration<uint16_t, std::milli> _at_send_delay;
597 rtos::Kernel::Clock::time_point _last_response_stop;
603 char _recv_buff[MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE];
609 ScopeType _current_scope;
623 bool _prefix_matched;
629 size_t _max_resp_length;
632 char _info_resp_prefix[MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE];
638 rtos::Kernel::Clock::time_point _start_time;
642 char _cmd_buffer[MBED_CONF_CELLULAR_AT_HANDLER_BUFFER_SIZE];
647 #endif //AT_HANDLER_H_
signed int nsapi_error_t
Type used to represent error codes.
The Mutex class is used to synchronize the execution of threads.
AT response error with error code and type.
The ConditionVariable class is a synchronization primitive that allows threads to wait until a partic...
Connected isochronous stream linked list.
Callback class based on template specialization.
Class for sending AT commands and parsing AT responses.