First build under Platformio. SEEMS to have improved the 10 second timeout in websocket.

Most significant change was moving BlueWireSerialPort variable in TxManage.h .....
Secondary was a few operator= were not returning *this ....
This commit is contained in:
Ray Jones 2019-06-27 06:04:24 +10:00
parent 52ecbcedae
commit eef4365a83
23 changed files with 52 additions and 69 deletions

View file

@ -119,8 +119,8 @@
#define RX_DATA_TIMOUT 50
const int FirmwareRevision = 23;
const int FirmwareSubRevision = 2;
const char* FirmwareDate = "16 Jun 2019";
const int FirmwareSubRevision = 3;
const char* FirmwareDate = "25 Jun 2019";
#ifdef ESP32
@ -156,6 +156,7 @@ long lastTemperatureTime; // used to moderate DS18B20 access
float fFilteredTemperature = -100; // -100: force direct update uopn first pass
const float fAlpha = 0.95; // exponential mean alpha
int DS18B20holdoff = 2;
int DS18B20holdon = 0;
int BoardRevision = 0;
unsigned long lastAnimationTime; // used to sequence updates to LCD for animation
@ -296,7 +297,7 @@ void listDir(fs::FS &fs, const char * dirname, uint8_t levels)
listDir(fs, file.name(), levels - 1);
}
} else {
DebugPort.printf(" FILE: %s SIZE: %ld\r\n", file.name(), file.size());
DebugPort.printf(" FILE: %s SIZE: %d\r\n", file.name(), file.size());
}
file = root.openNextFile();
}
@ -311,8 +312,6 @@ void interruptReboot()
void setup() {
char msg[128];
// initially, ensure the GPIO outputs are not activated during startup
// (GPIO2 tends to be one with default chip startup)
pinMode(GPIOout1_pin, OUTPUT);
@ -326,9 +325,11 @@ void setup() {
// Serial is the usual USB connection to a PC
// DO THIS BEFORE WE TRY AND SEND DEBUG INFO!
DebugPort.setWelcomeMsg("*************************************************\r\n"
DebugPort.setWelcomeMsg((char*)(
"*************************************************\r\n"
"* Connected to BTC heater controller debug port *\r\n"
"*************************************************\r\n");
"*************************************************\r\n"
));
DebugPort.setBufferSize(8192);
DebugPort.begin(115200);
DebugPort.println("_______________________________________________________________");
@ -348,7 +349,7 @@ void setup() {
}
else {
DebugPort.println("Mounted SPIFFS OK");
DebugPort.printf("SPIFFS usage: %ld/%ld\r\n", SPIFFS.usedBytes(), SPIFFS.totalBytes());
DebugPort.printf("SPIFFS usage: %d/%d\r\n", SPIFFS.usedBytes(), SPIFFS.totalBytes());
listDir(SPIFFS, "/", 2);
}
#endif
@ -779,12 +780,13 @@ void loop()
// update temperature reading,
// synchronised with serial reception as interrupts do get disabled in the OneWire library
tDelta = timenow - lastTemperatureTime;
if(tDelta > TEMPERATURE_INTERVAL) { // maintain a minimum holdoff period
lastTemperatureTime += TEMPERATURE_INTERVAL; // reset time to observe temeprature
if(tDelta > MIN_TEMPERATURE_INTERVAL) { // maintain a minimum holdoff period
lastTemperatureTime = millis(); // reset time to observe temeprature
fTemperature = TempSensor.getTempCByIndex(0); // read sensor
// DebugPort.printf("DS18B20 = %f\r\n", fTemperature);
// initialise filtered temperature upon very first pass
if(fTemperature > -80) { // avoid disconnected sensor readings being integrated
DS18B20holdon = 0;
if(DS18B20holdoff)
DS18B20holdoff--; // first value upon sensor connect is bad
else {
@ -798,8 +800,14 @@ void loop()
}
}
else {
DS18B20holdoff = 2;
fFilteredTemperature = -100;
DS18B20holdon++;
if(DS18B20holdon > 2) {
DS18B20holdon = 2;
if(!DS18B20holdoff)
DebugPort.println("\007DS18B20 sensor removed?");
DS18B20holdoff = 2;
fFilteredTemperature = -100;
}
}
TempSensor.requestTemperatures(); // prep sensor for future reading
@ -914,7 +922,7 @@ void heaterOff()
}
bool reqTemp(unsigned char newTemp)
bool reqTemp(unsigned char newTemp, bool save)
{
if(bHasOEMController)
return false;
@ -934,6 +942,7 @@ bool reqTemp(unsigned char newTemp)
else
settings.demandPump = newTemp;
NVstore.setUserSettings(settings);
if(save)
NVstore.save();
ScreenManager.reqUpdate();
@ -1090,8 +1099,10 @@ void checkDebugCommands()
{
// check for test commands received from PC Over USB
if(DebugPort.available()) {
#ifdef PROTOCOL_INVESTIGATION
static int mode = 0;
static int val = 0;
#endif
char rxVal = DebugPort.read();
@ -1355,8 +1366,8 @@ void ShowOTAScreen(int percent, eOTAmodes updateType)
void feedWatchdog()
{
uint64_t timeRem = timerRead(watchdogTimer);
if(timeRem > 100000) // 100ms
DebugPort.printf("WD time = %lld\r\n", timeRem); // print longer WD intervals
if(timeRem > 500000) // 500ms
DebugPort.printf("\007WD time = %lld\r\n", timeRem); // print longer WD intervals
timerWrite(watchdogTimer, 0); //reset timer (feed watchdog)
}

File diff suppressed because one or more lines are too long

View file

@ -130,8 +130,6 @@ C128x64_OLED::drawDotFactoryChar(int16_t x, int16_t y, unsigned char c, uint16_t
DBG(pr); DBG(F(" fg=")); DBG(color); DBG(F(" bg=")); DBGln(bg);
#endif
uint16_t char2print = c;
if(c >= pFontDescriptor->StartChar && c <= pFontDescriptor->EndChar) {
#ifdef DEBUG_FONT

View file

@ -86,7 +86,6 @@ CBasicScreen::show()
if(_showModeTime) {
const int border = 3;
const int radius = 4;
// Show selection between Fixed or Thermostat mode
long tDelta = millis() - _showModeTime;
if(tDelta < 0) {

View file

@ -79,8 +79,6 @@ CDetailedScreen::show()
{
CScreenHeader::show();
const char* c = String(getTemperatureSensor()).c_str();
int runstate = getHeaterInfo().getRunStateEx();
int errstate = getHeaterInfo().getErrState();
if(errstate) errstate--; // correct for +1 biased return value

View file

@ -66,7 +66,6 @@ CFuelMixtureScreen::show()
{
char str[16];
int xPos, yPos;
const int col2 = 90;
const int col3 = _display.width() - border;
_display.clearDisplay();

View file

@ -155,7 +155,6 @@ CPasswordScreen::_showPassword()
_display.getTextExtents("X", extents);
int charWidth = extents.width;
_display.getTextExtents(" ", extents);
int spaceWidth = extents.width;
for(int idx =0 ; idx < 4; idx++) {

View file

@ -53,7 +53,7 @@ CRebootScreen::show()
char msg[20];
char fillmsg[20];
memset(fillmsg, ' ', 20);
sprintf(msg, " REBOOT %d ", tDelta);
sprintf(msg, " REBOOT %ld ", tDelta);
fillmsg[strlen(msg)] = 0;
_printInverted(_display.xCentre(), yPos, fillmsg, true, eCentreJustify);

View file

@ -136,6 +136,8 @@ CScreen::_adjustExtents(CRect& extents, eJUSTIFY justify, const char* str)
{
_display.getTextExtents(str, extents);
switch(justify) {
case eLeftJustify:
break;
case eCentreJustify:
extents.xPos -= extents.width/2;
break;

View file

@ -71,8 +71,6 @@ CSetClockScreen::show()
char str[16];
int xPos, yPos;
const int col2 = 90;
const int col3 = _display.width() - border;
_printInverted(0, 15, " Set Clock ", true);
@ -226,7 +224,6 @@ CSetClockScreen::keyHandler(uint8_t event)
void
CSetClockScreen::_adjTimeDate(int dir)
{
int days;
switch(_rowSel) {
case 1:
working.adjustDay(dir);

View file

@ -316,7 +316,6 @@ CSetTimerScreen::keyHandler(uint8_t event)
void
CSetTimerScreen::_adjust(int dir)
{
int days;
int maskDOW = 0x01 << _colSel; // if doing Day of Week - (_rowSel == 2)
switch(_colSel) {

View file

@ -87,7 +87,6 @@ CTimerChartScreen::show()
for(int dow = 0; dow < 7; dow++) {
int day = 0x01 << dow;
int ypos = dow*linespacing + 7; // top of first line
int pixel = 0;
int subpixel = 0;

View file

@ -147,7 +147,6 @@ CWiFiScreen::show()
bool
CWiFiScreen::animate()
{
bool retval = false;
// show next/prev menu navigation line
if(_rowSel == 0) {
_printMenuText(_display.xCentre(), 53, " \021 \020 ", true, eCentreJustify);

View file

@ -40,6 +40,7 @@ public:
const CProtocol& getFrame() const { return m_TxFrame; };
private:
HardwareSerial& m_BlueWireSerial;
CProtocol m_TxFrame;
bool m_bOnReq;
bool m_bOffReq;
@ -47,7 +48,6 @@ private:
int m_nTxGatePin;
unsigned char _rawCommand;
unsigned long m_nStartTime;
HardwareSerial& m_BlueWireSerial;
};

View file

@ -36,6 +36,7 @@ struct sHourMin {
sHourMin& operator=(const sHourMin& rhs) {
hour = rhs.hour;
min = rhs.min;
return *this;
}
bool operator!=(const sHourMin& rhs) {
return (hour != rhs.hour) || (min != rhs.min);
@ -62,6 +63,7 @@ struct sTimer : public CESP32_NVStorage {
repeat = rhs.repeat;
temperature = rhs.temperature;
timerID = rhs.timerID;
return *this;
}
void init(int idx) {
start.hour = 0;

View file

@ -61,7 +61,7 @@ void interpretJsonCommand(char* pLine)
for(it = obj.begin(); it != obj.end(); ++it) {
if(strcmp("TempDesired", it->key) == 0) {
if(!reqTemp(it->value.as<unsigned char>())) { // this request is blocked if OEM controller active
if( !reqTemp(it->value.as<unsigned char>(), false) ) { // this request is blocked if OEM controller active
JSONmoderator.reset("TempDesired");
}
}

View file

@ -80,9 +80,9 @@ bool TModerator<T>::shouldSend(const char* name, T value)
template<class T>
bool TModerator<T>::addJson(const char* name, T value, JsonObject& root)
{
bool retval;
if( retval = shouldSend(name, value ) )
root.set(name, value);
bool retval = shouldSend(name, value);
if(retval)
root.set(name, value);
return retval;
}

View file

@ -339,6 +339,7 @@ public:
void setCredentials(const sCredentials& info);
CHeaterStorage& operator=(const CHeaterStorage& rhs) {
_calValues = rhs._calValues;
return *this;
}
void setUserSettings(const sUserSettings& info);
void setHeaterTuning(const sHeaterTuning& info);

View file

@ -61,8 +61,13 @@ public:
bool checkValidStart(unsigned char val);
void setDelay(int ms);
bool delayExpired();
bool toggleReporting() { _report = !_report; };
bool isReporting() {return _report != 0;};
bool toggleReporting() {
_report = !_report;
return isReporting();
};
bool isReporting() {
return _report != 0;
};
};
@ -76,6 +81,7 @@ public:
}
void reset() {
newData = false;
Value = 0;
}
void setValue(int value) {
newData = true;
@ -135,7 +141,7 @@ public:
};
void report() {
prevTime = millis();
DebugPort.printf("%8dlms ", prevTime - refTime);
DebugPort.printf("%8ldms ", prevTime - refTime);
};
};

View file

@ -31,7 +31,7 @@ struct sGPIO;
extern void requestOn();
extern void requestOff();
extern bool reqTempDelta(int delta);
extern bool reqTemp(unsigned char newTemp);
extern bool reqTemp(unsigned char newTemp, bool save=true);
extern bool reqThermoToggle();
extern bool setThermostatMode(unsigned char);
extern bool getThermostatModeActive(); // OEM: actual mode from blue wire, BTC: or our NV

View file

@ -70,7 +70,7 @@ bool handleFileRead(String path) { // send the right file to the client (if it e
String contentType = getContentType(path); // Get the MIME type
if (SPIFFS.exists(path)) { // If the file exists
File file = SPIFFS.open(path, "r"); // Open it
size_t sent = server.streamFile(file, contentType); // And send it to the client
server.streamFile(file, contentType); // And send it to the client
file.close(); // Then close the file again
return true;
}
@ -401,7 +401,7 @@ void initWebServer(void) {
server.onNotFound([]()
{ // If the client requests any URI
if (!handleFileRead(server.uri())) { // send it if it exists
DebugPort.printf("WEB: NOT FOUND : %s\r\n", server.uri());
DebugPort.printf("WEB: NOT FOUND : %s\r\n", server.uri().c_str());
server.send(404, "text/plain", "404: Not Found"); // otherwise, respond with a 404 (Not Found) error
}
});
@ -423,6 +423,7 @@ bool doWebServer(void)
{
webSocket.loop();
server.handleClient();
return true;
}
bool isWebServerClientChange()

View file

@ -45,4 +45,4 @@
void wifiFactoryDefault();
int isWifiButton();
#endif __BTCWIFI_H__
#endif // __BTCWIFI_H__

View file

@ -74,7 +74,7 @@
///////////////////////////////////////////////////////////////////////////////
// DS18B20 temperature sensing
//
#define TEMPERATURE_INTERVAL 1000
#define MIN_TEMPERATURE_INTERVAL 500
///////////////////////////////////////////////////////////////////////////////
// Real Time Clock support