aqhome, aqhome-apps: cleanup, removed unneeded files.

This commit is contained in:
Martin Preuss
2025-03-14 21:22:48 +01:00
parent 31d8cb10df
commit 7e745c98e6
194 changed files with 292 additions and 17295 deletions

View File

@@ -19,8 +19,8 @@
#include "aqhome/events2/eventloop.h"
#include "aqhome/events2/fdobject.h"
#include "aqhome/ipc2/ttyobject.h"
#include "aqhome/ipc2/nodemsgreader.h"
#include "aqhome/ipc2/tty_object.h"
#include "aqhome/ipc2/node_msgreader.h"
#include "aqhome/ipc2/msgreader.h"
#include "aqhome/ipc2/msgwriter.h"
#include "aqhome/ipc2/endpoint.h"
@@ -40,269 +40,6 @@
#include <time.h>
static int _mqttConnect2(GWEN_MSG_ENDPOINT *epClient);
static GWEN_MSG *_awaitPacket2(GWEN_MSG_ENDPOINT *epClient, uint8_t expectedPacketType);
GWEN_MSG *createPingMsg(uint8_t destAddr, uint8_t srcAddr)
{
GWEN_MSG *msg;
int rv;
msg=GWEN_Msg_new(AQH_MAXMSGSIZE);
rv=GWEN_Msg_AddByte(msg, destAddr);
if (rv<0) {
fprintf(stderr, "ERROR1: %d\n", rv);
GWEN_Msg_free(msg);
return NULL;
}
rv=GWEN_Msg_AddByte(msg, 6); /* msglen */
if (rv<0) {
fprintf(stderr, "ERROR2: %d\n", rv);
GWEN_Msg_free(msg);
return NULL;
}
rv=GWEN_Msg_AddByte(msg, AQH_MSG_TYPE_PING); /* ping */
if (rv<0) {
fprintf(stderr, "ERROR3: %d\n", rv);
GWEN_Msg_free(msg);
return NULL;
}
rv=GWEN_Msg_AddByte(msg, srcAddr); /* src addr */
if (rv<0) {
fprintf(stderr, "ERROR4: %d\n", rv);
GWEN_Msg_free(msg);
return NULL;
}
rv=GWEN_Msg_AddByte(msg, 0); /* timestamp */
if (rv<0) {
fprintf(stderr, "ERROR5: %d\n", rv);
GWEN_Msg_free(msg);
return NULL;
}
rv=GWEN_Msg_AddByte(msg, 0); /* timestamp */
if (rv<0) {
fprintf(stderr, "ERROR6: %d\n", rv);
GWEN_Msg_free(msg);
return NULL;
}
rv=GWEN_Msg_AddByte(msg, 0); /* timestamp */
if (rv<0) {
fprintf(stderr, "ERROR7: %d\n", rv);
GWEN_Msg_free(msg);
return NULL;
}
rv=GWEN_Msg_AddByte(msg, 0); /* timestamp */
if (rv<0) {
fprintf(stderr, "ERROR8: %d\n", rv);
GWEN_Msg_free(msg);
return NULL;
}
rv=AQH_NodeMsg_AddChecksum(msg);
if (rv<0) {
fprintf(stderr, "ERROR9: %d\n", rv);
GWEN_Msg_free(msg);
return NULL;
}
return msg;
}
int testMqttConnection2()
{
GWEN_MSG_ENDPOINT *epClient;
int loop;
AQH_Init();
epClient=AQH_MqttClientEndpoint_new("TESTCLIENT1234", "127.0.0.1", 1883, NULL, 1);
for (loop=0;; loop++) {
DBG_INFO(GWEN_LOGDOMAIN, "Loop %d:", loop);
GWEN_MsgEndpoint_IoLoop(epClient, 2000); /* 2000 ms */
if (GWEN_MsgEndpoint_GetState(epClient)==GWEN_MSG_ENDPOINT_STATE_CONNECTED) {
DBG_INFO(AQH_LOGDOMAIN, "Connected.");
break;
}
}
return 0;
}
int testMqttSubscribe2(int argc, char **argv)
{
GWEN_MSG_ENDPOINT *epClient;
int rv;
GWEN_MSG *msgOut;
GWEN_MSG *msgIn;
uint16_t pckId;
const char *host="127.0.0.1";
AQH_Init();
if (argc>1)
host=argv[1];
DBG_ERROR(AQH_LOGDOMAIN, "Connecting to %s (%s)", host, argv[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_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);
if (msgOut==NULL) {
DBG_ERROR(NULL, "Error creating message");
return 2;
}
GWEN_MsgEndpoint_AddSendMessage(epClient, msgOut);
msgIn=_awaitPacket2(epClient, AQH_MQTTMSG_MSGTYPE_SUBACK);
if (msgIn) {
GWEN_BUFFER *buf;
buf=GWEN_Buffer_new(0, 256, 0, 1);
AQH_SubAckMqttMsg_DumpToBuffer(msgIn, buf, "received");
fprintf(stdout, "%s\n", GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf);
GWEN_Msg_free(msgIn);
}
for (;;) {
GWEN_MSG *msg;
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;
buf=GWEN_Buffer_new(0, 256, 0, 1);
AQH_PublishMqttMsg_DumpToBuffer(msg, buf, "received");
fprintf(stdout, "%s\n", GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf);
}
else {
DBG_ERROR(NULL, "Received this message:");
GWEN_Text_DumpString((const char*) GWEN_Msg_GetConstBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg), 2);
}
GWEN_Msg_free(msg);
}
}
return 0;
}
int testMqttSubscribe3(int argc, char **argv)
{
GWEN_MSG_ENDPOINT *epClient;
int rv;
//const char *host="127.0.0.1";
const char *host="192.168.117.192";
AQH_Init();
if (argc>1)
host=argv[1];
DBG_ERROR(AQH_LOGDOMAIN, "Connecting to %s (%s)", host, argv[1]);
epClient=AQH_MqttClientEndpoint_new("TESTCLIENT1234", host, 1883, NULL, 1);
GWEN_MsgEndpoint_AddFlags(epClient, AQH_ENDPOINT2_MQTTCLIENT_FLAGS_SUBSCRIBEALL);
rv=GWEN_MultilayerEndpoint_StartConnect(epClient);
if (rv<0 && rv!=GWEN_ERROR_IN_PROGRESS) {
DBG_ERROR(NULL, "Error on startConnect: %d", rv);
return 2;
}
for (;;) {
GWEN_MSG *msg;
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;
buf=GWEN_Buffer_new(0, 256, 0, 1);
AQH_PublishMqttMsg_DumpToBuffer(msg, buf, "received");
fprintf(stdout, "%s\n", GWEN_Buffer_GetStart(buf));
GWEN_Buffer_free(buf);
}
else {
DBG_ERROR(NULL, "Received this message:");
GWEN_Text_DumpString((const char*) GWEN_Msg_GetConstBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg), 2);
}
GWEN_Msg_free(msg);
}
}
return 0;
}
int _mqttConnect2(GWEN_MSG_ENDPOINT *epClient)
{
int loop;
for (loop=0;; loop++) {
DBG_INFO(GWEN_LOGDOMAIN, "Loop %d:", loop);
GWEN_MsgEndpoint_IoLoop(epClient, 2000); /* 2000 ms */
if (GWEN_MsgEndpoint_GetState(epClient)==GWEN_MSG_ENDPOINT_STATE_CONNECTED) {
DBG_INFO(AQH_LOGDOMAIN, "Connected.");
break;
}
else if (GWEN_MsgEndpoint_GetState(epClient)==GWEN_MSG_ENDPOINT_STATE_UNCONNECTED) {
DBG_INFO(AQH_LOGDOMAIN, "Disconnected.");
return GWEN_ERROR_IO;
}
}
return 0;
}
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_MsgEndpoint_IoLoop(epClient, 2000); /* 2000 ms */
msg=GWEN_MsgEndpoint_TakeFirstReceivedMessage(epClient);
if (msg) {
if ((AQH_MqttMsg_GetMsgTypeAndFlags(msg) & 0xf0)==(expectedPacketType & 0xf0)) {
return msg;
}
else {
DBG_ERROR(NULL, "Received this message:");
GWEN_Text_DumpString((const char*) GWEN_Msg_GetConstBuffer(msg), GWEN_Msg_GetBytesInBuffer(msg), 2);
}
}
} /* for */
return NULL;
}
#if 0
GWEN_MSG_ENDPOINT *_acceptHttpConnection(GWEN_UNUSED GWEN_MSG_ENDPOINT *ep,