mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
added option to enable serial on new installations
This commit is contained in:
@@ -47,7 +47,9 @@ MyESP::MyESP() {
|
|||||||
_helpProjectCmds = NULL;
|
_helpProjectCmds = NULL;
|
||||||
_helpProjectCmds_count = 0;
|
_helpProjectCmds_count = 0;
|
||||||
|
|
||||||
_serial = false;
|
_serial = false;
|
||||||
|
_serial_default = false;
|
||||||
|
|
||||||
_heartbeat = false;
|
_heartbeat = false;
|
||||||
_mqtt_host = NULL;
|
_mqtt_host = NULL;
|
||||||
_mqtt_password = NULL;
|
_mqtt_password = NULL;
|
||||||
@@ -198,7 +200,7 @@ void MyESP::_wifiCallback(justwifi_messages_t code, char * parameter) {
|
|||||||
|
|
||||||
// finally if we don't want Serial anymore, turn it off
|
// finally if we don't want Serial anymore, turn it off
|
||||||
if (!_serial) {
|
if (!_serial) {
|
||||||
myDebug_P(PSTR("Disabling serial port communication."));
|
myDebug_P(PSTR("[SYSTEM] Disabling serial port communication."));
|
||||||
SerialAndTelnet.flush(); // flush so all buffer is printed to serial
|
SerialAndTelnet.flush(); // flush so all buffer is printed to serial
|
||||||
SerialAndTelnet.setSerial(NULL);
|
SerialAndTelnet.setSerial(NULL);
|
||||||
}
|
}
|
||||||
@@ -837,16 +839,9 @@ bool MyESP::_changeSetting(uint8_t wc, const char * setting, const char * value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// force the serial on/off
|
// force the serial on/off
|
||||||
void MyESP::setUseSerial(bool toggle) {
|
void MyESP::setUseSerial(bool b) {
|
||||||
//(void)fs_saveConfig(); // save the setting for next reboot
|
_serial_default = _serial = b;
|
||||||
|
SerialAndTelnet.setSerial(b ? &Serial : NULL);
|
||||||
if (toggle) {
|
|
||||||
SerialAndTelnet.setSerial(&Serial);
|
|
||||||
_serial = true;
|
|
||||||
} else {
|
|
||||||
SerialAndTelnet.setSerial(NULL);
|
|
||||||
_serial = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyESP::_telnetCommand(char * commandLine) {
|
void MyESP::_telnetCommand(char * commandLine) {
|
||||||
@@ -1604,9 +1599,7 @@ bool MyESP::_fs_loadConfig() {
|
|||||||
value = json["mqtt_password"];
|
value = json["mqtt_password"];
|
||||||
_mqtt_password = (value) ? strdup(value) : NULL;
|
_mqtt_password = (value) ? strdup(value) : NULL;
|
||||||
|
|
||||||
_serial = (bool)json["serial"]; // defaults to off
|
_serial = json["serial"] | _serial_default;
|
||||||
|
|
||||||
// _serial = true; // uncomment for debugging everything to serial
|
|
||||||
|
|
||||||
_heartbeat = (bool)json["heartbeat"]; // defaults to off
|
_heartbeat = (bool)json["heartbeat"]; // defaults to off
|
||||||
|
|
||||||
@@ -2122,6 +2115,38 @@ void MyESP::_webserver_setup() {
|
|||||||
webServer.on("/resetall", [this]() { _webResetAllPage(); });
|
webServer.on("/resetall", [this]() { _webResetAllPage(); });
|
||||||
|
|
||||||
webServer.begin();
|
webServer.begin();
|
||||||
|
|
||||||
|
myDebug_P(PSTR("[WEB] Web server started."));
|
||||||
|
}
|
||||||
|
|
||||||
|
// bootup sequence
|
||||||
|
// quickly flash LED until we get a Wifi connection, or AP established
|
||||||
|
// fast way is to use WRITE_PERI_REG(PERIPHS_GPIO_BASEADDR + (state ? 4 : 8), (1 << EMSESP_Status.led_gpio)); // 4 is on, 8 is off
|
||||||
|
void MyESP::_bootupSequence() {
|
||||||
|
uint8_t boot_status = getSystemBootStatus();
|
||||||
|
|
||||||
|
if ((boot_status == MYESP_BOOTSTATUS_BOOTED) || (millis() <= MYESP_BOOTUP_DELAY)) {
|
||||||
|
return; // already booted, or still starting up
|
||||||
|
}
|
||||||
|
|
||||||
|
// only kick in after a few seconds
|
||||||
|
if (boot_status == MYESP_BOOTSTATUS_POWERON) {
|
||||||
|
_setSystemBootStatus(MYESP_BOOTSTATUS_BOOTING);
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint32_t last_bootupflash = 0;
|
||||||
|
|
||||||
|
// flash LED quickly
|
||||||
|
if ((millis() - last_bootupflash > MYESP_BOOTUP_FLASHDELAY)) {
|
||||||
|
last_bootupflash = millis();
|
||||||
|
int state = digitalRead(LED_BUILTIN);
|
||||||
|
digitalWrite(LED_BUILTIN, !state);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isWifiConnected()) {
|
||||||
|
_setSystemBootStatus(MYESP_BOOTSTATUS_BOOTED); // completed, reset flag
|
||||||
|
digitalWrite(LED_BUILTIN, LOW); // turn off LED
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup MyESP
|
// setup MyESP
|
||||||
@@ -2158,36 +2183,6 @@ void MyESP::begin(const char * app_hostname, const char * app_name, const char *
|
|||||||
_heartbeatCheck(true); // force heartbeat
|
_heartbeatCheck(true); // force heartbeat
|
||||||
}
|
}
|
||||||
|
|
||||||
// bootup sequence
|
|
||||||
// quickly flash LED until we get a Wifi connection, or AP established
|
|
||||||
// fast way is to use WRITE_PERI_REG(PERIPHS_GPIO_BASEADDR + (state ? 4 : 8), (1 << EMSESP_Status.led_gpio)); // 4 is on, 8 is off
|
|
||||||
void MyESP::_bootupSequence() {
|
|
||||||
uint8_t boot_status = getSystemBootStatus();
|
|
||||||
|
|
||||||
if ((boot_status == MYESP_BOOTSTATUS_BOOTED) || (millis() <= MYESP_BOOTUP_DELAY)) {
|
|
||||||
return; // already booted, or still starting up
|
|
||||||
}
|
|
||||||
|
|
||||||
// only kick in after a few seconds
|
|
||||||
if (boot_status == MYESP_BOOTSTATUS_POWERON) {
|
|
||||||
_setSystemBootStatus(MYESP_BOOTSTATUS_BOOTING);
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32_t last_bootupflash = 0;
|
|
||||||
|
|
||||||
// flash LED quickly
|
|
||||||
if ((millis() - last_bootupflash > MYESP_BOOTUP_FLASHDELAY)) {
|
|
||||||
last_bootupflash = millis();
|
|
||||||
int state = digitalRead(LED_BUILTIN);
|
|
||||||
digitalWrite(LED_BUILTIN, !state);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isWifiConnected()) {
|
|
||||||
_setSystemBootStatus(MYESP_BOOTSTATUS_BOOTED); // completed, reset flag
|
|
||||||
digitalWrite(LED_BUILTIN, LOW); // turn off LED
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Loop. This is called as often as possible and it handles wifi, telnet, mqtt etc
|
* Loop. This is called as often as possible and it handles wifi, telnet, mqtt etc
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#ifndef MyEMS_h
|
#ifndef MyEMS_h
|
||||||
#define MyEMS_h
|
#define MyEMS_h
|
||||||
|
|
||||||
#define MYESP_VERSION "1.1.20"
|
#define MYESP_VERSION "1.1.21"
|
||||||
|
|
||||||
#include <ArduinoJson.h>
|
#include <ArduinoJson.h>
|
||||||
#include <ArduinoOTA.h>
|
#include <ArduinoOTA.h>
|
||||||
@@ -377,6 +377,7 @@ class MyESP {
|
|||||||
char * _boottime;
|
char * _boottime;
|
||||||
bool _suspendOutput;
|
bool _suspendOutput;
|
||||||
bool _serial;
|
bool _serial;
|
||||||
|
bool _serial_default;
|
||||||
bool _heartbeat;
|
bool _heartbeat;
|
||||||
unsigned long _getUptime();
|
unsigned long _getUptime();
|
||||||
String _buildTime();
|
String _buildTime();
|
||||||
|
|||||||
@@ -8,10 +8,11 @@
|
|||||||
default_envs = debug
|
default_envs = debug
|
||||||
|
|
||||||
[common]
|
[common]
|
||||||
; -DMYESP_TIMESTAMP -DTESTS -DCRASH
|
; -DMYESP_TIMESTAMP -DTESTS -DCRASH -DNO_SERIAL
|
||||||
|
; -DNO_SERIAL if you want a fresh install to use the Serial port
|
||||||
debug_flags = -Wall -DCRASH
|
debug_flags = -Wall -DCRASH
|
||||||
release_flags = -w
|
release_flags = -w
|
||||||
general_flags = -g -DNO_GLOBAL_EEPROM
|
general_flags = -g -DNO_GLOBAL_EEPROM -DDNO_SERIAL
|
||||||
|
|
||||||
arduino_core_2_3_0 = espressif8266@1.5.0
|
arduino_core_2_3_0 = espressif8266@1.5.0
|
||||||
arduino_core_2_4_0 = espressif8266@1.6.0
|
arduino_core_2_4_0 = espressif8266@1.6.0
|
||||||
|
|||||||
Reference in New Issue
Block a user