mirror of
https://gitlab.com/wirelos/sprocket-plugin-mqtt.git
synced 2025-12-17 06:46:39 +01:00
use print fns, example publish task
This commit is contained in:
@@ -6,13 +6,20 @@
|
||||
WiFiNet *network;
|
||||
Sprocket *sprocket;
|
||||
|
||||
Task publishHeap;
|
||||
|
||||
void setup()
|
||||
{
|
||||
publishHeap.set(TASK_SECOND * 5, TASK_FOREVER, [](){
|
||||
sprocket->publish("local/topic", "heap=" + String(ESP.getFreeHeap()));
|
||||
});
|
||||
|
||||
sprocket = new Sprocket(
|
||||
{STARTUP_DELAY, SERIAL_BAUD_RATE});
|
||||
sprocket->subscribe("local/topic", [](String msg){
|
||||
Serial.println("Received: " + msg);
|
||||
Serial.println("Local: " + msg);
|
||||
});
|
||||
sprocket->addTask(publishHeap);
|
||||
sprocket->addPlugin(
|
||||
new MqttPlugin({"sprocket", "192.168.1.2", 1883, "wirelos/mqttSprocket-in/", "wirelos/mqttSprocket-out/"}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user