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 = "";
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;
//senseBox ID
@ -233,14 +231,13 @@ void ICACHE_FLASH_ATTR sendValues() {
WiFi.begin(ssid, password);
int tries = 0;
constexpr unsigned int retry_delay = 500;
constexpr unsigned int max_retry_delay = 10000;
while (WiFi.status() != WL_CONNECTED) {
tries++;
Serial.print(".");
if (tries*retry_delay >= powerbankInterval_max) {
if (tries*retry_delay >= max_retry_delay) {
Serial.println(" [ERROR]");
Serial.println("Retrying in 10 seconds..");
sendESPNOW();
delay(powerbankInterval);
Serial.println("Rebooting..");
ESP.restart();
}
delay(retry_delay);
@ -253,14 +250,13 @@ void ICACHE_FLASH_ATTR sendValues() {
Serial.println("dhcp");
int tries = 0;
constexpr unsigned int retry_delay = 500;
constexpr unsigned int max_retry_delay = 12000;
while (wifiMulti.run() != WL_CONNECTED) {
tries++;
Serial.print(".");
if (tries*retry_delay >= powerbankInterval_max) {
if (tries*retry_delay >= max_retry_delay) {
Serial.println(" [ERROR]");
Serial.println("Retrying in 10 seconds..");
sendESPNOW();
delay(powerbankInterval);
Serial.println("Rebooting..");
ESP.restart();
}
delay(retry_delay);
@ -344,12 +340,5 @@ void setup() {
void loop() {
//Serial.println(millis() - last_wifi_activity);
sendValues();
/* keep powerbank happy */
for(int i=0; i<(postingInterval/powerbankInterval); i++) {
delay(powerbankInterval);
//Serial.println(millis() - last_wifi_activity);
sendESPNOW();
}
//delay(powerbankInterval);
delay(postingInterval);
}

Loading…
Cancel
Save