Hi,
a few years ago, in 2019 I’ve made a device with NUCLEO + mbed os and it was connecting to Cayenne dashboard, and sent some data like temperature, humidity, etc.
Now I returned to this project, but my device can’t send any data to Cayenne. It’s connecting to mqtt.mydevices.com, it’s visible as online on dashbord, but portal disconnects my device after first command publishing any data. If device doesn’t publish any data or only subscribe some topics, it may stay connected for a long time.
I’ve used myDevicesIoT/Cayenne-MQTT-mbed: Cayenne MQTT mbed Library (github.com)
Maybe something has been changed from past days when my device was working well with Cayenne? I don’t know.
// Subscribe to required topics.
if ((error = mqttClient.subscribe(COMMAND_TOPIC, CAYENNE_ALL_CHANNELS)) != CAYENNE_SUCCESS) {
printf(“Subscription to Command topic failed, error: %d\n”, error);
return error;
}
if ((error = mqttClient.subscribe(CONFIG_TOPIC, CAYENNE_ALL_CHANNELS)) != CAYENNE_SUCCESS) {
printf(“Subscription to Config topic failed, error:%d\n”, error);
return error;
}
// Send device info.
if ((error = mqttClient.publishData(SYS_VERSION_TOPIC, CAYENNE_NO_CHANNEL, NULL, NULL, CAYENNE_VERSION)) != CAYENNE_SUCCESS) {
printf(“Publishing SYS_VERSION failed, error:%d\n”, error);
return error;
}
First two subscribe command have ended without error but publishData command returns error=-1 and my device becomes offline on dashboard.
Do you have any advice?
BR
Marek