Skip to content

Commit

Permalink
Merge pull request #923 from rechrtb/mqtt_fixes
Browse files Browse the repository at this point in the history
MQTT improvements and fixes
  • Loading branch information
dc42 authored Oct 27, 2023
2 parents 1166535 + 2266f96 commit e0dfb25
Show file tree
Hide file tree
Showing 13 changed files with 277 additions and 446 deletions.
154 changes: 0 additions & 154 deletions Scripts/MQTTDemo/README.md

This file was deleted.

66 changes: 0 additions & 66 deletions Scripts/MQTTDemo/echo.py

This file was deleted.

3 changes: 0 additions & 3 deletions Scripts/MQTTDemo/mosquitto.conf

This file was deleted.

2 changes: 0 additions & 2 deletions Scripts/MQTTDemo/passwords.txt

This file was deleted.

28 changes: 23 additions & 5 deletions src/GCodes/GCodes2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2079,14 +2079,32 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx
}
#endif

#if SUPPORT_MQTT
if ((type & MqttMessage) && (result != GCodeResult::error))
{
String<MaxGCodeLength> topic;
gb.MustSee('T');
gb.GetQuotedString(topic.GetRef());

bool seen = false;

uint32_t qos = 0;
gb.TryGetLimitedUIValue('Q', qos, seen, 3);

bool retain = 0;
gb.TryGetBValue('R', retain, seen);

bool dup = 0;
gb.TryGetBValue('D', dup, seen);

reprap.GetNetwork().MqttPublish(message.c_str(), topic.c_str(), qos, retain, dup);
}
#endif

if (result != GCodeResult::error)
{
// Append newline and send the message to the destinations,
// except for MqttMessage
if (type != MqttMessage)
{
message.cat('\n');
}
message.cat('\n');
platform.Message(type, message.c_str());
}
}
Expand Down
Loading

0 comments on commit e0dfb25

Please sign in to comment.