Browse Source

cleanup

main
Hendrik Langer 7 years ago
parent
commit
94ce87574a
  1. 40
      src/main.cpp

40
src/main.cpp

@ -8,7 +8,6 @@
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
extern "C" {
//#include <espnow.h>
#include "user_interface.h"
}
@ -92,7 +91,6 @@ DHT dht(DHT22_PIN, DHTTYPE);
SDS011 sds;
volatile unsigned long geiger_counts = 0;
unsigned long geiger_previousMillis;
unsigned long last_wifi_activity = 0;
unsigned long last_dhcp = 0;
IPAddress ip, dns, gateway, subnet;
char ssid[64];
@ -120,42 +118,6 @@ unsigned long rtcMillis() {
return ((uint64_t)(rtc_t*(uint64_t)cal) >> 12)/1000;
}
/*
void sendESPNOW() {
// unsigned long espnowmillis = millis();
uint8_t remoteMac[] = {0x5C, 0xCF, 0x7F, 0x5, 0xFD, 0xF0};
#define WIFI_CHANNEL 1
WiFi.forceSleepWake();
delay(1); // yield();
digitalWrite(LED_BUILTIN, LOW);
WiFi.persistent(false); // don't load and save credentials to flash
WiFi.mode(WIFI_STA);
if (esp_now_init()==0) {
if(esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER)==0){
esp_now_add_peer(remoteMac, ESP_NOW_ROLE_SLAVE, WIFI_CHANNEL, NULL, 0);
u8 bs[sizeof(sd)];
memcpy(bs, &sd, sizeof(sd));
for (int i=0; i<20; i++)
esp_now_send(NULL, bs, sizeof(sd)); // max ESP_NOW_MAX_DATA_LEN
} else {
DEBUG_MSG("error configuring ESP NOW\n");
}
} else {
DEBUG_MSG("error initializing ESP NOW\n");
}
last_wifi_activity = millis();
esp_now_deinit();
WiFi.mode(WIFI_OFF);
WiFi.forceSleepBegin();
delay(1); // yield();
digitalWrite(LED_BUILTIN, HIGH);
// DEBUG_MSG("sendESPNOW() took %d ms\n", millis()-espnowmillis);
}
*/
void ICACHE_FLASH_ATTR sendValues() {
sd.temperature = dht.readTemperature();
sd.humidity = dht.readHumidity();
@ -376,7 +338,6 @@ void ICACHE_FLASH_ATTR sendValues() {
}
loop_count++;
last_wifi_activity = rtcMillis();
WiFi.disconnect();
WiFi.mode(WIFI_OFF);
WiFi.forceSleepBegin();
@ -417,7 +378,6 @@ void setup() {
}
void loop() {
//DEBUG_MSG("%d\n", rtcMillis() - last_wifi_activity);
sendValues();
delay(postingInterval);
}

Loading…
Cancel
Save