Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscribe Retain Flag #73

Open
marc-gist opened this issue Aug 3, 2018 · 3 comments
Open

Subscribe Retain Flag #73

marc-gist opened this issue Aug 3, 2018 · 3 comments

Comments

@marc-gist
Copy link

How can I check in the subscribe callback if the payload is a retained value?

Thanks,

@hirotakaster
Copy link
Owner

@marc-gist
check the MQTT protocol and your MQTT broker server specifications.
http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html

@marc-gist
Copy link
Author

No, I mean in your code and on the Photon/Core.

i.e. my code:

void callback(char* topic, byte* payload, unsigned int length) {
    char p[length + 1];
    memcpy(p, payload, length);
    p[length] = NULL;
    
    Serial.printlnf("Payload %s", p);
    if(!strcmp(p, "check")) {
        check_sensor();
    }

I can check the topic and payload, but how can I check the retained flag?

@hirotakaster
Copy link
Owner

Now my callback don't have a retain flag argument as you know.
If you want to know the published message retain flag when your app first connect to the MQTT server, you could implements new callback method with checking the client.buffer mqtt header in loop() function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants