mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-03-30 08:52:11 +02:00
fix crash
This commit is contained in:
parent
88fdfa577a
commit
c94819e928
11 changed files with 40 additions and 13 deletions
|
|
@ -87,3 +87,5 @@ pio pkg exec -p tool-esptoolpy -- esptool.py --port COM9 read_flash 0x3F0000 0x1
|
|||
|
||||
|
||||
esp-coredump info_corefile --core coredump.bin --core-format=raw --gdb C:\Users\oem\.platformio\packages\toolchain-xtensa-esp32\bin\xtensa-esp32-elf-gdb.exe .pio\build\esp32dev\firmware.elf > coredump_report.txt
|
||||
|
||||
C:\Users\oem\.platformio\packages\framework-espidf\export.ps1
|
||||
|
|
@ -246,6 +246,8 @@
|
|||
<span id="spanMaxMemory" style="text-align:right;width:120px;"></span>
|
||||
<span style="text-align:right;display:inline-block;color:#00bcd4;">Min: </span>
|
||||
<span id="spanMinMemory" style="text-align:right;width:120px;"></span>
|
||||
<span style="text-align:right;display:inline-block;color:#00bcd4;">Uptime: </span>
|
||||
<span id="spanUptime" style="text-align:right;width:120px;"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="button-container">
|
||||
|
|
|
|||
|
|
@ -4385,6 +4385,8 @@ class Firmware {
|
|||
if (sp) sp.innerHTML = mem.max.fmt('#,##0');
|
||||
sp = document.getElementById('spanMinMemory');
|
||||
if (sp) sp.innerHTML = mem.min.fmt('#,##0');
|
||||
sp = document.getElementById('spanUptime');
|
||||
if (sp) sp.innerHTML = mem.uptime / 3600000;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -691,6 +691,7 @@ void Network::emitHeap(uint8_t num) {
|
|||
json->addElem("free", freeHeap);
|
||||
json->addElem("min", minHeap);
|
||||
json->addElem("total", ESP.getHeapSize());
|
||||
json->addElem("uptime", (uint64_t)millis());
|
||||
json->endObject();
|
||||
if(num == 255 && bTimeEmit && bValEmit) {
|
||||
sockEmit.endEmit(num);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ void SocketEmitter::startup() {
|
|||
}
|
||||
void SocketEmitter::begin() {
|
||||
sockServer.begin();
|
||||
sockServer.enableHeartbeat(20000, 10000, 3);
|
||||
sockServer.enableHeartbeat(3000, 2000, 2);
|
||||
sockServer.onEvent(this->wsEvent);
|
||||
Serial.println("Socket Server Started...");
|
||||
//settings.printAvailHeap();
|
||||
|
|
@ -90,7 +90,7 @@ JsonSockEvent *SocketEmitter::beginEmit(const char *evt) {
|
|||
this->json.beginEvent(&sockServer, evt, g_response, sizeof(g_response));
|
||||
return &this->json;
|
||||
}
|
||||
void SocketEmitter::endEmit(uint8_t num) { this->json.endEvent(num); sockServer.loop(); }
|
||||
void SocketEmitter::endEmit(uint8_t num) { this->json.endEvent(num); esp_task_wdt_reset(); sockServer.loop(); }
|
||||
void SocketEmitter::endEmitRoom(uint8_t room) {
|
||||
if(room < SOCK_MAX_ROOMS) {
|
||||
room_t *r = &this->rooms[room];
|
||||
|
|
|
|||
|
|
@ -1447,9 +1447,9 @@ void SomfyRoom::unpublish() {
|
|||
}
|
||||
void SomfyShade::publishState() {
|
||||
if(mqtt.connected()) {
|
||||
this->publish("position", this->transformPosition(this->currentPos), true);
|
||||
this->publish("direction", this->direction, true);
|
||||
this->publish("target", this->transformPosition(this->target), true);
|
||||
this->publish("position", (uint8_t)50, true);
|
||||
this->publish("direction", (int8_t)0, true);
|
||||
this->publish("target", (uint8_t)50, true);
|
||||
this->publish("lastRollingCode", this->lastRollingCode);
|
||||
this->publish("mypos", this->transformPosition(this->myPos), true);
|
||||
this->publish("myTiltPos", this->transformPosition(this->myTiltPos), true);
|
||||
|
|
@ -1796,7 +1796,7 @@ bool SomfyGroup::publish(const char *topic, bool val, bool retain) {
|
|||
float SomfyShade::p_currentPos(float pos) {
|
||||
float old = this->currentPos;
|
||||
this->currentPos = pos;
|
||||
if(floor(old) != floor(pos)) this->publish("position", this->transformPosition(static_cast<uint8_t>(floor(this->currentPos))));
|
||||
if(floor(old) != floor(pos)) this->publish("position", (uint8_t)50);
|
||||
return old;
|
||||
}
|
||||
float SomfyShade::p_currentTiltPos(float pos) {
|
||||
|
|
@ -2894,6 +2894,17 @@ void SomfyShade::sendCommand(somfy_commands cmd, uint8_t repeat, uint8_t stepSiz
|
|||
// This sendCommand function will always be called externally. sendCommand at the remote level
|
||||
// is expected to be called internally when the motor needs commanded.
|
||||
if(this->bitLength == 0) this->bitLength = somfy.transceiver.config.type;
|
||||
// If same direction command sent while already moving, stop the state tracking.
|
||||
// The real motor stops on its own when it receives the same direction again.
|
||||
if((cmd == somfy_commands::Up && this->direction == -1) ||
|
||||
(cmd == somfy_commands::Down && this->direction == 1)) {
|
||||
Serial.println("Same command as dir");
|
||||
SomfyRemote::sendCommand(cmd, repeat);
|
||||
this->p_target(this->currentPos);
|
||||
this->p_tiltTarget(this->currentTiltPos);
|
||||
this->setMovement(0);
|
||||
return;
|
||||
}
|
||||
if(cmd == somfy_commands::Up) {
|
||||
if(this->tiltType == tilt_types::euromode) {
|
||||
// In euromode we need to long press for 2 seconds on the
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ enum class radio_proto : byte { // Ordinal byte 0-255
|
|||
};
|
||||
enum class somfy_commands : byte {
|
||||
Unknown0 = 0x0,
|
||||
My = 0x1,
|
||||
Up = 0x2,
|
||||
MyUp = 0x3,
|
||||
Down = 0x4,
|
||||
My = 0x2,//DOWN
|
||||
Up = 0x1,
|
||||
MyUp = 0x4, //up
|
||||
Down = 0x3,
|
||||
MyDown = 0x5,
|
||||
UpDown = 0x6,
|
||||
MyUpDown = 0x7,
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ void setup() {
|
|||
net.setup();
|
||||
somfy.begin();
|
||||
//git.checkForUpdate();
|
||||
esp_task_wdt_init(7, true); //enable panic so ESP32 restarts
|
||||
esp_task_wdt_init(15, true); //enable panic so ESP32 restarts
|
||||
esp_task_wdt_add(NULL); //add current thread to WDT watch
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,11 +46,15 @@ void JsonResponse::endResponse() {
|
|||
server->sendContent("", 0);
|
||||
}
|
||||
void JsonResponse::send() {
|
||||
Serial.println("JsonResponse::send start ");
|
||||
unsigned long ts = millis();
|
||||
esp_task_wdt_reset();
|
||||
if(!this->_headersSent) server->send_P(200, "application/json", this->buff);
|
||||
else server->sendContent(this->buff);
|
||||
//Serial.printf("Sent %d bytes %d\n", strlen(this->buff), this->buffSize);
|
||||
this->buff[0] = 0x00;
|
||||
this->_headersSent = true;
|
||||
Serial.printf("JsonResponse::send end took %d ms\n", millis() - ts);
|
||||
}
|
||||
void JsonResponse::_safecat(const char *val, bool escape) {
|
||||
size_t len = (escape ? this->calcEscapedLength(val) : strlen(val)) + strlen(this->buff);
|
||||
|
|
@ -130,8 +134,9 @@ void JsonFormatter::addElem(const char *name, uint32_t nval) { sprintf(this->_nu
|
|||
void JsonFormatter::addElem(const char *name, int16_t nval) { sprintf(this->_numbuff, "%d", nval); this->_appendNumber(name); }
|
||||
void JsonFormatter::addElem(const char *name, uint16_t nval) { sprintf(this->_numbuff, "%u", nval); this->_appendNumber(name); }
|
||||
void JsonFormatter::addElem(const char *name, int64_t lval) { sprintf(this->_numbuff, "%lld", (long long)lval); this->_appendNumber(name); }
|
||||
void JsonFormatter::addElem(const char *name, uint64_t lval) { sprintf(this->_numbuff, "%llu", (unsigned long long)lval); this->_appendNumber(name); }
|
||||
*/
|
||||
void JsonFormatter::addElem(const char *name, uint64_t lval) { sprintf(this->_numbuff, "%llu", (unsigned long long)lval); this->_appendNumber(name); }
|
||||
|
||||
void JsonFormatter::addElem(const char *name, bool bval) { strcpy(this->_numbuff, bval ? "true" : "false"); this->_appendNumber(name); }
|
||||
|
||||
void JsonFormatter::_safecat(const char *val, bool escape) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include <WebServer.h>
|
||||
#include <WebSocketsServer.h>
|
||||
#include <esp_task_wdt.h>
|
||||
#include "Somfy.h"
|
||||
#ifndef wresp_h
|
||||
#define wresp_h
|
||||
|
|
@ -51,6 +52,7 @@ class JsonFormatter {
|
|||
void addElem(const char* name, uint32_t lval);
|
||||
void addElem(const char* name, bool bval);
|
||||
void addElem(const char *name, const char *val);
|
||||
void addElem(const char* name, uint64_t lval);
|
||||
};
|
||||
class JsonResponse : public JsonFormatter {
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -249,6 +249,7 @@ void Web::handleController(WebServer &server) {
|
|||
resp.addElem("maxGroupedShades", (uint8_t)SOMFY_MAX_GROUPED_SHADES);
|
||||
resp.addElem("maxLinkedRemotes", (uint8_t)SOMFY_MAX_LINKED_REMOTES);
|
||||
resp.addElem("startingAddress", (uint32_t)somfy.startingAddress);
|
||||
|
||||
resp.beginObject("transceiver");
|
||||
somfy.transceiver.toJSON(resp);
|
||||
resp.endObject();
|
||||
|
|
@ -815,6 +816,7 @@ void Web::handleDiscovery(WebServer &server) {
|
|||
resp.addElem("free", ESP.getFreeHeap());
|
||||
resp.addElem("min", ESP.getMinFreeHeap());
|
||||
resp.addElem("total", ESP.getHeapSize());
|
||||
resp.addElem("uptime", (uint64_t)millis());
|
||||
resp.endObject();
|
||||
resp.beginArray("rooms");
|
||||
somfy.toJSONRooms(resp);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue