[136] | 1 | @mainpage
|
---|
| 2 |
|
---|
[143] | 3 | # WeeESP8266 updated for Milkcoca SDK
|
---|
[136] | 4 |
|
---|
| 5 | An ESP8266 library for Arduino providing an easy-to-use way to manipulate ESP8266.
|
---|
[143] | 6 | Updated to support Milkcoca SDK<>, M0 and TOPPERS/R2CA.
|
---|
[136] | 7 |
|
---|
| 8 | # Source
|
---|
[143] | 9 | Source can be download at <>.
|
---|
| 10 | Original source can be download at <https://github.com/itead/ITEADLIB_Arduino_WeeESP8266>.
|
---|
[136] | 11 |
|
---|
| 12 | You can clone it by:
|
---|
| 13 |
|
---|
| 14 | git clone https://github.com/itead/ITEADLIB_Arduino_WeeESP8266.git
|
---|
| 15 |
|
---|
| 16 | # Documentation
|
---|
| 17 |
|
---|
| 18 | Online API documentation can be reached at <http://docs.iteadstudio.com/ITEADLIB_Arduino_WeeESP8266/index.html>.
|
---|
| 19 |
|
---|
| 20 | Offline API documentation can be found under directory
|
---|
| 21 | [doc](https://github.com/itead/ITEADLIB_Arduino_WeeESP8266/tree/master/doc).
|
---|
| 22 |
|
---|
| 23 | # How to get started
|
---|
| 24 |
|
---|
| 25 | On the home page of API documentation, the tabs of Examples, Classes and Modules
|
---|
| 26 | will be useful for Arduino lovers.
|
---|
| 27 |
|
---|
| 28 | # API List
|
---|
| 29 |
|
---|
| 30 | bool kick (void) : Verify ESP8266 whether live or not.
|
---|
| 31 |
|
---|
| 32 | bool restart (void) : Restart ESP8266 by "AT+RST".
|
---|
| 33 |
|
---|
| 34 | String getVersion (void) : Get the version of AT Command Set.
|
---|
| 35 |
|
---|
| 36 | bool setOprToStation (void) : Set operation mode to staion.
|
---|
| 37 |
|
---|
| 38 | bool setOprToSoftAP (void) : Set operation mode to softap.
|
---|
| 39 |
|
---|
| 40 | bool setOprToStationSoftAP (void) : Set operation mode to station + softap.
|
---|
| 41 |
|
---|
| 42 | String getAPList (void) : Search available AP list and return it.
|
---|
| 43 |
|
---|
| 44 | bool joinAP (String ssid, String pwd) : Join in AP.
|
---|
| 45 |
|
---|
| 46 | bool leaveAP (void) : Leave AP joined before.
|
---|
| 47 |
|
---|
| 48 | bool setSoftAPParam (String ssid, String pwd, uint8_t chl=7, uint8_t ecn=4) : Set SoftAP parameters.
|
---|
| 49 |
|
---|
| 50 | String getJoinedDeviceIP (void) : Get the IP list of devices connected to SoftAP.
|
---|
| 51 |
|
---|
| 52 | String getIPStatus (void) : Get the current status of connection(UDP and TCP).
|
---|
| 53 |
|
---|
| 54 | String getLocalIP (void) : Get the IP address of ESP8266.
|
---|
| 55 |
|
---|
| 56 | bool enableMUX (void) : Enable IP MUX(multiple connection mode).
|
---|
| 57 |
|
---|
| 58 | bool disableMUX (void) : Disable IP MUX(single connection mode).
|
---|
| 59 |
|
---|
| 60 | bool createTCP (String addr, uint32_t port) : Create TCP connection in single mode.
|
---|
| 61 |
|
---|
| 62 | bool releaseTCP (void) : Release TCP connection in single mode.
|
---|
| 63 |
|
---|
| 64 | bool registerUDP (String addr, uint32_t port) : Register UDP port number in single mode.
|
---|
| 65 |
|
---|
| 66 | bool unregisterUDP (void) : Unregister UDP port number in single mode.
|
---|
| 67 |
|
---|
| 68 | bool createTCP (uint8_t mux_id, String addr, uint32_t port) : Create TCP connection in multiple mode.
|
---|
| 69 |
|
---|
| 70 | bool releaseTCP (uint8_t mux_id) : Release TCP connection in multiple mode.
|
---|
| 71 |
|
---|
| 72 | bool registerUDP (uint8_t mux_id, String addr, uint32_t port) : Register UDP port number in multiple mode.
|
---|
| 73 |
|
---|
| 74 | bool unregisterUDP (uint8_t mux_id) : Unregister UDP port number in multiple mode.
|
---|
| 75 |
|
---|
| 76 | bool setTCPServerTimeout (uint32_t timeout=180) : Set the timeout of TCP Server.
|
---|
| 77 |
|
---|
| 78 | bool startServer (uint32_t port=333) ï¼ Start Server(Only in multiple mode).
|
---|
| 79 |
|
---|
| 80 | bool stopServer (void) : Stop Server(Only in multiple mode).
|
---|
| 81 |
|
---|
| 82 | bool startTCPServer (uint32_t port=333) : Start TCP Server(Only in multiple mode).
|
---|
| 83 |
|
---|
| 84 | bool stopTCPServer (void) : Stop TCP Server(Only in multiple mode).
|
---|
| 85 |
|
---|
| 86 | bool send (const uint8_t *buffer, uint32_t len) : Send data based on TCP or UDP builded already in single mode.
|
---|
| 87 |
|
---|
| 88 | bool send (uint8_t mux_id, const uint8_t *buffer, uint32_t len) : Send data based on one of TCP or UDP builded already in multiple mode.
|
---|
| 89 |
|
---|
| 90 | uint32_t recv (uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000) : Receive data from TCP or UDP builded already in single mode.
|
---|
| 91 |
|
---|
| 92 | uint32_t recv (uint8_t mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout=1000) : Receive data from one of TCP or UDP builded already in multiple mode.
|
---|
| 93 |
|
---|
| 94 | uint32_t recv (uint8_t *coming_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.
|
---|
| 95 |
|
---|
[143] | 96 | # Added API List
|
---|
[136] | 97 |
|
---|
[143] | 98 | void begin(SoftwareSerial &uart, uint32_t baud = 115200); : Begin ESP8266.
|
---|
| 99 |
|
---|
[178] | 100 | void begin(HardwareSerial &uart, uint32_t baud = 115200); : Begin ESP8266.
|
---|
[143] | 101 |
|
---|
| 102 | bool send(String &str); : Send data based on TCP or UDP builded already in single mode.
|
---|
| 103 |
|
---|
| 104 | bool send(uint8_t mux_id, String &str); : Send data based on one of TCP or UDP builded already in multiple mode.
|
---|
| 105 |
|
---|
[178] | 106 | int isdataAvailable(uint8_t mux_id); : Check data is available in multiple mode.
|
---|
[143] | 107 |
|
---|
[178] | 108 | int isdataAvailable(void); : Check data is available in single mode.
|
---|
| 109 |
|
---|
| 110 | int isConnected(void); : Check connection is opend in single mode.
|
---|
| 111 |
|
---|
| 112 | int isConnected(uint8_t mux_id); : Check specific connection is opend in multiple mode.
|
---|
| 113 |
|
---|
| 114 | int getMuxCStatus(uint8_t *mux_id_ptn); : Get connection link status.
|
---|
| 115 |
|
---|
[136] | 116 | # Mainboard Requires
|
---|
| 117 |
|
---|
| 118 | - RAM: not less than 2KBytes
|
---|
| 119 | - Serial: one serial (HardwareSerial or SoftwareSerial) at least
|
---|
| 120 |
|
---|
| 121 | # Suppported Mainboards
|
---|
| 122 |
|
---|
| 123 | - Arduino UNO and its derivatives
|
---|
| 124 | - Arduino MEGA and its derivatives
|
---|
[143] | 125 | - Arduino M0 and its derivatives
|
---|
[136] | 126 | - [Iteaduino UNO](http://imall.iteadstudio.com/im130312001.html)
|
---|
| 127 | - [WBoard Pro](http://imall.iteadstudio.com/im141125005.html)
|
---|
| 128 |
|
---|
| 129 | # Using SoftwareSerial
|
---|
| 130 |
|
---|
| 131 | If you want to use SoftwareSerial to communicate with ESP8266, you need to modify
|
---|
| 132 | the line in file `ESP8266.h`:
|
---|
| 133 |
|
---|
| 134 | //#define ESP8266_USE_SOFTWARE_SERIAL
|
---|
| 135 |
|
---|
| 136 | After modification, it should be:
|
---|
| 137 |
|
---|
| 138 | #define ESP8266_USE_SOFTWARE_SERIAL
|
---|
| 139 |
|
---|
| 140 |
|
---|
| 141 | # Hardware Connection
|
---|
| 142 |
|
---|
| 143 | WeeESP8266 library only needs an uart for hardware connection. All communications
|
---|
| 144 | are done via uart. In each example, you must specify the uart used by mainboard
|
---|
| 145 | to communicate with ESP8266 flashed AT firmware.
|
---|
| 146 |
|
---|
| 147 | ## MEGA and WBoard Pro
|
---|
| 148 |
|
---|
| 149 | For MEGA and WBoard Pro, `Serial1` will be used if you create an object (named wifi)
|
---|
| 150 | of class ESP8266 in your code like this:
|
---|
| 151 |
|
---|
| 152 | #include "ESP8266.h"
|
---|
| 153 | ESP8266 wifi(Serial1);
|
---|
| 154 |
|
---|
| 155 | The connection should be like these:
|
---|
| 156 |
|
---|
| 157 | ESP8266_TX->RX1(D19)
|
---|
| 158 | ESP8266_RX->TX1(D18)
|
---|
| 159 | ESP8266_CH_PD->3.3V
|
---|
| 160 | ESP8266_VCC->3.3V
|
---|
| 161 | ESP8266_GND->GND
|
---|
| 162 |
|
---|
| 163 | ## UNO
|
---|
| 164 |
|
---|
| 165 | To use SoftwareSerial, `mySerial` will be used if you create an object (named wifi)
|
---|
| 166 | of class ESP8266 in your code like this:
|
---|
| 167 |
|
---|
| 168 | #include "ESP8266.h"
|
---|
| 169 | #include <SoftwareSerial.h>
|
---|
| 170 |
|
---|
| 171 | SoftwareSerial mySerial(3, 2); /* RX:D3, TX:D2 */
|
---|
| 172 | ESP8266 wifi(mySerial);
|
---|
| 173 |
|
---|
| 174 | The connection should be like these:
|
---|
| 175 |
|
---|
| 176 | ESP8266_TX->RX(D3)
|
---|
| 177 | ESP8266_RX->TX(D2)
|
---|
| 178 | ESP8266_CH_PD->3.3V
|
---|
| 179 | ESP8266_VCC->3.3V
|
---|
| 180 | ESP8266_GND->GND
|
---|
| 181 |
|
---|
| 182 | # Attention
|
---|
| 183 |
|
---|
| 184 | The size of data from ESP8266 is too big for arduino sometimes, so the library can't
|
---|
| 185 | receive the whole buffer because the size of the hardware serial buffer which is
|
---|
| 186 | defined in HardwareSerial.h is too small.
|
---|
| 187 |
|
---|
[143] | 188 | UNO or MEGA or WBoard Pro
|
---|
[136] | 189 | Open the file from `\arduino\hardware\arduino\avr\cores\arduino\HardwareSerial.h`.
|
---|
| 190 |
|
---|
[143] | 191 | M0
|
---|
| 192 | Open the file from `\arduino\hardware\arduino\avr\cores\arduino\RingBuffer.h`.
|
---|
| 193 | See the follow line in the file.
|
---|
| 194 |
|
---|
[136] | 195 | #define SERIAL_BUFFER_SIZE 64
|
---|
| 196 |
|
---|
| 197 | The default size of the buffer is 64. Change it into a bigger number, like 256 or more.
|
---|
| 198 |
|
---|
| 199 |
|
---|
| 200 | -------------------------------------------------------------------------------
|
---|
| 201 |
|
---|
| 202 | # The End!
|
---|
| 203 |
|
---|
| 204 | -------------------------------------------------------------------------------
|
---|