Fix reboot bugs due to TinyConsole
This commit is contained in:
@@ -7,7 +7,7 @@ MqttBroker broker(PORT);
|
||||
*
|
||||
* +-----------------------------+
|
||||
* | ESP |
|
||||
* | +--------+ |
|
||||
* | +--------+ |
|
||||
* | | broker | | 1883 <--- External client/s
|
||||
* | +--------+ |
|
||||
* | |
|
||||
@@ -15,30 +15,30 @@ MqttBroker broker(PORT);
|
||||
*
|
||||
* Your ESP will become a MqttBroker.
|
||||
* You can test it with any client such as mqtt-spy for example
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
const char* ssid = "";
|
||||
const char* password = "";
|
||||
|
||||
void setup()
|
||||
void setup()
|
||||
{
|
||||
Serial.begin(115200);
|
||||
|
||||
if (strlen(ssid)==0)
|
||||
Serial << "****** PLEASE MODIFY ssid/password *************" << endl;
|
||||
Console << TinyConsole::red << "****** PLEASE MODIFY ssid/password *************" << endl;
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, password);
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
Serial << '.';
|
||||
delay(500);
|
||||
}
|
||||
Serial << "Connected to " << ssid << "IP address: " << WiFi.localIP() << endl;
|
||||
Connect << TinyConsole::green << "Connected to " << ssid << "IP address: " << WiFi.localIP() << endl;
|
||||
|
||||
broker.begin();
|
||||
Serial << "Broker ready : " << WiFi.localIP() << " on port " << PORT << endl;
|
||||
Console << "Broker ready : " << WiFi.localIP() << " on port " << PORT << endl;
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
||||
@@ -20,6 +20,7 @@ auto green = TinyConsole::green;
|
||||
auto red = TinyConsole::red;
|
||||
auto white = TinyConsole::white;
|
||||
auto cyan = TinyConsole::cyan;
|
||||
auto yellow = TinyConsole::yellow;
|
||||
|
||||
/** Very complex example
|
||||
* Console allowing to make any kind of test,
|
||||
@@ -420,9 +421,8 @@ struct Every
|
||||
else
|
||||
Console << red << "disabled";
|
||||
|
||||
Console << white <<
|
||||
auto mill=millis();
|
||||
Console << ms << "ms [" << cmd << "] next in ";
|
||||
Console << white << ms << "ms [" << cmd << "] next in ";
|
||||
if (mill > next)
|
||||
Console << "now";
|
||||
else
|
||||
@@ -440,6 +440,7 @@ std::vector<Every> everies;
|
||||
|
||||
void onCommand(const std::string& command)
|
||||
{
|
||||
Console << endl;
|
||||
std::string cmd=command;
|
||||
if (cmd.substr(0,3)!="set") replaceVars(cmd);
|
||||
eval(cmd);
|
||||
@@ -497,7 +498,7 @@ void eval(std::string& cmd)
|
||||
broker = brokers[s];
|
||||
}
|
||||
else
|
||||
Console << red << "Unable to find (" << s.c_str() << ")" << << white << endl;
|
||||
Console << red << "Unable to find (" << s.c_str() << ")" << white << endl;
|
||||
}
|
||||
if (client)
|
||||
{
|
||||
@@ -910,5 +911,5 @@ void loop()
|
||||
it.second->loop();
|
||||
|
||||
Automatic::loop();
|
||||
Console::loop();
|
||||
Console.loop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user