Skip to content

Instantly share code, notes, and snippets.

@pauletienney
Created December 30, 2015 20:57
Show Gist options
  • Save pauletienney/5f81bddc4d1610badf43 to your computer and use it in GitHub Desktop.
Save pauletienney/5f81bddc4d1610badf43 to your computer and use it in GitHub Desktop.
Try to make Arduino Uno + xbee shield 1.1 + wee wifi serial by Itead work together
#include <doxygen.h>
#include <ESP8266.h>
#define SSID "ssid"
#define PASSWORD "pass"
#define HOST_NAME "www.baidu.com"
#define HOST_PORT (80)
ESP8266 wifi(Serial);
void setup()
{
Serial.begin(9600);
Serial.print("setup begin\r\n");
Serial.print("FW Version: ");
Serial.println(wifi.getVersion().c_str());
if (wifi.setOprToStation()) {
Serial.print("to station ok\r\n");
} else {
Serial.print("to station err\r\n");
}
if (wifi.joinAP(SSID, PASSWORD)) {
Serial.print("Join AP success\r\n");
Serial.print("IP: ");
Serial.println(wifi.getLocalIP().c_str());
} else {
Serial.print("Join AP failure\r\n");
}
if (wifi.disableMUX()) {
Serial.print("single ok\r\n");
} else {
Serial.print("single err\r\n");
}
Serial.print("setup end\r\n");
}
void loop(void)
{
uint8_t buffer[1024] = {0};
if (wifi.createTCP(HOST_NAME, HOST_PORT)) {
Serial.print("create tcp ok\r\n");
} else {
Serial.print("create tcp err\r\n");
}
char *hello = "GET / HTTP/1.1\r\nHost: www.baidu.com\r\nConnection: close\r\n\r\n";
wifi.send((const uint8_t*)hello, strlen(hello));
uint32_t len = wifi.recv(buffer, sizeof(buffer), 10000);
if (len > 0) {
Serial.print("Received:[");
for(uint32_t i = 0; i < len; i++) {
Serial.print((char)buffer[i]);
}
Serial.print("]\r\n");
}
if (wifi.releaseTCP()) {
Serial.print("release tcp ok\r\n");
} else {
Serial.print("release tcp err\r\n");
}
while(1);
}
@pauletienney
Copy link
Author

I get this messages:

Join AP success
IP: AT+CIFSR
wrong syntax

ERROR
IP: AT+CIFSR

192.168.1.35
AT+CIPMUX=0
single ok
setup end
AT+CIPSTART="","",80
create tcp err
AT+CIPSEND=58
AT+CIPCLOSE
release tcp err

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment