Skip to content

Wifi mode AP pings only few seconds #2971

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

Closed
psykokwak-com opened this issue Jul 8, 2019 · 7 comments
Closed

Wifi mode AP pings only few seconds #2971

psykokwak-com opened this issue Jul 8, 2019 · 7 comments
Labels
Status: Stale Issue is stale stage (outdated/stuck)

Comments

@psykokwak-com
Copy link

psykokwak-com commented Jul 8, 2019

Hi all,
I simply use the AP WiFi exemple.
I start a ping on 192.168.4.1 then I connect to the ESP32. The WiFi connection is OK and I receive my pings... But only the first 3 or 4. Then after the ping stops until y disconnect then I reconnect.
The ping test is only for test. I have no connectivity at all (the embedded webserver does not respond).
I tried with my smartphone too. Same.

I Use the latest Arduino version (1.0.2).

No problem in STA mode.

fuck

@psykokwak-com
Copy link
Author

Considering this code :

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiAP.h>
#include <WebServer.h>

WebServer server(80);

void setup() {
  Serial.begin(115200);
  Serial.println();
  Serial.println("Configuring access point...");

  WiFi.softAP("MyAP", "");
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);

  server.on("/", []() {
    server.send(200, "text/plain", "OK");
  });

  server.begin();
}

void loop() {
  // ping 192.168.4.1 from my laptop works until I uncomment this
  // line then I try to reach http://192.168.4.1/
  // Then the ping command stops.
  // server.handleClient();
}

With a fresh install, and a "erase_flash" command on the ESP32.
As soon as I try to connect to the webserver using my browser.

Configuring access point...
I (31) wifi: wifi driver task: 3ffb5700, prio:23, stack:3584, core=0
I (71) wifi: wifi firmware version: 6d404d4
I (71) wifi: config NVS flash: disabled
I (74) wifi: config nano formating: disabled
I (79) wifi: Init dynamic tx buffer num: 32
I (82) wifi: Init data frame dynamic rx buffer num: 10
I (87) wifi: Init management frame dynamic rx buffer num: 10
I (93) wifi: Init static rx buffer size: 1600
I (97) wifi: Init static rx buffer num: 8
I (100) wifi: Init dynamic rx buffer num: 10
I (163) wifi: mode : softAP (30:ae:a4:cc:4c:5d)
I (164) wifi: Init max length of beacon: 752/752
I (164) wifi: Init max length of beacon: 752/752
[D][WiFiGeneric.cpp:336] _eventCallback(): Event: 0 - WIFI_READY
[D][WiFiGeneric.cpp:336] _eventCallback(): Event: 13 - AP_START
AP IP address: [D][WiFiGeneric.cpp:336] _eventCallback(): Event: 13 - AP_START
[D][WiFiGeneric.cpp:336] _eventCallback(): Event: 13 - AP_START
1
I (74080) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1
I (74080) wifi: station: 44:1c:a8:e3:26:ef join, AID=1, bgn, 20
[D][WiFiGeneric.cpp:336] _eventCallback(): Event: 15 - AP_STACONNECTED
[D][WiFiGeneric.cpp:336] _eventCallback(): Event: 17 - AP_STAIPASSIGNED
[D][WiFiGeneric.cpp:336] _eventCallback(): Event: 17 - AP_STAIPASSIGNED

Is there something I doing wrong ?

@lbernstone
Copy link
Contributor

Put a delay in your loop. 50ms should give the system some time to do other tasks.

@psykokwak-com
Copy link
Author

Nothing change!

@lbernstone
Copy link
Contributor

See if the sdkconfig.h changes in b0d8d4d help. You can copy the sdkconfig.h into your sketch folder and edit it there.

@psykokwak-com
Copy link
Author

psykokwak-com commented Jul 26, 2019

Are you sure that if I put the sdkconfig.h file into my arduino sketch folder, the arduino toolchain will use it to rebuild the binary ?

Edit 1 : Ok, I replaced the file directly in :

C:\Users<username>\AppData\Local\arduino15\packages\esp32\hardware\esp32\1.0.2\tools\sdk\include\config

Seems better : Now it works on my previous minimal test case but not on my real case.

Edit 2 : Using the @me-no-dev Async-Web-Server, it stills freeze with the two sdkconfig.h

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiAP.h>
#include <AsyncTCP.h>
#include <ESPAsyncWebServer.h>

AsyncWebServer server(80);

void setup() {
  Serial.begin(115200);
  Serial.println();

  WiFi.softAP("MyAP", "");
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);

  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
    request->send(200, "text/plain", "Hello, world");
  });

  server.begin();
}

void loop() {
}

Edit 3 : Using the mongoose webserver library, it works well with the new sdkconfig.h but not with the original one

#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiAP.h>
#include "mongoose.h"

static void ev_handler(struct mg_connection *nc, int ev, void *p) {
  if (ev == MG_EV_HTTP_REQUEST) {
    // Send Build date
    mg_send_head(nc, 200, -1, "Content-Type: application/json");

    mg_printf_http_chunk(nc, "{\"hwver\":%d,\"date\":\"%s\",\"time\":\"%s\"}", 1, __DATE__, __TIME__);
    mg_send_http_chunk(nc, "", 0); // Send empty chunk, the end of response

    nc->flags |= MG_F_SEND_AND_CLOSE;
  }
}
static const char *s_http_port = "80";
void setup() {
  Serial.begin(115200);
  Serial.println();

  WiFi.softAP("MyAP", "");
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);

  struct mg_mgr mgr;
  struct mg_connection *nc;

  mg_mgr_init(&mgr, NULL);
  printf("Starting web server on port %s\n", s_http_port);
  nc = mg_bind(&mgr, s_http_port, ev_handler);
  if (nc == NULL) {
    printf("Failed to create listener\n");
    return ;
  }

  // Set up HTTP server parameters
  mg_set_protocol_http_websocket(nc);

  for (;;) {
    mg_mgr_poll(&mgr, 1000);
  }
  mg_mgr_free(&mgr);
}

void loop() {
}

Edit 4 : Ok, after updating AsyncTCP and AsyncWebServer from github, it works using the latest sdkconfig.h

@stale
Copy link

stale bot commented Sep 24, 2019

[STALE_SET] This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale Issue is stale stage (outdated/stuck) label Sep 24, 2019
@stale
Copy link

stale bot commented Oct 8, 2019

[STALE_DEL] This stale issue has been automatically closed. Thank you for your contributions.

@stale stale bot closed this as completed Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Stale Issue is stale stage (outdated/stuck)
Projects
None yet
Development

No branches or pull requests

2 participants