Author Topic: Wifi starts but can't talk to custom server  (Read 3161 times)

kygix

  • Newbie
  • *
  • Posts: 8
Wifi starts but can't talk to custom server
« on: March 06, 2014, 09:49:24 pm »
Hello,

I've gotten past my wifi-hang-on-start issues and have hit a new (hopefully final) wall before I can get into my custom development. I'm using a USB cable, external power supply, the standard Arduino IDE, and the code below. My output window looks like this:

Quote
Enter any key to begin
Starting
wifi inited
Connected to wifi!
Server running at: 192.168.1.85
looped 500
[etc]

Note that it seems to start correctly and tells me that the main loop is running (via the "looped 500" message). But also note that it says the server is running at the IP without the specified port. Connecting to that IP works but it's the built-in wifi server, not my custom response. Further, trying to go to 192.168.1.85:8080 gives me a "could not connect" message in Chrome, indicating there is nothing there. I don't get a response from my regular network or if I get onto the DigiX's network and try from there. Both allow me to access the admin screens but not my custom server.

There has got to be a simple answer for this. Any help?

Thanks.

I've tried this code http://digistump.com/board/index.php/topic,1231.msg5459.html which is pretty much exactly what I want. I had to change the wifi.begin to 115200 from 9600, but the rest of the code as-is.
My "Other Setting" screen looks like this: http://i.imgur.com/uiEuVc5.png

Code: [Select]
#include <DigiFi.h>
DigiFi wifi;

void setup()
{
  Serial.begin(9600);

  //DigiX trick - since we are on serial over USB wait for character to be entered in serial terminal
  while(!Serial.available()){
    Serial.println("Enter any key to begin");
    delay(1000);
  }

  Serial.println("Starting");
  wifi.begin(115200);
  Serial.println("wifi inited");

  while (wifi.ready() != 1)
  {
    Serial.println("Error connecting to network");
    delay(15000);
  } 

  Serial.println("Connected to wifi!");
  Serial.print("Server running at: ");
  String address = wifi.server(8080);//sets up server and returns IP
  Serial.println(address);

//  wifi.close();
}

int loopCount = 0;
void loop()
{

  if ( wifi.serverRequest()){
      Serial.print("Request for: ");
     Serial.println(wifi.serverRequestPath());
     if(wifi.serverRequestPath()!="/")
       wifi.serverResponse("404 Not Found",404);
      else
       wifi.serverResponse("<html><body><h1>This is a test</h1></body></html>"); //defaults to 200
  }

  loopCount++;
  if (loopCount > 500) {
    loopCount = 0;
    Serial.println("looped 500");
  }
 
  delay(10); 
}
« Last Edit: March 06, 2014, 10:05:46 pm by kygix »

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Wifi starts but can't talk to custom server
« Reply #1 on: March 07, 2014, 02:27:53 pm »
Can you try setting the module via web interface to 9600 and changing your wifi begin statement to that as well?

kygix

  • Newbie
  • *
  • Posts: 8
Re: Wifi starts but can't talk to custom server
« Reply #2 on: March 07, 2014, 09:32:13 pm »
That worked! Whew. Thank you!