Skip to content

Updates to PubSubClient break MQTT client/callback #1

@KAJETALK

Description

@KAJETALK

It looks like PubSubClient has updated code which break the SecuritySensor4ToMQTT code

What is required now by PubSubClient is the following:
PubSubClient (server, port, [callback], client, [stream])

Creates a fully configured client instance.
Parameters

server : the address of the server (IPAddress, uint8_t[] or const char[])
port : the port to connect to (int)
callback : optional a pointer to a message callback function called when a message arrives for a subscription created by this client.
client : an instance of Client, typically EthernetClient.
stream : optional an instance of Stream, used to store received messages. See the mqtt_stream example for more information.

I was able to get it to compile by changing the callback method to the following:

void callback(
  char* topic,
  byte* payload,
  unsigned int length) {

And changing the constructor to the following:

// Instantiate MQTT client
EthernetClient ethClient;
PubSubClient client(server, 1883, callback, ethClient);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions