DebugTrace, Nextion, BrokerMQTT

This commit is contained in:
Mit4el
2024-09-20 11:07:08 +03:00
parent d2a55af97e
commit 3919e5a0ab
12 changed files with 1019 additions and 445 deletions

View File

@@ -125,6 +125,8 @@ namespace _Broker
}
}
bool _debug;
class BrokerMQTT : public IoTItem
{
private:
@@ -132,7 +134,7 @@ namespace _Broker
int _port = 0;
String _user;
String _pass;
bool _debug;
//bool _debug;
bool _brige;
String _server;
String _srvUser;
@@ -152,19 +154,6 @@ namespace _Broker
jsonRead(parameters, "srvUser", _srvUser);
jsonRead(parameters, "srvPass", _srvPass);
jsonRead(parameters, "srvPort", _srvPort);
if (_brige)
{
clientMqtt = new PicoMQTT::Client(_server.c_str(), _srvPort, nullptr, _srvUser.c_str(), _srvPass.c_str());
if (_debug)
{
SerialPrint("i", F("BrigeMQTT"), "Bridge mode : ON");
SerialPrint("i", F("BrigeMQTT"), "Bridge server: " + _server);
SerialPrint("i", F("BrigeMQTT"), "Bridge port: " + String(_srvPort));
SerialPrint("i", F("BrigeMQTT"), "Bridge user: " + _srvUser);
SerialPrint("i", F("BrigeMQTT"), "Bridge pass: " + _srvPass);
}
}
}
void doByInterval()
@@ -178,11 +167,30 @@ namespace _Broker
picoMqtt->begin();
picoMqtt->setDebug(_debug);
picoMqtt->setAuth(_user, _pass);
if (_brige)
{
clientMqtt = new PicoMQTT::Client(_server.c_str(), _srvPort, chipId.c_str(), _srvUser.c_str(), _srvPass.c_str());
clientMqtt->begin();
if (_debug)
{
SerialPrint("i", F("BrigeMQTT"), "Bridge mode : ON");
SerialPrint("i", F("BrigeMQTT"), "Bridge server: " + _server);
SerialPrint("i", F("BrigeMQTT"), "Bridge port: " + String(_srvPort));
SerialPrint("i", F("BrigeMQTT"), "Bridge user: " + _srvUser);
SerialPrint("i", F("BrigeMQTT"), "Bridge pass: " + _srvPass);
}
}
if (_brige && picoMqtt && clientMqtt)
{
picoMqtt->subscribe("#", [](const char *topic, const char *message)
{ clientMqtt->publish(topic, message);
SerialPrint("i", F("BrigeMQTT"), "client publish, topic: " + String(topic) + " msg: " + String(message) ); });
if (_debug)
SerialPrint("i", F("BrigeMQTT"), "Client publish, topic: " + String(topic) + " msg: " + String(message) ); });
clientMqtt->subscribe("#", [](const char *topic, const char *message)
{ picoMqtt->publish(topic, message);
if (_debug)
SerialPrint("i", F("BrigeMQTT"), "Server publish, topic: " + String(topic) + " msg: " + String(message) ); });
}
// picoMqtt.begin();
xTaskCreatePinnedToCore(

View File

@@ -686,7 +686,7 @@ public:
{
_myBot->sendMessage("ID: " + chipId, _chatID);
_myBot->sendMessage("chatID: " + _chatID, _chatID);
_myBot->sendMessage("Command: /help - this text \n /all - inline menu get all values \n /allMenu - bottom menu get all values \n /menu - bottom USER menu from scenario \n /get_id - get value by ID \n /set_id_value - set value in ID \n /file_name_type - take file from esp \n /file_type - support file type \n /reboot - reboot esp \n\n send file and write download - \"download\" file to esp \n\n send *.tft file - flash Nextion \n\n send firmware.bin or littltfs.bin - firmware ESP ", _chatID);
_myBot->sendMessage("Command: /help - this text \n /all - inline menu get all values \n /allMenu - bottom menu get all values \n /menu - bottom USER menu from scenario \n /get_id - get value by ID \n /set_id_value - set value in ID \n /file_/path/name_type - take file from esp \n /file_type - support file type \n /reboot - reboot esp \n\n send file and write download - \"download\" file to esp \n\n send *.tft file - flash Nextion \n\n send firmware.bin or littltfs.bin - firmware ESP ", _chatID);
}
}
else if (msg.text.indexOf("/reboot") != -1)