21 #include "platform/mbed_retarget.h" 23 #include "events/EventQueue.h" 24 #include "nsapi_types.h" 30 #include "UARTSerial.h" 38 #define AT_HANDLER_MUTEX 40 #if defined AT_HANDLER_MUTEX && defined MBED_CONF_RTOS_PRESENT 41 #include "ConditionVariable.h" 48 extern const char *OK;
49 extern const char *CRLF;
54 enum DeviceErrorType {
55 DeviceErrorTypeNoError = 0,
57 DeviceErrorTypeErrorCMS,
58 DeviceErrorTypeErrorCME
63 DeviceErrorType errType;
105 const char *delimiter, uint16_t send_delay,
bool debug_on);
153 void inc_ref_count();
159 void dec_ref_count();
172 void set_at_timeout(uint32_t timeout_milliseconds,
bool default_timeout =
false);
179 static void set_at_timeout_list(uint32_t timeout_milliseconds,
bool default_timeout =
false);
183 void restore_at_timeout();
209 void set_is_filehandle_usable(
bool usable);
216 bool sync(
int timeout_ms);
222 void set_send_delay(uint16_t send_delay);
228 void set_baud(
int baud_rate);
232 #if defined AT_HANDLER_MUTEX && defined MBED_CONF_RTOS_PRESENT 242 void remove_urc_handler(
const char *prefix);
248 int _last_3gpp_error;
250 uint16_t _oob_string_max_length;
251 char *_output_delimiter;
260 uint32_t _at_timeout;
261 uint32_t _previous_at_timeout;
263 uint16_t _at_send_delay;
264 uint64_t _last_response_stop;
279 virtual void cmd_start(
const char *cmd);
291 void cmd_start_stop(
const char *cmd,
const char *cmd_chr,
const char *format =
"", ...);
303 nsapi_error_t at_cmd_str(
const char *cmd,
const char *cmd_chr,
char *resp_buf,
size_t resp_buf_size,
const char *format =
"", ...);
314 nsapi_error_t at_cmd_int(
const char *cmd,
const char *cmd_chr,
int &resp,
const char *format =
"", ...);
324 nsapi_error_t at_cmd_discard(
const char *cmd,
const char *cmd_chr,
const char *format =
"", ...);
333 void write_int(int32_t param);
342 void write_string(
const char *param,
bool useQuotations =
true);
351 void cmd_stop_read_resp();
361 size_t write_bytes(
const uint8_t *data,
size_t len);
369 void set_stop_tag(
const char *stop_tag_seq);
376 void set_delimiter(
char delimiter);
380 void set_default_delimiter();
386 void use_delimiter(
bool use_delimiter);
392 void skip_param(uint32_t count = 1);
399 void skip_param(ssize_t len, uint32_t count);
407 ssize_t read_bytes(uint8_t *buf,
size_t len);
417 ssize_t read_string(
char *str,
size_t size,
bool read_even_stop_tag =
false);
428 ssize_t read_hex_string(
char *str,
size_t size);
436 void write_hex_string(
char *str,
size_t size);
452 void resp_start(
const char *prefix = NULL,
bool stop =
false);
482 bool info_elem(
char start_tag);
488 bool consume_to_stop_tag();
493 int get_3gpp_error();
505 void set_debug(
bool debug_on);
512 bool get_debug()
const;
518 static void set_debug_list(
bool debug_on);
523 char _recv_buff[BUFF_SIZE];
534 enum ScopeType {RespType, InfoType, ElemType, NotSet};
535 void set_scope(ScopeType scope_type);
536 ScopeType _current_scope;
556 bool _prefix_matched;
562 size_t _max_resp_length;
565 char _info_resp_prefix[BUFF_SIZE];
571 uint64_t _start_time;
575 char _cmd_buffer[BUFF_SIZE];
579 void handle_args(
const char *format, std::va_list list);
582 void handle_start(
const char *cmd,
const char *cmd_chr);
585 bool ok_to_proceed();
595 void rewind_buffer();
598 int poll_timeout(
bool wait_for_timeout =
true);
601 bool fill_buffer(
bool wait_for_timeout =
true);
603 void set_tag(tag_t *tag_dest,
const char *tag_seq);
606 bool match(
const char *str,
size_t size);
615 bool consume_char(
char ch);
618 bool consume_to_tag(
const char *tag,
bool consume_tag);
620 void resp(
const char *prefix,
bool check_urc);
623 ScopeType get_scope();
626 void information_response_stop();
628 void information_response_element_stop();
631 void at_error(
bool error_code, DeviceErrorType error_type);
637 void set_3gpp_error(
int err, DeviceErrorType error_type);
639 bool check_cmd_send();
640 size_t write(
const void *data,
size_t len);
651 const char *mem_str(
const char *dest,
size_t dest_len,
const char *src,
size_t src_len);
654 bool find_urc_handler(
const char *prefix);
662 void debug_print(
const char *p,
int len, ATType type);
667 #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...
Callback class based on template specialization.
Class for sending AT commands and parsing AT responses.