Found websocket write was blocking, returning 0, leading to WD reboot. Need to think of proper fix

This commit is contained in:
Ray Jones 2020-04-20 13:39:39 +10:00
parent 67998747d7
commit b58ed90432
47 changed files with 180 additions and 99 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 74 KiB

After

Width:  |  Height:  |  Size: 500 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 581 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 111 KiB

After

Width:  |  Height:  |  Size: 650 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 106 KiB

After

Width:  |  Height:  |  Size: 633 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 166 KiB

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 554 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 661 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 692 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 123 KiB

After

Width:  |  Height:  |  Size: 766 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 126 KiB

After

Width:  |  Height:  |  Size: 676 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 630 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 637 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 134 KiB

After

Width:  |  Height:  |  Size: 633 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 468 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 469 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 749 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 130 KiB

After

Width:  |  Height:  |  Size: 934 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

After

Width:  |  Height:  |  Size: 792 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 658 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 87 KiB

After

Width:  |  Height:  |  Size: 589 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 93 KiB

After

Width:  |  Height:  |  Size: 425 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

After

Width:  |  Height:  |  Size: 463 KiB

Binary file not shown.

View File

@ -617,27 +617,32 @@ size_t WebSockets::write(WSclient_t * client, uint8_t *out, size_t n) {
while(n > 0) {
if(client->tcp == NULL) {
DEBUG_WEBSOCKETS("[write] tcp is null!\n");
Serial.printf("\n%ld write tcp is null!\n", millis());
break;
}
if(!client->tcp->connected()) {
DEBUG_WEBSOCKETS("[write] not connected!\n");
Serial.printf("\n%ld write not connected!\n", millis());
break;
}
if((millis() - t) > WEBSOCKETS_TCP_TIMEOUT) {
DEBUG_WEBSOCKETS("[write] write TIMEOUT! %lu\n", (millis() - t));
Serial.printf("\n%ld write TIMEOUT!\n", millis());
break;
}
len = client->tcp->write((const uint8_t*)out, n);
if(len) {
if(len > 0) { // RLJ -1 returned?
t = millis();
out += len;
n -= len;
total += len;
//DEBUG_WEBSOCKETS("write %d left %d!\n", len, n);
} 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);
}
#if (WEBSOCKETS_NETWORK_TYPE == NETWORK_ESP8266)

View File

@ -25,6 +25,9 @@
#include "WebSockets.h"
#include "WebSocketsServer.h"
extern void feedWatchdog();
WebSocketsServer::WebSocketsServer(uint16_t port, String origin, String protocol) {
_port = port;
_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++) {
client = &_clients[i];
if(clientIsConnected(client)) {
feedWatchdog();
if(!sendFrame(client, WSop_text, payload, length, true, headerToPayload)) {
feedWatchdog();
Serial.println("\n \007STOPPING CLIENT");
disconnect(i);
ret = false;
}
}

View File

@ -14,15 +14,20 @@ platform = espressif32
board = esp32dev
framework = arduino
board_build.partitions = ABpartition.csv
upload_speed = 921600
;upload_protocol = espota
;upload_port = 192.168.20.120
;upload_flags =
; --port=3232
upload_port = COM14
;upload_port = COM5
; ; Options to use OTA upload
; upload_protocol = espota
; upload_port = 192.168.20.116
; upload_flags =
; --port=3232
; Options to use serial upload
upload_protocol = esptool
;monitor_speed = 115200
; upload_port = COM5
upload_port = COM14
upload_speed = 921600
monitor_speed = 115200
extra_scripts = post:add_CRC.py
; replace shitty Arduino millis with a linear time version
build_flags =

View File

@ -129,7 +129,7 @@
const int FirmwareRevision = 32;
const int FirmwareSubRevision = 0;
const int FirmwareMinorRevision = 4;
const int FirmwareMinorRevision = 5;
const char* FirmwareDate = "11 Apr 2020";
@ -173,6 +173,7 @@ int DS18B20holdoff = 2;
int BoardRevision = 0;
bool bTestBTModule = false;
bool bSetupMQTT = false;
bool bReportStack = false;
unsigned long lastAnimationTime; // used to sequence updates to LCD for animation
@ -289,7 +290,7 @@ void parentKeyHandler(uint8_t event)
void interruptReboot()
{
ets_printf("Software watchdog reboot......\r\n");
ets_printf("%ld Software watchdog reboot......\r\n", millis());
esp_restart();
}
@ -447,10 +448,10 @@ void setup() {
initOTA();
}
#endif // USE_OTA
initFOTA();
#if USE_WEBSERVER == 1
initWebServer();
#endif // USE_WEBSERVER
initFOTA();
#if USE_MQTT == 1
mqttInit();
#endif // USE_MQTT
@ -871,6 +872,11 @@ void loop()
if(tDelta > MIN_TEMPERATURE_INTERVAL) { // maintain a minimum holdoff period
lastTemperatureTime = millis(); // reset time to observe temeprature
if(bReportStack) {
int stackdepth = uxTaskGetStackHighWaterMark(NULL);
DebugPort.printf("Stack : %d\r\n", stackdepth);
}
TempSensor.readSensors();
if(TempSensor.getTemperature(0, fTemperature)) { // get Primary sensor temperature
if(DS18B20holdoff) {
@ -1377,15 +1383,18 @@ void checkDebugCommands()
else if(rxVal == 'h') {
getWebContent(true);
}
else if(rxVal == 'r') {
ESP.restart(); // reset the esp
else if(rxVal == ('b' & 0x1f)) { // CTRL-B Tst Mdoe: bluetooth module route
bTestBTModule = !bTestBTModule;
Bluetooth.test(bTestBTModule ? 0xff : 0x00); // special enter or leave BT test commands
}
else if(rxVal == ('h' & 0x1f)) { // CTRL-H hourmeter reset
pHourMeter->resetHard();
}
else if(rxVal == ('b' & 0x1f)) { // CTRL-B Tst Mdoe: bluetooth module route
bTestBTModule = !bTestBTModule;
Bluetooth.test(bTestBTModule ? 0xff : 0x00); // special enter or leave BT test commands
else if(rxVal == ('r' & 0x1f)) { // CTRL-R reboot
ESP.restart(); // reset the esp
}
else if(rxVal == ('s' & 0x1f)) { // CTRL-B Test Mode: bluetooth module route
bReportStack = !bReportStack;
}
}
#ifdef PROTOCOL_INVESTIGATION
@ -1613,6 +1622,8 @@ void feedWatchdog()
{
#if USE_SW_WATCHDOG == 1 && USE_JTAG == 0
// BEST NOT USE WATCHDOG WITH JTAG DEBUG :-)
// DebugPort.printf("\r %ld Watchdog fed", millis());
DebugPort.print("~");
WatchdogTick = 1500;
#else
WatchdogTick = -1;

View File

@ -45,7 +45,7 @@ public:
}
};
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
};

View File

@ -46,7 +46,7 @@ CBluetoothESP32HC05::CBluetoothESP32HC05(int keyPin, int sensePin, int rxPin, in
}
void
CBluetoothESP32HC05::openSerial(int baudrate)
CBluetoothESP32HC05::_openSerial(int baudrate)
{
// Open Serial port on the ESP32
// best to explicitly specify pins for the pin multiplexer!

View File

@ -28,7 +28,7 @@ class CBluetoothESP32HC05 : public CBluetoothHC05 {
public:
CBluetoothESP32HC05(int keyPin, int sensePin, int rxPin, int txPin);
protected:
void openSerial(int baudrate);
void _openSerial(int baudrate);
};
#if USE_CLASSIC_BLUETOOTH == 1

View File

@ -28,6 +28,11 @@
// 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
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 :-)
pinMode(_sensePin, INPUT);
_bTest = false;
_bGotMAC = false;
_BTbaudIdx = 0;
strcpy(_MAC, "unknown");
}
@ -48,27 +55,24 @@ CBluetoothHC05::CBluetoothHC05(int keyPin, int sensePin)
void
CBluetoothHC05::begin()
{
const int BTRates[] = {
9600, 38400, 115200, 19200, 57600, 2400, 4800, 1200
};
_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...");
int BTidx = 0;
// int BTidx = 0;
int maxTries = sizeof(BTRates)/sizeof(int);
for(BTidx = 0; BTidx < maxTries; BTidx++) {
DebugPort.printf(" @ %d baud... ", BTRates[BTidx]);
openSerial(BTRates[BTidx]); // open serial port at a std. baud rate
for(_BTbaudIdx = 0; _BTbaudIdx < maxTries; _BTbaudIdx++) {
DebugPort.printf(" @ %d baud... ", BTRates[_BTbaudIdx]);
_openSerial(BTRates[_BTbaudIdx]); // open serial port at a std. baud rate
delay(10);
flush();
_flush();
HC05_SerialPort.print("AT\r\n"); // clear the throat!
delay(100);
HC05_SerialPort.setTimeout(100);
@ -90,7 +94,7 @@ CBluetoothHC05::begin()
}
DebugPort.println("");
if(BTidx == maxTries) {
if(_BTbaudIdx == maxTries) {
// 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...
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...
// 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)");
openSerial(9600);
// _openSerial(9600);
_BTbaudIdx = 0;
_setCommandMode(false);
}
else {
// found a HC-05 module at one of its supported baud rates.
@ -137,7 +143,7 @@ CBluetoothHC05::begin()
}
else {
DebugPort.println("OK");
decodeMACresponse(response, len);
_decodeMACresponse(response, len);
DebugPort.print(" "); DebugPort.println(_MAC);
}
/*
@ -156,9 +162,9 @@ CBluetoothHC05::begin()
else {
DebugPort.println("OK");
}*/
flush();
_flush();
delay(100);
openSerial(9600);
_openSerial(9600);
// leave HC-05 command mode, return to data mode
digitalWrite(_keyPin, LOW);
@ -166,7 +172,7 @@ CBluetoothHC05::begin()
}
delay(50);
flush(); // ensure any AT command reponse dribbles are cleaned up!
_flush(); // ensure any AT command reponse dribbles are cleaned up!
DebugPort.println("");
}
@ -205,7 +211,7 @@ CBluetoothHC05::send(const char* Str)
}
void
CBluetoothHC05::openSerial(int baudrate)
CBluetoothHC05::_openSerial(int baudrate)
{
// standard serial port for Due, Mega (ESP32 uses virtual, derived from this class)
HC05_SerialPort.begin(baudrate);
@ -216,7 +222,7 @@ bool
CBluetoothHC05::ATCommand(const char* cmd)
{
if(!_bTest) {
flush(); // ensure response is for *this* command!
_flush(); // ensure response is for *this* command!
HC05_SerialPort.print(cmd);
char RxBuffer[16];
memset(RxBuffer, 0, 16);
@ -233,7 +239,7 @@ bool
CBluetoothHC05::ATResponse(const char* cmd, const char* respHdr, char* response, int& len)
{
if(!_bTest) {
flush(); // ensure response is for *this* command!
_flush(); // ensure response is for *this* command!
HC05_SerialPort.print(cmd);
memset(response, 0, len);
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
CBluetoothHC05::foldbackDesiredTemp()
CBluetoothHC05::_foldbackDesiredTemp()
{
StaticJsonBuffer<32> jsonBuffer; // create a JSON buffer on the stack
JsonObject& root = jsonBuffer.createObject(); // create object to add JSON commands to
@ -261,7 +267,7 @@ CBluetoothHC05::foldbackDesiredTemp()
}
void
CBluetoothHC05::flush()
CBluetoothHC05::_flush()
{
while(HC05_SerialPort.available())
HC05_SerialPort.read();
@ -283,18 +289,18 @@ CBluetoothHC05::test(char val)
else if(val == ('b' & 0x1f)) { // CTRL-B - leave bluetooth test mode
DebugPort.println("LEAVING Test Bluetooth mode");
digitalWrite(_keyPin, LOW); // request HC-05 module to enter command mode
openSerial(9600);
_openSerial(9600);
_bTest = false;
}
else if(val == ('c' & 0x1f)) { // CTRL-C - data mode
DebugPort.println("Test Bluetooth 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
DebugPort.println("Test Bluetooth DATA mode");
digitalWrite(_keyPin, LOW); // request HC-05 module to enter command mode
openSerial(9600);
_openSerial(9600);
}
else {
HC05_SerialPort.write(val);
@ -308,7 +314,7 @@ CBluetoothHC05::test(char val)
}
void
CBluetoothHC05::decodeMACresponse(char* pResponse, int len)
CBluetoothHC05::_decodeMACresponse(char* pResponse, int len)
{
// decode ADDR response from a HC-05
// NOTE:
@ -364,6 +370,7 @@ CBluetoothHC05::decodeMACresponse(char* pResponse, int len)
}
if (deficit < 0) { // more than 12 digits! - WHOA!
strcpy(_MAC, "unknown");
_bGotMAC = false;
}
else {
// build final colon separated MAC address
@ -375,7 +382,45 @@ CBluetoothHC05::decodeMACresponse(char* pResponse, int len)
*pDest++ = ':';
}
*--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

View File

@ -43,17 +43,20 @@ class CBluetoothHC05 : public CBluetoothAbstract {
CModerator foldbackModerator;
char _MAC[32];
bool _bTest;
bool _bGotMAC;
int _BTbaudIdx;
public:
CBluetoothHC05(int keyPin, int sensePin);
void begin();
void send(const char* Str);
void check();
virtual bool isConnected();
const char* getMAC() const { return _MAC; };
const char* getMAC();
virtual bool test(char); // returns true whilst test mode is active
protected:
virtual void openSerial(int baudrate);
virtual void foldbackDesiredTemp();
void flush();
void decodeMACresponse(char* pResponse, int len);
virtual void _openSerial(int baudrate);
virtual void _foldbackDesiredTemp();
void _flush();
void _decodeMACresponse(char* pResponse, int len);
void _setCommandMode(bool commandMode);
};

View File

@ -117,9 +117,11 @@ CSetTimerScreen::show()
yPos = 39;
{
CTransientFont AF(_display, &arialItalic_7ptFontInfo);
sprintf(str, "( %.1fHz )", calcPumpHz(_timerInfo.temperature));
_printMenuText(_display.xCentre()+5, yPos, str, false, eLeftJustify);
if(_timerInfo.temperature) {
CTransientFont AF(_display, &arialItalic_7ptFontInfo);
sprintf(str, "( %.1fHz )", calcPumpHz(_timerInfo.temperature));
_printMenuText(64, yPos, str, false, eLeftJustify);
}
}
// control
@ -140,6 +142,7 @@ CSetTimerScreen::show()
if(fTemp == 0) {
strcpy(str, "Current set ");
strcat(str, NVstore.getUserSettings().degF ? "`F" : "`C");
_printMenuText(_display.xCentre(), yPos, str, _rowSel==1 && _colSel==6, eCentreJustify);
}
else {
if(NVstore.getUserSettings().degF) {
@ -149,8 +152,8 @@ CSetTimerScreen::show()
else {
sprintf(str, "%.0f`C", fTemp);
}
_printMenuText(59, yPos, str, _rowSel==1 && _colSel==6, eRightJustify);
}
_printMenuText(_display.xCentre(), yPos, str, _rowSel==1 && _colSel==6, eRightJustify);

View File

@ -24,7 +24,7 @@
#include "KeyPad.h"
#include "../Utility/helpers.h"
#include "fonts/Arial.h"
#include "../WiFi/BTCWiFi.h"
#include "../WiFi/BTCWifi.h"
#include "../WiFi/BTCWebServer.h"

View File

@ -23,7 +23,7 @@
#include "../Utility/NVStorage.h"
#include "../Utility/helpers.h"
#include "../Utility/DemandManager.h"
#include "freertos/freertos.h"
#include <FreeRTOS.h>
//#define DEBUG_THERMOSTAT

View File

@ -413,19 +413,17 @@ void updateJSONclients(bool report)
char jsonStr[800];
{
if(makeJSONString(JSONmoderator, jsonStr, sizeof(jsonStr))) {
if (report) {
DebugPort.printf("JSON send: %s\r\n", jsonStr);
}
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
sendJSONtext(jsonStr);
if (report) DebugPort.println(" Done");
}
}
// update extended params
{
if(makeJSONStringEx(JSONmoderator, jsonStr, sizeof(jsonStr))) {
if (report) {
DebugPort.printf("JSON send: %s\r\n", jsonStr);
}
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
sendJSONtext(jsonStr);
if (report) DebugPort.println(" Done");
}
}
// update timer parameters
@ -433,10 +431,9 @@ void updateJSONclients(bool report)
for(int tmr=0; tmr<14; tmr++)
{
if(makeJSONTimerString(tmr, jsonStr, sizeof(jsonStr))) {
if (report) {
DebugPort.printf("JSON send: %s\r\n", jsonStr);
}
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
sendJSONtext(jsonStr);
if (report) DebugPort.println("Done");
bNewTimerInfo = true;
}
}
@ -452,48 +449,43 @@ void updateJSONclients(bool report)
root.set("TimerRefresh", 1);
root.printTo(jsonStr, 800);
if (report) {
DebugPort.printf("JSON send: %s\r\n", jsonStr);
}
sendJSONtext(jsonStr);
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
sendJSONtext(jsonStr);
if (report) DebugPort.println(" Done");
}
// report MQTT params
{
if(makeJSONStringMQTT(MQTTJSONmoderator, jsonStr, sizeof(jsonStr))) {
if (report) {
DebugPort.printf("JSON send: %s\r\n", jsonStr);
}
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
sendJSONtext(jsonStr);
if (report) DebugPort.println(" Done");
}
}
// report IP params
{
if(makeJSONStringIP(IPmoderator, jsonStr, sizeof(jsonStr))) {
if (report) {
DebugPort.printf("JSON send: %s\r\n", jsonStr);
}
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
sendJSONtext(jsonStr);
if (report) DebugPort.println(" Done");
}
}
// report System info
{
if(makeJSONStringSysInfo(SysModerator, jsonStr, sizeof(jsonStr))) {
if (report) {
DebugPort.printf("JSON send: %s\r\n", jsonStr);
}
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
sendJSONtext(jsonStr);
if (report) DebugPort.println(" Done");
}
}
{
if(makeJSONStringGPIO(GPIOmoderator, jsonStr, sizeof(jsonStr))) {
if (report) {
DebugPort.printf("JSON send: %s\r\n", jsonStr);
}
if (report) DebugPort.printf(" %ld JSON send: %s", millis(), jsonStr);
sendJSONtext(jsonStr);
if (report) DebugPort.println(" Done");
}
}
@ -570,11 +562,14 @@ void Expand(std::string& str)
void sendJSONtext(const char* jsonStr)
{
DebugPort.print("1");
sendWebSocketString( jsonStr );
DebugPort.print("2");
mqttPublishJSON(jsonStr);
DebugPort.print("3");
std::string expand = jsonStr;
Expand(expand);
getBluetoothClient().send( jsonStr );
getBluetoothClient().send( expand.c_str() );
}
void doJSONreboot(uint16_t PIN)

View File

@ -39,7 +39,7 @@
#include "../Utility/BTC_JSON.h"
#include "../Utility/TempSense.h"
#include "../Utility/DemandManager.h"
#include "freertos/freertos.h"
#include <FreeRTOS.h>
extern void DecodeCmd(const char* cmd, String& payload);

View File

@ -500,14 +500,14 @@ bool sendWebSocketString(const char* Str)
#endif
bTxWebData = true; // OLED tx data animation flag
webSocket.broadcastTXT(Str);
bool retval = webSocket.broadcastTXT(Str);
#ifdef WEBTIMES
unsigned long tWeb = profile.elapsed(true);
DebugPort.printf("Websend times : %ld,%ld\r\n", tCon, tWeb);
#endif
return true;
feedWatchdog();
return retval;
}
return false;
}

View File

@ -137,8 +137,8 @@ bool initWifi()
// for STA+AP mode we *must* use the same RF channel as STA
DebugPort.println("Starting AP mode");
WiFi.softAP(creds.APSSID, creds.APpassword, chnl);
DebugPort.printf(" AP SSID: %s\r\n", WiFi.softAPgetHostname());
DebugPort.printf(" AP IP address: %s\r\n", getWifiAPAddrStr());
// DebugPort.printf(" AP SSID: %s\r\n", WiFi.softAPgetHostname());
// DebugPort.printf(" AP IP address: %s\r\n", getWifiAPAddrStr());
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_19_5dBm);
// WiFi.setTxPower(WIFI_POWER_19_5dBm);
return retval;
}

View File

@ -31,8 +31,8 @@
#include "../Utility/MODBUS-CRC16.h"
#include "esp_ota_ops.h"
//#define TESTFOTA
//#define SYNCHRONOUS_FOTA
// #define TESTFOTA
// #define SYNCHRONOUS_FOTA
bool CheckFirmwareCRC(int filesize);
void onSuccess();
@ -86,7 +86,7 @@ void initOTA(){
static int prevPC = 0;
if(percent != prevPC) {
prevPC = percent;
DebugPort.printf("Progress: %u%%\r", percent);
DebugPort.printf("OTA progress: %u%%\r\n", percent);
DebugPort.handle(); // keep telnet spy alive
ShowOTAScreen(percent);
}
@ -247,7 +247,7 @@ void onWebProgress(size_t progress, size_t total)
static int prevPC = 0;
if(percent != prevPC) {
prevPC = percent;
DebugPort.printf("Progress: %u%%\r", percent);
DebugPort.printf("Web progress: %u%%\r\n", percent);
DebugPort.handle(); // keep telnet spy alive
ShowOTAScreen(percent, eOTAWWW);
}

View File

@ -35,7 +35,7 @@ sBrowserUpload::init()
Update
.onProgress([](unsigned int progress, unsigned int total) {
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
ShowOTAScreen(percent, eOTAWWW); // WWW update in place
DebugPort.print("^");
@ -118,6 +118,9 @@ sBrowserUpload::fragment(HTTPUpload& upload)
::SPIFFS.remove(SrcFile.name.c_str()); // remove the bad file from SPIFFS
return -2;
}
#ifdef SSL_SERVER
upload.totalSize += upload.currentSize;
#endif
}
}
else {
@ -127,6 +130,9 @@ sBrowserUpload::fragment(HTTPUpload& upload)
Update.printError(DebugPort);
return -3;
}
#ifdef SSL_SERVER
upload.totalSize += upload.currentSize;
#endif
}
return upload.totalSize;
}
@ -140,7 +146,7 @@ sBrowserUpload::end(HTTPUpload& upload)
// Close the file if still open (did not encounter write error)
if(DstFile.file) {
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 {
// file already closed indicates we encountered a write error
@ -152,12 +158,13 @@ sBrowserUpload::end(HTTPUpload& upload)
// check the added CRC we genertaed matches
// - this helps guard against malicious, badly formatted bin file attempts.
if(!CheckFirmwareCRC(SrcFile.size)) {
DebugPort.printf("\r\nCRC fail: %s, %d bytes\r\nRebooting...\r\n", SrcFile.name.c_str(), upload.totalSize);
Update.abort();
retval = -4;
}
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 {
Update.printError(DebugPort);
if(retval == upload.totalSize) {