7 Replies Latest reply on Dec 1, 2014 11:08 AM by UST_

    Edison-Arduino: WiFi Inquiries (w/ WiFi Server Example)




      I'm moving on to the next stage of my project and this part seems to be finicky, more so than I expected.

      I'm trying to send data, counts and date through the WiFi Server example code (with slight modification) I got the original example to run just fine. The code I refer to is posted below:

      I hit the if loop, then go to the for loop and print everything no problem, but then that's all that happens. Why doesn't it run through the rest of the code? I can sometimes get it to print on my browser, but then it doesn't refresh. Any insight or guidance would be greatly appreciated.




      if (Minute==2) {                // Minute if loop starts

                minute =0;

                for (int j=0; j<2; j++) {

                Serial.print("Number of Impulses:  ");


                Serial.print("  @   ");





      WiFiClient client = server.available();   // listen for incoming clients                           


        if (client) {                             // if you get a client,

          Serial.println("new client");           // print a message out the serial port

          String currentLine = "";                // make a String to hold incoming data from the client

          while (client.connected()) {            // loop while the client's connected

            if (client.available()) {             // if there's bytes to read from the client,

              char c = client.read();             // read a byte, then

              Serial.write(c);                    // print it out the serial monitor

              if (c == '\n') {                    // if the byte is a newline character



                // if the current line is blank, you got two newline characters in a row.

                // that's the end of the client HTTP request, so send a response:

                if (currentLine.length() == 0) {

                  // HTTP headers always start with a response code (e.g. HTTP/1.1 200 OK)

                  // and a content-type so the client knows what's coming, then a blank line: 

                  client.println("HTTP/1.1 200 OK");




                  // the content of the HTTP response follows the header:


              for (int i=0; i<2; i++) {

                  client.print("Number of Impulses:  ");


                  client.print(" @ ");


                  counter[i] = 0;

                  date [i] = 0;



                  // The HTTP response ends with another blank line:


                  //break out of the while loop:



                else {      // if you got a newline, then clear currentLine:

                  currentLine = "";



              else if (c != '\r') {    // if you got anything else but a carriage return character,

                currentLine += c;      // add it to the end of the currentLine





          // close the connection:


          Serial.println("end of loop - client disconnected");



      }                                                                                     // Minute if loop ends