-
Notifications
You must be signed in to change notification settings - Fork 2
Example MQTT node
Tom Lonergan edited this page Feb 12, 2024
·
1 revision
An MQTT node consists of an infinite loop:
void Example::run()
{
while (true /* or you may have a better exit condition */) {
mqtt_->consume();
const auto message = mqtt_.getMessage();
if (!message) { continue; }
const auto message = *message;
if (message.topic == kStateMachine) {
logger_.log(kFatal, "Received shutdown message");
break;
}
elif (message.topic == kIncomingData)
{
const auto result_message = process(message);
mqtt_->publish(result_message)
}
// there will be a core function for cross platform sleep soon
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}
- Home
- How to add and edit pages on the wiki
- Glossary
- Admin
- Projects & Subsystems
- Technical Guides
- Git
- C++
- Testing
- Build system
- Work In Progress