mirror of https://github.com/arendst/Tasmota.git
Free some more bytes from GPIOViewer
This commit is contained in:
parent
9fc47b7d90
commit
1854b9a069
|
@ -18,24 +18,24 @@
|
|||
#define XDRV_121 121
|
||||
|
||||
#ifndef GV_PORT
|
||||
#define GV_PORT 5557
|
||||
#define GV_PORT 5557 // SSE webserver port
|
||||
#endif
|
||||
#ifndef GV_SAMPLING_INTERVAL
|
||||
#define GV_SAMPLING_INTERVAL 100 // [GvSampling] milliseconds - Use Tasmota Scheduler (100) or Ticker (20..99,101..1000)
|
||||
#define GV_SAMPLING_INTERVAL 100 // [GvSampling] milliseconds - Use Tasmota Scheduler (100) or Ticker (20..99,101..1000)
|
||||
#endif
|
||||
|
||||
#define GV_KEEP_ALIVE 1000 // milliseconds - If no activity after this do a heap size event anyway
|
||||
#define GV_KEEP_ALIVE 1000 // milliseconds - If no activity after this do a heap size event anyway
|
||||
|
||||
//#define GV_BASE_URL "https://thelastoutpostworkshop.github.io/microcontroller_devkit/gpio_viewer/assets/"
|
||||
#ifdef ESP8266
|
||||
#ifndef GV_BASE_URL
|
||||
#undef GV_BASE_URL // Fix compiler warning
|
||||
#undef GV_BASE_URL // Fix compiler warning
|
||||
#define GV_BASE_URL "https://ota.tasmota.com/tasmota/gpio_viewer/assets/"
|
||||
#endif
|
||||
#endif // ESP8266
|
||||
#ifdef ESP32
|
||||
#ifndef GV_BASE_URL
|
||||
#undef GV_BASE_URL // Fix compiler warning
|
||||
#undef GV_BASE_URL // Fix compiler warning
|
||||
#define GV_BASE_URL "https://ota.tasmota.com/tasmota32/gpio_viewer/assets/"
|
||||
#endif
|
||||
#endif // ESP32
|
||||
|
@ -49,12 +49,11 @@ const char *GVRelease = "1.0.7";
|
|||
#endif
|
||||
|
||||
const char HTTP_GV_EVENT[] PROGMEM =
|
||||
// Set CORS headers for global responses
|
||||
"HTTP/1.1 200 OK\n"
|
||||
"Content-Type: text/event-stream;\n"
|
||||
"Connection: keep-alive\n"
|
||||
"Cache-Control: no-cache\n"
|
||||
"Access-Control-Allow-Origin: *\n\n";
|
||||
"Content-Type: text/event-stream;\n" // Server Sent Event protocol
|
||||
"Connection: keep-alive\n" // Permanent connection
|
||||
"Cache-Control: no-cache\n" // Do not store data into local cache
|
||||
"Access-Control-Allow-Origin: *\n\n"; // Enable CORS
|
||||
|
||||
enum GVPinTypes {
|
||||
GV_DigitalPin = 0,
|
||||
|
@ -119,7 +118,7 @@ void GVHandleRoot(void) {
|
|||
0,
|
||||
#endif // ESP32
|
||||
ESP_getFreeSketchSpace() / 1024);
|
||||
if (content == nullptr) { return; } // Avoid crash
|
||||
if (content == nullptr) { return; } // Avoid crash
|
||||
GV.WebServer->send_P(200, "text/html", content);
|
||||
free(content);
|
||||
}
|
||||
|
@ -172,8 +171,8 @@ void GVCloseEvent(void) {
|
|||
void GVEventSend(const char *message, const char *event, uint32_t id) {
|
||||
if (GV.WebClient.connected()) {
|
||||
// generateEventMessage() in AsyncEventSource.cpp
|
||||
// GV.WebClient.printf_P(PSTR("retry: 0\r\nid: %u\r\nevent: %s\r\ndata: %s\r\n\r\n"), id, event, message);
|
||||
GV.WebClient.printf_P(PSTR("id: %u\r\nevent: %s\r\ndata: %s\r\n\r\n"), id, event, message);
|
||||
// GV.WebClient.printf_P(PSTR("retry:0\nid:%u\nevent:%s\ndata:%s\n\n"), id, event, message);
|
||||
GV.WebClient.printf_P(PSTR("id:%u\nevent:%s\ndata:%s\n\n"), id, event, message);
|
||||
} else {
|
||||
GVEventDisconnected();
|
||||
}
|
||||
|
@ -299,7 +298,7 @@ void GVMonitorTask(void) {
|
|||
* Commands
|
||||
\*********************************************************************************************/
|
||||
|
||||
const char kGVCommands[] PROGMEM = "GV|" // Prefix
|
||||
const char kGVCommands[] PROGMEM = "GV|" // Prefix
|
||||
"Viewer|Sampling";
|
||||
|
||||
void (* const GVCommand[])(void) PROGMEM = {
|
||||
|
@ -313,13 +312,13 @@ void CmndGvViewer(void) {
|
|||
*/
|
||||
if ((XdrvMailbox.payload >= 0) && (XdrvMailbox.payload <= 2)) {
|
||||
uint32_t state = XdrvMailbox.payload;
|
||||
if (2 == state) { // Toggle
|
||||
if (2 == state) { // Toggle
|
||||
state = GV.active ^1;
|
||||
}
|
||||
if (state) { // On
|
||||
if (state) { // On
|
||||
GVBegin();
|
||||
} else { // Off
|
||||
GVCloseEvent(); // Stop current updates
|
||||
} else { // Off
|
||||
GVCloseEvent(); // Stop current updates
|
||||
GVStop();
|
||||
}
|
||||
}
|
||||
|
@ -335,8 +334,8 @@ void CmndGvSampling(void) {
|
|||
GvSampling 20 .. 1000 - Set sampling interval
|
||||
*/
|
||||
if ((XdrvMailbox.payload >= 20) && (XdrvMailbox.payload <= 1000)) {
|
||||
GVCloseEvent(); // Stop current updates
|
||||
GV.sampling = XdrvMailbox.payload; // 20 - 1000 milliseconds
|
||||
GVCloseEvent(); // Stop current updates
|
||||
GV.sampling = XdrvMailbox.payload; // 20 - 1000 milliseconds
|
||||
}
|
||||
ResponseCmndNumber(GV.sampling);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue