diff --git a/.gitignore b/.gitignore index f54810a..6495c33 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,6 @@ docs/* test/*.md test/env/* -test/*.py +test/configure_*.py TODO.md data/*.min.htm \ No newline at end of file diff --git a/html/device.htm b/html/device.htm index 0541eaf..237a2d3 100644 --- a/html/device.htm +++ b/html/device.htm @@ -100,7 +100,7 @@ $('#spinner').show(); $.getJSON(url, function (cfg) { console.log( cfg ); - $("#app-ver").text(cfg["app-ver"] + " (html 0.4.0)"); + $("#app-ver").text(cfg["app-ver"] + " (html 0.4.9)"); $("#mdns").text(cfg["mdns"]); $("#id").text(cfg["id"]); }) diff --git a/platformio.ini b/platformio.ini index 17f3e1d..6f4abdd 100644 --- a/platformio.ini +++ b/platformio.ini @@ -32,6 +32,12 @@ build_flags = #-D DEBUG_ESP_CORE #-D SKIP_SLEEPMODE #-D DOUBLERESETDETECTOR_DEBUG true + -D CFG_DISABLE_LOGGING # Turn off verbose logging for some of the parts (too much will cause a crash) but also add space + -D GYRO_DISABLE_LOGGING + -D PUSH_DISABLE_LOGGING + -D TSEN_DISABLE_LOGGING + -D WEB_DISABLE_LOGGING + -D MAIN_DISABLE_LOGGING -D USE_LITTLEFS=true -D EMBED_HTML # If this is not used the html files needs to be on the file system (can be uploaded) -D USER_SSID=\""\"" # =\""myssid\"" diff --git a/src/config.cpp b/src/config.cpp index d36dbdb..fc37151 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -25,8 +25,6 @@ SOFTWARE. #include "helper.h" #include -#define CFG_DISABLE_LOGGING - Config myConfig; // diff --git a/src/gyro.cpp b/src/gyro.cpp index 9f2c331..3bf26e5 100644 --- a/src/gyro.cpp +++ b/src/gyro.cpp @@ -24,8 +24,6 @@ SOFTWARE. #include "gyro.h" #include "helper.h" -#define GYRO_DISABLE_LOGGING - GyroSensor myGyro; #define GYRO_USE_INTERRUPT // Use interrupt to detect when new sample is ready @@ -245,7 +243,7 @@ bool GyroSensor::read() { validValue = true; angle = calculateAngle( lastGyroData ); #if !defined( GYRO_DISABLE_LOGGING ) - Log.notice(F("GYRO: Sensor values %d,%d,%d\t%F" CR), raw.ax, raw.ay, raw.az, angle ); + Log.notice(F("GYRO: Sensor values %d,%d,%d\t%F" CR), lastGyroData.ax, lastGyroData.ay, lastGyroData.az, angle ); #endif } diff --git a/src/main.cpp b/src/main.cpp index 14c2c1e..2ee8619 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -31,8 +31,6 @@ SOFTWARE. #include "pushtarget.h" #include -#define MAIN_DISABLE_LOGGING - // Settings for double reset detector. #define ESP8266_DRD_USE_RTC true #define DRD_TIMEOUT 2 @@ -85,9 +83,7 @@ void checkSleepMode( float angle, float volt ) { // sleep mode active when flat //sleepModeActive = ( angle<85 && angle>5 ) ? true : false; - #if LOG_LEVEL==6 && !defined( MAIN_DISABLE_LOGGING ) - Log.verbose(F("MAIN: Deep sleep mode %s (angle=%F volt=%F)." CR), sleepModeActive ? "true":"false", angle, volt ); - #endif + Log.notice(F("MAIN: Deep sleep mode %s (angle=%F volt=%F)." CR), sleepModeActive ? "true":"false", angle, volt ); } // diff --git a/src/pushtarget.cpp b/src/pushtarget.cpp index 0495d5c..c5c4ec8 100644 --- a/src/pushtarget.cpp +++ b/src/pushtarget.cpp @@ -25,8 +25,6 @@ SOFTWARE. #include "config.h" #include "gyro.h" // For testing the tempsensor in the gyro -#define PUSH_DISABLE_LOGGING - PushTarget myPushTarget; // diff --git a/src/tempsensor.cpp b/src/tempsensor.cpp index 10f07aa..0d9faa4 100644 --- a/src/tempsensor.cpp +++ b/src/tempsensor.cpp @@ -29,8 +29,6 @@ SOFTWARE. #include #include -#define TSEN_DISABLE_LOGGING - // // Conversion between C and F // diff --git a/src/webserver.cpp b/src/webserver.cpp index 00db470..0843e65 100644 --- a/src/webserver.cpp +++ b/src/webserver.cpp @@ -30,8 +30,6 @@ SOFTWARE. #include #include -#define WEB_DISABLE_LOGGING - WebServer myWebServer; // My wrapper class fr webserver functions extern bool sleepModeActive; extern bool sleepModeAlwaysSkip; diff --git a/src/wifi.cpp b/src/wifi.cpp index 8f2eef5..f3377aa 100644 --- a/src/wifi.cpp +++ b/src/wifi.cpp @@ -53,7 +53,7 @@ bool Wifi::connect( bool showPortal ) { showPortal = true; } else { //Log.info(F("WIFI: Using SSID=%s and %s." CR), myConfig.getWifiSSID(), myConfig.getWifiPass() ); - Log.info(F("WIFI: Using SSID=%s and %s." CR), myConfig.getWifiSSID(), "*****" ); + //Log.info(F("WIFI: Using SSID=%s and %s." CR), myConfig.getWifiSSID(), "*****" ); } if( strlen(userSSID)==0 && showPortal ) { @@ -82,13 +82,13 @@ bool Wifi::connect( bool showPortal ) { // Connect to wifi int i = 0; - Log.notice(F("WIFI: Connecting to WIFI, mode=%d,persistent=%d,fhy=%d ." CR), WiFi.getMode(), WiFi.getPersistent(), WiFi.getPhyMode() ); + //Log.notice(F("WIFI: Connecting to WIFI, mode=%d,persistent=%d,fhy=%d ." CR), WiFi.getMode(), WiFi.getPersistent(), WiFi.getPhyMode() ); WiFi.mode(WIFI_STA); if( strlen(userSSID) ) { - Log.notice(F("WIFI: Connecting to wifi using predefined settings %s." CR), userSSID); + Log.notice(F("WIFI: Connecting to wifi using hardcoded settings %s." CR), userSSID); WiFi.begin( userSSID, userPWD ); } else { - Log.notice(F("WIFI: Connecting to wifi using stored settings. %s." CR), myConfig.getWifiSSID()); + Log.notice(F("WIFI: Connecting to wifi using stored settings %s." CR), myConfig.getWifiSSID()); WiFi.begin(myConfig.getWifiSSID(), myConfig.getWifiPass()); } diff --git a/test/configure.py b/test/configure.py new file mode 100644 index 0000000..7ec5fa2 --- /dev/null +++ b/test/configure.py @@ -0,0 +1,81 @@ +import requests +import json + +host = "192.168.1.1" # IP adress (or name) of the device to send these settings to +id = "ee1bfc" # Device ID (shown in serial console during startup or in UI) + +def set_config( url, json ): + headers = { "ContentType": "application/json" } + print( url ) + #print( json ) + resp = requests.post( url, headers=headers, data=json ) + if resp.status_code != 200 : + print ( "Failed " ) + else : + print ( "Success " ) + +# +# Configure the device settings. +# +url = "http://" + host + "/api/config/device" +json = { "id": id, + "mdns": "gravmon", # Name of the device + "temp-format": "C", # Temperature format C or F + "sleep-interval": 30 # Sleep interval in seconds + } +set_config( url, json ) + +# +# Configure the push settings. Blank means that its no used. +# +url = "http://" + host + "/api/config/push" +json = { "id": id, + "http-push": "http://192.168.1.1/ispindel", # HTTP endpoint + "http-push2": "", # HTTP endpoint2 + "brewfather-push": "", # Brewfather URL + "influxdb2-push": "", # InfluxDB2 settings + "influxdb2-org": "", + "influxdb2-bucket": "", + "influxdb2-auth": "" + } +set_config( url, json ) + + +# +# Configure the gravity settings. +# +url = "http://" + host + "/api/config/gravity" +json = { "id": id, + "gravity-formula": "", # If you want to set the gravity formula + "gravity-temp-adjustment": "off" # on or off + } +set_config( url, json ) + +# +# Configure the hardware settings. +# +url = "http://" + host + "/api/config/hardware" +json = { "id": id, + "voltage-factor": 1.59, # Default value for voltage calculation + "temp-adjustment": 0, # If temp sensor needs to be corrected + "ota-url": "" # if the device should seach for a new update when active + } +set_config( url, json ) + +# +# Configure the gravity formula settings. If this is called the formula will be updated based on these measurements (zero angle values will be ignored) +# +url = "http://" + host + "/api/formula" +json = { "id": id, + "a1": 22.4, + "a2": 54.4, + "a3": 58, + "a4": 0, + "a5": 0, + "g1": 1.000, + "g2": 1.053, + "g3": 1.062, + "g4": 1, + "g5": 1 + } +set_config( url, json )