Browse Source

remove powerbank ping

lightsleep
Hendrik Langer 7 years ago
parent
commit
fd68f88a55
  1. 25
      src/main.cpp

25
src/main.cpp

@ -27,8 +27,6 @@ const char* server = "ingress.opensensemap.org";
//const char* password = ""; //const char* password = "";
constexpr unsigned int postingInterval = 60000; //Uploadintervall in Millisekunden constexpr unsigned int postingInterval = 60000; //Uploadintervall in Millisekunden
constexpr unsigned int powerbankInterval = 10000/2;
constexpr unsigned int powerbankInterval_max = 10000;
constexpr unsigned int dhcp_interval = 60*60*1000; constexpr unsigned int dhcp_interval = 60*60*1000;
//senseBox ID //senseBox ID
@ -233,14 +231,13 @@ void ICACHE_FLASH_ATTR sendValues() {
WiFi.begin(ssid, password); WiFi.begin(ssid, password);
int tries = 0; int tries = 0;
constexpr unsigned int retry_delay = 500; constexpr unsigned int retry_delay = 500;
constexpr unsigned int max_retry_delay = 10000;
while (WiFi.status() != WL_CONNECTED) { while (WiFi.status() != WL_CONNECTED) {
tries++; tries++;
Serial.print("."); Serial.print(".");
if (tries*retry_delay >= powerbankInterval_max) { if (tries*retry_delay >= max_retry_delay) {
Serial.println(" [ERROR]"); Serial.println(" [ERROR]");
Serial.println("Retrying in 10 seconds.."); Serial.println("Rebooting..");
sendESPNOW();
delay(powerbankInterval);
ESP.restart(); ESP.restart();
} }
delay(retry_delay); delay(retry_delay);
@ -253,14 +250,13 @@ void ICACHE_FLASH_ATTR sendValues() {
Serial.println("dhcp"); Serial.println("dhcp");
int tries = 0; int tries = 0;
constexpr unsigned int retry_delay = 500; constexpr unsigned int retry_delay = 500;
constexpr unsigned int max_retry_delay = 12000;
while (wifiMulti.run() != WL_CONNECTED) { while (wifiMulti.run() != WL_CONNECTED) {
tries++; tries++;
Serial.print("."); Serial.print(".");
if (tries*retry_delay >= powerbankInterval_max) { if (tries*retry_delay >= max_retry_delay) {
Serial.println(" [ERROR]"); Serial.println(" [ERROR]");
Serial.println("Retrying in 10 seconds.."); Serial.println("Rebooting..");
sendESPNOW();
delay(powerbankInterval);
ESP.restart(); ESP.restart();
} }
delay(retry_delay); delay(retry_delay);
@ -344,12 +340,5 @@ void setup() {
void loop() { void loop() {
//Serial.println(millis() - last_wifi_activity); //Serial.println(millis() - last_wifi_activity);
sendValues(); sendValues();
delay(postingInterval);
/* keep powerbank happy */
for(int i=0; i<(postingInterval/powerbankInterval); i++) {
delay(powerbankInterval);
//Serial.println(millis() - last_wifi_activity);
sendESPNOW();
}
//delay(powerbankInterval);
} }

Loading…
Cancel
Save