adapted to latest changes in gwen (msgio API v2 becomes v1).

This commit is contained in:
Martin Preuss
2023-07-12 19:30:53 +02:00
parent 7a4edb6854
commit 0fd58567fe
37 changed files with 956 additions and 956 deletions

View File

@@ -15,7 +15,7 @@
#include <aqhome/api.h>
#include <aqhome/aqhome.h>
#include "aqhome/mqtt/endpoint2_mqttc.h"
#include "aqhome/mqtt/endpoint_mqttc.h"
#include <aqhome/mqtt/msg_mqtt_connect.h>
#include <aqhome/mqtt/msg_mqtt_connack.h>
#include <aqhome/mqtt/msg_mqtt_publish.h>
@@ -44,7 +44,7 @@
* ------------------------------------------------------------------------------------------------
*/
static GWEN_MSG *_awaitPacket(GWEN_MSG_ENDPOINT2 *epTcp, uint8_t expectedPacketType, int timeoutInSeconds);
static GWEN_MSG *_awaitPacket(GWEN_MSG_ENDPOINT *epTcp, uint8_t expectedPacketType, int timeoutInSeconds);
@@ -53,7 +53,7 @@ static GWEN_MSG *_awaitPacket(GWEN_MSG_ENDPOINT2 *epTcp, uint8_t expectedPacketT
* ------------------------------------------------------------------------------------------------
*/
GWEN_MSG_ENDPOINT2 *AqHomeMqttLog_CreateMqttEndpoint(GWEN_DB_NODE *dbArgs)
GWEN_MSG_ENDPOINT *AqHomeMqttLog_CreateMqttEndpoint(GWEN_DB_NODE *dbArgs)
{
const char *mqttAddress;
int mqttPort;
@@ -68,17 +68,17 @@ GWEN_MSG_ENDPOINT2 *AqHomeMqttLog_CreateMqttEndpoint(GWEN_DB_NODE *dbArgs)
mqttKeepAlive=GWEN_DB_GetIntValue(dbArgs, "mqttKeepAlive", 0, 600);
if (mqttAddress && *mqttAddress && mqttPort) {
GWEN_MSG_ENDPOINT2 *epMqtt;
GWEN_MSG_ENDPOINT *epMqtt;
DBG_INFO(AQH_LOGDOMAIN, "Connecting to %s (port %d)", mqttAddress, mqttPort);
epMqtt=AQH_MqttClientEndpoint2_new(mqttClientId, mqttAddress, mqttPort, NULL, 0);
epMqtt=AQH_MqttClientEndpoint_new(mqttClientId, mqttAddress, mqttPort, NULL, 0);
if (epMqtt==NULL) {
DBG_ERROR(AQH_LOGDOMAIN, "Error creating endpoint TCP");
return NULL;
}
if (mqttTopicPrefix && *mqttTopicPrefix)
AQH_MqttClientEndpoint2_SetTopicPrefix(epMqtt, mqttTopicPrefix);
AQH_MqttClientEndpoint2_SetKeepAliveTime(epMqtt, mqttKeepAlive);
AQH_MqttClientEndpoint_SetTopicPrefix(epMqtt, mqttTopicPrefix);
AQH_MqttClientEndpoint_SetKeepAliveTime(epMqtt, mqttKeepAlive);
return epMqtt;
}
@@ -88,41 +88,41 @@ GWEN_MSG_ENDPOINT2 *AqHomeMqttLog_CreateMqttEndpoint(GWEN_DB_NODE *dbArgs)
int AqHomeMqttLog_MqttConnect(GWEN_MSG_ENDPOINT2 *epTcp)
int AqHomeMqttLog_MqttConnect(GWEN_MSG_ENDPOINT *epTcp)
{
if (GWEN_MsgEndpoint2_GetState(epTcp)==GWEN_MSG_ENDPOINT_STATE_UNCONNECTED) {
if (GWEN_MsgEndpoint_GetState(epTcp)==GWEN_MSG_ENDPOINT_STATE_UNCONNECTED) {
int rv;
rv=AQH_MqttClientEndpoint2_StartConnect(epTcp);
rv=AQH_MqttClientEndpoint_StartConnect(epTcp);
if (rv<0 && rv!=GWEN_ERROR_IN_PROGRESS) {
DBG_ERROR(NULL, "Error starting to connect (%d)", rv);
return rv;
}
}
while(GWEN_MsgEndpoint2_GetState(epTcp)!=GWEN_MSG_ENDPOINT_STATE_CONNECTED) {
while(GWEN_MsgEndpoint_GetState(epTcp)!=GWEN_MSG_ENDPOINT_STATE_CONNECTED) {
DBG_DEBUG(NULL, "Next loop");
GWEN_MsgEndpoint2_IoLoop(epTcp, 2000); /* 2000 ms */
GWEN_MsgEndpoint_IoLoop(epTcp, 2000); /* 2000 ms */
}
return 0;
}
int AqHomeMqttLog_Subscribe(GWEN_MSG_ENDPOINT2 *epTcp, const char *topicFilter)
int AqHomeMqttLog_Subscribe(GWEN_MSG_ENDPOINT *epTcp, const char *topicFilter)
{
uint16_t pckId;
GWEN_MSG *msgOut;
GWEN_MSG *msgIn;
DBG_INFO(NULL, "Sending SUBSCRIBE %s", topicFilter);
pckId=AQH_MqttClientEndpoint2_GetNextPacketId(epTcp);
pckId=AQH_MqttClientEndpoint_GetNextPacketId(epTcp);
msgOut=GWEN_SubscribeMqttMsg_new(AQH_MQTTMSG_MSGTYPE_SUBSCRIBE, pckId, topicFilter, 0);
if (msgOut==NULL) {
DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_INTERNAL;
}
GWEN_MsgEndpoint2_AddSendMessage(epTcp, msgOut);
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
DBG_INFO(NULL, "Waiting for response");
msgIn=_awaitPacket(epTcp, AQH_MQTTMSG_MSGTYPE_SUBACK, AQHOME_MQTTLOG_DEFAULT_CMDTIMEOUT);
@@ -141,7 +141,7 @@ int AqHomeMqttLog_Subscribe(GWEN_MSG_ENDPOINT2 *epTcp, const char *topicFilter)
int AqHomeMqttLog_Ping(GWEN_MSG_ENDPOINT2 *epTcp)
int AqHomeMqttLog_Ping(GWEN_MSG_ENDPOINT *epTcp)
{
GWEN_MSG *msgOut;
@@ -151,14 +151,14 @@ int AqHomeMqttLog_Ping(GWEN_MSG_ENDPOINT2 *epTcp)
DBG_ERROR(NULL, "Error creating message");
return GWEN_ERROR_INTERNAL;
}
GWEN_MsgEndpoint2_AddSendMessage(epTcp, msgOut);
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
return 0;
}
GWEN_MSG *_awaitPacket(GWEN_MSG_ENDPOINT2 *epTcp, uint8_t expectedPacketType, int timeoutInSeconds)
GWEN_MSG *_awaitPacket(GWEN_MSG_ENDPOINT *epTcp, uint8_t expectedPacketType, int timeoutInSeconds)
{
time_t startTime;
@@ -168,8 +168,8 @@ GWEN_MSG *_awaitPacket(GWEN_MSG_ENDPOINT2 *epTcp, uint8_t expectedPacketType, in
GWEN_MSG *msg;
time_t now;
GWEN_MsgEndpoint2_IoLoop(epTcp, 2000); /* 2000 ms */
msg=GWEN_MsgEndpoint2_TakeFirstReceivedMessage(epTcp);
GWEN_MsgEndpoint_IoLoop(epTcp, 2000); /* 2000 ms */
msg=GWEN_MsgEndpoint_TakeFirstReceivedMessage(epTcp);
if (msg) {
if ((AQH_MqttMsg_GetMsgTypeAndFlags(msg) & 0xf0)==(expectedPacketType & 0xf0)) {
return msg;