Closed evandavey closed 8 years ago
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; }
I've managed to narrow this down to being a problem with the topicName. Turns out the max payload size needs to be increased.
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.