Skip to content

Commit d4c7252

Browse files
committed
[ESP8266 Setup] Fix bootloop during initial setup Custom ESP8266 build
1 parent 30acc89 commit d4c7252

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/src/ESPEasyCore/ESPEasy_Console.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ EspEasy_Console_t::EspEasy_Console_t()
7676
void EspEasy_Console_t::reInit()
7777
{
7878
updateActiveTaskUseSerial0();
79+
bool somethingChanged = false;
7980
#if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
8081
const ESPEasySerialPort port = static_cast<ESPEasySerialPort>(Settings.console_serial_port);
8182

@@ -114,6 +115,7 @@ void EspEasy_Console_t::reInit()
114115
_fallbackSerial._serial->end();
115116
delete _fallbackSerial._serial;
116117
_fallbackSerial._serial = nullptr;
118+
somethingChanged = true;
117119
}
118120
}
119121
# endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
@@ -128,6 +130,7 @@ void EspEasy_Console_t::reInit()
128130
_mainSerial._serial->end();
129131
delete _mainSerial._serial;
130132
_mainSerial._serial = nullptr;
133+
somethingChanged = true;
131134
}
132135

133136
_console_serial_port = Settings.console_serial_port;
@@ -140,6 +143,7 @@ void EspEasy_Console_t::reInit()
140143
static_cast<ESPEasySerialPort>(_console_serial_port),
141144
_console_serial_rxpin,
142145
_console_serial_txpin);
146+
somethingChanged = true;
143147
}
144148
# if USES_ESPEASY_CONSOLE_FALLBACK_PORT
145149

@@ -148,6 +152,7 @@ void EspEasy_Console_t::reInit()
148152
ESPEasySerialPort::serial0,
149153
SOC_RX0,
150154
SOC_TX0);
155+
somethingChanged = true;
151156
}
152157
# endif // if USES_ESPEASY_CONSOLE_FALLBACK_PORT
153158

@@ -164,7 +169,9 @@ void EspEasy_Console_t::reInit()
164169
_mainSerial._serialWriteBuffer.clear();
165170
}
166171
#endif // if FEATURE_DEFINE_SERIAL_CONSOLE_PORT
167-
begin(Settings.BaudRate);
172+
if (somethingChanged) {
173+
begin(Settings.BaudRate);
174+
}
168175
}
169176

170177
void EspEasy_Console_t::begin(uint32_t baudrate)

src/src/Helpers/_Plugin_init.cpp

+11-7
Original file line numberDiff line numberDiff line change
@@ -2083,6 +2083,8 @@ constexpr const Plugin_ptr_t PROGMEM Plugin_ptr[] =
20832083
#endif // ifdef USES_P255
20842084
};
20852085

2086+
bool _Plugin_init_setupDone = false;
2087+
20862088

20872089
constexpr size_t DeviceIndex_to_Plugin_id_size = NR_ELEMENTS(DeviceIndex_to_Plugin_id);
20882090

@@ -2174,7 +2176,7 @@ deviceIndex_t getDeviceIndex_from_PluginID(pluginID_t pluginID)
21742176

21752177
pluginID_t getPluginID_from_DeviceIndex(deviceIndex_t deviceIndex)
21762178
{
2177-
if (deviceIndex < DeviceIndex_to_Plugin_id_size)
2179+
if (validDeviceIndex_init(deviceIndex))
21782180
{
21792181
return pluginID_t::toPluginID(pgm_read_byte(DeviceIndex_to_Plugin_id + deviceIndex.value));
21802182
}
@@ -2183,13 +2185,16 @@ pluginID_t getPluginID_from_DeviceIndex(deviceIndex_t deviceIndex)
21832185

21842186
bool validDeviceIndex_init(deviceIndex_t deviceIndex)
21852187
{
2186-
return deviceIndex < DeviceIndex_to_Plugin_id_size;
2188+
if (_Plugin_init_setupDone) {
2189+
return deviceIndex < DeviceIndex_to_Plugin_id_size;
2190+
}
2191+
return false;
21872192
}
21882193

21892194
// Array containing "DeviceIndex" alfabetically sorted.
21902195
deviceIndex_t getDeviceIndex_sorted(deviceIndex_t deviceIndex)
21912196
{
2192-
if (deviceIndex < DeviceIndex_to_Plugin_id_size) {
2197+
if (validDeviceIndex_init(deviceIndex)) {
21932198
return DeviceIndex_sorted[deviceIndex.value];
21942199
}
21952200
return INVALID_DEVICE_INDEX;
@@ -2198,7 +2203,7 @@ deviceIndex_t getDeviceIndex_sorted(deviceIndex_t deviceIndex)
21982203

21992204
boolean PluginCall(deviceIndex_t deviceIndex, uint8_t function, struct EventStruct *event, String& string)
22002205
{
2201-
if (deviceIndex < DeviceIndex_to_Plugin_id_size)
2206+
if (validDeviceIndex_init(deviceIndex))
22022207
{
22032208
Plugin_ptr_t plugin_call = (Plugin_ptr_t)pgm_read_ptr(Plugin_ptr + deviceIndex.value);
22042209
return plugin_call(function, event, string);
@@ -2208,10 +2213,9 @@ boolean PluginCall(deviceIndex_t deviceIndex, uint8_t function, struct EventStru
22082213

22092214
void PluginSetup()
22102215
{
2211-
static bool setupDone = false;
2212-
if (setupDone) return;
2216+
if (_Plugin_init_setupDone) return;
22132217

2214-
setupDone = true;
2218+
_Plugin_init_setupDone = true;
22152219

22162220
for (size_t id = 0; id < Plugin_id_to_DeviceIndex_size; ++id)
22172221
{

0 commit comments

Comments
 (0)