- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear developers,
I try to use Intel Edison as a server to show a webpage, here are my codes:
# include
int status = WL_IDLE_STATUS; //to save the connection conditon
WiFiServer server(8080); //define a server object,port 8080
void setup() {
Serial.begin(9600);
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to Network named: ");
Serial.println("FAST_1001");
status = WiFi.begin("FAST_1001", "guanlele");
delay(10000); //connect every 10 secconds
}
Serial.print("SSID: ");
Serial.println(WiFi.SSID());
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
server.begin(); //start and listen to 8080
}
void loop() {
WiFiClient client = server.available(); //listen if a client ask for service
if(client)
{
Serial.println("new Client");
String currentLine = ""; //to store the asked information
while (client.connected()){
if (client.available())
{
char c = client.read();
Serial.write(c);
if(c == '\n'){
if(currentLine.length() == 0){
server.println("");
server.println("");
server.println("Intel Edison");
server.println("");
server.println("");
server.println("HTML TEST");
server.println("Edison");
server.println("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1492625839609&di=eebffbc30e08cf6bc51bbc4cc83eee22&imgtype=0&src=http://d.ifengimg.com/mw604/y3.ifengimg.com/ifengimcp/pic/20151112/fc1cee98b0359d30e720_size220_w440_h409.jpg\"/>");
server.println("");
server.println("");
server.println(); //to end the response
break;
}
else {
currentLine = "";
}
}
else if ( c != '\r') {
currentLine += c;
}
}
}
client.stop();
Serial.println("client disconnected");
}
}
After compling my codes, Serial shows that the ip address distributed to my Intel Edison is 192.168.1.102, but after I entered "192.168.1.102:8080" to my IE url, it did not show the webpage I designed but jumped directly to Being telling me that the address could not be found.
Could you please tell me what I can do to show my webpage?
Regards,
Guan Guan
- Tags:
- Intel® Makers
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
From the reference for WiFiServer.available: (which is https://www.arduino.cc/en/Reference/WiFiServerAvailable here)
"if no Client has data available for reading, this object will evaluate to false in an if-statement"
Therefore I think you need to do the server.available() inside a loop, so that it will keep looping until a client (web browser) connects.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
Thank you so much for your reply!
I have already include server.avaliable() inside a loop by writing
void loop() {
WiFiClient client = server.available(); //listen if a client ask for service
//other codes
}
Could you please tell me is there anything wrong with these part of codes?
Regards,
Guan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Guan,
I was wondering if you still need assistance in this case. Could you please share the current state of your project, and tell me if you are using the latest firmware version?
Do you experience the same issue with the default WiFiWebServer example from the Arduino IDE?
If you have any other question or update, don't hesitate to contact us.
Regards,
Andres V.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page