Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Revision:
1:9db0e321a9f4
Parent:
0:5b88d5760320
--- a/features/cellular/framework/AT/ATHandler.h	Tue Dec 17 23:23:45 2019 +0000
+++ b/features/cellular/framework/AT/ATHandler.h	Tue Dec 31 06:02:27 2019 +0000
@@ -21,16 +21,13 @@
 #include "platform/mbed_retarget.h"
 
 #include "events/EventQueue.h"
-#include "PlatformMutex.h"
 #include "nsapi_types.h"
 
 #include "Callback.h"
 
 #include <cstdarg>
 
-namespace mbed {
-
-class FileHandle;
+#include "UARTSerial.h"
 
 /**
  * If application calls associated FileHandle only from single thread context
@@ -40,6 +37,14 @@
   */
 #define AT_HANDLER_MUTEX
 
+#if defined AT_HANDLER_MUTEX && defined MBED_CONF_RTOS_PRESENT
+#include "ConditionVariable.h"
+#endif
+
+namespace mbed {
+
+class FileHandle;
+
 extern const char *OK;
 extern const char *CRLF;
 
@@ -210,10 +215,23 @@
      */
     bool sync(int timeout_ms);
 
+    /** Sets the delay to be applied before sending any AT command.
+     *
+     *  @param send_delay the minimum delay in ms between the end of last response and the beginning of a new command
+     */
+    void set_send_delay(uint16_t send_delay);
+
+    /** Sets UARTSerial filehandle to given baud rate
+     *
+     *  @param baud_rate
+     */
+    void set_baud(int baud_rate);
+
 protected:
     void event();
-#ifdef AT_HANDLER_MUTEX
-    PlatformMutex _fileHandleMutex;
+#if defined AT_HANDLER_MUTEX && defined MBED_CONF_RTOS_PRESENT
+    rtos::Mutex _fileHandleMutex;
+    rtos::ConditionVariable _oobCv;
 #endif
     FileHandle *_fileHandle;
 private:
@@ -245,7 +263,6 @@
     uint16_t _at_send_delay;
     uint64_t _last_response_stop;
 
-    bool _oob_queued;
     int32_t _ref_count;
     bool _is_fh_usable;
 
@@ -410,9 +427,17 @@
      */
     ssize_t read_hex_string(char *str, size_t size);
 
-    /** Reads as string and converts result to integer. Supports only positive integers.
+    /** Converts contained chars to their hex ascii value and writes the resulting string to the file handle
+     *  For example: "AV" to "4156".
      *
-     *  @return the positive integer or -1 in case of error.
+     *  @param str input buffer to be converted to hex ascii
+     *  @param size of the input param str
+     */
+    void write_hex_string(char *str, size_t size);
+
+    /** Reads as string and converts result to integer. Supports only non-negative integers.
+     *
+     *  @return the non-negative integer or -1 in case of error.
      */
     int32_t read_int();
 
@@ -544,6 +569,8 @@
 
     // time when a command or an URC processing was started
     uint64_t _start_time;
+    // eventqueue event id
+    int _event_id;
 
     char _cmd_buffer[BUFF_SIZE];