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

@@ -7,7 +7,7 @@
#include "aqhome/ipc/msg_ipc_ping.h"
#include "aqhome/ipc/msg_ipc_forward.h"
#include "aqhome/ipc/msg_ipc_setaccmsggrps.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"
@@ -28,8 +28,8 @@
#include <time.h>
static int _mqttConnect2(GWEN_MSG_ENDPOINT2 *epClient);
static GWEN_MSG *_awaitPacket2(GWEN_MSG_ENDPOINT2 *epClient, uint8_t expectedPacketType);
static int _mqttConnect2(GWEN_MSG_ENDPOINT *epClient);
static GWEN_MSG *_awaitPacket2(GWEN_MSG_ENDPOINT *epClient, uint8_t expectedPacketType);
@@ -104,18 +104,18 @@ GWEN_MSG *createPingMsg(uint8_t destAddr, uint8_t srcAddr)
int testMqttConnection2()
{
GWEN_MSG_ENDPOINT2 *epClient;
GWEN_MSG_ENDPOINT *epClient;
int loop;
AQH_Init();
epClient=AQH_MqttClientEndpoint2_new("TESTCLIENT1234", "127.0.0.1", 1883, NULL, 1);
epClient=AQH_MqttClientEndpoint_new("TESTCLIENT1234", "127.0.0.1", 1883, NULL, 1);
for (loop=0;; loop++) {
DBG_INFO(GWEN_LOGDOMAIN, "Loop %d:", loop);
GWEN_MsgEndpoint2_IoLoop(epClient, 2000); /* 2000 ms */
GWEN_MsgEndpoint_IoLoop(epClient, 2000); /* 2000 ms */
if (GWEN_MsgEndpoint2_GetState(epClient)==GWEN_MSG_ENDPOINT_STATE_CONNECTED) {
if (GWEN_MsgEndpoint_GetState(epClient)==GWEN_MSG_ENDPOINT_STATE_CONNECTED) {
DBG_INFO(AQH_LOGDOMAIN, "Connected.");
break;
}
@@ -127,7 +127,7 @@ int testMqttConnection2()
int testMqttSubscribe2(int argc, char **argv)
{
GWEN_MSG_ENDPOINT2 *epClient;
GWEN_MSG_ENDPOINT *epClient;
int rv;
GWEN_MSG *msgOut;
GWEN_MSG *msgIn;
@@ -140,14 +140,14 @@ int testMqttSubscribe2(int argc, char **argv)
host=argv[1];
DBG_ERROR(AQH_LOGDOMAIN, "Connecting to %s (%s)", host, argv[1]);
epClient=AQH_MqttClientEndpoint2_new("TESTCLIENT1234", host, 1883, NULL, 1);
epClient=AQH_MqttClientEndpoint_new("TESTCLIENT1234", host, 1883, NULL, 1);
rv=_mqttConnect2(epClient);
if (rv<0) {
DBG_INFO(AQH_LOGDOMAIN, "here (%d)", rv);
return 2;
}
pckId=AQH_MqttClientEndpoint2_GetNextPacketId(epClient);
pckId=AQH_MqttClientEndpoint_GetNextPacketId(epClient);
//msgOut=AQH_PublishMqttMsg_new(AQH_MQTTMSG_FLAGS_QOS1, 1, "test/subject1", (const uint8_t*) "29.9", 4);
//msgOut=GWEN_SubscribeMqttMsg_new(AQH_MQTTMSG_MSGTYPE_SUBSCRIBE, pckId, "aqhome/#", 0);
msgOut=GWEN_SubscribeMqttMsg_new(AQH_MQTTMSG_MSGTYPE_SUBSCRIBE, pckId, "#", 0);
@@ -155,7 +155,7 @@ int testMqttSubscribe2(int argc, char **argv)
DBG_ERROR(NULL, "Error creating message");
return 2;
}
GWEN_MsgEndpoint2_AddSendMessage(epClient, msgOut);
GWEN_MsgEndpoint_AddSendMessage(epClient, msgOut);
msgIn=_awaitPacket2(epClient, AQH_MQTTMSG_MSGTYPE_SUBACK);
if (msgIn) {
@@ -171,8 +171,8 @@ int testMqttSubscribe2(int argc, char **argv)
for (;;) {
GWEN_MSG *msg;
GWEN_MsgEndpoint2_IoLoop(epClient, 2000); /* 2000 ms */
msg=GWEN_MsgEndpoint2_TakeFirstReceivedMessage(epClient);
GWEN_MsgEndpoint_IoLoop(epClient, 2000); /* 2000 ms */
msg=GWEN_MsgEndpoint_TakeFirstReceivedMessage(epClient);
if (msg) {
if ((AQH_MqttMsg_GetMsgTypeAndFlags(msg) & 0xf0)==(AQH_MQTTMSG_MSGTYPE_PUBLISH & 0xf0)) {
GWEN_BUFFER *buf;
@@ -196,19 +196,19 @@ int testMqttSubscribe2(int argc, char **argv)
int _mqttConnect2(GWEN_MSG_ENDPOINT2 *epClient)
int _mqttConnect2(GWEN_MSG_ENDPOINT *epClient)
{
int loop;
for (loop=0;; loop++) {
DBG_INFO(GWEN_LOGDOMAIN, "Loop %d:", loop);
GWEN_MsgEndpoint2_IoLoop(epClient, 2000); /* 2000 ms */
GWEN_MsgEndpoint_IoLoop(epClient, 2000); /* 2000 ms */
if (GWEN_MsgEndpoint2_GetState(epClient)==GWEN_MSG_ENDPOINT_STATE_CONNECTED) {
if (GWEN_MsgEndpoint_GetState(epClient)==GWEN_MSG_ENDPOINT_STATE_CONNECTED) {
DBG_INFO(AQH_LOGDOMAIN, "Connected.");
break;
}
else if (GWEN_MsgEndpoint2_GetState(epClient)==GWEN_MSG_ENDPOINT_STATE_UNCONNECTED) {
else if (GWEN_MsgEndpoint_GetState(epClient)==GWEN_MSG_ENDPOINT_STATE_UNCONNECTED) {
DBG_INFO(AQH_LOGDOMAIN, "Disconnected.");
return GWEN_ERROR_IO;
}
@@ -219,15 +219,15 @@ int _mqttConnect2(GWEN_MSG_ENDPOINT2 *epClient)
GWEN_MSG *_awaitPacket2(GWEN_MSG_ENDPOINT2 *epClient, uint8_t expectedPacketType)
GWEN_MSG *_awaitPacket2(GWEN_MSG_ENDPOINT *epClient, uint8_t expectedPacketType)
{
fprintf(stdout, "Waiting for response\n");
for (;;) {
GWEN_MSG *msg;
DBG_DEBUG(AQH_LOGDOMAIN, "Next loop");
GWEN_MsgEndpoint2_IoLoop(epClient, 2000); /* 2000 ms */
msg=GWEN_MsgEndpoint2_TakeFirstReceivedMessage(epClient);
GWEN_MsgEndpoint_IoLoop(epClient, 2000); /* 2000 ms */
msg=GWEN_MsgEndpoint_TakeFirstReceivedMessage(epClient);
if (msg) {
if ((AQH_MqttMsg_GetMsgTypeAndFlags(msg) & 0xf0)==(expectedPacketType & 0xf0)) {
return msg;