Code Monkey home page Code Monkey logo

Comments (4)

bill-orange avatar bill-orange commented on July 26, 2024

Well that almost worked. I had about 15 hours of operation without a problem. That's a record.

I should note that the symptoms changed a bit. When the Webserver became unresponsive, Ping continued to work . After an hour or so it recovered on its own for no clear reason.

So: I depreciated the PING solution and added in this proposed solution.

me-no-dev/ESPAsyncWebServer#54 (comment)

Presently testing. We will see. It is doing something the Webserver is not very snappy as before.

EDIT ** overnight it became unresponsive again:(

from fsbrowserng.

bill-orange avatar bill-orange commented on July 26, 2024

This is clearly a work-around, but it seems to resolve 'unresponsive' behavior. Then code it not meant to run alone. Merge it into your existing sketch that has 'unresponsive' issues.

#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
#include <ESP8266Ping.h>
#define FPM_SLEEP_MAX_TIME 0xFFFFFFF

unsigned long pingTest = 1000UL * 60UL * 30UL; // Test connection every 30 minuites
unsigned long prevMillis = 0; // used for temp timing counter

extern "C" {
#include "user_interface.h" // Required for wifi_station_connect() to work
}

extern "C" {
extern char *netif_list;
uint8_t etharp_request(char *, char *); // required for forceArp to work
}

void forceARP() {
char *netif = netif_list;

while (netif)
{
etharp_request((netif), (netif + 4));
netif = *((char **) netif);
}
}

void setup() {
wifi_set_sleep_type(NONE_SLEEP_T); // May help stability
// add your code to connect to the internet and so forth

}

void loop() {
// ----------------------Connectivity testing within Loop() -----------
HTTPClient http_1; // used in ping test
unsigned long currentMillis = millis(); // timer for data
unsigned long pingMillis = millis(); // timer for data

if ((pingMillis - prevMillis) > pingTest) {
prevMillis = pingMillis;
WiFiOff();
Serial.print("WiFi - OFF ");
delay (20);
WiFiOn();
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("WiFi - ON");
if (Ping.ping(WiFi.gatewayIP())) {
Serial.print("ping gateway Success!! Ping Time (mS) = "); Serial.println(Ping.averageTime());
forceARP();
} else {
Serial.println("Failed ping to gateway!");
ESP.restart();
}
if (Ping.ping(WiFi.localIP()), 1) {
Serial.print("ping localIP Success!! Ping Time (mS) = "); Serial.println(Ping.averageTime());
forceARP();
} else {
Serial.println("ping Error :(");
ESP.restart();

}
http_1.begin("http://api.wunderground.com"); // or some other web site you like
int httpCode = http_1.GET();
if (httpCode > 0) {
Serial.println ("connection test okay!");
}
else {
Serial.print("connection test failed! code: ");
Serial.println(httpCode);
ESP.restart();
}
http_1.end();
}
// -------------------- end testing ---------------------------
// rest of your loop goes here
}

//----------------------------------- WiFi On OFF ----------------------------------

void WiFiOn() {

wifi_fpm_do_wakeup();
wifi_fpm_close();

//Serial.println("Reconnecting");
wifi_set_opmode(STATION_MODE);
wifi_station_connect();
}

void WiFiOff() {

//Serial.println("diconnecting client and wifi");
//client.disconnect();
wifi_station_disconnect();
wifi_set_opmode(NULL_MODE);
wifi_set_sleep_type(MODEM_SLEEP_T);
wifi_fpm_open();
wifi_fpm_do_sleep(FPM_SLEEP_MAX_TIME);

}

from fsbrowserng.

species5618 avatar species5618 commented on July 26, 2024

Sorry short in time at the moment
May be able to support you in this over the holidays

My temp sensor based on this seems to reboot every few days
And stops responding to are requests
But web server still works. May be related

from fsbrowserng.

bill-orange avatar bill-orange commented on July 26, 2024

Thanks. Possibly related. Also try, accessing the. server from an iPhone using Safari. After a couple of refreshes it begins to ignore the Safari browser. Here'a a link to my sketch. It plots actual temperature vs Wunderground forecast..

from fsbrowserng.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.