Found websocket write was blocking, returning 0, leading to WD reboot. Need to think of proper fix
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 500 KiB |
Before Width: | Height: | Size: 97 KiB After Width: | Height: | Size: 581 KiB |
Before Width: | Height: | Size: 111 KiB After Width: | Height: | Size: 650 KiB |
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 633 KiB |
Before Width: | Height: | Size: 166 KiB After Width: | Height: | Size: 144 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 554 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 661 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 692 KiB |
Before Width: | Height: | Size: 123 KiB After Width: | Height: | Size: 766 KiB |
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 676 KiB |
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 630 KiB |
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 637 KiB |
Before Width: | Height: | Size: 134 KiB After Width: | Height: | Size: 633 KiB |
Before Width: | Height: | Size: 100 KiB After Width: | Height: | Size: 468 KiB |
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 469 KiB |
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 749 KiB |
Before Width: | Height: | Size: 130 KiB After Width: | Height: | Size: 934 KiB |
Before Width: | Height: | Size: 137 KiB After Width: | Height: | Size: 792 KiB |
Before Width: | Height: | Size: 138 KiB After Width: | Height: | Size: 658 KiB |
Before Width: | Height: | Size: 87 KiB After Width: | Height: | Size: 589 KiB |
Before Width: | Height: | Size: 93 KiB After Width: | Height: | Size: 425 KiB |
Before Width: | Height: | Size: 110 KiB After Width: | Height: | Size: 463 KiB |
|
@ -617,27 +617,32 @@ size_t WebSockets::write(WSclient_t * client, uint8_t *out, size_t n) {
|
||||||
while(n > 0) {
|
while(n > 0) {
|
||||||
if(client->tcp == NULL) {
|
if(client->tcp == NULL) {
|
||||||
DEBUG_WEBSOCKETS("[write] tcp is null!\n");
|
DEBUG_WEBSOCKETS("[write] tcp is null!\n");
|
||||||
|
Serial.printf("\n%ld write tcp is null!\n", millis());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!client->tcp->connected()) {
|
if(!client->tcp->connected()) {
|
||||||
DEBUG_WEBSOCKETS("[write] not connected!\n");
|
DEBUG_WEBSOCKETS("[write] not connected!\n");
|
||||||
|
Serial.printf("\n%ld write not connected!\n", millis());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((millis() - t) > WEBSOCKETS_TCP_TIMEOUT) {
|
if((millis() - t) > WEBSOCKETS_TCP_TIMEOUT) {
|
||||||
DEBUG_WEBSOCKETS("[write] write TIMEOUT! %lu\n", (millis() - t));
|
DEBUG_WEBSOCKETS("[write] write TIMEOUT! %lu\n", (millis() - t));
|
||||||
|
Serial.printf("\n%ld write TIMEOUT!\n", millis());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
len = client->tcp->write((const uint8_t*)out, n);
|
len = client->tcp->write((const uint8_t*)out, n);
|
||||||
if(len) {
|
if(len > 0) { // RLJ -1 returned?
|
||||||
t = millis();
|
t = millis();
|
||||||
out += len;
|
out += len;
|
||||||
n -= len;
|
n -= len;
|
||||||
total += len;
|
total += len;
|
||||||
//DEBUG_WEBSOCKETS("write %d left %d!\n", len, n);
|
//DEBUG_WEBSOCKETS("write %d left %d!\n", len, n);
|
||||||
} else {
|
} else {
|
||||||
|
Serial.printf("\n%ld write %d failed left %d!\n", millis(), len, n);
|
||||||
|
// break;
|
||||||
//DEBUG_WEBSOCKETS("write %d failed left %d!\n", len, n);
|
//DEBUG_WEBSOCKETS("write %d failed left %d!\n", len, n);
|
||||||
}
|
}
|
||||||
#if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266)
|
#if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266)
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
#include "WebSockets.h"
|
#include "WebSockets.h"
|
||||||
#include "WebSocketsServer.h"
|
#include "WebSocketsServer.h"
|
||||||
|
|
||||||
|
extern void feedWatchdog();
|
||||||
|
|
||||||
|
|
||||||
WebSocketsServer::WebSocketsServer(uint16_t port, String origin, String protocol) {
|
WebSocketsServer::WebSocketsServer(uint16_t port, String origin, String protocol) {
|
||||||
_port = port;
|
_port = port;
|
||||||
_origin = origin;
|
_origin = origin;
|
||||||
|
@ -222,7 +225,11 @@ bool WebSocketsServer::broadcastTXT(uint8_t * payload, size_t length, bool heade
|
||||||
for(uint8_t i = 0; i < WEBSOCKETS_SERVER_CLIENT_MAX; i++) {
|
for(uint8_t i = 0; i < WEBSOCKETS_SERVER_CLIENT_MAX; i++) {
|
||||||
client = &_clients[i];
|
client = &_clients[i];
|
||||||
if(clientIsConnected(client)) {
|
if(clientIsConnected(client)) {
|
||||||
|
feedWatchdog();
|
||||||
if(!sendFrame(client, WSop_text, payload, length, true, headerToPayload)) {
|
if(!sendFrame(client, WSop_text, payload, length, true, headerToPayload)) {
|
||||||
|
feedWatchdog();
|
||||||
|
Serial.println("\n \007STOPPING CLIENT");
|
||||||
|
disconnect(i);
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,15 +14,20 @@ platform = espressif32
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board_build.partitions = ABpartition.csv
|
board_build.partitions = ABpartition.csv
|
||||||
upload_speed = 921600
|
|
||||||
;upload_protocol = espota
|
; ; Options to use OTA upload
|
||||||
;upload_port = 192.168.20.120
|
; upload_protocol = espota
|
||||||
;upload_flags =
|
; upload_port = 192.168.20.116
|
||||||
; --port=3232
|
; upload_flags =
|
||||||
upload_port = COM14
|
; --port=3232
|
||||||
;upload_port = COM5
|
|
||||||
|
; Options to use serial upload
|
||||||
upload_protocol = esptool
|
upload_protocol = esptool
|
||||||
;monitor_speed = 115200
|
; upload_port = COM5
|
||||||
|
upload_port = COM14
|
||||||
|
upload_speed = 921600
|
||||||
|
monitor_speed = 115200
|
||||||
|
|
||||||
extra_scripts = post:add_CRC.py
|
extra_scripts = post:add_CRC.py
|
||||||
; replace shitty Arduino millis with a linear time version
|
; replace shitty Arduino millis with a linear time version
|
||||||
build_flags =
|
build_flags =
|
||||||
|
|
|
@ -129,7 +129,7 @@
|
||||||
|
|
||||||
const int FirmwareRevision = 32;
|
const int FirmwareRevision = 32;
|
||||||
const int FirmwareSubRevision = 0;
|
const int FirmwareSubRevision = 0;
|
||||||
const int FirmwareMinorRevision = 4;
|
const int FirmwareMinorRevision = 5;
|
||||||
const char* FirmwareDate = "11 Apr 2020";
|
const char* FirmwareDate = "11 Apr 2020";
|
||||||
|
|
||||||
|
|
||||||
|
@ -173,6 +173,7 @@ int DS18B20holdoff = 2;
|
||||||
int BoardRevision = 0;
|
int BoardRevision = 0;
|
||||||
bool bTestBTModule = false;
|
bool bTestBTModule = false;
|
||||||
bool bSetupMQTT = false;
|
bool bSetupMQTT = false;
|
||||||
|
bool bReportStack = false;
|
||||||
|
|
||||||
unsigned long lastAnimationTime; // used to sequence updates to LCD for animation
|
unsigned long lastAnimationTime; // used to sequence updates to LCD for animation
|
||||||
|
|
||||||
|
@ -289,7 +290,7 @@ void parentKeyHandler(uint8_t event)
|
||||||
|
|
||||||
void interruptReboot()
|
void interruptReboot()
|
||||||
{
|
{
|
||||||
ets_printf("Software watchdog reboot......\r\n");
|
ets_printf("%ld Software watchdog reboot......\r\n", millis());
|
||||||
esp_restart();
|
esp_restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,10 +448,10 @@ void setup() {
|
||||||
initOTA();
|
initOTA();
|
||||||
}
|
}
|
||||||
#endif // USE_OTA
|
#endif // USE_OTA
|
||||||
initFOTA();
|
|
||||||
#if USE_WEBSERVER == 1
|
#if USE_WEBSERVER == 1
|
||||||
initWebServer();
|
initWebServer();
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
|
initFOTA();
|
||||||
#if USE_MQTT == 1
|
#if USE_MQTT == 1
|
||||||
mqttInit();
|
mqttInit();
|
||||||
#endif // USE_MQTT
|
#endif // USE_MQTT
|
||||||
|
@ -871,6 +872,11 @@ void loop()
|
||||||
if(tDelta > MIN_TEMPERATURE_INTERVAL) { // maintain a minimum holdoff period
|
if(tDelta > MIN_TEMPERATURE_INTERVAL) { // maintain a minimum holdoff period
|
||||||
lastTemperatureTime = millis(); // reset time to observe temeprature
|
lastTemperatureTime = millis(); // reset time to observe temeprature
|
||||||
|
|
||||||
|
if(bReportStack) {
|
||||||
|
int stackdepth = uxTaskGetStackHighWaterMark(NULL);
|
||||||
|
DebugPort.printf("Stack : %d\r\n", stackdepth);
|
||||||
|
}
|
||||||
|
|
||||||
TempSensor.readSensors();
|
TempSensor.readSensors();
|
||||||
if(TempSensor.getTemperature(0, fTemperature)) { // get Primary sensor temperature
|
if(TempSensor.getTemperature(0, fTemperature)) { // get Primary sensor temperature
|
||||||
if(DS18B20holdoff) {
|
if(DS18B20holdoff) {
|
||||||
|
@ -1377,15 +1383,18 @@ void checkDebugCommands()
|
||||||
else if(rxVal == 'h') {
|
else if(rxVal == 'h') {
|
||||||
getWebContent(true);
|
getWebContent(true);
|
||||||
}
|
}
|
||||||
else if(rxVal == 'r') {
|
else if(rxVal == ('b' & 0x1f)) { // CTRL-B Tst Mdoe: bluetooth module route
|
||||||
ESP.restart(); // reset the esp
|
bTestBTModule = !bTestBTModule;
|
||||||
|
Bluetooth.test(bTestBTModule ? 0xff : 0x00); // special enter or leave BT test commands
|
||||||
}
|
}
|
||||||
else if(rxVal == ('h' & 0x1f)) { // CTRL-H hourmeter reset
|
else if(rxVal == ('h' & 0x1f)) { // CTRL-H hourmeter reset
|
||||||
pHourMeter->resetHard();
|
pHourMeter->resetHard();
|
||||||
}
|
}
|
||||||
else if(rxVal == ('b' & 0x1f)) { // CTRL-B Tst Mdoe: bluetooth module route
|
else if(rxVal == ('r' & 0x1f)) { // CTRL-R reboot
|
||||||
bTestBTModule = !bTestBTModule;
|
ESP.restart(); // reset the esp
|
||||||
Bluetooth.test(bTestBTModule ? 0xff : 0x00); // special enter or leave BT test commands
|
}
|
||||||
|
else if(rxVal == ('s' & 0x1f)) { // CTRL-B Test Mode: bluetooth module route
|
||||||
|
bReportStack = !bReportStack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef PROTOCOL_INVESTIGATION
|
#ifdef PROTOCOL_INVESTIGATION
|
||||||
|
@ -1613,6 +1622,8 @@ void feedWatchdog()
|
||||||
{
|
{
|
||||||
#if USE_SW_WATCHDOG == 1 && USE_JTAG == 0
|
#if USE_SW_WATCHDOG == 1 && USE_JTAG == 0
|
||||||
// BEST NOT USE WATCHDOG WITH JTAG DEBUG :-)
|
// BEST NOT USE WATCHDOG WITH JTAG DEBUG :-)
|
||||||
|
// DebugPort.printf("\r %ld Watchdog fed", millis());
|
||||||
|
DebugPort.print("~");
|
||||||
WatchdogTick = 1500;
|
WatchdogTick = 1500;
|
||||||
#else
|
#else
|
||||||
WatchdogTick = -1;
|
WatchdogTick = -1;
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
virtual bool isConnected() { return false; };
|
virtual bool isConnected() { return false; };
|
||||||
virtual const char* getMAC() const { return "unknown"; };
|
virtual const char* getMAC() { return "unknown"; };
|
||||||
virtual bool test(char) { return false; }; // returns true whilst test mode is active
|
virtual bool test(char) { return false; }; // returns true whilst test mode is active
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ CBluetoothESP32HC05::CBluetoothESP32HC05(int keyPin, int sensePin, int rxPin, in
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CBluetoothESP32HC05::openSerial(int baudrate)
|
CBluetoothESP32HC05::_openSerial(int baudrate)
|
||||||
{
|
{
|
||||||
// Open Serial port on the ESP32
|
// Open Serial port on the ESP32
|
||||||
// best to explicitly specify pins for the pin multiplexer!
|
// best to explicitly specify pins for the pin multiplexer!
|
||||||
|
|
|
@ -28,7 +28,7 @@ class CBluetoothESP32HC05 : public CBluetoothHC05 {
|
||||||
public:
|
public:
|
||||||
CBluetoothESP32HC05(int keyPin, int sensePin, int rxPin, int txPin);
|
CBluetoothESP32HC05(int keyPin, int sensePin, int rxPin, int txPin);
|
||||||
protected:
|
protected:
|
||||||
void openSerial(int baudrate);
|
void _openSerial(int baudrate);
|
||||||
};
|
};
|
||||||
|
|
||||||
#if USE_CLASSIC_BLUETOOTH == 1
|
#if USE_CLASSIC_BLUETOOTH == 1
|
||||||
|
|
|
@ -28,6 +28,11 @@
|
||||||
|
|
||||||
// Bluetooth access via HC-05 Module, using a UART
|
// Bluetooth access via HC-05 Module, using a UART
|
||||||
|
|
||||||
|
static const int BTRates[] = {
|
||||||
|
9600, 38400, 115200, 19200, 57600, 2400, 4800, 1200
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#if USE_HC05_BLUETOOTH == 1
|
#if USE_HC05_BLUETOOTH == 1
|
||||||
CBluetoothHC05::CBluetoothHC05(int keyPin, int sensePin)
|
CBluetoothHC05::CBluetoothHC05(int keyPin, int sensePin)
|
||||||
{
|
{
|
||||||
|
@ -41,6 +46,8 @@ CBluetoothHC05::CBluetoothHC05(int keyPin, int sensePin)
|
||||||
// this line goes high when a BT client is connected :-)
|
// this line goes high when a BT client is connected :-)
|
||||||
pinMode(_sensePin, INPUT);
|
pinMode(_sensePin, INPUT);
|
||||||
_bTest = false;
|
_bTest = false;
|
||||||
|
_bGotMAC = false;
|
||||||
|
_BTbaudIdx = 0;
|
||||||
strcpy(_MAC, "unknown");
|
strcpy(_MAC, "unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,27 +55,24 @@ CBluetoothHC05::CBluetoothHC05(int keyPin, int sensePin)
|
||||||
void
|
void
|
||||||
CBluetoothHC05::begin()
|
CBluetoothHC05::begin()
|
||||||
{
|
{
|
||||||
const int BTRates[] = {
|
|
||||||
9600, 38400, 115200, 19200, 57600, 2400, 4800, 1200
|
|
||||||
};
|
|
||||||
|
|
||||||
_rxLine.clear();
|
_rxLine.clear();
|
||||||
|
|
||||||
digitalWrite(_keyPin, HIGH); // request HC-05 module to enter command mode
|
_setCommandMode(true);
|
||||||
|
// digitalWrite(_keyPin, HIGH); // request HC-05 module to enter command mode
|
||||||
|
|
||||||
delay(50);
|
// delay(50);
|
||||||
|
|
||||||
openSerial(9600); // virtual function, may call derived class method here
|
// _openSerial(9600); // virtual function, may call derived class method here
|
||||||
|
|
||||||
DebugPort.println("\r\n\r\nAttempting to detect HC-05 Bluetooth module...");
|
DebugPort.println("\r\n\r\nAttempting to detect HC-05 Bluetooth module...");
|
||||||
|
|
||||||
int BTidx = 0;
|
// int BTidx = 0;
|
||||||
int maxTries = sizeof(BTRates)/sizeof(int);
|
int maxTries = sizeof(BTRates)/sizeof(int);
|
||||||
for(BTidx = 0; BTidx < maxTries; BTidx++) {
|
for(_BTbaudIdx = 0; _BTbaudIdx < maxTries; _BTbaudIdx++) {
|
||||||
DebugPort.printf(" @ %d baud... ", BTRates[BTidx]);
|
DebugPort.printf(" @ %d baud... ", BTRates[_BTbaudIdx]);
|
||||||
openSerial(BTRates[BTidx]); // open serial port at a std. baud rate
|
_openSerial(BTRates[_BTbaudIdx]); // open serial port at a std. baud rate
|
||||||
delay(10);
|
delay(10);
|
||||||
flush();
|
_flush();
|
||||||
HC05_SerialPort.print("AT\r\n"); // clear the throat!
|
HC05_SerialPort.print("AT\r\n"); // clear the throat!
|
||||||
delay(100);
|
delay(100);
|
||||||
HC05_SerialPort.setTimeout(100);
|
HC05_SerialPort.setTimeout(100);
|
||||||
|
@ -90,7 +94,7 @@ CBluetoothHC05::begin()
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugPort.println("");
|
DebugPort.println("");
|
||||||
if(BTidx == maxTries) {
|
if(_BTbaudIdx == maxTries) {
|
||||||
// we could not get anywhere with the AT commands, but maybe this is the other module
|
// we could not get anywhere with the AT commands, but maybe this is the other module
|
||||||
// plough on and assume 9600 baud, but at the mercy of whatever the module name is...
|
// plough on and assume 9600 baud, but at the mercy of whatever the module name is...
|
||||||
DebugPort.println("FAILED to detect a HC-05 Bluetooth module :-(");
|
DebugPort.println("FAILED to detect a HC-05 Bluetooth module :-(");
|
||||||
|
@ -98,7 +102,9 @@ CBluetoothHC05::begin()
|
||||||
// assume it is 9600, and just (try to) use it like that...
|
// assume it is 9600, and just (try to) use it like that...
|
||||||
// we will sense the STATE line to prove a client is hanging off the link...
|
// we will sense the STATE line to prove a client is hanging off the link...
|
||||||
DebugPort.println("ASSUMING a HC-05 module @ 9600baud (Unknown name)");
|
DebugPort.println("ASSUMING a HC-05 module @ 9600baud (Unknown name)");
|
||||||
openSerial(9600);
|
// _openSerial(9600);
|
||||||
|
_BTbaudIdx = 0;
|
||||||
|
_setCommandMode(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// found a HC-05 module at one of its supported baud rates.
|
// found a HC-05 module at one of its supported baud rates.
|
||||||
|
@ -137,7 +143,7 @@ CBluetoothHC05::begin()
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DebugPort.println("OK");
|
DebugPort.println("OK");
|
||||||
decodeMACresponse(response, len);
|
_decodeMACresponse(response, len);
|
||||||
DebugPort.print(" "); DebugPort.println(_MAC);
|
DebugPort.print(" "); DebugPort.println(_MAC);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
@ -156,9 +162,9 @@ CBluetoothHC05::begin()
|
||||||
else {
|
else {
|
||||||
DebugPort.println("OK");
|
DebugPort.println("OK");
|
||||||
}*/
|
}*/
|
||||||
flush();
|
_flush();
|
||||||
delay(100);
|
delay(100);
|
||||||
openSerial(9600);
|
_openSerial(9600);
|
||||||
|
|
||||||
// leave HC-05 command mode, return to data mode
|
// leave HC-05 command mode, return to data mode
|
||||||
digitalWrite(_keyPin, LOW);
|
digitalWrite(_keyPin, LOW);
|
||||||
|
@ -166,7 +172,7 @@ CBluetoothHC05::begin()
|
||||||
}
|
}
|
||||||
|
|
||||||
delay(50);
|
delay(50);
|
||||||
flush(); // ensure any AT command reponse dribbles are cleaned up!
|
_flush(); // ensure any AT command reponse dribbles are cleaned up!
|
||||||
|
|
||||||
DebugPort.println("");
|
DebugPort.println("");
|
||||||
}
|
}
|
||||||
|
@ -205,7 +211,7 @@ CBluetoothHC05::send(const char* Str)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CBluetoothHC05::openSerial(int baudrate)
|
CBluetoothHC05::_openSerial(int baudrate)
|
||||||
{
|
{
|
||||||
// standard serial port for Due, Mega (ESP32 uses virtual, derived from this class)
|
// standard serial port for Due, Mega (ESP32 uses virtual, derived from this class)
|
||||||
HC05_SerialPort.begin(baudrate);
|
HC05_SerialPort.begin(baudrate);
|
||||||
|
@ -216,7 +222,7 @@ bool
|
||||||
CBluetoothHC05::ATCommand(const char* cmd)
|
CBluetoothHC05::ATCommand(const char* cmd)
|
||||||
{
|
{
|
||||||
if(!_bTest) {
|
if(!_bTest) {
|
||||||
flush(); // ensure response is for *this* command!
|
_flush(); // ensure response is for *this* command!
|
||||||
HC05_SerialPort.print(cmd);
|
HC05_SerialPort.print(cmd);
|
||||||
char RxBuffer[16];
|
char RxBuffer[16];
|
||||||
memset(RxBuffer, 0, 16);
|
memset(RxBuffer, 0, 16);
|
||||||
|
@ -233,7 +239,7 @@ bool
|
||||||
CBluetoothHC05::ATResponse(const char* cmd, const char* respHdr, char* response, int& len)
|
CBluetoothHC05::ATResponse(const char* cmd, const char* respHdr, char* response, int& len)
|
||||||
{
|
{
|
||||||
if(!_bTest) {
|
if(!_bTest) {
|
||||||
flush(); // ensure response is for *this* command!
|
_flush(); // ensure response is for *this* command!
|
||||||
HC05_SerialPort.print(cmd);
|
HC05_SerialPort.print(cmd);
|
||||||
memset(response, 0, len);
|
memset(response, 0, len);
|
||||||
int read = HC05_SerialPort.readBytesUntil('\n', response, len); // \n is not included in returned string!
|
int read = HC05_SerialPort.readBytesUntil('\n', response, len); // \n is not included in returned string!
|
||||||
|
@ -248,7 +254,7 @@ CBluetoothHC05::ATResponse(const char* cmd, const char* respHdr, char* response,
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CBluetoothHC05::foldbackDesiredTemp()
|
CBluetoothHC05::_foldbackDesiredTemp()
|
||||||
{
|
{
|
||||||
StaticJsonBuffer<32> jsonBuffer; // create a JSON buffer on the stack
|
StaticJsonBuffer<32> jsonBuffer; // create a JSON buffer on the stack
|
||||||
JsonObject& root = jsonBuffer.createObject(); // create object to add JSON commands to
|
JsonObject& root = jsonBuffer.createObject(); // create object to add JSON commands to
|
||||||
|
@ -261,7 +267,7 @@ CBluetoothHC05::foldbackDesiredTemp()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CBluetoothHC05::flush()
|
CBluetoothHC05::_flush()
|
||||||
{
|
{
|
||||||
while(HC05_SerialPort.available())
|
while(HC05_SerialPort.available())
|
||||||
HC05_SerialPort.read();
|
HC05_SerialPort.read();
|
||||||
|
@ -283,18 +289,18 @@ CBluetoothHC05::test(char val)
|
||||||
else if(val == ('b' & 0x1f)) { // CTRL-B - leave bluetooth test mode
|
else if(val == ('b' & 0x1f)) { // CTRL-B - leave bluetooth test mode
|
||||||
DebugPort.println("LEAVING Test Bluetooth mode");
|
DebugPort.println("LEAVING Test Bluetooth mode");
|
||||||
digitalWrite(_keyPin, LOW); // request HC-05 module to enter command mode
|
digitalWrite(_keyPin, LOW); // request HC-05 module to enter command mode
|
||||||
openSerial(9600);
|
_openSerial(9600);
|
||||||
_bTest = false;
|
_bTest = false;
|
||||||
}
|
}
|
||||||
else if(val == ('c' & 0x1f)) { // CTRL-C - data mode
|
else if(val == ('c' & 0x1f)) { // CTRL-C - data mode
|
||||||
DebugPort.println("Test Bluetooth COMMAND mode");
|
DebugPort.println("Test Bluetooth COMMAND mode");
|
||||||
digitalWrite(_keyPin, HIGH); // request HC-05 module to enter command mode
|
digitalWrite(_keyPin, HIGH); // request HC-05 module to enter command mode
|
||||||
openSerial(9600);
|
_openSerial(9600);
|
||||||
}
|
}
|
||||||
else if(val == ('d' & 0x1f)) { // CTRL-D - data mode
|
else if(val == ('d' & 0x1f)) { // CTRL-D - data mode
|
||||||
DebugPort.println("Test Bluetooth DATA mode");
|
DebugPort.println("Test Bluetooth DATA mode");
|
||||||
digitalWrite(_keyPin, LOW); // request HC-05 module to enter command mode
|
digitalWrite(_keyPin, LOW); // request HC-05 module to enter command mode
|
||||||
openSerial(9600);
|
_openSerial(9600);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
HC05_SerialPort.write(val);
|
HC05_SerialPort.write(val);
|
||||||
|
@ -308,7 +314,7 @@ CBluetoothHC05::test(char val)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
CBluetoothHC05::decodeMACresponse(char* pResponse, int len)
|
CBluetoothHC05::_decodeMACresponse(char* pResponse, int len)
|
||||||
{
|
{
|
||||||
// decode ADDR response from a HC-05
|
// decode ADDR response from a HC-05
|
||||||
// NOTE:
|
// NOTE:
|
||||||
|
@ -364,6 +370,7 @@ CBluetoothHC05::decodeMACresponse(char* pResponse, int len)
|
||||||
}
|
}
|
||||||
if (deficit < 0) { // more than 12 digits! - WHOA!
|
if (deficit < 0) { // more than 12 digits! - WHOA!
|
||||||
strcpy(_MAC, "unknown");
|
strcpy(_MAC, "unknown");
|
||||||
|
_bGotMAC = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// build final colon separated MAC address
|
// build final colon separated MAC address
|
||||||
|
@ -375,7 +382,45 @@ CBluetoothHC05::decodeMACresponse(char* pResponse, int len)
|
||||||
*pDest++ = ':';
|
*pDest++ = ':';
|
||||||
}
|
}
|
||||||
*--pDest = 0; // step back and replace last colon with the null terminator!
|
*--pDest = 0; // step back and replace last colon with the null terminator!
|
||||||
|
_bGotMAC = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
const char*
|
||||||
|
CBluetoothHC05::getMAC()
|
||||||
|
{
|
||||||
|
if(!_bGotMAC) {
|
||||||
|
DebugPort.print(" Getting MAC address...");
|
||||||
|
_setCommandMode(true);
|
||||||
|
int len = 32;
|
||||||
|
char response[32];
|
||||||
|
if(!ATResponse("AT+ADDR?\r\n", "+ADDR:", response, len)) {
|
||||||
|
DebugPort.println("FAILED");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DebugPort.println("OK");
|
||||||
|
_decodeMACresponse(response, len);
|
||||||
|
DebugPort.print(" "); DebugPort.println(_MAC);
|
||||||
|
}
|
||||||
|
_setCommandMode(false);
|
||||||
|
}
|
||||||
|
return _MAC;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
CBluetoothHC05::_setCommandMode(bool commandMode)
|
||||||
|
{
|
||||||
|
if(commandMode) {
|
||||||
|
digitalWrite(_keyPin, HIGH); // request HC-05 module to enter command mode
|
||||||
|
delay(50);
|
||||||
|
_openSerial(BTRates[_BTbaudIdx]); // open serial port at a std. baud rate
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
digitalWrite(_keyPin, LOW); // request HC-05 module to enter data mode
|
||||||
|
delay(50);
|
||||||
|
_openSerial(9600); // virtual function, may call derived class method here
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -43,17 +43,20 @@ class CBluetoothHC05 : public CBluetoothAbstract {
|
||||||
CModerator foldbackModerator;
|
CModerator foldbackModerator;
|
||||||
char _MAC[32];
|
char _MAC[32];
|
||||||
bool _bTest;
|
bool _bTest;
|
||||||
|
bool _bGotMAC;
|
||||||
|
int _BTbaudIdx;
|
||||||
public:
|
public:
|
||||||
CBluetoothHC05(int keyPin, int sensePin);
|
CBluetoothHC05(int keyPin, int sensePin);
|
||||||
void begin();
|
void begin();
|
||||||
void send(const char* Str);
|
void send(const char* Str);
|
||||||
void check();
|
void check();
|
||||||
virtual bool isConnected();
|
virtual bool isConnected();
|
||||||
const char* getMAC() const { return _MAC; };
|
const char* getMAC();
|
||||||
virtual bool test(char); // returns true whilst test mode is active
|
virtual bool test(char); // returns true whilst test mode is active
|
||||||
protected:
|
protected:
|
||||||
virtual void openSerial(int baudrate);
|
virtual void _openSerial(int baudrate);
|
||||||
virtual void foldbackDesiredTemp();
|
virtual void _foldbackDesiredTemp();
|
||||||
void flush();
|
void _flush();
|
||||||
void decodeMACresponse(char* pResponse, int len);
|
void _decodeMACresponse(char* pResponse, int len);
|
||||||
|
void _setCommandMode(bool commandMode);
|
||||||
};
|
};
|
|
@ -117,9 +117,11 @@ CSetTimerScreen::show()
|
||||||
|
|
||||||
yPos = 39;
|
yPos = 39;
|
||||||
{
|
{
|
||||||
CTransientFont AF(_display, &arialItalic_7ptFontInfo);
|
if(_timerInfo.temperature) {
|
||||||
sprintf(str, "( %.1fHz )", calcPumpHz(_timerInfo.temperature));
|
CTransientFont AF(_display, &arialItalic_7ptFontInfo);
|
||||||
_printMenuText(_display.xCentre()+5, yPos, str, false, eLeftJustify);
|
sprintf(str, "( %.1fHz )", calcPumpHz(_timerInfo.temperature));
|
||||||
|
_printMenuText(64, yPos, str, false, eLeftJustify);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// control
|
// control
|
||||||
|
@ -140,6 +142,7 @@ CSetTimerScreen::show()
|
||||||
if(fTemp == 0) {
|
if(fTemp == 0) {
|
||||||
strcpy(str, "Current set ");
|
strcpy(str, "Current set ");
|
||||||
strcat(str, NVstore.getUserSettings().degF ? "`F" : "`C");
|
strcat(str, NVstore.getUserSettings().degF ? "`F" : "`C");
|
||||||
|
_printMenuText(_display.xCentre(), yPos, str, _rowSel==1 && _colSel==6, eCentreJustify);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(NVstore.getUserSettings().degF) {
|
if(NVstore.getUserSettings().degF) {
|
||||||
|
@ -149,8 +152,8 @@ CSetTimerScreen::show()
|
||||||
else {
|
else {
|
||||||
sprintf(str, "%.0f`C", fTemp);
|
sprintf(str, "%.0f`C", fTemp);
|
||||||
}
|
}
|
||||||
|
_printMenuText(59, yPos, str, _rowSel==1 && _colSel==6, eRightJustify);
|
||||||
}
|
}
|
||||||
_printMenuText(_display.xCentre(), yPos, str, _rowSel==1 && _colSel==6, eRightJustify);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "KeyPad.h"
|
#include "KeyPad.h"
|
||||||
#include "../Utility/helpers.h"
|
#include "../Utility/helpers.h"
|
||||||
#include "fonts/Arial.h"
|
#include "fonts/Arial.h"
|
||||||
#include "../WiFi/BTCWiFi.h"
|
#include "../WiFi/BTCWifi.h"
|
||||||
#include "../WiFi/BTCWebServer.h"
|
#include "../WiFi/BTCWebServer.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include "../Utility/NVStorage.h"
|
#include "../Utility/NVStorage.h"
|
||||||
#include "../Utility/helpers.h"
|
#include "../Utility/helpers.h"
|
||||||
#include "../Utility/DemandManager.h"
|
#include "../Utility/DemandManager.h"
|
||||||
#include "freertos/freertos.h"
|
#include <FreeRTOS.h>
|
||||||
|
|
||||||
//#define DEBUG_THERMOSTAT
|
//#define DEBUG_THERMOSTAT
|
||||||
|
|
||||||
|
|
|
@ -413,19 +413,17 @@ void updateJSONclients(bool report)
|
||||||
char jsonStr[800];
|
char jsonStr[800];
|
||||||
{
|
{
|
||||||
if(makeJSONString(JSONmoderator, jsonStr, sizeof(jsonStr))) {
|
if(makeJSONString(JSONmoderator, jsonStr, sizeof(jsonStr))) {
|
||||||
if (report) {
|
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
|
||||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
|
||||||
}
|
|
||||||
sendJSONtext(jsonStr);
|
sendJSONtext(jsonStr);
|
||||||
|
if (report) DebugPort.println(" Done");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// update extended params
|
// update extended params
|
||||||
{
|
{
|
||||||
if(makeJSONStringEx(JSONmoderator, jsonStr, sizeof(jsonStr))) {
|
if(makeJSONStringEx(JSONmoderator, jsonStr, sizeof(jsonStr))) {
|
||||||
if (report) {
|
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
|
||||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
|
||||||
}
|
|
||||||
sendJSONtext(jsonStr);
|
sendJSONtext(jsonStr);
|
||||||
|
if (report) DebugPort.println(" Done");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// update timer parameters
|
// update timer parameters
|
||||||
|
@ -433,10 +431,9 @@ void updateJSONclients(bool report)
|
||||||
for(int tmr=0; tmr<14; tmr++)
|
for(int tmr=0; tmr<14; tmr++)
|
||||||
{
|
{
|
||||||
if(makeJSONTimerString(tmr, jsonStr, sizeof(jsonStr))) {
|
if(makeJSONTimerString(tmr, jsonStr, sizeof(jsonStr))) {
|
||||||
if (report) {
|
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
|
||||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
|
||||||
}
|
|
||||||
sendJSONtext(jsonStr);
|
sendJSONtext(jsonStr);
|
||||||
|
if (report) DebugPort.println("Done");
|
||||||
bNewTimerInfo = true;
|
bNewTimerInfo = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -452,48 +449,43 @@ void updateJSONclients(bool report)
|
||||||
root.set("TimerRefresh", 1);
|
root.set("TimerRefresh", 1);
|
||||||
root.printTo(jsonStr, 800);
|
root.printTo(jsonStr, 800);
|
||||||
|
|
||||||
if (report) {
|
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
|
||||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
sendJSONtext(jsonStr);
|
||||||
}
|
if (report) DebugPort.println(" Done");
|
||||||
sendJSONtext(jsonStr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// report MQTT params
|
// report MQTT params
|
||||||
{
|
{
|
||||||
if(makeJSONStringMQTT(MQTTJSONmoderator, jsonStr, sizeof(jsonStr))) {
|
if(makeJSONStringMQTT(MQTTJSONmoderator, jsonStr, sizeof(jsonStr))) {
|
||||||
if (report) {
|
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
|
||||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
|
||||||
}
|
|
||||||
sendJSONtext(jsonStr);
|
sendJSONtext(jsonStr);
|
||||||
|
if (report) DebugPort.println(" Done");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// report IP params
|
// report IP params
|
||||||
{
|
{
|
||||||
if(makeJSONStringIP(IPmoderator, jsonStr, sizeof(jsonStr))) {
|
if(makeJSONStringIP(IPmoderator, jsonStr, sizeof(jsonStr))) {
|
||||||
if (report) {
|
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
|
||||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
|
||||||
}
|
|
||||||
sendJSONtext(jsonStr);
|
sendJSONtext(jsonStr);
|
||||||
|
if (report) DebugPort.println(" Done");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// report System info
|
// report System info
|
||||||
{
|
{
|
||||||
if(makeJSONStringSysInfo(SysModerator, jsonStr, sizeof(jsonStr))) {
|
if(makeJSONStringSysInfo(SysModerator, jsonStr, sizeof(jsonStr))) {
|
||||||
if (report) {
|
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
|
||||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
|
||||||
}
|
|
||||||
sendJSONtext(jsonStr);
|
sendJSONtext(jsonStr);
|
||||||
|
if (report) DebugPort.println(" Done");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
if(makeJSONStringGPIO(GPIOmoderator, jsonStr, sizeof(jsonStr))) {
|
if(makeJSONStringGPIO(GPIOmoderator, jsonStr, sizeof(jsonStr))) {
|
||||||
if (report) {
|
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
|
||||||
DebugPort.printf("JSON send: %s\r\n", jsonStr);
|
|
||||||
}
|
|
||||||
sendJSONtext(jsonStr);
|
sendJSONtext(jsonStr);
|
||||||
|
if (report) DebugPort.println(" Done");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -570,11 +562,14 @@ void Expand(std::string& str)
|
||||||
|
|
||||||
void sendJSONtext(const char* jsonStr)
|
void sendJSONtext(const char* jsonStr)
|
||||||
{
|
{
|
||||||
|
DebugPort.print("1");
|
||||||
sendWebSocketString( jsonStr );
|
sendWebSocketString( jsonStr );
|
||||||
|
DebugPort.print("2");
|
||||||
mqttPublishJSON(jsonStr);
|
mqttPublishJSON(jsonStr);
|
||||||
|
DebugPort.print("3");
|
||||||
std::string expand = jsonStr;
|
std::string expand = jsonStr;
|
||||||
Expand(expand);
|
Expand(expand);
|
||||||
getBluetoothClient().send( jsonStr );
|
getBluetoothClient().send( expand.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void doJSONreboot(uint16_t PIN)
|
void doJSONreboot(uint16_t PIN)
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
#include "../Utility/BTC_JSON.h"
|
#include "../Utility/BTC_JSON.h"
|
||||||
#include "../Utility/TempSense.h"
|
#include "../Utility/TempSense.h"
|
||||||
#include "../Utility/DemandManager.h"
|
#include "../Utility/DemandManager.h"
|
||||||
#include "freertos/freertos.h"
|
#include <FreeRTOS.h>
|
||||||
|
|
||||||
extern void DecodeCmd(const char* cmd, String& payload);
|
extern void DecodeCmd(const char* cmd, String& payload);
|
||||||
|
|
||||||
|
|
|
@ -500,14 +500,14 @@ bool sendWebSocketString(const char* Str)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bTxWebData = true; // OLED tx data animation flag
|
bTxWebData = true; // OLED tx data animation flag
|
||||||
webSocket.broadcastTXT(Str);
|
bool retval = webSocket.broadcastTXT(Str);
|
||||||
|
|
||||||
#ifdef WEBTIMES
|
#ifdef WEBTIMES
|
||||||
unsigned long tWeb = profile.elapsed(true);
|
unsigned long tWeb = profile.elapsed(true);
|
||||||
DebugPort.printf("Websend times : %ld,%ld\r\n", tCon, tWeb);
|
DebugPort.printf("Websend times : %ld,%ld\r\n", tCon, tWeb);
|
||||||
#endif
|
#endif
|
||||||
|
feedWatchdog();
|
||||||
return true;
|
return retval;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -137,8 +137,8 @@ bool initWifi()
|
||||||
// for STA+AP mode we *must* use the same RF channel as STA
|
// for STA+AP mode we *must* use the same RF channel as STA
|
||||||
DebugPort.println("Starting AP mode");
|
DebugPort.println("Starting AP mode");
|
||||||
WiFi.softAP(creds.APSSID, creds.APpassword, chnl);
|
WiFi.softAP(creds.APSSID, creds.APpassword, chnl);
|
||||||
DebugPort.printf(" AP SSID: %s\r\n", WiFi.softAPgetHostname());
|
// DebugPort.printf(" AP SSID: %s\r\n", WiFi.softAPgetHostname());
|
||||||
DebugPort.printf(" AP IP address: %s\r\n", getWifiAPAddrStr());
|
// DebugPort.printf(" AP IP address: %s\r\n", getWifiAPAddrStr());
|
||||||
DebugPort.printf("WifiMode after initWifi = %d\r\n", WiFi.getMode());
|
DebugPort.printf("WifiMode after initWifi = %d\r\n", WiFi.getMode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ bool initWifi()
|
||||||
}
|
}
|
||||||
|
|
||||||
// WiFi.setTxPower(WIFI_POWER_MINUS_1dBm);
|
// WiFi.setTxPower(WIFI_POWER_MINUS_1dBm);
|
||||||
WiFi.setTxPower(WIFI_POWER_19_5dBm);
|
// WiFi.setTxPower(WIFI_POWER_19_5dBm);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,8 +31,8 @@
|
||||||
#include "../Utility/MODBUS-CRC16.h"
|
#include "../Utility/MODBUS-CRC16.h"
|
||||||
#include "esp_ota_ops.h"
|
#include "esp_ota_ops.h"
|
||||||
|
|
||||||
//#define TESTFOTA
|
// #define TESTFOTA
|
||||||
//#define SYNCHRONOUS_FOTA
|
// #define SYNCHRONOUS_FOTA
|
||||||
|
|
||||||
bool CheckFirmwareCRC(int filesize);
|
bool CheckFirmwareCRC(int filesize);
|
||||||
void onSuccess();
|
void onSuccess();
|
||||||
|
@ -86,7 +86,7 @@ void initOTA(){
|
||||||
static int prevPC = 0;
|
static int prevPC = 0;
|
||||||
if(percent != prevPC) {
|
if(percent != prevPC) {
|
||||||
prevPC = percent;
|
prevPC = percent;
|
||||||
DebugPort.printf("Progress: %u%%\r", percent);
|
DebugPort.printf("OTA progress: %u%%\r\n", percent);
|
||||||
DebugPort.handle(); // keep telnet spy alive
|
DebugPort.handle(); // keep telnet spy alive
|
||||||
ShowOTAScreen(percent);
|
ShowOTAScreen(percent);
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ void onWebProgress(size_t progress, size_t total)
|
||||||
static int prevPC = 0;
|
static int prevPC = 0;
|
||||||
if(percent != prevPC) {
|
if(percent != prevPC) {
|
||||||
prevPC = percent;
|
prevPC = percent;
|
||||||
DebugPort.printf("Progress: %u%%\r", percent);
|
DebugPort.printf("Web progress: %u%%\r\n", percent);
|
||||||
DebugPort.handle(); // keep telnet spy alive
|
DebugPort.handle(); // keep telnet spy alive
|
||||||
ShowOTAScreen(percent, eOTAWWW);
|
ShowOTAScreen(percent, eOTAWWW);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ sBrowserUpload::init()
|
||||||
Update
|
Update
|
||||||
.onProgress([](unsigned int progress, unsigned int total) {
|
.onProgress([](unsigned int progress, unsigned int total) {
|
||||||
int percent = (progress / (total / 100));
|
int percent = (progress / (total / 100));
|
||||||
DebugPort.printf("Progress: %u%%\r", percent);
|
DebugPort.printf("Browser progress: %u%%\r\n", percent);
|
||||||
DebugPort.handle(); // keep telnet spy alive
|
DebugPort.handle(); // keep telnet spy alive
|
||||||
ShowOTAScreen(percent, eOTAWWW); // WWW update in place
|
ShowOTAScreen(percent, eOTAWWW); // WWW update in place
|
||||||
DebugPort.print("^");
|
DebugPort.print("^");
|
||||||
|
@ -118,6 +118,9 @@ sBrowserUpload::fragment(HTTPUpload& upload)
|
||||||
::SPIFFS.remove(SrcFile.name.c_str()); // remove the bad file from SPIFFS
|
::SPIFFS.remove(SrcFile.name.c_str()); // remove the bad file from SPIFFS
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
#ifdef SSL_SERVER
|
||||||
|
upload.totalSize += upload.currentSize;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -127,6 +130,9 @@ sBrowserUpload::fragment(HTTPUpload& upload)
|
||||||
Update.printError(DebugPort);
|
Update.printError(DebugPort);
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
|
#ifdef SSL_SERVER
|
||||||
|
upload.totalSize += upload.currentSize;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
return upload.totalSize;
|
return upload.totalSize;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +146,7 @@ sBrowserUpload::end(HTTPUpload& upload)
|
||||||
// Close the file if still open (did not encounter write error)
|
// Close the file if still open (did not encounter write error)
|
||||||
if(DstFile.file) {
|
if(DstFile.file) {
|
||||||
DstFile.file.close();
|
DstFile.file.close();
|
||||||
DebugPort.printf("Final SPIFFS upload Size: %d\r\n", upload.totalSize);
|
DebugPort.printf("\r\nFinal SPIFFS upload Size: %d\r\n", upload.totalSize);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// file already closed indicates we encountered a write error
|
// file already closed indicates we encountered a write error
|
||||||
|
@ -152,12 +158,13 @@ sBrowserUpload::end(HTTPUpload& upload)
|
||||||
// check the added CRC we genertaed matches
|
// check the added CRC we genertaed matches
|
||||||
// - this helps guard against malicious, badly formatted bin file attempts.
|
// - this helps guard against malicious, badly formatted bin file attempts.
|
||||||
if(!CheckFirmwareCRC(SrcFile.size)) {
|
if(!CheckFirmwareCRC(SrcFile.size)) {
|
||||||
|
DebugPort.printf("\r\nCRC fail: %s, %d bytes\r\nRebooting...\r\n", SrcFile.name.c_str(), upload.totalSize);
|
||||||
Update.abort();
|
Update.abort();
|
||||||
retval = -4;
|
retval = -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Update.end()) {
|
if (Update.end()) {
|
||||||
DebugPort.printf("Update Success: %s, %d bytes\r\nRebooting...\r\n", SrcFile.name.c_str(), upload.totalSize);
|
DebugPort.printf("\r\nUpdate Success: %s, %d bytes\r\nRebooting...\r\n", SrcFile.name.c_str(), upload.totalSize);
|
||||||
} else {
|
} else {
|
||||||
Update.printError(DebugPort);
|
Update.printError(DebugPort);
|
||||||
if(retval == upload.totalSize) {
|
if(retval == upload.totalSize) {
|
||||||
|
|