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

Example of connect with willFlag=1 #47

Closed
evandavey opened this issue Sep 8, 2016 · 1 comment
Closed

Example of connect with willFlag=1 #47

evandavey opened this issue Sep 8, 2016 · 1 comment

Comments

@evandavey
Copy link

I've searched the examples but can't find any that has a last will and testament. The code below generates a rc=-1 with MQTTSerialize_connect failing.

char willTopic[100] = "/device/";
strcat(willTopic,username);
strcat(willTopic,"/shadow/update");

MQTTPacket_connectData data = MQTTPacket_connectData_initializer;     
data.MQTTVersion = 3;
data.clientID.cstring = (char*) username;
data.username.cstring = (char*) username;
data.password.cstring = (char*) password;
data.cleansession = 1;
data.keepAliveInterval = 30;
data.will.message.cstring = (char*) "{\"connected\":false}";
data.will.topicName.cstring = (char*) willTopic;
data.willFlag = 1;


// this will call the read and write functions of the cellular code
int rc = _client->connect(data);
if (rc != 0) {
    ERROR(F("MQTT connect error: %d"),rc);
    return false;
} 
@evandavey
Copy link
Author

evandavey commented Sep 13, 2016

I've managed to narrow this down to being a problem with the topicName. Turns out the max payload size needs to be increased.

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

1 participant