Dopasowany do naszego firmware'u

Dependencies:   ArduinoAPI

Fork of WeeESP8266 by ITEAD STUDIO

Revision:
9:dec2cf52b744
Parent:
6:18eb2d9fb2ac
Child:
10:002615561b0b
--- a/ESP8266.h	Sat Feb 07 00:57:05 2015 +0000
+++ b/ESP8266.h	Sat Feb 07 05:24:08 2015 +0000
@@ -301,28 +301,28 @@
      * @retval true - success.
      * @retval false - failure.
      */
-    bool send(uint8_t mux_id, const char *buffer, uint32_t len);
+    bool send(uint8_t mux_id, const uint8_t *buffer, uint32_t len);
     
     /**
      * Receive data from TCP or UDP builded already in single mode. 
      *
      * @param buffer - the buffer for storing data. 
-     * @param len - the length of the buffer. 
+     * @param buffer_size - the length of the buffer. 
      * @param timeout - the time waiting data. 
      * @return the length of data received actually. 
      */
-    uint32_t recv(uint8_t *buffer, uint32_t len, uint32_t timeout = 1000);
+    uint32_t recv(uint8_t *buffer, uint32_t buffer_size, uint32_t timeout = 1000);
     
     /**
      * Receive data from one of TCP or UDP builded already in multiple mode. 
      *
      * @param mux_id - the identifier of this TCP(available value: 0 - 4). 
      * @param buffer - the buffer for storing data. 
-     * @param len - the length of the buffer. 
+     * @param buffer_size - the length of the buffer. 
      * @param timeout - the time waiting data. 
      * @return the length of data received actually. 
      */
-    uint32_t recv(uint8_t mux_id, uint8_t *buffer, uint32_t len, uint32_t timeout = 1000);
+    uint32_t recv(uint8_t mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout = 1000);
     
     /**
      * Receive data from all of TCP or UDP builded already in multiple mode. 
@@ -332,19 +332,51 @@
      * 
      * @param coming_mux_id - the identifier of TCP or UDP. 
      * @param buffer - the buffer for storing data. 
-     * @param len - the length of the buffer. 
+     * @param buffer_size - the length of the buffer. 
      * @param timeout - the time waiting data. 
      * @return the length of data received actually. 
      */
-    uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t len, uint32_t timeout = 1000);
+    uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout = 1000);
 
  private:
+    /* 
+     * Recvive data from uart. Return all received data if target found or timeout. 
+     */
     String recvString(String target, uint32_t timeout = 1000);
+    
+    /* 
+     * Recvive data from uart. Return all received data if one of target1 and target2 found or timeout. 
+     */
     String recvString(String target1, String target2, uint32_t timeout = 1000);
+    
+    /* 
+     * Recvive data from uart. Return all received data if one of target1, target2 and target3 found or timeout. 
+     */
     String recvString(String target1, String target2, String target3, uint32_t timeout = 1000);
+    
+    /* 
+     * Recvive data from uart and search first target. Return true if target found, false for timeout.
+     */
     bool recvFind(String target, uint32_t timeout = 1000);
+    
+    /* 
+     * Recvive data from uart and search first target and cut out the substring between begin and end(excluding begin and end self). 
+     * Return true if target found, false for timeout.
+     */
     bool recvFindAndFilter(String target, String begin, String end, String &data, uint32_t timeout = 1000);
     
+    /*
+     * Receive a package from uart. 
+     *
+     * @param buffer - the buffer storing data. 
+     * @param buffer_size - guess what!
+     * @param data_len - the length of data actually received(maybe more than buffer_size, the remained data will be abandoned).
+     * @param timeout - the duration waitting data comming.
+     * @param coming_mux_id - in single connection mode, should be NULL and not NULL in multiple. 
+     */
+    uint32_t recvPkg(uint8_t *buffer, uint8_t buffer_size, uint32_t *data_len, uint32_t timeout, uint8_t *coming_mux_id);
+    
+    
     bool eAT(void);
     bool eATRST(void);
     bool eATGMR(String &version);
@@ -359,13 +391,13 @@
     bool eATCIPSTATUS(String &list);
     bool sATCIPSTARTSingle(String type, String addr, uint32_t port);
     bool sATCIPSTARTMultiple(uint8_t mux_id, String type, String addr, uint32_t port);
-    bool sATCIPSENDSingle(uint8_t *buffer, uint32_t len);
-    bool sATCIPSENDMultiple(uint8_t mux_id, uint8_t *buffer, uint32_t len);
+    bool sATCIPSENDSingle(const uint8_t *buffer, uint32_t len);
+    bool sATCIPSENDMultiple(uint8_t mux_id, const uint8_t *buffer, uint32_t len);
     bool sATCIPCLOSEMulitple(uint8_t mux_id);
     bool eATCIPCLOSESingle(void);
     bool eATCIFSR(String &list);
     bool sATCIPMUX(uint8_t mode);
-    bool sATCIPSERVER(uint8_t mode, uint32_t port);
+    bool sATCIPSERVER(uint8_t mode, uint32_t port = 333);
     bool sATCIPSTO(uint32_t timeout);
     
     /*