Skip to content

Commit

Permalink
Resurrect MQTT examples.
Browse files Browse the repository at this point in the history
This refactored to put the cmake-include files in the library reactors, making them easier to use.
This also updated the docs and the installation instructions.
  • Loading branch information
edwardalee committed Jan 27, 2024
1 parent 884f634 commit 98ee75a
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 23 deletions.
3 changes: 1 addition & 2 deletions examples/C/src/mqtt/MQTTDistributed.lf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* The code generator produces three programs, bin/MQTTDistributed_RTI, bin/MQTTDistributed_source,
* and bin/MQTTDistributed_destination, plus a script bin/MQTTDistributed that runs all three.
*
* Since the source and destination are running in the same executable, there is no clock
* If the source and destination are running in the same machine, there is no clock
* synchronization error.
*
* See README.md for prerequisites and further information.
Expand All @@ -21,7 +21,6 @@
* @author Edward A. Lee
*/
target C {
cmake-include: ["include/paho-extension.cmake", "include/mosquitto-extension.cmake"],
timeout: 10 secs,
coordination: centralized
}
Expand Down
1 change: 0 additions & 1 deletion examples/C/src/mqtt/MQTTDistributedActivity.lf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
* @author Edward A. Lee
*/
target C {
cmake-include: ["include/paho-extension.cmake", "include/mosquitto-extension.cmake"],
timeout: 10 secs,
coordination: centralized
}
Expand Down
9 changes: 2 additions & 7 deletions examples/C/src/mqtt/MQTTLegacy.lf
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,13 @@
*
* This is a federated program, the publisher and subscriber run in separate programs. This would
* work pretty much the same way, however, as an unfederated program. To run as an unfederated
* program, add to cmake-include the following file:
*
* "include/net_utils.cmake"
*
* and change the `federated` keyword to `main`.
* program, just change the `federated` keyword to `main`.
*
* See README.md for prerequisites and further information.
*
* @author Edward A. Lee
*/
target C {
cmake-include: ["include/paho-extension.cmake", "include/mosquitto-extension.cmake"],
timeout: 1 min,
coordination: centralized
}
Expand All @@ -49,7 +44,7 @@ reactor Subscriber {
sub.message -> dsp.message
}

federated reactor {
main reactor {
source = new Publisher()
destination = new Subscriber()
}
4 changes: 0 additions & 4 deletions examples/C/src/mqtt/MQTTLogical.lf
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
* @author Edward A. Lee
*/
target C {
cmake-include: [
"include/paho-extension.cmake", // For #include "MQTTClient.h"
// For encode_int64()
"include/net_utils.cmake"],
timeout: 10 secs
}

Expand Down
4 changes: 0 additions & 4 deletions examples/C/src/mqtt/MQTTPhysical.lf
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
* @author Edward A. Lee
*/
target C {
cmake-include: [
"include/paho-extension.cmake", // For #include "MQTTClient.h"
// For encode_int64() and extract_int64()
"include/net_utils.cmake"],
timeout: 10 secs
}

Expand Down
2 changes: 1 addition & 1 deletion examples/C/src/mqtt/include/net_utils.cmake
Original file line number Diff line number Diff line change
@@ -1 +1 @@
target_sources(${LF_MAIN_TARGET} PRIVATE "core/federated/net_util.c")
target_sources(${LF_MAIN_TARGET} PRIVATE "core/federated/network/net_util.c")
8 changes: 6 additions & 2 deletions examples/C/src/mqtt/lib/MQTTPublisher.lf
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,18 @@
* @author Ravi Akella
* @author Edward A. Lee
*/
target C
target C {
cmake-include: [
"../include/paho-extension.cmake",
"../include/net_utils.cmake" // For encode_int64()
]
}

preamble {=
#ifndef MQTT_PUBLISHER_H
#define MQTT_PUBLISHER_H

#include "platform.h" // Defines lf_critical_section_enter(), etc.
#include "tag.h" // Defines lf_time_logical()
#include <string.h> // Defines memcpy

#include "MQTTClient.h"
Expand Down
8 changes: 6 additions & 2 deletions examples/C/src/mqtt/lib/MQTTSubscriber.lf
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,18 @@
* @author Ravi Akella
* @author Edward A. Lee
*/
target C
target C {
cmake-include: [
"../include/paho-extension.cmake",
"../include/net_utils.cmake" // For extract_int64()
]
}

preamble {=
#ifndef MQTT_SUBSCRIBER_H
#define MQTT_SUBSCRIBER_H

#include "platform.h" // Defines lf_critical_section_enter(), etc.
#include "tag.h" // Defines lf_time_logical()
#include <string.h> // Defines memcmp()

#include "MQTTClient.h"
Expand Down

0 comments on commit 98ee75a

Please sign in to comment.