aqhome, aqhome-apps: cleanup, removed unneeded files.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user