Provide an easy-to-use way to manipulate ESP8266.
Fork of WeeESP8266 by
Diff: ESP8266.h
- Revision:
- 4:c8e2381d34d2
- Parent:
- 3:9f745022331a
- Child:
- 5:5fa655d7212c
--- a/ESP8266.h Fri Feb 06 04:01:50 2015 +0000 +++ b/ESP8266.h Fri Feb 06 04:50:49 2015 +0000 @@ -170,9 +170,6 @@ */ bool disableMUX(void); - /* - * Single connection mode methods - */ /** * Create TCP connection in single mode. @@ -209,31 +206,7 @@ * @retval false - failure. */ bool unregisterUDP(void); - - /** - * Send data based on TCP or UDP builded already in single mode. - * - * @param buffer - the buffer of data to send. - * @param len - the length of data to send. - * @retval true - success. - * @retval false - failure. - */ - bool send(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 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); - - /* - * Multiple connection mode methods - */ - + /** * Create TCP connection in multiple mode. * @@ -273,8 +246,53 @@ * @retval false - failure. */ bool unregisterUDP(uint8_t mux_id); + + + /** + * Set the timeout of TCP Server. + * + * @param timeout - the duration for timeout by second(0 ~ 28800, default:180). + * @retval true - success. + * @retval false - failure. + */ + bool setTCPServerTimeout(uint32_t timeout = 180); /** + * Start TCP Server(Only in multiple mode). + * + * After started, user should call method: getIPStatus to know the status of TCP connections. + * The methods of receiving data can be called for user's any purpose. After communication, + * release the TCP connection is needed by calling method: releaseTCP with mux_id. + * + * @param port - the port number to listen(default: 333). + * @retval true - success. + * @retval false - failure. + * + * @see String getIPStatus(void); + * @see uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t len, uint32_t timeout); + * @see bool releaseTCP(uint8_t mux_id); + */ + bool startTCPServer(uint32_t port = 333); + + /** + * Stop TCP Server(Only in multiple mode). + * + * @retval true - success. + * @retval false - failure. + */ + bool stopTCPServer(void); + + /** + * Send data based on TCP or UDP builded already in single mode. + * + * @param buffer - the buffer of data to send. + * @param len - the length of data to send. + * @retval true - success. + * @retval false - failure. + */ + bool send(const uint8_t *buffer, uint32_t len); + + /** * Send data based on one of TCP or UDP builded already in multiple mode. * * @param mux_id - the identifier of this TCP(available value: 0 - 4). @@ -286,6 +304,16 @@ bool send(uint8_t mux_id, const char *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 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); + + /** * 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). @@ -309,46 +337,7 @@ * @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); - - /* - * Server - */ - - /** - * Set the timeout of TCP Server. - * - * @param timeout - the duration for timeout by second(0 ~ 28800, default:180). - * @retval true - success. - * @retval false - failure. - */ - bool setTCPServerTimeout(uint32_t timeout = 180); - - /** - * Start TCP Server(Only in multiple mode). - * - * After started, user should call method: getIPStatus to know the status of TCP connections. - * The methods of receiving data can be called for user's any purpose. After communication, - * release the TCP connection is needed by calling method: releaseTCP with mux_id. - * - * @param port - the port number to listen(default: 333). - * @retval true - success. - * @retval false - failure. - * - * @see String getIPStatus(void); - * @see uint32_t recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t len, uint32_t timeout); - * @see bool releaseTCP(uint8_t mux_id); - */ - bool startTCPServer(uint32_t port = 333); - - - /** - * Stop TCP Server(Only in multiple mode). - * - * @retval true - success. - * @retval false - failure. - */ - bool stopTCPServer(void); - + private: ArduinoSerial *m_puart; /* The UART to communicate with ESP8266 */