use print fns, example publish task

This commit is contained in:
2018-11-15 12:32:02 +01:00
parent accd942c34
commit 4c27a0fe7b
2 changed files with 21 additions and 43 deletions

View File

@@ -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/"}));