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

@@ -31,7 +31,7 @@
* ------------------------------------------------------------------------------------------------
*/
static int _handlePublish(AQH_OBJECT *o, const char *rcvdTopic, const char *rcvdValue);
static int _handlePublish(AQH_OBJECT *o, AQH_MQTTLOG_SERVER *xo, const char *rcvdTopic, const char *rcvdValue);
static void _handleNumTopic(AQH_MQTTLOG_SERVER *xo, AQHMQTT_DEVICE *device,
AQHMQTT_TOPIC *topic, const char *rcvdValue);
static void _handleJsonTopic(AQH_MQTTLOG_SERVER *xo, AQHMQTT_DEVICE *device,
@@ -69,12 +69,12 @@ void AQH_MqttLogServer_HandlePublishMsg(AQH_OBJECT *o, GWEN_UNUSED AQH_OBJECT *e
if (topic && value) {
int rv;
rv=_handlePublish(o, topic, value);
rv=_handlePublish(o, xo, topic, value);
if (rv!=1) {
DBG_INFO(NULL, "New topic \"%s\", trying to register", topic);
rv=_registerNewDeviceForTopic(xo, topic);
if (rv==1) {
rv=_handlePublish(o, topic, value);
rv=_handlePublish(o, xo, topic, value);
if (rv!=1) {
DBG_ERROR(NULL, "Topic \"%s\" still not handled, SNH!", topic);
}
@@ -92,53 +92,48 @@ void AQH_MqttLogServer_HandlePublishMsg(AQH_OBJECT *o, GWEN_UNUSED AQH_OBJECT *e
int _handlePublish(AQH_OBJECT *o, const char *rcvdTopic, const char *rcvdValue)
int _handlePublish(AQH_OBJECT *o, AQH_MQTTLOG_SERVER *xo, const char *rcvdTopic, const char *rcvdValue)
{
if (o && rcvdTopic && *rcvdTopic) {
AQH_MQTTLOG_SERVER *xo;
if (o && rcvdTopic && *rcvdTopic && xo && xo->registeredDeviceList) {
AQHMQTT_DEVICE *device;
xo=AQH_MqttLogServer_GetServerData(o);
if (xo && xo->registeredDeviceList) {
AQHMQTT_DEVICE *device;
device=AQHMQTT_Device_List_First(xo->registeredDeviceList);
while(device) {
AQHMQTT_TOPIC_LIST *topicList;
const char *sDeviceName;
const char *sDeviceId;
device=AQHMQTT_Device_List_First(xo->registeredDeviceList);
while(device) {
AQHMQTT_TOPIC_LIST *topicList;
const char *sDeviceName;
const char *sDeviceId;
sDeviceName=AQHMQTT_Device_GetName(device);
sDeviceId=AQHMQTT_Device_GetId(device);
sDeviceName=AQHMQTT_Device_GetName(device);
sDeviceId=AQHMQTT_Device_GetId(device);
topicList=AQHMQTT_Device_GetTopicList(device);
if (topicList) {
AQHMQTT_TOPIC *topic;
topicList=AQHMQTT_Device_GetTopicList(device);
if (topicList) {
AQHMQTT_TOPIC *topic;
topic=_findTopicMatchingTopic(topicList, rcvdTopic, AQHMQTT_TopicDir_In);
topic=_findTopicMatchingTopic(topicList, rcvdTopic, AQHMQTT_TopicDir_In);
#if 0
if (topic==NULL) {
topic=_findMaskMatchingTopic(topicList, rcvdTopic, AQHMQTT_TopicDir_In);
if (topic)
AQHMQTT_Topic_SetTopic(topic, rcvdTopic);
}
#endif
if (topic) {
DBG_INFO(AQH_LOGDOMAIN,
"Handling topic \"%s\" for device type %s (id: %s)",
rcvdTopic,
sDeviceName, sDeviceId?sDeviceId:"<no id>");
if (AQHMQTT_Topic_GetTopicType(topic)==AQHMQTT_TopicType_Json)
_handleJsonTopic(xo, device, topic, rcvdValue);
else
_handleNumTopic(xo, device, topic, rcvdValue);
return 1;
}
if (topic==NULL) {
topic=_findMaskMatchingTopic(topicList, rcvdTopic, AQHMQTT_TopicDir_In);
if (topic)
AQHMQTT_Topic_SetTopic(topic, rcvdTopic);
}
#endif
if (topic) {
DBG_INFO(AQH_LOGDOMAIN,
"Handling topic \"%s\" for device type %s (id: %s)",
rcvdTopic,
sDeviceName, sDeviceId?sDeviceId:"<no id>");
if (AQHMQTT_Topic_GetTopicType(topic)==AQHMQTT_TopicType_Json)
_handleJsonTopic(xo, device, topic, rcvdValue);
else
_handleNumTopic(xo, device, topic, rcvdValue);
return 1;
}
device=AQHMQTT_Device_List_Next(device);
}
DBG_INFO(AQH_LOGDOMAIN, "ignoring topic \"%s\"", rcvdTopic);
device=AQHMQTT_Device_List_Next(device);
}
DBG_INFO(AQH_LOGDOMAIN, "ignoring topic \"%s\"", rcvdTopic);
}
return 0;
}
@@ -282,7 +277,7 @@ void _sendAnnounceValueMessage(AQH_MQTTLOG_SERVER *xo, const AQHMQTT_DEVICE *dev
AQH_Endpoint_GetNextMessageId(xo->brokerEndpoint), 0,
0, msgValue);
if (pubMsg) {
DBG_INFO(AQH_LOGDOMAIN, "BROKER ANNOUNCE_VALUE %s", AQH_Value_GetName(msgValue));
DBG_ERROR(AQH_LOGDOMAIN, "BROKER ANNOUNCE_VALUE %s/%s", AQH_Value_GetDeviceName(msgValue), AQH_Value_GetName(msgValue));
AQH_Endpoint_AddMsgOut(xo->brokerEndpoint, pubMsg);
}
AQH_Value_free(msgValue);

View File

@@ -31,8 +31,7 @@
static void _sendDataForDevice(AQH_MQTTLOG_SERVER *xo, const AQHMQTT_DEVICE *device,
const char *valueName, const char *valueData);
static void _sendValueToMqtt(AQH_MQTTLOG_SERVER *xo, const char *deviceId,
const AQHMQTT_TOPIC *topic, const char *valueData);
static void _sendValueToMqtt(AQH_MQTTLOG_SERVER *xo, const char *deviceId, const AQHMQTT_TOPIC *topic, const char *valueData);
static GWEN_BUFFER *_createBufferForTopic(const char *deviceId, const AQHMQTT_TOPIC *topic);
@@ -131,7 +130,7 @@ void _sendDataForDevice(AQH_MQTTLOG_SERVER *xo,
void _sendValueToMqtt(AQH_MQTTLOG_SERVER *xo, const char *deviceId, const AQHMQTT_TOPIC *topic, const char *valueData)
void _sendValueToMqtt(AQH_MQTTLOG_SERVER *xo, const char *deviceId, const AQHMQTT_TOPIC *topic, const char *valueData)
{
GWEN_BUFFER *buf;
#if !DEBUG_DRY_RUN

View File

@@ -109,10 +109,10 @@ static int _handleSignal(AQH_OBJECT *o, uint32_t slotId, AQH_OBJECT *senderObjec
static int _handleBrokerDown(AQH_MQTTLOG_SERVER *xo);
static int _handleMqttDown(AQH_MQTTLOG_SERVER *xo);
static void _handleMsgFromBroker(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg);
static void _handleMsgFromBroker(AQH_OBJECT *o, const AQH_MESSAGE *msg);
static void _handleMsgFromMqtt(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg);
static void _handleMqttMsgPingRsp(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg);
static void _handleMqttMsgPingRsp(void);
static int _createPidFile(const char *pidFilename);
static int _diffInSeconds(time_t t1, time_t t0);
@@ -474,7 +474,7 @@ int _startBroker(AQH_OBJECT *o, AQH_MQTTLOG_SERVER *xo)
DBG_ERROR(NULL, "Error connecting to broker: %d", rv);
return (rv<0)?rv:GWEN_ERROR_PERMISSIONS;
}
DBG_NOTICE(NULL, "Connected to broker at %s:%d", xo->brokerAddress, xo->brokerPort);
DBG_NOTICE(NULL, "Fully connected to broker at %s:%d", xo->brokerAddress, xo->brokerPort);
return 0;
}
else {
@@ -658,7 +658,7 @@ void AQH_MqttLogServer_HandleBrokerMsgs(AQH_OBJECT *o)
while( (msg=AQH_Endpoint_GetNextMsgIn(xo->brokerEndpoint)) ) {
AQH_Message_SetObject(msg, xo->brokerEndpoint);
_handleMsgFromBroker(o, xo->brokerEndpoint, msg);
_handleMsgFromBroker(o, msg);
AQH_Message_free(msg);
}
}
@@ -666,7 +666,7 @@ void AQH_MqttLogServer_HandleBrokerMsgs(AQH_OBJECT *o)
void _handleMsgFromBroker(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg)
void _handleMsgFromBroker(AQH_OBJECT *o, const AQH_MESSAGE *msg)
{
GWEN_TAG16_LIST *tagList;
@@ -762,14 +762,14 @@ void _handleMsgFromMqtt(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg)
code=AQH_MqttMessage_GetTypeAndFlags(msg);
switch(code & 0xf0) {
case (AQH_MQTTMSG_MSGTYPE_PUBLISH & 0xf0): AQH_MqttLogServer_HandlePublishMsg(o, ep, msg); break;
case (AQH_MQTTMSG_MSGTYPE_PINGRESP & 0xf0): _handleMqttMsgPingRsp(o, ep, msg); break;
case (AQH_MQTTMSG_MSGTYPE_PINGRESP & 0xf0): _handleMqttMsgPingRsp(); break;
default: break;
}
}
void _handleMqttMsgPingRsp(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg)
void _handleMqttMsgPingRsp(void)
{
DBG_INFO(NULL, "PING response received");
}
@@ -962,8 +962,9 @@ void AQH_MqttLogServer_LoadRuntimeDeviceFiles(AQH_OBJECT *o)
DBG_INFO(NULL, "Loading registered devices from file \"%s\"", xo->deviceFile);
deviceList=AQH_MqttLogServer_ReadDeviceFile(o, xo->deviceFile);
if (deviceList)
AQH_MqttLogServer_SetRegisteredDeviceList(o, deviceList);
if (deviceList==NULL)
deviceList=AQHMQTT_Device_List_new();
AQH_MqttLogServer_SetRegisteredDeviceList(o, deviceList);
}
}
}
@@ -999,7 +1000,7 @@ int AQH_MqttLogServer_SaveRuntimeDeviceFiles(AQH_OBJECT *o)
* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
*/
int _handleSignal(AQH_OBJECT *o, uint32_t slotId, AQH_OBJECT *senderObject, GWEN_UNUSED int param1, void *param2)
int _handleSignal(AQH_OBJECT *o, uint32_t slotId, GWEN_UNUSED AQH_OBJECT *senderObject, GWEN_UNUSED int param1, GWEN_UNUSED void *param2)
{
AQH_MQTTLOG_SERVER *xo;

View File

@@ -80,7 +80,7 @@ AQHMQTT_DEVICE_LIST *AQH_MqttLogServer_ReadDeviceFile(AQH_OBJECT *o, const char
deviceList=AQHMQTT_Device_List_new();
rv=_readDeviceFileToList(sFilename, deviceList);
if (rv<0) {
DBG_ERROR(NULL, "File \"%s\" not found", sFilename);
DBG_ERROR(NULL, "Could not read file \"%s\" (empty?)", sFilename);
AQHMQTT_Device_List_free(deviceList);
return NULL;
}

View File

@@ -258,22 +258,24 @@ void _setDeviceName(AQH_VALUE *value, uint32_t uid)
void _announceValue(AQH_NODE_SERVER *xo, uint32_t uid, const AQHNODE_VALUE *v)
{
AQH_VALUE *value;
AQH_MESSAGE *msg;
value=AQH_Value_new();
_setDeviceName(value, uid);
AQH_Value_SetDriver(value, "nodes");
AQH_Value_SetName(value, AQHNODE_Value_GetName(v));
AQH_Value_SetValueUnits(value, AQHNODE_Value_GetValueUnits(v));
AQH_Value_SetValueType(value, AQHNODE_Value_GetValueType(v));
AQH_Value_SetModality(value, AQHNODE_Value_GetModality(v));
if (xo && xo->brokerEndpoint) {
AQH_VALUE *value;
AQH_MESSAGE *msg;
msg=AQH_IpcdMessageValues_newForOne(AQH_MSGTYPE_IPC_DATA_ANNOUNCEVALUE,
AQH_Endpoint_GetNextMessageId(xo->brokerEndpoint), 0,
0, value);
AQH_Endpoint_AddMsgOut(xo->brokerEndpoint, msg);
AQH_Value_free(value);
value=AQH_Value_new();
_setDeviceName(value, uid);
AQH_Value_SetDriver(value, "nodes");
AQH_Value_SetName(value, AQHNODE_Value_GetName(v));
AQH_Value_SetValueUnits(value, AQHNODE_Value_GetValueUnits(v));
AQH_Value_SetValueType(value, AQHNODE_Value_GetValueType(v));
AQH_Value_SetModality(value, AQHNODE_Value_GetModality(v));
msg=AQH_IpcdMessageValues_newForOne(AQH_MSGTYPE_IPC_DATA_ANNOUNCEVALUE,
AQH_Endpoint_GetNextMessageId(xo->brokerEndpoint), 0,
0, value);
AQH_Endpoint_AddMsgOut(xo->brokerEndpoint, msg);
AQH_Value_free(value);
}
}

View File

@@ -149,13 +149,13 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop)
now=time(NULL);
if (_diffInSeconds(now, timeLastConnectionCleanup)>CONNCLEAN_INTERVAL_IN_SECS) {
DBG_ERROR(NULL, "Cleanup connections");
DBG_INFO(NULL, "Cleanup connections");
AQH_NodeServer_CleanupClients(aqh);
timeLastConnectionCleanup=now;
}
if (_diffInSeconds(now, timeLastConnCheck)>CONNCHECK_INTERVAL_IN_SECS) {
DBG_ERROR(NULL, "Check connections");
DBG_INFO(NULL, "Check connections");
AQH_NodeServer_CheckBrokerConnection(aqh);
AQH_NodeServer_CheckTtyConnection(aqh);
timeLastConnCheck=now;

View File

@@ -24,7 +24,7 @@
#include <aqhome/ipc2/ipc_server.h>
#include <aqhome/ipc2/tcpd_object.h>
#include <aqhome/ipc2/tty_endpoint.h>
#include <aqhome/ipc2/ttyobject.h>
#include <aqhome/ipc2/tty_object.h>
#include <aqhome/ipc2/tcp_object.h>
#include <aqhome/ipc2/tcpd_object.h>
#include <aqhome/ipc2/ipc_client.h>
@@ -580,7 +580,7 @@ int _startBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo)
DBG_ERROR(NULL, "Error connecting to broker: %d", rv);
return (rv<0)?rv:GWEN_ERROR_PERMISSIONS;
}
DBG_ERROR(NULL, "Connected to broker at %s:%d", xo->brokerAddress, xo->brokerPort);
DBG_ERROR(NULL, "Fully connected to broker at %s:%d", xo->brokerAddress, xo->brokerPort);
return 0;
}
else {
@@ -808,7 +808,7 @@ void _handleMsgFromTty(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH_MESSAGE *ms
uint8_t code;
code=AQH_NodeMessage_GetMsgType(msg);
DBG_ERROR(NULL, "Received Node packet %d (%x)", (int) code, code);
DBG_INFO(NULL, "Received Node packet %d (%x)", (int) code, code);
AQH_NodeServer_NodeMsgToDb(o, msg);
_writeTtyMsgToLogFile(xo, msg);
_forwardTtyMsgToBroker(o, xo, msg);
@@ -1117,7 +1117,7 @@ void _handleMsgFromBroker(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg)
code=AQH_IpcMessage_GetCode(msg);
protoId=AQH_IpcMessage_GetProtoId(msg);
if (protoId==AQH_IPC_PROTOCOL_DATA_ID) {
DBG_ERROR(NULL, "Received IPC packet %d (%x)", (int) code, code);
DBG_INFO(NULL, "Received IPC packet %d (%x)", (int) code, code);
switch(code) {
case AQH_MSGTYPE_IPC_DATA_SETDATA: AQH_NodeServer_HandleSetData(o, ep, msg); break;
default: break;

View File

@@ -198,7 +198,7 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop)
}
if (_diffInSeconds(now, lastSaveTime)>AQHOME_REACT_SAVE_INTERVAL) {
DBG_ERROR(NULL, "Writing var file");
DBG_INFO(NULL, "Writing var file");
rv=AQH_ReactServer_WriteVarsFile(aqh);
if (rv<0) {
DBG_INFO(NULL, "Error writing runtime data");

View File

@@ -496,7 +496,7 @@ int _startBroker(AQH_OBJECT *o, AQH_REACT_SERVER *xo)
DBG_ERROR(NULL, "Error connecting to broker: %d", rv);
return (rv<0)?rv:GWEN_ERROR_PERMISSIONS;
}
DBG_INFO(NULL, "Connected to broker at %s:%d", xo->brokerAddress, xo->brokerPort);
DBG_ERROR(NULL, "Fully connected to broker at %s:%d", xo->brokerAddress, xo->brokerPort);
return 0;
}
else {