| API For Arduino developers

- Main Page
- Related Pages
- Classes
- Files
- Examples

- File List
- File Members

test.ino
1
23 #include "ESP8266.h"
24
25 #define SSID "ITEAD"
26 #define PASSWORD "12345678"
27
28 ESP8266 wifi(Serial1,9600);
29
30 void setup(void)
31 {
32 Serial.begin(9600);
33 Serial.print("setup begin\r\n");
34 if(wifi.setUart(9600,2)){
35 Serial.println("set uart is ok ");
36 }
37 else{
38 Serial.println("set uart is error");
39 }
40 Serial.println(wifi.getWifiModeList().c_str());
41 if(wifi.setOprToSoftAP(2,2)){
42 Serial.println("it is STA");
43 }
44 if(wifi.setOprToStation(2,2)){
45 Serial.println("it is AP");
46 }
47 if(wifi.setOprToStationSoftAP(2,2)){
48 Serial.println("it is AP+SoftAP");
49 }
50 Serial.println(wifi.getAPList().c_str());
51 wifi.joinAP(SSID,PASSWORD);
52 Serial.println(wifi.getNowConecAp(1).c_str());
53 if(wifi.leaveAP())
54 {
55 Serial.println("it is leave");
56 }
57 Serial.println(wifi.getNowConecAp(1).c_str());
58 if(wifi.setSoftAPParam("aaa","12345678"))
59 {
60 Serial.println("it is set param ok");
61 }
62 Serial.println(wifi.getSoftAPParam());
63 Serial.println(wifi.getJoinedDeviceIP().c_str());
64 Serial.print("the state of DHCP:");
65 Serial.println(wifi.getDHCP().c_str());
66 if(wifi.setDHCP(2,1)){
67 Serial.println("it is set DHCP OK");
68 }
69 Serial.println(wifi.getDHCP().c_str());
70 if(wifi.setAutoConnect(0)){
71 Serial.println("take off auto connect ok");
72 }
73 Serial.print("get the station mac: ");
74 Serial.println(wifi.getStationMac().c_str());
75 if(wifi.setStationMac("18:fe:35:98:d3:7b")){
76 Serial.println("set station mac is ok ");
77 }
78 else {
79 Serial.println("it is error");
80 }
81 Serial.print("get the station mac: ");
82 Serial.println(wifi.getStationMac().c_str());
83 Serial.print("get the station's ip");
84 Serial.println(wifi.getStationIp().c_str());
85
86 if(wifi.setStationIp("192.168.1.6","192.168.1.1","255.255.255.0")){
87 Serial.println("set station's ip is ok");
88 }
89 else{
90 Serial.println("set station's ip is error");
91 }
92 Serial.print("get the station's ip");
93 Serial.println(wifi.getStationIp().c_str());
94
95 Serial.print("get the ap's ap");
96 Serial.println(wifi.getAPIp().c_str());
97
98 if(wifi.setAPIp("192.168.1.1")){
99 Serial.println("set ap's ip is ok");
100 }
101 else
102 {
103 Serial.println("set ap's is is error");
104 }
105 Serial.print("get the ap's ap");
106 Serial.println(wifi.getAPIp().c_str());
107
108 if(wifi.startSmartConfig(1)){
109 Serial.println("start smartconfig is ok");
110 }
111 else{
112 Serial.println("start smartconfig is error");
113 }
114 if(wifi.stopSmartConfig()){
115 Serial.println("stop smartconfig is ok");
116 }
117 else{
118 Serial.println("stop smartconfig is error");
119 }
120 Serial.print("get the current status of connection:");
121 Serial.println(wifi.getIPStatus().c_str());
122 if(wifi.saveTransLink(1,"192.168.1.18",1006)){
123 Serial.println("save trans link is ok");
124 }
125 else{
126 Serial.println("save trans link is error");
127 }
128 Serial.println("setup end\r\n");
129 }
130
131 void loop(void)
132 {
133 }
134
ESP8266::setAutoConnect
bool setAutoConnect(uint8_t en)
make boot automatically connected.
Definition: ESP8266.cpp:220
ESP8266::getStationIp
String getStationIp(uint8_t pattern=3)
Get the station's IP.
Definition: ESP8266.cpp:237
ESP8266::joinAP
bool joinAP(String ssid, String pwd, uint8_t pattern=3)
Join in AP.
Definition: ESP8266.cpp:178
ESP8266::setSoftAPParam
bool setSoftAPParam(String ssid, String pwd, uint8_t chl=7, uint8_t ecn=4, uint8_t pattern=3)
Set SoftAP parameters.
Definition: ESP8266.cpp:197
ESP8266::getDHCP
String getDHCP(uint8_t pattern=3)
Get the current state of DHCP.
Definition: ESP8266.cpp:209
ESP8266::setOprToSoftAP
bool setOprToSoftAP(uint8_t pattern1=3, uint8_t pattern2=3)
Set operation mode to softap.
Definition: ESP8266.cpp:129
ESP8266::setStationMac
bool setStationMac(String mac, uint8_t pattern=3)
Set the station's MAC address.
Definition: ESP8266.cpp:232
ESP8266::getNowConecAp
String getNowConecAp(uint8_t pattern=3)
Search and returns the current connect AP.
Definition: ESP8266.cpp:163
ESP8266::setStationIp
bool setStationIp(String ip, String gateway, String netmask, uint8_t pattern=3)
Set the station's IP.
Definition: ESP8266.cpp:244
ESP8266::setUart
bool setUart(uint32_t baudrate, uint8_t pattern)
Set up a serial port configuration.
Definition: ESP8266.cpp:96
ESP8266::getWifiModeList
String getWifiModeList(void)
Get the model values list.
Definition: ESP8266.cpp:123
ESP8266::setAPIp
bool setAPIp(String ip, uint8_t pattern=3)
Set the AP IP.
Definition: ESP8266.cpp:256
ESP8266.h
The definition of class ESP8266.
ESP8266::getSoftAPParam
String getSoftAPParam(uint8_t pattern=3)
get SoftAP parameters.
Definition: ESP8266.cpp:188
ESP8266::saveTransLink
bool saveTransLink(uint8_t mode, String ip, uint32_t port)
Save the passthrough links.
Definition: ESP8266.cpp:363
ESP8266::startSmartConfig
bool startSmartConfig(uint8_t type)
start smartconfig.
Definition: ESP8266.cpp:261
ESP8266::setDHCP
bool setDHCP(uint8_t mode, uint8_t en, uint8_t pattern=3)
Set the state of DHCP.
Definition: ESP8266.cpp:215
ESP8266::setOprToStationSoftAP
bool setOprToStationSoftAP(uint8_t pattern1=3, uint8_t pattern2=3)
Set operation mode to station + softap.
Definition: ESP8266.cpp:146
ESP8266::leaveAP
bool leaveAP(void)
Leave AP joined before.
Definition: ESP8266.cpp:183
ESP8266::getAPIp
String getAPIp(uint8_t pattern=3)
Get the AP's IP.
Definition: ESP8266.cpp:249
ESP8266::stopSmartConfig
bool stopSmartConfig(void)
stop smartconfig.
Definition: ESP8266.cpp:266
ESP8266
Provide an easy-to-use way to manipulate ESP8266.
Definition: ESP8266.h:42
ESP8266::getAPList
String getAPList(void)
Search available AP list and return it.
Definition: ESP8266.cpp:171
ESP8266::getStationMac
String getStationMac(uint8_t pattern=3)
Get the station's MAC address.
Definition: ESP8266.cpp:224
ESP8266::getIPStatus
String getIPStatus(void)
Get the current status of connection(UDP and TCP).
Definition: ESP8266.cpp:274
ESP8266::setOprToStation
bool setOprToStation(uint8_t pattern1=3, uint8_t pattern2=3)
Set operation mode to station.
Definition: ESP8266.cpp:107
ESP8266::getJoinedDeviceIP
String getJoinedDeviceIP(void)
Get the IP list of devices connected to SoftAP.
Definition: ESP8266.cpp:202