mirror of https://github.com/arendst/Tasmota.git
GPIOViewer function shuffle. No functional changes
This commit is contained in:
parent
969611835c
commit
a10e3b9bc5
|
@ -157,7 +157,7 @@ int GetPinMode(uint32_t pin) {
|
||||||
return GV_INPUT_PULLUP; // ESP8266 = 0x02 : 0x00, ESP32 = 0x05 : x01
|
return GV_INPUT_PULLUP; // ESP8266 = 0x02 : 0x00, ESP32 = 0x05 : x01
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************************************************************/
|
/*-------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#ifdef ESP32
|
#ifdef ESP32
|
||||||
#ifdef SOC_ADC_SUPPORTED
|
#ifdef SOC_ADC_SUPPORTED
|
||||||
|
@ -178,6 +178,8 @@ int8_t GVDigitalPinToAnalogChannel(uint8_t pin) {
|
||||||
#endif // SOC_ADC_SUPPORTED
|
#endif // SOC_ADC_SUPPORTED
|
||||||
#endif // ESP32
|
#endif // ESP32
|
||||||
|
|
||||||
|
/*********************************************************************************************/
|
||||||
|
|
||||||
bool GVInit(void) {
|
bool GVInit(void) {
|
||||||
if (!GV) {
|
if (!GV) {
|
||||||
// Executed once
|
// Executed once
|
||||||
|
@ -211,13 +213,7 @@ bool GVInit(void) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GVStop(void) {
|
/*-------------------------------------------------------------------------------------------*/
|
||||||
GV->sse_ready = false;
|
|
||||||
GV->ticker.detach();
|
|
||||||
|
|
||||||
GV->WebServer->stop();
|
|
||||||
GV->WebServer = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GVBegin(void) {
|
void GVBegin(void) {
|
||||||
if (GV->WebServer == nullptr) {
|
if (GV->WebServer == nullptr) {
|
||||||
|
@ -227,6 +223,7 @@ void GVBegin(void) {
|
||||||
// GV->WebServer->sendHeader(F("Access-Control-Allow-Methods"), F("GET, POST, OPTIONS"));
|
// GV->WebServer->sendHeader(F("Access-Control-Allow-Methods"), F("GET, POST, OPTIONS"));
|
||||||
// GV->WebServer->sendHeader(F("Access-Control-Allow-Headers"), F("Content-Type"));
|
// GV->WebServer->sendHeader(F("Access-Control-Allow-Headers"), F("Content-Type"));
|
||||||
GV->WebServer->on("/", GVHandleRoot);
|
GV->WebServer->on("/", GVHandleRoot);
|
||||||
|
GV->WebServer->on("/events", GVHandleEvents);
|
||||||
GV->WebServer->on("/release", GVHandleRelease);
|
GV->WebServer->on("/release", GVHandleRelease);
|
||||||
GV->WebServer->on("/free_psram", GVHandleFreePSRam);
|
GV->WebServer->on("/free_psram", GVHandleFreePSRam);
|
||||||
GV->WebServer->on("/sampling", GVHandleSampling);
|
GV->WebServer->on("/sampling", GVHandleSampling);
|
||||||
|
@ -234,11 +231,20 @@ void GVBegin(void) {
|
||||||
GV->WebServer->on("/partition", GVHandlePartition);
|
GV->WebServer->on("/partition", GVHandlePartition);
|
||||||
GV->WebServer->on("/pinmodes", GVHandlePinModes);
|
GV->WebServer->on("/pinmodes", GVHandlePinModes);
|
||||||
GV->WebServer->on("/pinfunctions", GVHandlePinFunctions);
|
GV->WebServer->on("/pinfunctions", GVHandlePinFunctions);
|
||||||
GV->WebServer->on("/events", GVHandleEvents);
|
|
||||||
GV->WebServer->begin();
|
GV->WebServer->begin();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void GVStop(void) {
|
||||||
|
GV->sse_ready = false;
|
||||||
|
GV->ticker.detach();
|
||||||
|
|
||||||
|
GV->WebServer->stop();
|
||||||
|
GV->WebServer = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************************************************************************/
|
/*********************************************************************************************/
|
||||||
|
|
||||||
void GVHandleRoot(void) {
|
void GVHandleRoot(void) {
|
||||||
|
@ -265,6 +271,27 @@ void GVWebserverSendJson(String &jsonResponse) {
|
||||||
GV->WebServer->send(200, "application/json", jsonResponse);
|
GV->WebServer->send(200, "application/json", jsonResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
void GVHandleEvents(void) {
|
||||||
|
GVWebClient = GV->WebServer->client();
|
||||||
|
GVWebClient.setNoDelay(true);
|
||||||
|
// GVWebClient.setSync(true);
|
||||||
|
|
||||||
|
GV->WebServer->setContentLength(CONTENT_LENGTH_UNKNOWN); // The payload can go on forever
|
||||||
|
GV->WebServer->sendContent_P(HTTP_GV_EVENT);
|
||||||
|
#ifdef ESP32
|
||||||
|
GVWebClient.setSSE(true);
|
||||||
|
#endif
|
||||||
|
GV->sse_ready = true; // Ready for async updates
|
||||||
|
if (GV->sampling != 100) {
|
||||||
|
GV->ticker.attach_ms(GV->sampling, GVMonitorTask); // Use Tasmota Scheduler (100) or Ticker (20..99,101..1000)
|
||||||
|
}
|
||||||
|
AddLog(LOG_LEVEL_DEBUG, PSTR("IOV: Connected"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*********************************************************************************************/
|
||||||
|
|
||||||
void GVHandleRelease(void) {
|
void GVHandleRelease(void) {
|
||||||
String jsonResponse = "{\"release\":\"" + String(GVRelease) + "\"}";
|
String jsonResponse = "{\"release\":\"" + String(GVRelease) + "\"}";
|
||||||
GVWebserverSendJson(jsonResponse);
|
GVWebserverSendJson(jsonResponse);
|
||||||
|
@ -443,25 +470,6 @@ void GVHandlePinFunctions(void) {
|
||||||
GVWebserverSendJson(jsonResponse);
|
GVWebserverSendJson(jsonResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
void GVHandleEvents(void) {
|
|
||||||
GVWebClient = GV->WebServer->client();
|
|
||||||
GVWebClient.setNoDelay(true);
|
|
||||||
// GVWebClient.setSync(true);
|
|
||||||
|
|
||||||
GV->WebServer->setContentLength(CONTENT_LENGTH_UNKNOWN); // The payload can go on forever
|
|
||||||
GV->WebServer->sendContent_P(HTTP_GV_EVENT);
|
|
||||||
#ifdef ESP32
|
|
||||||
GVWebClient.setSSE(true);
|
|
||||||
#endif
|
|
||||||
GV->sse_ready = true; // Ready for async updates
|
|
||||||
if (GV->sampling != 100) {
|
|
||||||
GV->ticker.attach_ms(GV->sampling, GVMonitorTask); // Use Tasmota Scheduler (100) or Ticker (20..99,101..1000)
|
|
||||||
}
|
|
||||||
AddLog(LOG_LEVEL_DEBUG, PSTR("IOV: Connected"));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*********************************************************************************************/
|
/*********************************************************************************************/
|
||||||
|
|
||||||
void GVEventDisconnected(void) {
|
void GVEventDisconnected(void) {
|
||||||
|
@ -472,6 +480,8 @@ void GVEventDisconnected(void) {
|
||||||
GV->ticker.detach();
|
GV->ticker.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
void GVCloseEvent(void) {
|
void GVCloseEvent(void) {
|
||||||
if (GV->WebServer) {
|
if (GV->WebServer) {
|
||||||
GVEventSend("{}", "close", millis()); // Closes web page
|
GVEventSend("{}", "close", millis()); // Closes web page
|
||||||
|
@ -479,6 +489,8 @@ void GVCloseEvent(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
//void GVEventSend(const char *message, const char *event=NULL, uint32_t id=0, uint32_t reconnect=0);
|
//void GVEventSend(const char *message, const char *event=NULL, uint32_t id=0, uint32_t reconnect=0);
|
||||||
void GVEventSend(const char *message, const char *event, uint32_t id) {
|
void GVEventSend(const char *message, const char *event, uint32_t id) {
|
||||||
if (GVWebClient.connected()) {
|
if (GVWebClient.connected()) {
|
||||||
|
|
Loading…
Reference in New Issue