Hello everyone,
I have a problem with the MQTT receiver. I'm sending a message using proto file like
"
TurnOn/ On j
2 <reply/ 24: 0A: C4: 40: D5: 7C / 9d3cc41f-0d35-4543-8521-1bdd63c59b99 "
But in the ESP32 code I got:
And (18713) Mqtt: DATA =
Switch / selector
2
Cuts out some information like "reply ...."
MQTT problem
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: MQTT problem
Can you post the code that sends/receives this?
Re: MQTT problem
Hi,
I have only code for receiving information.
But If I use for example MQTT explorer like external APP I can see corect frame.
I have only code for receiving information.
But If I use for example MQTT explorer like external APP I can see corect frame.
Code: Select all
esp_err_t Protocols::Mqtt::mqttEventHandlerCb(esp_mqtt_event_handle_t t_event)
{
std::string userContext = *((std::string*) t_event->user_context);
switch (t_event->event_id)
{
case MQTT_EVENT_CONNECTED:
{
}
break;
case MQTT_EVENT_DISCONNECTED:
{
ESP_LOGI(Protocols::Mqtt::TAG, "MQTT_EVENT_DISCONNECTED - client %s", userContext.c_str());
}
break;
case MQTT_EVENT_SUBSCRIBED:
ESP_LOGI(Protocols::Mqtt::TAG, "MQTT_EVENT_SUBSCRIBED, msg_id=%d", t_event->msg_id);
break;
case MQTT_EVENT_UNSUBSCRIBED:
ESP_LOGI(Protocols::Mqtt::TAG, "MQTT_EVENT_UNSUBSCRIBED, msg_id=%d", t_event->msg_id);
break;
case MQTT_EVENT_PUBLISHED:
ESP_LOGI(Protocols::Mqtt::TAG, "MQTT_EVENT_PUBLISHED, msg_id=%d", t_event->msg_id);
break;
case MQTT_EVENT_DATA:
{
ESP_LOGI(Protocols::Mqtt::TAG, "MQTT_EVENT_DATA");
ESP_LOGD(Protocols::Mqtt::TAG,"TOPIC= %.*s", t_event->topic_len, t_event->topic);
}
break;
case MQTT_EVENT_ERROR:
ESP_LOGI(Protocols::Mqtt::TAG, "MQTT_EVENT_ERROR - client %s", userContext.c_str());
break;
default:
break;
}
return ESP_OK;
}
Re: MQTT problem
This is probably caused by "�" inside the message. How we can avoid this problem?
-
- Posts: 9766
- Joined: Thu Nov 26, 2015 4:08 am
Re: MQTT problem
Not sure what that character is, but the issue may be that it's a NULL (ASCII value 0). In that case, ESP_LOG* (which is based on printf) will stop printing data there. Your data still is in the string, you may simply need to filter out that character for it to log correctly.
Who is online
Users browsing this forum: Baidu [Spider] and 164 guests