Skip to content

Feature request: simple example that works #142

Open
@rwb196884

Description

@rwb196884

Copied this from https://github.com/plapointe6/EspMQTTClient/blob/master/examples/SimpleMQTTClient/SimpleMQTTClient.ino
but it doesn't do anything.
Is it supposed to do something?

// Origin: https://github.com/plapointe6/EspMQTTClient/blob/master/examples/SimpleMQTTClient/SimpleMQTTClient.ino

// Doesn't work.

#include "EspMQTTClient.h"

EspMQTTClient client(
  "196883",
  "MYWIFI3520",
  "192.168.1.113",  // MQTT Broker server ip
  "",   // Can be omitted if not needed
  "",   // Can be omitted if not needed
  "ESP32",     // Client name that uniquely identify your device
  1883              // The MQTT port, default to 1883. this line can be omitted
);

void setup()
{
  Serial.begin(115200);

  client.enableDebuggingMessages(); // Enable debugging messages sent to serial output
}

void onConnectionEstablished()
{
  client.subscribe("zigbe2mqtt/Home/+/Thermostat", [](const String & topic, const String & payload) {
    Serial.println("(From wildcard) topic: " + topic + ", payload: " + payload);
  });
}

int n = 0
void loop()
{
  client.loop();
  if ( n % 1000000 == 0) {
    Serial.println(n);
  }
  n++
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions