aqhome: started working on database code.
This commit is contained in:
101
aqhome/data/0BUILD
Normal file
101
aqhome/data/0BUILD
Normal file
@@ -0,0 +1,101 @@
|
||||
<?xml?>
|
||||
|
||||
<gwbuild>
|
||||
|
||||
<target type="ConvenienceLibrary" name="aqhdata" >
|
||||
|
||||
<includes type="c" >
|
||||
$(gwenhywfar_cflags)
|
||||
$(aqdatabase_cflags)
|
||||
-I$(topsrcdir)
|
||||
-I$(topbuilddir)
|
||||
</includes>
|
||||
|
||||
<includes type="tm2" >
|
||||
--include=$(builddir)
|
||||
--include=$(srcdir)
|
||||
--include=$(aqdatabase_AQDATABASE_TYPEMAKERDIR)/c
|
||||
</includes>
|
||||
|
||||
|
||||
<define name="BUILDING_AQHOME" />
|
||||
|
||||
<setVar name="local/cflags">$(visibility_cflags)</setVar>
|
||||
|
||||
|
||||
<setVar name="tm2flags" >
|
||||
--api=AQHOME_API
|
||||
</setVar>
|
||||
|
||||
<setVar name="local/typefiles" >
|
||||
room.t2d
|
||||
device.t2d
|
||||
mqtttopic.t2d
|
||||
value.t2d
|
||||
datapoint.t2d
|
||||
</setVar>
|
||||
|
||||
<setVar name="local/built_sources" >
|
||||
room.c
|
||||
device.c
|
||||
mqtttopic.c
|
||||
value.c
|
||||
datapoint.c
|
||||
</setVar>
|
||||
|
||||
<setVar name="local/built_headers_pub">
|
||||
room.h
|
||||
device.h
|
||||
mqtttopic.h
|
||||
value.h
|
||||
datapoint.h
|
||||
</setVar>
|
||||
|
||||
|
||||
<setVar name="local/built_headers_priv" >
|
||||
room_p.h
|
||||
device_p.h
|
||||
mqtttopic_p.h
|
||||
value_p.h
|
||||
datapoint_p.h
|
||||
</setVar>
|
||||
|
||||
|
||||
<headers dist="false" install="$(pkgincludedir)/data" >
|
||||
$(local/built_headers_pub)
|
||||
</headers>
|
||||
|
||||
|
||||
<headers dist="true" install="$(pkgincludedir)/data" >
|
||||
storage.h
|
||||
</headers>
|
||||
|
||||
|
||||
<headers dist="true" >
|
||||
storage_p.h
|
||||
</headers>
|
||||
|
||||
|
||||
<sources>
|
||||
$(local/typefiles)
|
||||
|
||||
storage.c
|
||||
</sources>
|
||||
|
||||
|
||||
<extradist>
|
||||
</extradist>
|
||||
|
||||
|
||||
<useTargets>
|
||||
</useTargets>
|
||||
|
||||
<subdirs>
|
||||
</subdirs>
|
||||
|
||||
|
||||
|
||||
|
||||
</target>
|
||||
|
||||
</gwbuild>
|
||||
79
aqhome/data/README
Normal file
79
aqhome/data/README
Normal file
@@ -0,0 +1,79 @@
|
||||
|
||||
room:
|
||||
- id
|
||||
- name
|
||||
- description
|
||||
- colour
|
||||
|
||||
|
||||
device
|
||||
- id
|
||||
- name
|
||||
- room
|
||||
- location
|
||||
- description
|
||||
|
||||
mqtt-topic:
|
||||
- id
|
||||
- deviceId
|
||||
- mqttTopic
|
||||
- mqttDataType (num, json)
|
||||
|
||||
|
||||
value:
|
||||
- id
|
||||
- topicId
|
||||
- value type (temp, humidity, speed, door, length, width, counter, gauge)
|
||||
- units
|
||||
- dataPath (for JSON)
|
||||
|
||||
|
||||
|
||||
|
||||
datapoint:
|
||||
- value id
|
||||
- timestamp
|
||||
- value
|
||||
|
||||
|
||||
lastDatapoint: (DB: no rollback, otherwise db would double in size)
|
||||
- module id
|
||||
- timestamp
|
||||
- value
|
||||
|
||||
|
||||
|
||||
Processing MQTT publish messages:
|
||||
- create data point
|
||||
- set timestamp in data point
|
||||
- find MQTT_TOPIC for topic string
|
||||
- mqttType:
|
||||
- num:
|
||||
- lookup first value
|
||||
- store data in data point
|
||||
- json: parse data
|
||||
- for every VALUE assigned to that topic:
|
||||
- store data in data point
|
||||
- write data point to long term db
|
||||
- write data point to lastValues db
|
||||
|
||||
|
||||
Storage API:
|
||||
- handleMqttPublish(AQH_STORAGE *st, const char *topic, const char *value)
|
||||
|
||||
- addDevice(AQH_STORAGE *st, AQH_DEVICE *dev)
|
||||
- getDeviceList(const AQH_STORAGE *st)
|
||||
- getDeviceById(const AQH_STORAGE *st, uint32_t id)
|
||||
|
||||
- addMqttTopic(AQH_STORAGE *st, AQH_MQTT_TOPIC *t);
|
||||
- getMqttTopicList(const AQH_STORAGE *st)
|
||||
- getMqttTopicById(const AQH_STORAGE *st, uint32_t id)
|
||||
- getMqttTopicByTopic(const AQH_STORAGE *st, const char *topic)
|
||||
|
||||
- addValue(AQH_STORAGE *st, AQH_VALUE *value)
|
||||
- getValueList(const AQH_STORAGE *st)
|
||||
- getValueById(const AQH_STORAGE *st, uint32_t id)
|
||||
|
||||
|
||||
|
||||
|
||||
65
aqhome/data/datapoint.t2d
Normal file
65
aqhome/data/datapoint.t2d
Normal file
@@ -0,0 +1,65 @@
|
||||
<?xml?>
|
||||
|
||||
<tm2>
|
||||
<type id="AQH_DATAPOINT" type="pointer">
|
||||
<descr>
|
||||
</descr>
|
||||
<lang id="c">
|
||||
<identifier>AQH_DATAPOINT</identifier>
|
||||
<prefix>AQH_DataPoint</prefix>
|
||||
<baseFileName>datapoint</baseFileName>
|
||||
|
||||
<flags>
|
||||
with_list1
|
||||
with_list2
|
||||
with_xml
|
||||
with_object
|
||||
</flags>
|
||||
|
||||
<headers>
|
||||
<header type="sys" loc="pre">aqhome/api.h</header>
|
||||
<header type="sys" loc="pre">aqdatabase/aqdb_value.h</header>
|
||||
<header type="sys" loc="pre">gwenhywfar/timestamp.h</header>
|
||||
</headers>
|
||||
|
||||
</lang>
|
||||
|
||||
|
||||
<members>
|
||||
|
||||
<member name="id" type="uint64_t" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<flags>with_getbymember</flags>
|
||||
<access>public</access>
|
||||
</member>
|
||||
|
||||
<member name="valueId" type="int" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<flags></flags>
|
||||
<access>public</access>
|
||||
</member>
|
||||
|
||||
<member name="timestamp" type="gwen_timestamp" maxlen="8" >
|
||||
<access>public</access>
|
||||
<flags>with_sortbymember</flags>
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
</member>
|
||||
|
||||
<member name="value" type="AQDB_VALUE" maxlen="256" >
|
||||
<access>public</access>
|
||||
<flags>own with_sortbymember</flags>
|
||||
<setflags>const dup</setflags>
|
||||
<getflags>const</getflags>
|
||||
<default>NULL</default>
|
||||
<preset>NULL</preset>
|
||||
</member>
|
||||
|
||||
|
||||
</members>
|
||||
|
||||
</type>
|
||||
|
||||
</tm2>
|
||||
73
aqhome/data/device.t2d
Normal file
73
aqhome/data/device.t2d
Normal file
@@ -0,0 +1,73 @@
|
||||
<?xml?>
|
||||
|
||||
<tm2>
|
||||
<type id="AQH_DEVICE" type="pointer">
|
||||
<descr>
|
||||
</descr>
|
||||
<lang id="c">
|
||||
<identifier>AQH_DEVICE</identifier>
|
||||
<prefix>AQH_Device</prefix>
|
||||
<baseFileName>device</baseFileName>
|
||||
|
||||
<flags>
|
||||
with_xml
|
||||
with_db
|
||||
with_list1
|
||||
with_list2
|
||||
</flags>
|
||||
|
||||
<headers>
|
||||
<header type="sys" loc="pre">aqhome/api.h</header>
|
||||
</headers>
|
||||
|
||||
<inlines>
|
||||
</inlines>
|
||||
|
||||
|
||||
|
||||
</lang>
|
||||
|
||||
|
||||
<members>
|
||||
|
||||
<member name="id" type="uint64_t" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags>with_getbymember</flags>
|
||||
</member>
|
||||
|
||||
<member name="roomId" type="uint64_t" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="name" type="char_ptr" maxlen="32">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="location" type="char_ptr" maxlen="32">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="description" type="char_ptr" maxlen="256">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
</members>
|
||||
|
||||
</type>
|
||||
|
||||
</tm2>
|
||||
|
||||
66
aqhome/data/mqtttopic.t2d
Normal file
66
aqhome/data/mqtttopic.t2d
Normal file
@@ -0,0 +1,66 @@
|
||||
<?xml?>
|
||||
|
||||
<tm2>
|
||||
<type id="AQH_MQTT_TOPIC" type="pointer">
|
||||
<descr>
|
||||
</descr>
|
||||
<lang id="c">
|
||||
<identifier>AQH_MQTT_TOPIC</identifier>
|
||||
<prefix>AQH_MqttTopic</prefix>
|
||||
<baseFileName>mqtttopic</baseFileName>
|
||||
|
||||
<flags>
|
||||
with_xml
|
||||
with_db
|
||||
with_list1
|
||||
with_list2
|
||||
</flags>
|
||||
|
||||
<headers>
|
||||
<header type="sys" loc="pre">aqhome/api.h</header>
|
||||
</headers>
|
||||
|
||||
<inlines>
|
||||
</inlines>
|
||||
|
||||
|
||||
|
||||
</lang>
|
||||
|
||||
|
||||
<members>
|
||||
|
||||
<member name="id" type="uint64_t" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags>with_getbymember</flags>
|
||||
</member>
|
||||
|
||||
<member name="deviceId" type="uint64_t" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="mqttTopic" type="char_ptr" maxlen="256">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags>with_getbymember</flags>
|
||||
</member>
|
||||
|
||||
<member name="mqttDataType" type="int" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
</members>
|
||||
|
||||
</type>
|
||||
|
||||
</tm2>
|
||||
|
||||
89
aqhome/data/mqttvalue.t2d
Normal file
89
aqhome/data/mqttvalue.t2d
Normal file
@@ -0,0 +1,89 @@
|
||||
<?xml?>
|
||||
|
||||
<tm2>
|
||||
<type id="AQH_VALUE" type="pointer">
|
||||
<descr>
|
||||
</descr>
|
||||
<lang id="c">
|
||||
<identifier>AQH_VALUE</identifier>
|
||||
<prefix>AQH_Value</prefix>
|
||||
<baseFileName>value</baseFileName>
|
||||
|
||||
<flags>
|
||||
with_xml
|
||||
with_db
|
||||
with_list1
|
||||
with_list2
|
||||
</flags>
|
||||
|
||||
<headers>
|
||||
<header type="sys" loc="pre">aqhome/api.h</header>
|
||||
</headers>
|
||||
|
||||
<inlines>
|
||||
</inlines>
|
||||
|
||||
|
||||
|
||||
</lang>
|
||||
|
||||
|
||||
<members>
|
||||
|
||||
<member name="id" type="uint32_t" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="deviceId" type="uint32_t" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="valueType" type="int" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="valueUnits" type="char_ptr" maxlen="256">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="mqttTopic" type="char_ptr" maxlen="256">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="mqttDataType" type="int" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="mqttJsonPath" type="char_ptr" maxlen="256">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
|
||||
|
||||
</members>
|
||||
|
||||
</type>
|
||||
|
||||
</tm2>
|
||||
|
||||
66
aqhome/data/room.t2d
Normal file
66
aqhome/data/room.t2d
Normal file
@@ -0,0 +1,66 @@
|
||||
<?xml?>
|
||||
|
||||
<tm2>
|
||||
<type id="AQH_ROOM" type="pointer">
|
||||
<descr>
|
||||
</descr>
|
||||
<lang id="c">
|
||||
<identifier>AQH_ROOM</identifier>
|
||||
<prefix>AQH_Room</prefix>
|
||||
<baseFileName>room</baseFileName>
|
||||
|
||||
<flags>
|
||||
with_xml
|
||||
with_db
|
||||
with_list1
|
||||
with_list2
|
||||
</flags>
|
||||
|
||||
<headers>
|
||||
<header type="sys" loc="pre">aqhome/api.h</header>
|
||||
</headers>
|
||||
|
||||
<inlines>
|
||||
</inlines>
|
||||
|
||||
|
||||
|
||||
</lang>
|
||||
|
||||
|
||||
<members>
|
||||
|
||||
<member name="id" type="uint64_t" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags>with_getbymember</flags>
|
||||
</member>
|
||||
|
||||
<member name="name" type="char_ptr" maxlen="32">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="description" type="char_ptr" maxlen="256">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="colour" type="uint32_t" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
</members>
|
||||
|
||||
</type>
|
||||
|
||||
</tm2>
|
||||
|
||||
158
aqhome/data/storage.c
Normal file
158
aqhome/data/storage.c
Normal file
@@ -0,0 +1,158 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project Gwenhywfar.
|
||||
* Gwenhywfar (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "aqhome/data/storage_p.h"
|
||||
|
||||
#include <gwenhywfar/debug.h>
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* forward declarations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------------------------------
|
||||
* implementations
|
||||
* ------------------------------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
AQH_STORAGE *AQH_Storage_new(void)
|
||||
{
|
||||
AQH_STORAGE *sto;
|
||||
|
||||
GWEN_NEW_OBJECT(AQH_STORAGE, sto);
|
||||
sto->deviceList=AQH_Device_List_new();
|
||||
sto->mqttTopicList=AQH_MqttTopic_List_new();
|
||||
sto->valueList=AQH_Value_List_new();
|
||||
|
||||
return sto;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_Storage_free(AQH_STORAGE *sto)
|
||||
{
|
||||
if (sto) {
|
||||
AQH_Value_List_free(sto->valueList);
|
||||
AQH_MqttTopic_List_free(sto->mqttTopicList);
|
||||
AQH_Device_List_free(sto->deviceList);
|
||||
|
||||
GWEN_FREE_OBJECT(sto);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_Storage_AddDevice(AQH_STORAGE *sto, AQH_DEVICE *dev)
|
||||
{
|
||||
if (sto && dev) {
|
||||
uint64_t id;
|
||||
|
||||
id=++(sto->lastDeviceId);
|
||||
AQH_Device_SetId(dev, id);
|
||||
AQH_Device_List_Add(dev, sto->deviceList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQH_DEVICE_LIST *AQH_Storage_GetDeviceList(const AQH_STORAGE *sto)
|
||||
{
|
||||
return sto?sto->deviceList:NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQH_DEVICE *AQH_Storage_GetDeviceById(const AQH_STORAGE *sto, uint64_t id)
|
||||
{
|
||||
return sto?AQH_Device_List_GetById(sto->deviceList, id):NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_Storage_AddMqttTopic(AQH_STORAGE *sto, AQH_MQTT_TOPIC *t)
|
||||
{
|
||||
if (sto && t) {
|
||||
uint64_t id;
|
||||
|
||||
id=++(sto->lastTopicId);
|
||||
AQH_MqttTopic_SetId(t, id);
|
||||
AQH_MqttTopic_List_Add(t, sto->mqttTopicList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQH_MQTT_TOPIC_LIST *AQH_Storage_GetMqttTopicList(const AQH_STORAGE *sto)
|
||||
{
|
||||
return sto?sto->mqttTopicList:NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQH_MQTT_TOPIC *AQH_Storage_GetMqttTopicById(const AQH_STORAGE *sto, uint64_t id)
|
||||
{
|
||||
return sto?AQH_MqttTopic_List_GetById(sto->mqttTopicList, id):NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQH_MQTT_TOPIC *AQH_Storage_GetMqttTopicByTopic(const AQH_STORAGE *sto, const char *topic)
|
||||
{
|
||||
return sto?AQH_MqttTopic_List_GetByMqttTopic(sto->mqttTopicList, topic):NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_Storage_AddValue(AQH_STORAGE *sto, AQH_VALUE *value)
|
||||
{
|
||||
if (sto && value) {
|
||||
uint64_t id;
|
||||
|
||||
id=++(sto->lastValueId);
|
||||
AQH_Value_SetId(value, id);
|
||||
AQH_Value_List_Add(value, sto->valueList);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQH_VALUE_LIST *AQH_Storage_GetValueList(const AQH_STORAGE *sto)
|
||||
{
|
||||
return sto?sto->valueList:NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
AQH_VALUE *AQH_Storage_GetValueById(const AQH_STORAGE *sto, uint64_t id)
|
||||
{
|
||||
return sto?AQH_Value_List_GetById(sto->valueList, id):NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void AQH_Storage_HandleMqttPublish(AQH_STORAGE *sto, const char *topic, const char *value)
|
||||
{
|
||||
/* TODO */
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
76
aqhome/data/storage.h
Normal file
76
aqhome/data/storage.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project Gwenhywfar.
|
||||
* Gwenhywfar (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_STORAGE_H
|
||||
#define AQH_STORAGE_H
|
||||
|
||||
|
||||
#include <aqhome/api.h>
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef struct AQH_STORAGE AQH_STORAGE;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#include "aqhome/data/room.h"
|
||||
#include "aqhome/data/device.h"
|
||||
#include "aqhome/data/mqtttopic.h"
|
||||
#include "aqhome/data/value.h"
|
||||
#include "aqhome/data/datapoint.h"
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*/
|
||||
AQHOME_API AQH_STORAGE *AQH_Storage_new(void);
|
||||
AQHOME_API void AQH_Storage_free(AQH_STORAGE *sto);
|
||||
|
||||
AQHOME_API void AQH_Storage_AddDevice(AQH_STORAGE *sto, AQH_DEVICE *dev);
|
||||
AQHOME_API AQH_DEVICE_LIST *AQH_Storage_GetDeviceList(const AQH_STORAGE *sto);
|
||||
AQHOME_API AQH_DEVICE *AQH_Storage_GetDeviceById(const AQH_STORAGE *sto, uint64_t id);
|
||||
|
||||
AQHOME_API void AQH_Storage_AddMqttTopic(AQH_STORAGE *sto, AQH_MQTT_TOPIC *t);
|
||||
AQHOME_API AQH_MQTT_TOPIC_LIST *AQH_Storage_GetMqttTopicList(const AQH_STORAGE *sto);
|
||||
AQHOME_API AQH_MQTT_TOPIC *AQH_Storage_GetMqttTopicById(const AQH_STORAGE *sto, uint64_t id);
|
||||
AQHOME_API AQH_MQTT_TOPIC *AQH_Storage_GetMqttTopicByTopic(const AQH_STORAGE *sto, const char *topic);
|
||||
|
||||
AQHOME_API void AQH_Storage_AddValue(AQH_STORAGE *sto, AQH_VALUE *value);
|
||||
AQHOME_API AQH_VALUE_LIST *AQH_Storage_GetValueList(const AQH_STORAGE *sto);
|
||||
AQHOME_API AQH_VALUE *AQH_Storage_GetValueById(const AQH_STORAGE *sto, uint64_t id);
|
||||
|
||||
|
||||
AQHOME_API void AQH_Storage_HandleMqttPublish(AQH_STORAGE *sto, const char *topic, const char *value);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
31
aqhome/data/storage_p.h
Normal file
31
aqhome/data/storage_p.h
Normal file
@@ -0,0 +1,31 @@
|
||||
/****************************************************************************
|
||||
* This file is part of the project Gwenhywfar.
|
||||
* Gwenhywfar (c) by 2023 Martin Preuss, all rights reserved.
|
||||
*
|
||||
* The license for this file can be found in the file COPYING which you
|
||||
* should have received along with this file.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef AQH_STORAGE_P_H
|
||||
#define AQH_STORAGE_P_H
|
||||
|
||||
|
||||
#include "aqhome/data/storage.h"
|
||||
|
||||
|
||||
|
||||
struct AQH_STORAGE {
|
||||
AQH_DEVICE_LIST *deviceList;
|
||||
AQH_MQTT_TOPIC_LIST *mqttTopicList;
|
||||
AQH_VALUE_LIST *valueList;
|
||||
|
||||
uint64_t lastDeviceId;
|
||||
uint64_t lastTopicId;
|
||||
uint64_t lastValueId;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -29,8 +29,15 @@
|
||||
|
||||
|
||||
<members>
|
||||
|
||||
<member name="nodeUid" type="uint32_t" maxlen="8">
|
||||
|
||||
<member name="id" type="uint64_t" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags>with_getbymember</flags>
|
||||
</member>
|
||||
|
||||
<member name="topicId" type="uint64_t" maxlen="8">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
@@ -44,14 +51,14 @@
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="numerator" type="int" maxlen="8">
|
||||
<member name="valueUnits" type="char_ptr" maxlen="32">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
<flags></flags>
|
||||
</member>
|
||||
|
||||
<member name="denominator" type="int" maxlen="8">
|
||||
<member name="dataPath" type="char_ptr" maxlen="256">
|
||||
<default>0</default>
|
||||
<preset>0</preset>
|
||||
<access>public</access>
|
||||
@@ -59,6 +66,7 @@
|
||||
</member>
|
||||
|
||||
|
||||
|
||||
</members>
|
||||
|
||||
</type>
|
||||
|
||||
Reference in New Issue
Block a user