Skip to content

Multiple unsubscribe or publish with QoS 1 in callback #80

Description

@jreber2

A ESP8266 client is subscribed to 9 topics (all retained messages). In callback are 9 if statements that are handling the received messages. After connection is established and callback function is set, ESP get stuck in callback function (and newer gets out) under certain conditions:
Case 1:
If statement for the first four or more topics: when a message on a topic is received, the client unsubscribes from the topic.
Case 2:
If statement for the last seven or more topics: when a message on a topic is received, the client unsubscribes from the topic.
Case 3:
If statement for the first four or more topics: when a message on a topic is received, the client publishes a message to another topic with QoS 1 (works with QoS 0).
Case 4:
If statement for the last seven or more topics: when a message on a topic is received, the client publishes a message to another topic with QoS 1 (works with QoS 0).

It’s a bit complicated but I hope you can get the point.

Unsubscribe is done as follows:
MQTTclient.unsubscribe(MQTT::Unsubscribe().add_topic(pub.topic()));

And publish:
MQTTclient.publish(MQTT::Publish(topic, payload) //(String topic, String payload)
.set_retain() // Set retain flag
.set_qos(qos) // (0-2) Set QoS value
);

Could you help me with the issue?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions