Added timeout check at wifi connect
This commit is contained in:
parent
e15f01d290
commit
fb9fde73a4
Binary file not shown.
BIN
bin/firmware.bin
BIN
bin/firmware.bin
Binary file not shown.
@ -1 +1 @@
|
|||||||
{ "project":"gravmon", "version":"0.2.2", "html": [ "index.min.htm", "device.min.htm", "config.min.htm", "about.min.htm" ] }
|
{ "project":"gravmon", "version":"0.2.3", "html": [ "index.min.htm", "device.min.htm", "config.min.htm", "about.min.htm" ] }
|
@ -26,7 +26,7 @@ build_flags = #-O0 -Wl,-Map,output.map
|
|||||||
#-D SKIP_SLEEPMODE
|
#-D SKIP_SLEEPMODE
|
||||||
-D USE_LITTLEFS=true
|
-D USE_LITTLEFS=true
|
||||||
#-D EMBED_HTML
|
#-D EMBED_HTML
|
||||||
-D CFG_APPVER="\"0.2.2\""
|
-D CFG_APPVER="\"0.2.3\""
|
||||||
lib_deps =
|
lib_deps =
|
||||||
# https://github.com/jrowberg/i2cdevlib.git # Using local copy of this library
|
# https://github.com/jrowberg/i2cdevlib.git # Using local copy of this library
|
||||||
https://github.com/codeplea/tinyexpr
|
https://github.com/codeplea/tinyexpr
|
||||||
|
@ -27,8 +27,6 @@ SOFTWARE.
|
|||||||
#include "tinyexpr.h"
|
#include "tinyexpr.h"
|
||||||
#include "tempsensor.h"
|
#include "tempsensor.h"
|
||||||
|
|
||||||
//#define LOG_LEVEL 5
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Calculates gravity according to supplied formula, compatible with iSpindle/Fermentrack formula
|
// Calculates gravity according to supplied formula, compatible with iSpindle/Fermentrack formula
|
||||||
//
|
//
|
||||||
|
@ -49,6 +49,9 @@ void printBuildOptions() {
|
|||||||
#ifdef SKIP_SLEEPMODE
|
#ifdef SKIP_SLEEPMODE
|
||||||
"SKIP_SLEEP "
|
"SKIP_SLEEP "
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef EMBED_HTML
|
||||||
|
"EMBED_HTML "
|
||||||
|
#endif
|
||||||
#ifdef ACTIVATE_OTA
|
#ifdef ACTIVATE_OTA
|
||||||
"OTA "
|
"OTA "
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,7 +32,7 @@ SOFTWARE.
|
|||||||
// Conversion between C and F
|
// Conversion between C and F
|
||||||
//
|
//
|
||||||
float convertCtoF( float t ) {
|
float convertCtoF( float t ) {
|
||||||
return (t * 1.8 ) + 32.0;
|
return (t * 1.8 ) + 32.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
OneWire myOneWire(D6);
|
OneWire myOneWire(D6);
|
||||||
@ -47,36 +47,36 @@ TempSensor myTempSensor;
|
|||||||
void TempSensor::setup() {
|
void TempSensor::setup() {
|
||||||
|
|
||||||
#if defined( SIMULATE_TEMP )
|
#if defined( SIMULATE_TEMP )
|
||||||
hasSensors = true;
|
hasSensors = true;
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if( mySensors.getDeviceCount() )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if LOG_LEVEL==6
|
|
||||||
Log.verbose(F("TSEN: Looking for temp sensors." CR));
|
|
||||||
#endif
|
#endif
|
||||||
mySensors.begin();
|
|
||||||
|
|
||||||
if( mySensors.getDeviceCount() ) {
|
if( mySensors.getDeviceCount() )
|
||||||
Log.notice(F("TSEN: Found %d sensors." CR), mySensors.getDeviceCount());
|
return;
|
||||||
mySensors.setResolution(TEMPERATURE_PRECISION);
|
|
||||||
}
|
|
||||||
|
|
||||||
float t = myConfig.getTempSensorAdj();
|
|
||||||
|
|
||||||
// Set the temp sensor adjustment values
|
|
||||||
if( myConfig.isTempC() ) {
|
|
||||||
tempSensorAdjF = t * 1.8; // Convert the adjustment value to C
|
|
||||||
tempSensorAdjC = t;
|
|
||||||
} else {
|
|
||||||
tempSensorAdjF = t;
|
|
||||||
tempSensorAdjC = t * 0.556; // Convert the adjustent value to F
|
|
||||||
}
|
|
||||||
|
|
||||||
#if LOG_LEVEL==6
|
#if LOG_LEVEL==6
|
||||||
Log.verbose(F("TSEN: Adjustment values for temp sensor %F C, %F F." CR), tempSensorAdjC, tempSensorAdjF );
|
Log.verbose(F("TSEN: Looking for temp sensors." CR));
|
||||||
|
#endif
|
||||||
|
mySensors.begin();
|
||||||
|
|
||||||
|
if( mySensors.getDeviceCount() ) {
|
||||||
|
Log.notice(F("TSEN: Found %d sensors." CR), mySensors.getDeviceCount());
|
||||||
|
mySensors.setResolution(TEMPERATURE_PRECISION);
|
||||||
|
}
|
||||||
|
|
||||||
|
float t = myConfig.getTempSensorAdj();
|
||||||
|
|
||||||
|
// Set the temp sensor adjustment values
|
||||||
|
if( myConfig.isTempC() ) {
|
||||||
|
tempSensorAdjF = t * 1.8; // Convert the adjustment value to C
|
||||||
|
tempSensorAdjC = t;
|
||||||
|
} else {
|
||||||
|
tempSensorAdjF = t;
|
||||||
|
tempSensorAdjC = t * 0.556; // Convert the adjustent value to F
|
||||||
|
}
|
||||||
|
|
||||||
|
#if LOG_LEVEL==6
|
||||||
|
Log.verbose(F("TSEN: Adjustment values for temp sensor %F C, %F F." CR), tempSensorAdjC, tempSensorAdjF );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,25 +84,25 @@ void TempSensor::setup() {
|
|||||||
// Retrieving value from sensor
|
// Retrieving value from sensor
|
||||||
//
|
//
|
||||||
float TempSensor::getValue() {
|
float TempSensor::getValue() {
|
||||||
float c = 0;
|
float c = 0;
|
||||||
|
|
||||||
#if defined( SIMULATE_TEMP )
|
#if defined( SIMULATE_TEMP )
|
||||||
return 21;
|
return 21;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Read the sensors
|
// Read the sensors
|
||||||
mySensors.requestTemperatures();
|
mySensors.requestTemperatures();
|
||||||
|
|
||||||
if( mySensors.getDeviceCount() >= 1) {
|
if( mySensors.getDeviceCount() >= 1) {
|
||||||
c = mySensors.getTempCByIndex(0);
|
c = mySensors.getTempCByIndex(0);
|
||||||
|
|
||||||
#if LOG_LEVEL==6
|
#if LOG_LEVEL==6
|
||||||
Log.verbose(F("TSEN: Reciving temp value for sensor %F C." CR), c);
|
Log.verbose(F("TSEN: Reciving temp value for sensor %F C." CR), c);
|
||||||
#endif
|
#endif
|
||||||
hasSensor = true;
|
hasSensor = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
// EOF
|
// EOF
|
@ -75,13 +75,18 @@ bool Wifi::connect( bool showPortal ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Add timeout after x retries to not end up in forever loop.
|
|
||||||
|
|
||||||
// Connect to wifi
|
// Connect to wifi
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
WiFi.begin();
|
WiFi.begin();
|
||||||
while( WiFi.status() != WL_CONNECTED ) {
|
while( WiFi.status() != WL_CONNECTED ) {
|
||||||
delay(100);
|
delay(100);
|
||||||
Serial.print( "." );
|
Serial.print( "." );
|
||||||
|
|
||||||
|
if( i++ > 100 ) {
|
||||||
|
LittleFS.end();
|
||||||
|
ESP.reset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Serial.print( CR );
|
Serial.print( CR );
|
||||||
connectedFlag = true;
|
connectedFlag = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user