Fix reboot bugs due to TinyConsole
This commit is contained in:
@@ -26,7 +26,7 @@ void setup()
|
|||||||
Serial.begin(115200);
|
Serial.begin(115200);
|
||||||
|
|
||||||
if (strlen(ssid)==0)
|
if (strlen(ssid)==0)
|
||||||
Serial << "****** PLEASE MODIFY ssid/password *************" << endl;
|
Console << TinyConsole::red << "****** PLEASE MODIFY ssid/password *************" << endl;
|
||||||
|
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
WiFi.begin(ssid, password);
|
WiFi.begin(ssid, password);
|
||||||
@@ -35,10 +35,10 @@ void setup()
|
|||||||
Serial << '.';
|
Serial << '.';
|
||||||
delay(500);
|
delay(500);
|
||||||
}
|
}
|
||||||
Serial << "Connected to " << ssid << "IP address: " << WiFi.localIP() << endl;
|
Connect << TinyConsole::green << "Connected to " << ssid << "IP address: " << WiFi.localIP() << endl;
|
||||||
|
|
||||||
broker.begin();
|
broker.begin();
|
||||||
Serial << "Broker ready : " << WiFi.localIP() << " on port " << PORT << endl;
|
Console << "Broker ready : " << WiFi.localIP() << " on port " << PORT << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ auto green = TinyConsole::green;
|
|||||||
auto red = TinyConsole::red;
|
auto red = TinyConsole::red;
|
||||||
auto white = TinyConsole::white;
|
auto white = TinyConsole::white;
|
||||||
auto cyan = TinyConsole::cyan;
|
auto cyan = TinyConsole::cyan;
|
||||||
|
auto yellow = TinyConsole::yellow;
|
||||||
|
|
||||||
/** Very complex example
|
/** Very complex example
|
||||||
* Console allowing to make any kind of test,
|
* Console allowing to make any kind of test,
|
||||||
@@ -420,9 +421,8 @@ struct Every
|
|||||||
else
|
else
|
||||||
Console << red << "disabled";
|
Console << red << "disabled";
|
||||||
|
|
||||||
Console << white <<
|
|
||||||
auto mill=millis();
|
auto mill=millis();
|
||||||
Console << ms << "ms [" << cmd << "] next in ";
|
Console << white << ms << "ms [" << cmd << "] next in ";
|
||||||
if (mill > next)
|
if (mill > next)
|
||||||
Console << "now";
|
Console << "now";
|
||||||
else
|
else
|
||||||
@@ -440,6 +440,7 @@ std::vector<Every> everies;
|
|||||||
|
|
||||||
void onCommand(const std::string& command)
|
void onCommand(const std::string& command)
|
||||||
{
|
{
|
||||||
|
Console << endl;
|
||||||
std::string cmd=command;
|
std::string cmd=command;
|
||||||
if (cmd.substr(0,3)!="set") replaceVars(cmd);
|
if (cmd.substr(0,3)!="set") replaceVars(cmd);
|
||||||
eval(cmd);
|
eval(cmd);
|
||||||
@@ -497,7 +498,7 @@ void eval(std::string& cmd)
|
|||||||
broker = brokers[s];
|
broker = brokers[s];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Console << red << "Unable to find (" << s.c_str() << ")" << << white << endl;
|
Console << red << "Unable to find (" << s.c_str() << ")" << white << endl;
|
||||||
}
|
}
|
||||||
if (client)
|
if (client)
|
||||||
{
|
{
|
||||||
@@ -910,5 +911,5 @@ void loop()
|
|||||||
it.second->loop();
|
it.second->loop();
|
||||||
|
|
||||||
Automatic::loop();
|
Automatic::loop();
|
||||||
Console::loop();
|
Console.loop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name=TinyMqtt
|
name=TinyMqtt
|
||||||
version=0.9.5
|
version=0.9.6
|
||||||
author=Francois BIOT, HSaturn, <hsaturn@gmail.com>
|
author=Francois BIOT, HSaturn, <hsaturn@gmail.com>
|
||||||
maintainer=Francois BIOT, HSaturn, <hsaturn@gmail.com>
|
maintainer=Francois BIOT, HSaturn, <hsaturn@gmail.com>
|
||||||
sentence=A tiny broker and client library for MQTT messaging.
|
sentence=A tiny broker and client library for MQTT messaging.
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// vim: ts=2 sw=2 expandtab
|
||||||
#include "TinyMqtt.h"
|
#include "TinyMqtt.h"
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
@@ -589,9 +590,9 @@ void MqttClient::processMessage(MqttMessage* mesg)
|
|||||||
mesg->getString(payload, len);
|
mesg->getString(payload, len);
|
||||||
Topic published(payload, len);
|
Topic published(payload, len);
|
||||||
payload += len;
|
payload += len;
|
||||||
#ifdef TINY_MQTT_DEBUG
|
#ifdef TINY_MQTT_DEBUG
|
||||||
Console << "Received Publish (" << published.str().c_str() << ") size=" << (int)len << endl;
|
Console << "Received Publish (" << published.str().c_str() << ") size=" << (int)len << endl;
|
||||||
#endif
|
#endif
|
||||||
// << '(' << std::string(payload, len).c_str() << ')' << " msglen=" << mesg->length() << endl;
|
// << '(' << std::string(payload, len).c_str() << ')' << " msglen=" << mesg->length() << endl;
|
||||||
if (qos) payload+=2; // ignore packet identifier if any
|
if (qos) payload+=2; // ignore packet identifier if any
|
||||||
len=mesg->end()-payload;
|
len=mesg->end()-payload;
|
||||||
@@ -898,13 +899,13 @@ void MqttMessage::hexdump(const char* prefix) const
|
|||||||
Type typ=static_cast<Type>(buffer[0] & 0xF0);
|
Type typ=static_cast<Type>(buffer[0] & 0xF0);
|
||||||
if (tts.find(typ) != tts.end())
|
if (tts.find(typ) != tts.end())
|
||||||
t=tts[typ];
|
t=tts[typ];
|
||||||
Console.fg(cyan);
|
Console.fg(cyan);
|
||||||
#ifdef NOT_ESP_CORE
|
#ifdef NOT_ESP_CORE
|
||||||
Console << "---> MESSAGE " << t << ' ' << _HEX(typ) << ' ' << " mem=???" << endl;
|
Console << "---> MESSAGE " << t << ' ' << _HEX(typ) << ' ' << " mem=???" << endl;
|
||||||
#else
|
#else
|
||||||
Console << "---> MESSAGE " << t << ' ' << _HEX(typ) << ' ' << " mem=" << ESP.getFreeHeap() << endl;
|
Console << "---> MESSAGE " << t << ' ' << _HEX(typ) << ' ' << " mem=" << ESP.getFreeHeap() << endl;
|
||||||
#endif
|
#endif
|
||||||
Console.fg(white);
|
Console.fg(white);
|
||||||
|
|
||||||
uint16_t addr=0;
|
uint16_t addr=0;
|
||||||
const int bytes_per_row = 8;
|
const int bytes_per_row = 8;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// vim: ts=2 sw=2 expandtab
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// TODO Should add a AUnit with both TINY_MQTT_ASYNC and not TINY_MQTT_ASYNC
|
// TODO Should add a AUnit with both TINY_MQTT_ASYNC and not TINY_MQTT_ASYNC
|
||||||
|
|||||||
Reference in New Issue
Block a user