Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working with Arduino Zero #55

Open
Gius-8 opened this issue Jul 3, 2016 · 7 comments
Open

Not working with Arduino Zero #55

Gius-8 opened this issue Jul 3, 2016 · 7 comments

Comments

@Gius-8
Copy link

Gius-8 commented Jul 3, 2016

I'm trying this library with an Arduino Zero but does not work for me. I tried to solve with the solution #27 but I get this compile error:

EspDrv.cpp:` In static member function 'static int EspDrv::sendCmd(const __FlashStringHelper*, int, ...)':

EspDrv.cpp:1023:2: error: 'va_list' was not declared in this scope
  va_list args;
  ^
EspDrv.cpp:1023:10: error: expected ';' before 'args'

  va_list args;

          ^

EspDrv.cpp:1024:12: error: 'args' was not declared in this scope

  va_start (args, timeout);

            ^

EspDrv.cpp:1024:25: error: 'va_start' was not declared in this scope

  va_start (args, timeout);

                         ^

EspDrv.cpp:1026:14: error: 'va_end' was not declared in this scope

  va_end (args);

              ^

exit status 1

How can I fix the problem?

@diegommarino
Copy link

Please, may you paste your full code?

@Gius-8
Copy link
Author

Gius-8 commented Jul 7, 2016

Hello, this is the code I am using:

#include "WiFiEsp.h"

char ssid[] = "TwimEsp";         // your network SSID (name)
char pass[] = "12345678";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
int reqCount = 0;                // number of requests received

WiFiEspServer server(80);

// use a ring buffer to increase speed and reduce memory allocation
WifiEspRingBuffer buf(8);

void setup()
{
  Serial.begin(115200);   // initialize serial for debugging
  Serial1.begin(9600);    // initialize serial for ESP module
  WiFi.init(&Serial1);    // initialize ESP module

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    while (true); // don't continue
  }

  Serial.print("Attempting to start AP ");
  Serial.println(ssid);

  // uncomment these two lines if you want to set the IP address of the AP
  //IPAddress localIp(192, 168, 111, 111);
  //WiFi.configAP(localIp);

  // start access point
  status = WiFi.beginAP(ssid, 10, pass, ENC_TYPE_WPA2_PSK);

  Serial.println("Access point started");
  printWifiStatus();

  // start the web server on port 80
  server.begin();
  Serial.println("Server started");
}


void loop()
{
  WiFiEspClient 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
    buf.init();                               // initialize the circular buffer
    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
        buf.push(c);                          // push it to the ring buffer

        // you got two newline characters in a row
        // that's the end of the HTTP request, so send a response
        if (buf.endsWith("\r\n\r\n")) {
          sendHttpResponse(client);
          break;
        }
      }
    }

    // give the web browser time to receive the data
    delay(10);

    // close the connection
    client.stop();
    Serial.println("Client disconnected");
  }
}

void sendHttpResponse(WiFiEspClient client)
{
  client.print(
    "HTTP/1.1 200 OK\r\n"
    "Content-Type: text/html\r\n"
    "Connection: close\r\n"  // the connection will be closed after completion of the response
    "Refresh: 20\r\n"        // refresh the page automatically every 20 sec
    "\r\n");
  client.print("<!DOCTYPE HTML>\r\n");
  client.print("<html>\r\n");
  client.print("<h1>Hello World!</h1>\r\n");
  client.print("Requests received: ");
  client.print(++reqCount);
  client.print("<br>\r\n");
  client.print("Analog input A0: ");
  client.print(analogRead(0));
  client.print("<br>\r\n");
  client.print("</html>\r\n");
}

void printWifiStatus()
{
  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print where to go in the browser
  Serial.println();
  Serial.print("To see this page in action, connect to ");
  Serial.print(ssid);
  Serial.print(" and open a browser to http://");
  Serial.println(ip);
  Serial.println();
}

I simply modify the sample "WebServerAP". But to me by the error I wrote above.

@xymopen
Copy link

xymopen commented Oct 9, 2016

Try add #include <cstdarg> to EspDrv.cpp. It passes the compile but I haven't try it with my board.

@lenny1972
Copy link

I'll try soon and let you know.
Thanks for now

2016-10-09 19:44 GMT+02:00 Xu Yiming [email protected]:

Try add #include to EspDrv.cpp. It passes the compile but I
haven't try it on my board.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#55 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMafC38I_ffMQR3xzd4YMahIel8SjKllks5qySgCgaJpZM4JD09j
.

@Gius-8
Copy link
Author

Gius-8 commented Oct 10, 2016

Hello,
I tried the solution of @xymopen. It works perfectly :D .
Thank you so much!!!

@xymopen
Copy link

xymopen commented Oct 10, 2016

About to try it on my Due.
And I find that this fix will make it incompitable with UNO(and possibly other AVR-based boards). To stay compitable add #include <stdarg.h> instead of #include <cstdarg>.

@xymopen
Copy link

xymopen commented Oct 10, 2016

Tested and fine with my Due.

ninjampa added a commit to FTTechBrasil/WiFiEsp that referenced this issue Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants