decreased verbosity, send MQTT ping every 2 minutes to avoid disconnect.

This commit is contained in:
Martin Preuss
2023-07-12 16:45:20 +02:00
parent 4489314b47
commit c7f232dd98
9 changed files with 56 additions and 15 deletions

View File

@@ -94,7 +94,7 @@ int AqHomeMqttLog_MqttConnect(GWEN_MSG_ENDPOINT2 *epTcp)
int rv;
rv=AQH_MqttClientEndpoint2_StartConnect(epTcp);
if (rv<0) {
if (rv<0 && rv!=GWEN_ERROR_IN_PROGRESS) {
DBG_ERROR(NULL, "Error starting to connect (%d)", rv);
return rv;
}
@@ -122,9 +122,6 @@ int AqHomeMqttLog_Subscribe(GWEN_MSG_ENDPOINT2 *epTcp, const char *topicFilter)
DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_INTERNAL;
}
DBG_ERROR(NULL, "Sending this message:");
GWEN_Text_DumpString((const char*) GWEN_Msg_GetConstBuffer(msgOut), GWEN_Msg_GetBytesInBuffer(msgOut), 2);
GWEN_MsgEndpoint2_AddSendMessage(epTcp, msgOut);
DBG_INFO(NULL, "Waiting for response");
@@ -144,6 +141,23 @@ int AqHomeMqttLog_Subscribe(GWEN_MSG_ENDPOINT2 *epTcp, const char *topicFilter)
int AqHomeMqttLog_Ping(GWEN_MSG_ENDPOINT2 *epTcp)
{
GWEN_MSG *msgOut;
DBG_INFO(AQH_LOGDOMAIN, "Sending PING");
msgOut=GWEN_MqttMsg_new(AQH_MQTTMSG_MSGTYPE_PINGREQ, 0, NULL);
if (msgOut==NULL) {
DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_INTERNAL;
}
GWEN_MsgEndpoint2_AddSendMessage(epTcp, msgOut);
return 0;
}
GWEN_MSG *_awaitPacket(GWEN_MSG_ENDPOINT2 *epTcp, uint8_t expectedPacketType, int timeoutInSeconds)
{
time_t startTime;