martin-ger / esp_mqtt

MQTT Broker/Bridge on the ESP8266
MIT License
295 stars 69 forks source link

About "uint32_t *args" the first parameter of MqttDataCallback #14

Closed TridentTD closed 6 years ago

TridentTD commented 6 years ago
typedef void (*MqttDataCallback)(uint32_t *args, const char* topic, uint32_t topic_len, const char *data, uint32_t length);

How to use this "args" in MQTT Broker's DataCallback? Is it MQTT_ClientCon type?

martin-ger commented 6 years ago

When you receive the callback from a remote subscription (via the original client lib) you get a pointer to a MQTTclient struct, when you get it from the local broker it is set to NULL.

In some cases it could be the publishing MQTT_ClientCon, but e.g. for retained messages this doesn't work. Also it is not the intention of MQTT and the pubsub model to provide local extra info on the sender of a publication to a subscriber

TridentTD commented 6 years ago

Thank you .. because of retained messages, it is set to NULL.....

If for normal messages , can I get a pointer to MQTT_ClientCon struct, and for retained messages, get a pointer to NULL instead?

martin-ger commented 6 years ago

Sorry, no - it COULD be done - in fact, you get NULL all the time...

TridentTD commented 6 years ago

Thanks.