Compare commits
228 Commits
mp-2025_02
...
mp-2025_05
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
deddf42379 | ||
|
|
e584245965 | ||
|
|
46720d791c | ||
|
|
af75532ba7 | ||
|
|
335163f887 | ||
|
|
b3274466a3 | ||
|
|
064e84f5e8 | ||
|
|
18bc231951 | ||
|
|
9a19bf739d | ||
|
|
9e6feecb88 | ||
|
|
baf77ed182 | ||
|
|
b2f7232422 | ||
|
|
961568f721 | ||
|
|
042db13994 | ||
|
|
ba434d88a2 | ||
|
|
d32e2f4b81 | ||
|
|
e40139fee2 | ||
|
|
d8612a01ca | ||
|
|
474e63c395 | ||
|
|
ceaeb756fb | ||
|
|
603a8e93d0 | ||
|
|
4fdfd77a54 | ||
|
|
6b5f5e877d | ||
|
|
77bb64fbb6 | ||
|
|
92d5e30f3c | ||
|
|
349c11d641 | ||
|
|
027edb9aba | ||
|
|
868c2b32f8 | ||
|
|
2acd25e805 | ||
|
|
b730fd068c | ||
|
|
3e9aeeed05 | ||
|
|
158cf994c5 | ||
|
|
391c06e7e5 | ||
|
|
fa5acddcbe | ||
|
|
7d233136eb | ||
|
|
a4975038b4 | ||
|
|
229e68077c | ||
|
|
143180d68b | ||
|
|
c065415713 | ||
|
|
b01e8ff004 | ||
|
|
de94590fa0 | ||
|
|
b3d7d492d7 | ||
|
|
d29147fe57 | ||
|
|
a0898b8327 | ||
|
|
2ca246deca | ||
|
|
c1d347b70b | ||
|
|
381afa97f4 | ||
|
|
cb379d4149 | ||
|
|
aceffdfad2 | ||
|
|
8ece026f2d | ||
|
|
d000c8621e | ||
|
|
cf1eba68f0 | ||
|
|
b6800e538d | ||
|
|
b8fbbb7125 | ||
|
|
4b4753415a | ||
|
|
1c053d0492 | ||
|
|
44b8848996 | ||
|
|
550967c176 | ||
|
|
e713711a61 | ||
|
|
613a7e629d | ||
|
|
5026a7b753 | ||
|
|
75b602811c | ||
|
|
2897aece2c | ||
|
|
2cc260790c | ||
|
|
1ac4b8cad0 | ||
|
|
ab3b2be725 | ||
|
|
10e4aa8f85 | ||
|
|
ea0d426430 | ||
|
|
27a0214b5d | ||
|
|
f9cd1833da | ||
|
|
f8d3d09716 | ||
|
|
484a455df7 | ||
|
|
21c2c60f4f | ||
|
|
5a46db37c1 | ||
|
|
e545251b27 | ||
|
|
d51ca9b1d1 | ||
|
|
dba503df5b | ||
|
|
732dcd74f7 | ||
|
|
930229b969 | ||
|
|
bb4e16cae7 | ||
|
|
f5606554c9 | ||
|
|
d97d2ac08f | ||
|
|
f834a4ecc5 | ||
|
|
92b7d1bb13 | ||
|
|
b775c9b6b2 | ||
|
|
63acb95834 | ||
|
|
faa46c7e38 | ||
|
|
fee3606a61 | ||
|
|
92bcd366cb | ||
|
|
bc54f5bda1 | ||
|
|
30945807d8 | ||
|
|
95a0e6ea9d | ||
|
|
47275556f9 | ||
|
|
25fb6f262d | ||
|
|
147f920eb6 | ||
|
|
b63d625d12 | ||
|
|
11657cef75 | ||
|
|
5dd0e6fd95 | ||
|
|
9a993445c4 | ||
|
|
4baa949a77 | ||
|
|
c7823d3874 | ||
|
|
074a7e5650 | ||
|
|
64e2cf5d25 | ||
|
|
cc7ef0cf30 | ||
|
|
9102d90c34 | ||
|
|
6832487c46 | ||
|
|
f5cf85a931 | ||
|
|
d57d721dbf | ||
|
|
aa97197413 | ||
|
|
d7df84549b | ||
|
|
8feb8982c1 | ||
|
|
f4acc829f7 | ||
|
|
34b2fe4007 | ||
|
|
72f52da17b | ||
|
|
eecb022a0c | ||
|
|
9063962c7d | ||
|
|
9e25cbb183 | ||
|
|
9af57eaac0 | ||
|
|
f31567e785 | ||
|
|
dc62f1fe05 | ||
|
|
868268d116 | ||
|
|
9f663b0ed9 | ||
|
|
827497bb5e | ||
|
|
688f02df47 | ||
|
|
33ec6d0a67 | ||
|
|
b3f19b0432 | ||
|
|
e6ea506a74 | ||
|
|
2ac090cf14 | ||
|
|
46b24bf442 | ||
|
|
9a854977a4 | ||
|
|
e25b0ad69d | ||
|
|
b632a10fff | ||
|
|
e20b1c52d3 | ||
|
|
08e1428902 | ||
|
|
5f220dc86f | ||
|
|
51d32dc505 | ||
|
|
048eccf4c6 | ||
|
|
9e37ebb261 | ||
|
|
de89bc94b6 | ||
|
|
ab9c177793 | ||
|
|
6ce1aac1d7 | ||
|
|
e56f2600e8 | ||
|
|
614a30fd4e | ||
|
|
5981ec44e4 | ||
|
|
8008819989 | ||
|
|
7edaed601b | ||
|
|
06434512c7 | ||
|
|
fa65bc53b5 | ||
|
|
c1a67a36ef | ||
|
|
1e90682605 | ||
|
|
2357b63b42 | ||
|
|
e1b2650221 | ||
|
|
52ae473ad1 | ||
|
|
833819f713 | ||
|
|
155fc9a743 | ||
|
|
a03fc012f4 | ||
|
|
5b93d58309 | ||
|
|
bef677eda4 | ||
|
|
265a1e6043 | ||
|
|
b21c111aa3 | ||
|
|
b9419520f4 | ||
|
|
8925ce23e9 | ||
|
|
feabc76e36 | ||
|
|
f806cf30e5 | ||
|
|
15199a17a5 | ||
|
|
30654509b1 | ||
|
|
ea2162e8f4 | ||
|
|
ebba98ef16 | ||
|
|
b995f1c3fb | ||
|
|
77e573192e | ||
|
|
ba55a2898d | ||
|
|
16a6bb08b5 | ||
|
|
b2a087c959 | ||
|
|
7349dcba8d | ||
|
|
e4145afbfe | ||
|
|
876d1cad0e | ||
|
|
eea0a66b84 | ||
|
|
b4d71a0fad | ||
|
|
89542e06c9 | ||
|
|
3555b49219 | ||
|
|
791afb80f8 | ||
|
|
924c4d27e8 | ||
|
|
cac611deae | ||
|
|
aee2c384c8 | ||
|
|
78fda7727a | ||
|
|
45e668ec88 | ||
|
|
c6f1ac94fa | ||
|
|
8c9fd4574d | ||
|
|
f9a73a61e9 | ||
|
|
0165b02310 | ||
|
|
24dc3e1c0a | ||
|
|
7b6cb4da34 | ||
|
|
c8fcd46325 | ||
|
|
3ffc4a3410 | ||
|
|
52eb92a00c | ||
|
|
ebce002614 | ||
|
|
595f983071 | ||
|
|
8586269033 | ||
|
|
0f598a5552 | ||
|
|
236f6832a3 | ||
|
|
373a553ac8 | ||
|
|
2964347e7b | ||
|
|
3f0e9c9294 | ||
|
|
0b946c5748 | ||
|
|
c808f8640e | ||
|
|
1fa0d976d2 | ||
|
|
091307290e | ||
|
|
7a045abcc2 | ||
|
|
95d589b126 | ||
|
|
d27664d7c9 | ||
|
|
ebf9c6eb30 | ||
|
|
fef6011426 | ||
|
|
daa07428eb | ||
|
|
0d8d684e78 | ||
|
|
bab6721b2c | ||
|
|
d468d2fb1a | ||
|
|
d897f40903 | ||
|
|
9a7a7e75f9 | ||
|
|
a14c2c892c | ||
|
|
cc64f793ec | ||
|
|
32d5287a3a | ||
|
|
4dd3decb06 | ||
|
|
171caacc92 | ||
|
|
2320ba3a69 | ||
|
|
72c8923bfe | ||
|
|
14c9ac17a1 | ||
|
|
7e745c98e6 | ||
|
|
31d8cb10df |
3
0BUILD
3
0BUILD
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<gwbuild>
|
<gwbuild>
|
||||||
|
|
||||||
<project name="aqhome" version="0.0.4" so_current="0" so_age="0" so_revision="4" write_config_h="TRUE">
|
<project name="aqhome" version="0.0.10" so_current="0" so_age="0" so_revision="10" write_config_h="TRUE">
|
||||||
<setVar name="package">$(project_name)</setVar>
|
<setVar name="package">$(project_name)</setVar>
|
||||||
<setVar name="version">
|
<setVar name="version">
|
||||||
$(project_vmajor).$(project_vminor).$(project_vpatchlevel)
|
$(project_vmajor).$(project_vminor).$(project_vpatchlevel)
|
||||||
@@ -149,6 +149,7 @@
|
|||||||
<dep id="gwenhywfar" name="gwenhywfar" minversion="5.11.2" required="TRUE" >
|
<dep id="gwenhywfar" name="gwenhywfar" minversion="5.11.2" required="TRUE" >
|
||||||
<variables>plugindir gwengui-fox16</variables>
|
<variables>plugindir gwengui-fox16</variables>
|
||||||
</dep>
|
</dep>
|
||||||
|
<dep id="aqcgi" name="aqcgi" minversion="0.0.1" required="TRUE" />
|
||||||
<!-- <dep id="aqdatabase" name="aqdatabase" minversion="1.99.1" required="TRUE" >
|
<!-- <dep id="aqdatabase" name="aqdatabase" minversion="1.99.1" required="TRUE" >
|
||||||
<variables>aqdatabase_typemakerdir</variables>
|
<variables>aqdatabase_typemakerdir</variables>
|
||||||
</dep>
|
</dep>
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
aqhome-data
|
aqhome-data
|
||||||
aqhome-nodes
|
aqhome-nodes
|
||||||
aqhome-react
|
aqhome-react
|
||||||
|
aqhome-cgi
|
||||||
</subdirs>
|
</subdirs>
|
||||||
|
|
||||||
</gwbuild>
|
</gwbuild>
|
||||||
|
|||||||
142
apps/aqhome-cgi/0BUILD
Normal file
142
apps/aqhome-cgi/0BUILD
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
<?xml?>
|
||||||
|
|
||||||
|
<gwbuild>
|
||||||
|
|
||||||
|
|
||||||
|
<target type="Program" name="aqhome-cgi" install="$(sbindir)" >
|
||||||
|
|
||||||
|
<includes type="c" >
|
||||||
|
$(gwenhywfar_cflags)
|
||||||
|
$(aqcgi_cflags)
|
||||||
|
-I$(topsrcdir)
|
||||||
|
-I$(topbuilddir)
|
||||||
|
-I$(topsrcdir)/apps
|
||||||
|
-I$(topbuilddir)/apps
|
||||||
|
-I$(builddir)
|
||||||
|
-I$(srcdir)
|
||||||
|
</includes>
|
||||||
|
|
||||||
|
<includes type="tm2" >
|
||||||
|
--include=$(builddir)
|
||||||
|
--include=$(srcdir)
|
||||||
|
</includes>
|
||||||
|
|
||||||
|
<setVar name="local/cflags">$(visibility_cflags)</setVar>
|
||||||
|
|
||||||
|
<setVar name="tm2flags" >
|
||||||
|
</setVar>
|
||||||
|
|
||||||
|
<setVar name="local/typefiles" >
|
||||||
|
</setVar>
|
||||||
|
|
||||||
|
<setVar name="local/built_sources" >
|
||||||
|
</setVar>
|
||||||
|
|
||||||
|
<setVar name="local/built_headers_pub">
|
||||||
|
</setVar>
|
||||||
|
|
||||||
|
<setVar name="local/built_headers_priv" >
|
||||||
|
</setVar>
|
||||||
|
|
||||||
|
<headers dist="true" >
|
||||||
|
</headers>
|
||||||
|
|
||||||
|
<sources>
|
||||||
|
$(local/typefiles)
|
||||||
|
main.c
|
||||||
|
</sources>
|
||||||
|
|
||||||
|
<useTargets>
|
||||||
|
aqhome
|
||||||
|
aqhomecgi
|
||||||
|
aqhcgi_service
|
||||||
|
</useTargets>
|
||||||
|
|
||||||
|
<libraries>
|
||||||
|
$(gwenhywfar_libs)
|
||||||
|
-lm
|
||||||
|
</libraries>
|
||||||
|
|
||||||
|
<subdirs>
|
||||||
|
</subdirs>
|
||||||
|
|
||||||
|
|
||||||
|
<extradist>
|
||||||
|
</extradist>
|
||||||
|
|
||||||
|
|
||||||
|
</target>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<target type="ConvenienceLibrary" name="aqhomecgi" >
|
||||||
|
|
||||||
|
<includes type="c" >
|
||||||
|
$(gwenhywfar_cflags)
|
||||||
|
-I$(topsrcdir)
|
||||||
|
-I$(topbuilddir)
|
||||||
|
-I$(topsrcdir)/apps
|
||||||
|
-I$(topbuilddir)/apps
|
||||||
|
-I$(builddir)
|
||||||
|
-I$(srcdir)
|
||||||
|
</includes>
|
||||||
|
|
||||||
|
<includes type="tm2" >
|
||||||
|
--include=$(builddir)
|
||||||
|
--include=$(srcdir)
|
||||||
|
</includes>
|
||||||
|
|
||||||
|
<setVar name="local/cflags">$(visibility_cflags)</setVar>
|
||||||
|
|
||||||
|
<setVar name="tm2flags" >
|
||||||
|
</setVar>
|
||||||
|
|
||||||
|
<setVar name="local/typefiles" >
|
||||||
|
</setVar>
|
||||||
|
|
||||||
|
<setVar name="local/built_sources" >
|
||||||
|
</setVar>
|
||||||
|
|
||||||
|
<setVar name="local/built_headers_pub">
|
||||||
|
</setVar>
|
||||||
|
|
||||||
|
<setVar name="local/built_headers_priv" >
|
||||||
|
</setVar>
|
||||||
|
|
||||||
|
<headers dist="true" >
|
||||||
|
service_file.h
|
||||||
|
service_file_p.h
|
||||||
|
</headers>
|
||||||
|
|
||||||
|
<sources>
|
||||||
|
$(local/typefiles)
|
||||||
|
|
||||||
|
service_file.c
|
||||||
|
</sources>
|
||||||
|
|
||||||
|
<useTargets>
|
||||||
|
aqhome
|
||||||
|
aqhcgi_service
|
||||||
|
</useTargets>
|
||||||
|
|
||||||
|
<libraries>
|
||||||
|
$(gwenhywfar_libs)
|
||||||
|
-lm
|
||||||
|
$(aqcgi_libs)
|
||||||
|
</libraries>
|
||||||
|
|
||||||
|
<subdirs>
|
||||||
|
service
|
||||||
|
</subdirs>
|
||||||
|
|
||||||
|
|
||||||
|
<extradist>
|
||||||
|
</extradist>
|
||||||
|
|
||||||
|
|
||||||
|
</target>
|
||||||
|
|
||||||
|
|
||||||
|
</gwbuild>
|
||||||
|
|
||||||
|
|
||||||
0
apps/aqhome-cgi/dummy.c
Normal file
0
apps/aqhome-cgi/dummy.c
Normal file
11
apps/aqhome-cgi/main.c
Normal file
11
apps/aqhome-cgi/main.c
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2,12 +2,16 @@
|
|||||||
|
|
||||||
<gwbuild>
|
<gwbuild>
|
||||||
|
|
||||||
<target type="ConvenienceLibrary" name="aqhservice" >
|
<target type="ConvenienceLibrary" name="aqhcgi_service" >
|
||||||
|
|
||||||
<includes type="c" >
|
<includes type="c" >
|
||||||
$(gwenhywfar_cflags)
|
$(gwenhywfar_cflags)
|
||||||
-I$(topsrcdir)
|
-I$(topsrcdir)
|
||||||
-I$(topbuilddir)
|
-I$(topbuilddir)
|
||||||
|
-I$(topsrcdir)/apps
|
||||||
|
-I$(topbuilddir)/apps
|
||||||
|
-I$(builddir)
|
||||||
|
-I$(srcdir)
|
||||||
</includes>
|
</includes>
|
||||||
|
|
||||||
<includes type="tm2" >
|
<includes type="tm2" >
|
||||||
@@ -21,7 +25,7 @@
|
|||||||
<setVar name="local/cflags">$(visibility_cflags)</setVar>
|
<setVar name="local/cflags">$(visibility_cflags)</setVar>
|
||||||
|
|
||||||
|
|
||||||
<setVar name="tm2flags" >
|
<setVar name="tm2flags-INACTIVE" >
|
||||||
--api=AQHOME_API
|
--api=AQHOME_API
|
||||||
</setVar>
|
</setVar>
|
||||||
|
|
||||||
20
apps/aqhome-cgi/service/README
Normal file
20
apps/aqhome-cgi/service/README
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
|
||||||
|
|
||||||
|
- service:
|
||||||
|
- userList
|
||||||
|
- rootModule
|
||||||
|
- sessionList
|
||||||
|
|
||||||
|
- user:
|
||||||
|
- modulePerms
|
||||||
|
|
||||||
|
- module:
|
||||||
|
- roleList
|
||||||
|
- permDefList
|
||||||
|
|
||||||
|
- session
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -15,6 +15,7 @@
|
|||||||
with_db
|
with_db
|
||||||
with_list1
|
with_list1
|
||||||
with_list2
|
with_list2
|
||||||
|
with_tree2
|
||||||
nodup
|
nodup
|
||||||
nocopy
|
nocopy
|
||||||
</flags>
|
</flags>
|
||||||
@@ -22,8 +23,8 @@
|
|||||||
<headers>
|
<headers>
|
||||||
<header type="sys" loc="pre">aqhome/api.h</header>
|
<header type="sys" loc="pre">aqhome/api.h</header>
|
||||||
<header type="sys" loc="pre">gwenhywfar/error.h</header>
|
<header type="sys" loc="pre">gwenhywfar/error.h</header>
|
||||||
<header type="sys" loc="post">aqhome/service/role.h</header>
|
<header type="sys" loc="post">aqhome-cgi/service/role.h</header>
|
||||||
<header type="sys" loc="post">aqhome/service/permdef.h</header>
|
<header type="sys" loc="post">aqhome-cgi/service/permdef.h</header>
|
||||||
</headers>
|
</headers>
|
||||||
|
|
||||||
<inlines>
|
<inlines>
|
||||||
@@ -31,6 +32,13 @@
|
|||||||
|
|
||||||
</lang>
|
</lang>
|
||||||
|
|
||||||
|
<defines>
|
||||||
|
<define id="AQH_MODULE_FLAGS" prefix="AQH_MODULE_FLAGS_">
|
||||||
|
<item name="ACTIVE" value="0x00000001" />
|
||||||
|
</define>
|
||||||
|
|
||||||
|
</defines>
|
||||||
|
|
||||||
|
|
||||||
<members>
|
<members>
|
||||||
|
|
||||||
@@ -41,6 +49,13 @@
|
|||||||
<flags>with_getbymember</flags>
|
<flags>with_getbymember</flags>
|
||||||
</member>
|
</member>
|
||||||
|
|
||||||
|
<member name="flags" type="uint32_t" maxlen="4">
|
||||||
|
<default>0</default>
|
||||||
|
<preset>0</preset>
|
||||||
|
<access>public</access>
|
||||||
|
<flags>with_flags</flags>
|
||||||
|
</member>
|
||||||
|
|
||||||
<member name="name" type="char_ptr" maxlen="16">
|
<member name="name" type="char_ptr" maxlen="16">
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
<preset>0</preset>
|
<preset>0</preset>
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
<headers>
|
<headers>
|
||||||
<header type="sys" loc="pre">aqhome/api.h</header>
|
<header type="sys" loc="pre">aqhome/api.h</header>
|
||||||
<header type="sys" loc="pre">gwenhywfar/error.h</header>
|
<header type="sys" loc="pre">gwenhywfar/error.h</header>
|
||||||
<header type="sys" loc="post">aqhome/service/role.h</header>
|
<header type="sys" loc="post">aqhome-cgi/service/role.h</header>
|
||||||
</headers>
|
</headers>
|
||||||
|
|
||||||
<inlines>
|
<inlines>
|
||||||
355
apps/aqhome-cgi/service/service.c
Normal file
355
apps/aqhome-cgi/service/service.c
Normal file
@@ -0,0 +1,355 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2025 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
|
||||||
|
|
||||||
|
//#define DISABLE_DEBUGLOG
|
||||||
|
|
||||||
|
|
||||||
|
#include "aqhome-cgi/service/service_p.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/stringlist.h>
|
||||||
|
#include <gwenhywfar/text.h>
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_INHERIT_FUNCTIONS(AQH_SERVICE);
|
||||||
|
GWEN_LIST_FUNCTIONS(AQH_SERVICE, AQH_Service);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQH_SERVICE *AQH_Service_new(void)
|
||||||
|
{
|
||||||
|
AQH_SERVICE *sv;
|
||||||
|
|
||||||
|
GWEN_NEW_OBJECT(AQH_SERVICE, sv);
|
||||||
|
GWEN_INHERIT_INIT(AQH_SERVICE, sv);
|
||||||
|
GWEN_LIST_INIT(AQH_SERVICE, sv);
|
||||||
|
|
||||||
|
return sv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_free(AQH_SERVICE *sv)
|
||||||
|
{
|
||||||
|
if (sv) {
|
||||||
|
GWEN_LIST_FINI(AQH_SERVICE, sv);
|
||||||
|
GWEN_INHERIT_FINI(AQH_SERVICE, sv);
|
||||||
|
|
||||||
|
GWEN_FREE_OBJECT(sv);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
AQH_MODULE *AQH_Service_GetModuleByPath(const AQH_SERVICE *sv, const char *s)
|
||||||
|
{
|
||||||
|
if (sv && s && *s) {
|
||||||
|
GWEN_STRINGLIST *sl;
|
||||||
|
|
||||||
|
sl=GWEN_StringList_fromString2(s, "/", 0,
|
||||||
|
GWEN_TEXT_FLAGS_DEL_QUOTES |
|
||||||
|
GWEN_TEXT_FLAGS_DEL_LEADING_BLANKS |
|
||||||
|
GWEN_TEXT_FLAGS_DEL_MULTIPLE_BLANKS |
|
||||||
|
GWEN_TEXT_FLAGS_DEL_TRAILING_BLANKS);
|
||||||
|
if (sl) {
|
||||||
|
GWEN_STRINGLISTENTRY *se;
|
||||||
|
AQH_MODULE *m;
|
||||||
|
|
||||||
|
m=sv->rootModule;
|
||||||
|
se=GWEN_StringList_FirstEntry(sl);
|
||||||
|
while(se && m) {
|
||||||
|
const char *sWantedName;
|
||||||
|
|
||||||
|
sWantedName=GWEN_StringListEntry_Data(se);
|
||||||
|
if (sWantedName && *sWantedName) {
|
||||||
|
AQH_MODULE *mTemp;
|
||||||
|
|
||||||
|
mTemp=AQH_Module_Tree2_GetFirstChild(m);
|
||||||
|
while(mTemp) {
|
||||||
|
const char *sModName;
|
||||||
|
|
||||||
|
sModName=AQH_Module_GetName(mTemp);
|
||||||
|
if (sModName && *sModName && 0==strcasecmp(sModName, sWantedName))
|
||||||
|
break;
|
||||||
|
mTemp=AQH_Module_Tree2_GetNext(mTemp);
|
||||||
|
}
|
||||||
|
if (mTemp==NULL) {
|
||||||
|
DBG_ERROR(NULL, "Module \%s\" not found", sWantedName);
|
||||||
|
GWEN_StringList_free(sl);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
m=mTemp;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DBG_ERROR(NULL, "Empty path element in \"%s\"", s);
|
||||||
|
GWEN_StringList_free(sl);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
se=GWEN_StringListEntry_Next(se);
|
||||||
|
} /* while(se && m) */
|
||||||
|
GWEN_StringList_free(sl);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DBG_ERROR(NULL, "Bad path \"%s\"", s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQH_Service_HandleRequest(AQH_SERVICE *sv, AQCGI_REQUEST *req)
|
||||||
|
{
|
||||||
|
return (sv && sv->handleRequestFn)?(sv->handleRequestFn(sv, req)):GWEN_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQH_USER *AQH_Service_LoadUser(AQH_SERVICE *sv, const char *s)
|
||||||
|
{
|
||||||
|
return (sv && sv->loadUserFn)?(sv->loadUserFn(sv, s)):NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQH_Service_SaveUser(AQH_SERVICE *sv, AQH_USER *user)
|
||||||
|
{
|
||||||
|
return (sv && sv->saveUserFn)?(sv->saveUserFn(sv, user)):GWEN_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQH_Service_AddUser(AQH_SERVICE *sv, AQH_USER *user)
|
||||||
|
{
|
||||||
|
return (sv && sv->addUserFn)?(sv->addUserFn(sv, user)):GWEN_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQH_Service_DelUser(AQH_SERVICE *sv, const char *s)
|
||||||
|
{
|
||||||
|
return (sv && sv->delUserFn)?(sv->delUserFn(sv, s)):GWEN_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_STRINGLIST *AQH_Service_ListUsers(AQH_SERVICE *sv)
|
||||||
|
{
|
||||||
|
return (sv && sv->listUsersFn)?(sv->listUsersFn(sv)):NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQH_MODULE *AQH_Service_LoadModule(AQH_SERVICE *sv, const char *s)
|
||||||
|
{
|
||||||
|
return (sv && sv->loadModuleFn)?(sv->loadModuleFn(sv, s)):NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQH_Service_SaveModule(AQH_SERVICE *sv, AQH_MODULE *module)
|
||||||
|
{
|
||||||
|
return (sv && sv->saveModuleFn)?(sv->saveModuleFn(sv, module)):GWEN_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQH_Service_AddModule(AQH_SERVICE *sv, AQH_MODULE *module)
|
||||||
|
{
|
||||||
|
return (sv && sv->addModuleFn)?(sv->addModuleFn(sv, module)):GWEN_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQH_Service_DelModule(AQH_SERVICE *sv, const char *s)
|
||||||
|
{
|
||||||
|
return (sv && sv->delModuleFn)?(sv->delModuleFn(sv, s)):GWEN_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_STRINGLIST *AQH_Service_ListModules(AQH_SERVICE *sv)
|
||||||
|
{
|
||||||
|
return (sv && sv->listModulesFn)?(sv->listModulesFn(sv)):NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQH_SESSION* AQH_Service_LoadSession(AQH_SERVICE *sv, const char *s)
|
||||||
|
{
|
||||||
|
return (sv && sv->loadSessionFn)?(sv->loadSessionFn(sv, s)):NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQH_Service_SaveSession(AQH_SERVICE *sv, AQH_SESSION *session)
|
||||||
|
{
|
||||||
|
return (sv && sv->saveSessionFn)?(sv->saveSessionFn(sv, session)):GWEN_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQH_Service_AddSession(AQH_SERVICE *sv, AQH_SESSION *session)
|
||||||
|
{
|
||||||
|
return (sv && sv->addSessionFn)?(sv->addSessionFn(sv, session)):GWEN_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQH_Service_DelSession(AQH_SERVICE *sv, const char *s)
|
||||||
|
{
|
||||||
|
return (sv && sv->delSessionFn)?(sv->delSessionFn(sv, s)):GWEN_ERROR_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetHandleRequestFn(AQH_SERVICE *sv, AQH_SERVICE_HANDLEREQUEST_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->handleRequestFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetLoadUserFn(AQH_SERVICE *sv, AQH_SERVICE_LOADUSER_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->loadUserFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetSaveUserFn(AQH_SERVICE *sv, AQH_SERVICE_SAVEUSER_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->saveUserFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetAddUserFn(AQH_SERVICE *sv, AQH_SERVICE_ADDUSER_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->addUserFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetDelUserFn(AQH_SERVICE *sv, AQH_SERVICE_DELUSER_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->delUserFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetListUsersFn(AQH_SERVICE *sv, AQH_SERVICE_LISTUSERS_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->listUsersFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetLoadModuleFn(AQH_SERVICE *sv, AQH_SERVICE_LOADMODULE_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->loadModuleFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetSaveModuleFn(AQH_SERVICE *sv, AQH_SERVICE_SAVEMODULE_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->saveModuleFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetAddModuleFn(AQH_SERVICE *sv, AQH_SERVICE_ADDMODULE_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->addModuleFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetDelModuleFn(AQH_SERVICE *sv, AQH_SERVICE_DELMODULE_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->delModuleFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetListModulesFn(AQH_SERVICE *sv, AQH_SERVICE_LISTMODULES_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->listModulesFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetLoadSessionFn(AQH_SERVICE *sv, AQH_SERVICE_LOADSESSION_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->loadSessionFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetSaveSessionFn(AQH_SERVICE *sv, AQH_SERVICE_SAVESESSION_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->saveSessionFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetAddSessionFn(AQH_SERVICE *sv, AQH_SERVICE_ADDSESSION_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->addSessionFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetDelSessionFn(AQH_SERVICE *sv, AQH_SERVICE_DELSESSION_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->delSessionFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetListSessionsFn(AQH_SERVICE *sv, AQH_SERVICE_LISTSESSIONS_FN f)
|
||||||
|
{
|
||||||
|
if (sv)
|
||||||
|
sv->listSessionsFn=f;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
104
apps/aqhome-cgi/service/service.h
Normal file
104
apps/aqhome-cgi/service/service.h
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2025 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 AQHOME_SERVICE_H
|
||||||
|
#define AQHOME_SERVICE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <aqhome/api.h>
|
||||||
|
|
||||||
|
#include <gwenhywfar/inherit.h>
|
||||||
|
#include <gwenhywfar/list.h>
|
||||||
|
#include <gwenhywfar/stringlist.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct AQH_SERVICE AQH_SERVICE;
|
||||||
|
GWEN_INHERIT_FUNCTION_DEFS(AQH_SERVICE);
|
||||||
|
GWEN_LIST_FUNCTION_DEFS(AQH_SERVICE, AQH_Service);
|
||||||
|
|
||||||
|
|
||||||
|
#include "aqhome-cgi/service/user.h"
|
||||||
|
#include "aqhome-cgi/service/module.h"
|
||||||
|
#include "aqhome-cgi/service/session.h"
|
||||||
|
|
||||||
|
#include <aqcgi/cgi.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef int (*AQH_SERVICE_HANDLEREQUEST_FN)(AQH_SERVICE *sv, AQCGI_REQUEST *req);
|
||||||
|
|
||||||
|
typedef AQH_USER* (*AQH_SERVICE_LOADUSER_FN)(AQH_SERVICE *sv, const char *s);
|
||||||
|
typedef int (*AQH_SERVICE_SAVEUSER_FN)(AQH_SERVICE *sv, AQH_USER *user);
|
||||||
|
typedef int (*AQH_SERVICE_ADDUSER_FN)(AQH_SERVICE *sv, AQH_USER *user);
|
||||||
|
typedef int (*AQH_SERVICE_DELUSER_FN)(AQH_SERVICE *sv, const char *s);
|
||||||
|
typedef GWEN_STRINGLIST* (*AQH_SERVICE_LISTUSERS_FN)(AQH_SERVICE *sv);
|
||||||
|
|
||||||
|
typedef AQH_MODULE* (*AQH_SERVICE_LOADMODULE_FN)(AQH_SERVICE *sv, const char *s);
|
||||||
|
typedef int (*AQH_SERVICE_SAVEMODULE_FN)(AQH_SERVICE *sv, AQH_MODULE *module);
|
||||||
|
typedef int (*AQH_SERVICE_ADDMODULE_FN)(AQH_SERVICE *sv, AQH_MODULE *module);
|
||||||
|
typedef int (*AQH_SERVICE_DELMODULE_FN)(AQH_SERVICE *sv, const char *s);
|
||||||
|
typedef GWEN_STRINGLIST* (*AQH_SERVICE_LISTMODULES_FN)(AQH_SERVICE *sv);
|
||||||
|
|
||||||
|
|
||||||
|
typedef AQH_SESSION* (*AQH_SERVICE_LOADSESSION_FN)(AQH_SERVICE *sv, const char *s);
|
||||||
|
typedef int (*AQH_SERVICE_SAVESESSION_FN)(AQH_SERVICE *sv, AQH_SESSION *session);
|
||||||
|
typedef int (*AQH_SERVICE_ADDSESSION_FN)(AQH_SERVICE *sv, AQH_SESSION *session);
|
||||||
|
typedef int (*AQH_SERVICE_DELSESSION_FN)(AQH_SERVICE *sv, const char *s);
|
||||||
|
typedef GWEN_STRINGLIST* (*AQH_SERVICE_LISTSESSIONS_FN)(AQH_SERVICE *sv);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQH_SERVICE *AQH_Service_new(void);
|
||||||
|
void AQH_Service_free(AQH_SERVICE *sv);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int AQH_Service_HandleRequest(AQH_SERVICE *sv, AQCGI_REQUEST *req);
|
||||||
|
|
||||||
|
AQH_USER *AQH_Service_LoadUser(AQH_SERVICE *sv, const char *s);
|
||||||
|
int AQH_Service_SaveUser(AQH_SERVICE *sv, AQH_USER *user);
|
||||||
|
int AQH_Service_AddUser(AQH_SERVICE *sv, AQH_USER *user);
|
||||||
|
int AQH_Service_DelUser(AQH_SERVICE *sv, const char *s);
|
||||||
|
GWEN_STRINGLIST *AQH_Service_ListUsers(AQH_SERVICE *sv);
|
||||||
|
|
||||||
|
AQH_MODULE *AQH_Service_LoadModule(AQH_SERVICE *sv, const char *s);
|
||||||
|
int AQH_Service_SaveModule(AQH_SERVICE *sv, AQH_MODULE *module);
|
||||||
|
int AQH_Service_AddModule(AQH_SERVICE *sv, AQH_MODULE *module);
|
||||||
|
int AQH_Service_DelModule(AQH_SERVICE *sv, const char *s);
|
||||||
|
GWEN_STRINGLIST *AQH_Service_ListModules(AQH_SERVICE *sv);
|
||||||
|
|
||||||
|
AQH_SESSION* AQH_Service_LoadSession(AQH_SERVICE *sv, const char *s);
|
||||||
|
int AQH_Service_SaveSession(AQH_SERVICE *sv, AQH_SESSION *session);
|
||||||
|
int AQH_Service_AddSession(AQH_SERVICE *sv, AQH_SESSION *session);
|
||||||
|
int AQH_Service_DelSession(AQH_SERVICE *sv, const char *s);
|
||||||
|
GWEN_STRINGLIST *AQH_Service_ListSessions(AQH_SERVICE *sv);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void AQH_Service_SetHandleRequestFn(AQH_SERVICE *sv, AQH_SERVICE_HANDLEREQUEST_FN f);
|
||||||
|
|
||||||
|
void AQH_Service_SetLoadUserFn(AQH_SERVICE *sv, AQH_SERVICE_LOADUSER_FN f);
|
||||||
|
void AQH_Service_SetSaveUserFn(AQH_SERVICE *sv, AQH_SERVICE_SAVEUSER_FN f);
|
||||||
|
void AQH_Service_SetAddUserFn(AQH_SERVICE *sv, AQH_SERVICE_ADDUSER_FN f);
|
||||||
|
void AQH_Service_SetDelUserFn(AQH_SERVICE *sv, AQH_SERVICE_DELUSER_FN f);
|
||||||
|
void AQH_Service_SetListUsersFn(AQH_SERVICE *sv, AQH_SERVICE_LISTUSERS_FN f);
|
||||||
|
|
||||||
|
void AQH_Service_SetLoadModuleFn(AQH_SERVICE *sv, AQH_SERVICE_LOADMODULE_FN f);
|
||||||
|
void AQH_Service_SetSaveModuleFn(AQH_SERVICE *sv, AQH_SERVICE_SAVEMODULE_FN f);
|
||||||
|
void AQH_Service_SetAddModuleFn(AQH_SERVICE *sv, AQH_SERVICE_ADDMODULE_FN f);
|
||||||
|
void AQH_Service_SetDelModuleFn(AQH_SERVICE *sv, AQH_SERVICE_DELMODULE_FN f);
|
||||||
|
void AQH_Service_SetListModulesFn(AQH_SERVICE *sv, AQH_SERVICE_LISTMODULES_FN f);
|
||||||
|
|
||||||
|
void AQH_Service_SetLoadSessionFn(AQH_SERVICE *sv, AQH_SERVICE_LOADSESSION_FN f);
|
||||||
|
void AQH_Service_SetSaveSessionFn(AQH_SERVICE *sv, AQH_SERVICE_SAVESESSION_FN f);
|
||||||
|
void AQH_Service_SetAddSessionFn(AQH_SERVICE *sv, AQH_SERVICE_ADDSESSION_FN f);
|
||||||
|
void AQH_Service_SetDelSessionFn(AQH_SERVICE *sv, AQH_SERVICE_DELSESSION_FN f);
|
||||||
|
void AQH_Service_SetListSessionsFn(AQH_SERVICE *sv, AQH_SERVICE_LISTSESSIONS_FN f);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
45
apps/aqhome-cgi/service/service_p.h
Normal file
45
apps/aqhome-cgi/service/service_p.h
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (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 AQHOME_SERVICE_P_H
|
||||||
|
#define AQHOME_SERVICE_P_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "aqhome-cgi/service/service.h"
|
||||||
|
|
||||||
|
|
||||||
|
struct AQH_SERVICE {
|
||||||
|
GWEN_INHERIT_ELEMENT(AQH_SERVICE);
|
||||||
|
GWEN_LIST_ELEMENT(AQH_SERVICE);
|
||||||
|
|
||||||
|
AQH_SERVICE_HANDLEREQUEST_FN handleRequestFn;
|
||||||
|
|
||||||
|
AQH_SERVICE_LOADUSER_FN loadUserFn;
|
||||||
|
AQH_SERVICE_SAVEUSER_FN saveUserFn;
|
||||||
|
AQH_SERVICE_ADDUSER_FN addUserFn;
|
||||||
|
AQH_SERVICE_DELUSER_FN delUserFn;
|
||||||
|
AQH_SERVICE_LISTUSERS_FN listUsersFn;
|
||||||
|
|
||||||
|
AQH_SERVICE_LOADMODULE_FN loadModuleFn;
|
||||||
|
AQH_SERVICE_SAVEMODULE_FN saveModuleFn;
|
||||||
|
AQH_SERVICE_ADDMODULE_FN addModuleFn;
|
||||||
|
AQH_SERVICE_DELMODULE_FN delModuleFn;
|
||||||
|
AQH_SERVICE_LISTMODULES_FN listModulesFn;
|
||||||
|
|
||||||
|
AQH_SERVICE_LOADSESSION_FN loadSessionFn;
|
||||||
|
AQH_SERVICE_SAVESESSION_FN saveSessionFn;
|
||||||
|
AQH_SERVICE_ADDSESSION_FN addSessionFn;
|
||||||
|
AQH_SERVICE_DELSESSION_FN delSessionFn;
|
||||||
|
AQH_SERVICE_LISTSESSIONS_FN listSessionsFn;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<header type="sys" loc="pre">aqhome/api.h</header>
|
<header type="sys" loc="pre">aqhome/api.h</header>
|
||||||
<header type="sys" loc="pre">gwenhywfar/error.h</header>
|
<header type="sys" loc="pre">gwenhywfar/error.h</header>
|
||||||
<header type="sys" loc="pre">gwenhywfar/timestamp.h</header>
|
<header type="sys" loc="pre">gwenhywfar/timestamp.h</header>
|
||||||
<header type="sys" loc="post">aqhome/service/user.h</header>
|
<header type="sys" loc="post">aqhome-cgi/service/user.h</header>
|
||||||
</headers>
|
</headers>
|
||||||
|
|
||||||
<inlines>
|
<inlines>
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
<header type="sys" loc="pre">aqhome/api.h</header>
|
<header type="sys" loc="pre">aqhome/api.h</header>
|
||||||
<header type="sys" loc="pre">gwenhywfar/error.h</header>
|
<header type="sys" loc="pre">gwenhywfar/error.h</header>
|
||||||
<header type="sys" loc="pre">gwenhywfar/timestamp.h</header>
|
<header type="sys" loc="pre">gwenhywfar/timestamp.h</header>
|
||||||
<header type="sys" loc="post">aqhome/service/moduleperms.h</header>
|
<header type="sys" loc="post">aqhome-cgi/service/moduleperms.h</header>
|
||||||
</headers>
|
</headers>
|
||||||
|
|
||||||
<inlines>
|
<inlines>
|
||||||
579
apps/aqhome-cgi/service_file.c
Normal file
579
apps/aqhome-cgi/service_file.c
Normal file
@@ -0,0 +1,579 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* This file is part of the project AqHome.
|
||||||
|
* AqHome (c) by 2025 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
|
||||||
|
|
||||||
|
//#define DISABLE_DEBUGLOG
|
||||||
|
|
||||||
|
|
||||||
|
#include "./service_file_p.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/misc.h>
|
||||||
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* defs and enums
|
||||||
|
* ------------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define AQH_SERVICE_FILE_GROUP_USERS "users"
|
||||||
|
#define AQH_SERVICE_FILE_GROUP_MODULES "modules"
|
||||||
|
#define AQH_SERVICE_FILE_GROUP_SESSIONS "sessions"
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* global vars
|
||||||
|
* ------------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
GWEN_INHERIT(AQH_SERVICE, AQH_SERVICE_FILE)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* forward declarations
|
||||||
|
* ------------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void GWENHYWFAR_CB _freeData(void *bp, void *p);
|
||||||
|
|
||||||
|
static AQH_USER *_loadUser(AQH_SERVICE *sv, const char *s);
|
||||||
|
static int _saveUser(AQH_SERVICE *sv, AQH_USER *user);
|
||||||
|
static int _addUser(AQH_SERVICE *sv, AQH_USER *user);
|
||||||
|
static int _delUser(AQH_SERVICE *sv, const char *s);
|
||||||
|
static GWEN_STRINGLIST *_listUsers(AQH_SERVICE *sv);
|
||||||
|
|
||||||
|
static AQH_MODULE *_loadModule(AQH_SERVICE *sv, const char *s);
|
||||||
|
static int _saveModule(AQH_SERVICE *sv, AQH_MODULE *module);
|
||||||
|
static int _addModule(AQH_SERVICE *sv, AQH_MODULE *module);
|
||||||
|
static int _delModule(AQH_SERVICE *sv, const char *s);
|
||||||
|
static GWEN_STRINGLIST *_listModules(AQH_SERVICE *sv);
|
||||||
|
|
||||||
|
static AQH_SESSION* _loadSession(AQH_SERVICE *sv, const char *s);
|
||||||
|
static int _saveSession(AQH_SERVICE *sv, AQH_SESSION *session);
|
||||||
|
static int _addSession(AQH_SERVICE *sv, AQH_SESSION *session);
|
||||||
|
static int _delSession(AQH_SERVICE *sv, const char *s);
|
||||||
|
static GWEN_STRINGLIST *_listSessions(AQH_SERVICE *sv);
|
||||||
|
|
||||||
|
static GWEN_DB_NODE *_loadGroupLocked(AQH_SERVICE *sv, const char *groupName, const char *subGroupName);
|
||||||
|
static int _saveGroupLocked(AQH_SERVICE *sv, const char *groupName, const char *subGroupName, GWEN_DB_NODE *db);
|
||||||
|
static int _addGroupLocked(AQH_SERVICE *sv, const char *groupName, const char *subGroupName, GWEN_DB_NODE *db);
|
||||||
|
static int _deleteGroup(AQH_SERVICE *sv, const char *groupName, const char *subGroupName);
|
||||||
|
static GWEN_STRINGLIST *_listGroup(AQH_SERVICE *sv, const char *groupName);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
* code
|
||||||
|
* ------------------------------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
AQH_SERVICE *AQH_ServiceFiles_new(const char *baseFolder)
|
||||||
|
{
|
||||||
|
AQH_SERVICE *sv;
|
||||||
|
AQH_SERVICE_FILE *xs;
|
||||||
|
GWEN_BUFFER *dbuf;
|
||||||
|
|
||||||
|
sv=AQH_Service_new();
|
||||||
|
GWEN_NEW_OBJECT(AQH_SERVICE_FILE, xs);
|
||||||
|
GWEN_INHERIT_SETDATA(AQH_SERVICE, AQH_SERVICE_FILE, sv, xs, _freeData);
|
||||||
|
xs->baseFolder=strdup(baseFolder);
|
||||||
|
|
||||||
|
AQH_Service_SetLoadUserFn(sv, _loadUser);
|
||||||
|
AQH_Service_SetSaveUserFn(sv, _saveUser);
|
||||||
|
AQH_Service_SetAddUserFn(sv, _addUser);
|
||||||
|
AQH_Service_SetDelUserFn(sv, _delUser);
|
||||||
|
AQH_Service_SetListUsersFn(sv, _listUsers);
|
||||||
|
|
||||||
|
AQH_Service_SetLoadModuleFn(sv, _loadModule);
|
||||||
|
AQH_Service_SetSaveModuleFn(sv, _saveModule);
|
||||||
|
AQH_Service_SetAddModuleFn(sv, _addModule);
|
||||||
|
AQH_Service_SetDelModuleFn(sv, _delModule);
|
||||||
|
AQH_Service_SetListModulesFn(sv, _listModules);
|
||||||
|
|
||||||
|
AQH_Service_SetLoadSessionFn(sv, _loadSession);
|
||||||
|
AQH_Service_SetSaveSessionFn(sv, _saveSession);
|
||||||
|
AQH_Service_SetAddSessionFn(sv, _addSession);
|
||||||
|
AQH_Service_SetDelSessionFn(sv, _delSession);
|
||||||
|
AQH_Service_SetListSessionsFn(sv, _listSessions);
|
||||||
|
|
||||||
|
dbuf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||||
|
GWEN_Buffer_AppendArgs(dbuf, "dir://%s", baseFolder);
|
||||||
|
DBG_ERROR(NULL, "Creating config mgr \"%s\"", GWEN_Buffer_GetStart(dbuf));
|
||||||
|
xs->configMgr=GWEN_ConfigMgr_Factory(GWEN_Buffer_GetStart(dbuf));
|
||||||
|
if (xs->configMgr==NULL) {
|
||||||
|
DBG_ERROR(NULL, "Error creating config mgr \"%s\"", GWEN_Buffer_GetStart(dbuf));
|
||||||
|
GWEN_Buffer_free(dbuf);
|
||||||
|
AQH_Service_free(sv);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
GWEN_Buffer_free(dbuf);
|
||||||
|
|
||||||
|
return sv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p)
|
||||||
|
{
|
||||||
|
AQH_SERVICE_FILE *xs;
|
||||||
|
|
||||||
|
xs=(AQH_SERVICE_FILE*) p;
|
||||||
|
GWEN_ConfigMgr_free(xs->configMgr);
|
||||||
|
free(xs->baseFolder);
|
||||||
|
GWEN_FREE_OBJECT(xs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQH_USER *_loadUser(AQH_SERVICE *sv, const char *s)
|
||||||
|
{
|
||||||
|
GWEN_DB_NODE *db;
|
||||||
|
|
||||||
|
db=_loadGroupLocked(sv, AQH_SERVICE_FILE_GROUP_USERS, s);
|
||||||
|
if (db) {
|
||||||
|
AQH_USER *user;
|
||||||
|
|
||||||
|
user=AQH_User_fromDb(db);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _saveUser(AQH_SERVICE *sv, AQH_USER *user)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
s=AQH_User_GetAlias(user);
|
||||||
|
if (s && *s) {
|
||||||
|
GWEN_DB_NODE *db;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
db=GWEN_DB_Group_new(s);
|
||||||
|
rv=AQH_User_toDb(user, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "here (%d)", rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
rv=_saveGroupLocked(sv, AQH_SERVICE_FILE_GROUP_USERS, s, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "here (%d)", rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return GWEN_ERROR_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _addUser(AQH_SERVICE *sv, AQH_USER *user)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
s=AQH_User_GetAlias(user);
|
||||||
|
if (s && *s) {
|
||||||
|
GWEN_DB_NODE *db;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
db=GWEN_DB_Group_new(s);
|
||||||
|
rv=AQH_User_toDb(user, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "here (%d)", rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
rv=_addGroupLocked(sv, AQH_SERVICE_FILE_GROUP_USERS, s, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "here (%d)", rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return GWEN_ERROR_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _delUser(AQH_SERVICE *sv, const char *s)
|
||||||
|
{
|
||||||
|
return _deleteGroup(sv, AQH_SERVICE_FILE_GROUP_USERS, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_STRINGLIST *_listUsers(AQH_SERVICE *sv)
|
||||||
|
{
|
||||||
|
return _listGroup(sv, AQH_SERVICE_FILE_GROUP_USERS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQH_MODULE *_loadModule(AQH_SERVICE *sv, const char *s)
|
||||||
|
{
|
||||||
|
GWEN_DB_NODE *db;
|
||||||
|
|
||||||
|
db=_loadGroupLocked(sv, AQH_SERVICE_FILE_GROUP_MODULES, s);
|
||||||
|
if (db) {
|
||||||
|
AQH_MODULE *module;
|
||||||
|
|
||||||
|
module=AQH_Module_fromDb(db);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return module;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _saveModule(AQH_SERVICE *sv, AQH_MODULE *module)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
s=AQH_Module_GetName(module);
|
||||||
|
if (s && *s) {
|
||||||
|
GWEN_DB_NODE *db;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
db=GWEN_DB_Group_new(s);
|
||||||
|
rv=AQH_Module_toDb(module, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "here (%d)", rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
rv=_saveGroupLocked(sv, AQH_SERVICE_FILE_GROUP_MODULES, s, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "here (%d)", rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return GWEN_ERROR_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _addModule(AQH_SERVICE *sv, AQH_MODULE *module)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
s=AQH_Module_GetName(module);
|
||||||
|
if (s && *s) {
|
||||||
|
GWEN_DB_NODE *db;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
db=GWEN_DB_Group_new(s);
|
||||||
|
rv=AQH_Module_toDb(module, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "here (%d)", rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
rv=_addGroupLocked(sv, AQH_SERVICE_FILE_GROUP_MODULES, s, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "here (%d)", rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return GWEN_ERROR_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _delModule(AQH_SERVICE *sv, const char *s)
|
||||||
|
{
|
||||||
|
return _deleteGroup(sv, AQH_SERVICE_FILE_GROUP_MODULES, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_STRINGLIST *_listModules(AQH_SERVICE *sv)
|
||||||
|
{
|
||||||
|
return _listGroup(sv, AQH_SERVICE_FILE_GROUP_MODULES);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
AQH_SESSION* _loadSession(AQH_SERVICE *sv, const char *s)
|
||||||
|
{
|
||||||
|
GWEN_DB_NODE *db;
|
||||||
|
|
||||||
|
db=_loadGroupLocked(sv, AQH_SERVICE_FILE_GROUP_SESSIONS, s);
|
||||||
|
if (db) {
|
||||||
|
AQH_SESSION *session;
|
||||||
|
|
||||||
|
session=AQH_Session_fromDb(db);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _saveSession(AQH_SERVICE *sv, AQH_SESSION *session)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
s=AQH_Session_GetUid(session);
|
||||||
|
if (s && *s) {
|
||||||
|
GWEN_DB_NODE *db;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
db=GWEN_DB_Group_new(s);
|
||||||
|
rv=AQH_Session_toDb(session, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "here (%d)", rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
rv=_saveGroupLocked(sv, AQH_SERVICE_FILE_GROUP_SESSIONS, s, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "here (%d)", rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return GWEN_ERROR_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _addSession(AQH_SERVICE *sv, AQH_SESSION *session)
|
||||||
|
{
|
||||||
|
const char *s;
|
||||||
|
|
||||||
|
s=AQH_Session_GetUid(session);
|
||||||
|
if (s && *s) {
|
||||||
|
GWEN_DB_NODE *db;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
db=GWEN_DB_Group_new(s);
|
||||||
|
rv=AQH_Session_toDb(session, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "here (%d)", rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
rv=_addGroupLocked(sv, AQH_SERVICE_FILE_GROUP_SESSIONS, s, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "here (%d)", rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return GWEN_ERROR_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _delSession(AQH_SERVICE *sv, const char *s)
|
||||||
|
{
|
||||||
|
return _deleteGroup(sv, AQH_SERVICE_FILE_GROUP_SESSIONS, s);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_STRINGLIST *_listSessions(AQH_SERVICE *sv)
|
||||||
|
{
|
||||||
|
return _listGroup(sv, AQH_SERVICE_FILE_GROUP_SESSIONS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_DB_NODE *_loadGroupLocked(AQH_SERVICE *sv, const char *groupName, const char *subGroupName)
|
||||||
|
{
|
||||||
|
if (sv && groupName && subGroupName) {
|
||||||
|
AQH_SERVICE_FILE *xs;
|
||||||
|
|
||||||
|
xs=GWEN_INHERIT_GETDATA(AQH_SERVICE, AQH_SERVICE_FILE, sv);
|
||||||
|
if (xs) {
|
||||||
|
GWEN_DB_NODE *db=NULL;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
rv=GWEN_ConfigMgr_LockGroup(xs->configMgr, groupName, subGroupName);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "Error locking group \"%s/%s\": %d", groupName, subGroupName, rv);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
rv=GWEN_ConfigMgr_GetGroup(xs->configMgr, groupName, subGroupName, &db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "Error reading group \"%s/%s\": %d", groupName, subGroupName, rv);
|
||||||
|
GWEN_ConfigMgr_UnlockGroup(xs->configMgr, groupName, subGroupName);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
rv=GWEN_ConfigMgr_UnlockGroup(xs->configMgr, groupName, subGroupName);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "Error unlocking group \"%s/%s\": %d", groupName, subGroupName, rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _saveGroupLocked(AQH_SERVICE *sv, const char *groupName, const char *subGroupName, GWEN_DB_NODE *db)
|
||||||
|
{
|
||||||
|
if (sv && groupName && subGroupName && db) {
|
||||||
|
AQH_SERVICE_FILE *xs;
|
||||||
|
|
||||||
|
xs=GWEN_INHERIT_GETDATA(AQH_SERVICE, AQH_SERVICE_FILE, sv);
|
||||||
|
if (xs) {
|
||||||
|
GWEN_DB_NODE *db=NULL;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
rv=GWEN_ConfigMgr_LockGroup(xs->configMgr, groupName, subGroupName);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "Error locking group \"%s/%s\": %d", groupName, subGroupName, rv);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv=GWEN_ConfigMgr_SetGroup(xs->configMgr, groupName, subGroupName, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "Error writing group \"%s/%s\": %d", groupName, subGroupName, rv);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv=GWEN_ConfigMgr_UnlockGroup(xs->configMgr, groupName, subGroupName);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "Error unlocking group \"%s/%s\": %d", groupName, subGroupName, rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GWEN_ERROR_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _addGroupLocked(AQH_SERVICE *sv, const char *groupName, const char *subGroupName, GWEN_DB_NODE *db)
|
||||||
|
{
|
||||||
|
if (sv && groupName && subGroupName && db) {
|
||||||
|
AQH_SERVICE_FILE *xs;
|
||||||
|
|
||||||
|
xs=GWEN_INHERIT_GETDATA(AQH_SERVICE, AQH_SERVICE_FILE, sv);
|
||||||
|
if (xs) {
|
||||||
|
GWEN_DB_NODE *db=NULL;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
rv=GWEN_ConfigMgr_HasGroup(xs->configMgr, groupName, subGroupName);
|
||||||
|
if (rv>=0) {
|
||||||
|
DBG_ERROR(NULL, "Group \"%s/%s\" already exists", groupName, subGroupName);
|
||||||
|
return GWEN_ERROR_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv=GWEN_ConfigMgr_LockGroup(xs->configMgr, groupName, subGroupName);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "Error locking group \"%s/%s\": %d", groupName, subGroupName, rv);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv=GWEN_ConfigMgr_SetGroup(xs->configMgr, groupName, subGroupName, db);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "Error writing group \"%s/%s\": %d", groupName, subGroupName, rv);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv=GWEN_ConfigMgr_UnlockGroup(xs->configMgr, groupName, subGroupName);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "Error unlocking group \"%s/%s\": %d", groupName, subGroupName, rv);
|
||||||
|
GWEN_DB_Group_free(db);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GWEN_ERROR_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int _deleteGroup(AQH_SERVICE *sv, const char *groupName, const char *subGroupName)
|
||||||
|
{
|
||||||
|
if (sv && groupName && subGroupName) {
|
||||||
|
AQH_SERVICE_FILE *xs;
|
||||||
|
|
||||||
|
xs=GWEN_INHERIT_GETDATA(AQH_SERVICE, AQH_SERVICE_FILE, sv);
|
||||||
|
if (xs) {
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
rv=GWEN_ConfigMgr_DeleteGroup(xs->configMgr, groupName, subGroupName);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "Error writing group \"%s/%s\": %d", groupName, subGroupName, rv);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return GWEN_ERROR_INVALID;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GWEN_STRINGLIST *_listGroup(AQH_SERVICE *sv, const char *groupName)
|
||||||
|
{
|
||||||
|
if (sv && groupName) {
|
||||||
|
AQH_SERVICE_FILE *xs;
|
||||||
|
|
||||||
|
xs=GWEN_INHERIT_GETDATA(AQH_SERVICE, AQH_SERVICE_FILE, sv);
|
||||||
|
if (xs) {
|
||||||
|
GWEN_STRINGLIST *sl;
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
sl=GWEN_StringList_new();
|
||||||
|
rv=GWEN_ConfigMgr_ListSubGroups(xs->configMgr, groupName, sl);
|
||||||
|
if (rv<0) {
|
||||||
|
DBG_ERROR(NULL, "Error listing group \"%s\": %d", groupName, rv);
|
||||||
|
GWEN_StringList_free(sl);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
if (GWEN_StringList_Count(sl)==0) {
|
||||||
|
GWEN_StringList_free(sl);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return sl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1,16 +1,20 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* This file is part of the project AqHome.
|
* This file is part of the project AqHome.
|
||||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
* AqHome (c) by 2025 Martin Preuss, all rights reserved.
|
||||||
*
|
*
|
||||||
* The license for this file can be found in the file COPYING which you
|
* The license for this file can be found in the file COPYING which you
|
||||||
* should have received along with this file.
|
* should have received along with this file.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifdef HAVE_CONFIG_H
|
#ifndef AQHOME_SERVICE_FILE_H
|
||||||
# include <config.h>
|
#define AQHOME_SERVICE_FILE_H
|
||||||
|
|
||||||
|
|
||||||
|
#include "aqhome-cgi/service/service.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <aqhome/ipc/nodes/ipc_nodes.h>
|
|
||||||
|
|
||||||
|
|
||||||
@@ -6,24 +6,23 @@
|
|||||||
* should have received along with this file.
|
* should have received along with this file.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef AQH_ENDPOINT_MQTT_P_H
|
#ifndef AQHOME_SERVICE_FILE_P_H
|
||||||
#define AQH_ENDPOINT_MQTT_P_H
|
#define AQHOME_SERVICE_FILE_P_H
|
||||||
|
|
||||||
|
|
||||||
#include "aqhome/mqtt/endpoint_mqtt.h"
|
#include "aqhome-cgi/service_file.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/configmgr.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct AQH_ENDPOINT_MQTT AQH_ENDPOINT_MQTT;
|
typedef struct AQH_SERVICE_FILE AQH_SERVICE_FILE;
|
||||||
struct AQH_ENDPOINT_MQTT {
|
struct AQH_SERVICE_FILE {
|
||||||
char *clientId;
|
char *baseFolder;
|
||||||
uint16_t lastPacketId;
|
GWEN_CONFIGMGR *configMgr;
|
||||||
uint16_t keepAliveTime;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -120,8 +120,9 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
_runService(aqh, eventLoop);
|
_runService(aqh, eventLoop);
|
||||||
|
|
||||||
//AqHomeData_Fini(aqh);
|
AqHomeDataServer_Fini(aqh);
|
||||||
AQH_Object_free(aqh);
|
AQH_Object_free(aqh);
|
||||||
|
AQH_EventLoop_free(eventLoop);
|
||||||
|
|
||||||
GWEN_Gui_SetGui(NULL);
|
GWEN_Gui_SetGui(NULL);
|
||||||
GWEN_Gui_free(gui);
|
GWEN_Gui_free(gui);
|
||||||
|
|||||||
@@ -47,59 +47,57 @@ static void _sendDeviceList(AQH_OBJECT *ep, const AQH_DEVICE_LIST *vl, uint32_t
|
|||||||
* ------------------------------------------------------------------------------------------------
|
* ------------------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void AqHomeDataServer_HandleGetDevices(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList)
|
void AqHomeDataServer_HandleGetDevices(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg, GWEN_UNUSED const GWEN_TAG16_LIST *tagList)
|
||||||
{
|
{
|
||||||
if (tagList) {
|
AQHOME_SERVER *xo;
|
||||||
AQHOME_SERVER *xo;
|
|
||||||
|
|
||||||
xo=AqHomeDataServer_GetServerData(o);
|
xo=AqHomeDataServer_GetServerData(o);
|
||||||
if (xo) {
|
if (xo) {
|
||||||
const AQH_DEVICE_LIST *origDeviceList;
|
const AQH_DEVICE_LIST *origDeviceList;
|
||||||
uint32_t refMsgId;
|
uint32_t refMsgId;
|
||||||
|
|
||||||
refMsgId=AQH_IpcMessage_GetMsgId(msg);
|
refMsgId=AQH_IpcMessage_GetMsgId(msg);
|
||||||
|
|
||||||
DBG_ERROR(NULL, "HandleGetDevices");
|
DBG_INFO(NULL, "HandleGetDevices");
|
||||||
origDeviceList=AQH_Storage_GetDeviceList(xo->storage);
|
origDeviceList=AQH_Storage_GetDeviceList(xo->storage);
|
||||||
if (origDeviceList) {
|
if (origDeviceList) {
|
||||||
DBG_ERROR(NULL, "Have a list of %d devices", AQH_Device_List_GetCount(origDeviceList));
|
DBG_INFO(NULL, "Have a list of %d devices", AQH_Device_List_GetCount(origDeviceList));
|
||||||
if (AQH_Device_List_GetCount(origDeviceList)<AQHOMEDATA_DEVICESPERMSG) {
|
if (AQH_Device_List_GetCount(origDeviceList)<AQHOMEDATA_DEVICESPERMSG) {
|
||||||
DBG_ERROR(NULL, "Sending all entries in one message");
|
DBG_INFO(NULL, "Sending all entries in one message");
|
||||||
_sendDeviceList(ep, origDeviceList, AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, refMsgId);
|
_sendDeviceList(ep, origDeviceList, AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, refMsgId);
|
||||||
}
|
|
||||||
else {
|
|
||||||
AQH_DEVICE_LIST *tmpDeviceList;
|
|
||||||
const AQH_DEVICE *v;
|
|
||||||
|
|
||||||
DBG_INFO(NULL, "Sending entries in multiple messages");
|
|
||||||
tmpDeviceList=AQH_Device_List_new();
|
|
||||||
v=AQH_Device_List_First(origDeviceList);
|
|
||||||
while(v) {
|
|
||||||
const AQH_DEVICE *next;
|
|
||||||
AQH_DEVICE *copyOfDevice;
|
|
||||||
|
|
||||||
next=AQH_Device_List_Next(v);
|
|
||||||
copyOfDevice=AQH_Device_dup(v);
|
|
||||||
AQH_Device_List_Add(copyOfDevice, tmpDeviceList);
|
|
||||||
if (AQH_Device_List_GetCount(tmpDeviceList)>=AQHOMEDATA_DEVICESPERMSG) {
|
|
||||||
DBG_ERROR(NULL, "Sending %d devices", AQH_Device_List_GetCount(tmpDeviceList));
|
|
||||||
_sendDeviceList(ep, tmpDeviceList, next?0:AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, refMsgId);
|
|
||||||
AQH_Device_List_Clear(tmpDeviceList);
|
|
||||||
}
|
|
||||||
v=next;
|
|
||||||
}
|
|
||||||
if (AQH_Device_List_GetCount(tmpDeviceList)) {
|
|
||||||
DBG_ERROR(NULL, "Sending %d devices", AQH_Device_List_GetCount(tmpDeviceList));
|
|
||||||
_sendDeviceList(ep, tmpDeviceList, AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, refMsgId); /* send remaining */
|
|
||||||
}
|
|
||||||
AQH_Device_List_free(tmpDeviceList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* empty list */
|
AQH_DEVICE_LIST *tmpDeviceList;
|
||||||
_sendDeviceList(ep, NULL, AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, refMsgId);
|
const AQH_DEVICE *v;
|
||||||
|
|
||||||
|
DBG_INFO(NULL, "Sending entries in multiple messages");
|
||||||
|
tmpDeviceList=AQH_Device_List_new();
|
||||||
|
v=AQH_Device_List_First(origDeviceList);
|
||||||
|
while(v) {
|
||||||
|
const AQH_DEVICE *next;
|
||||||
|
AQH_DEVICE *copyOfDevice;
|
||||||
|
|
||||||
|
next=AQH_Device_List_Next(v);
|
||||||
|
copyOfDevice=AQH_Device_dup(v);
|
||||||
|
AQH_Device_List_Add(copyOfDevice, tmpDeviceList);
|
||||||
|
if (AQH_Device_List_GetCount(tmpDeviceList)>=AQHOMEDATA_DEVICESPERMSG) {
|
||||||
|
DBG_INFO(NULL, "Sending %d devices", AQH_Device_List_GetCount(tmpDeviceList));
|
||||||
|
_sendDeviceList(ep, tmpDeviceList, next?0:AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, refMsgId);
|
||||||
|
AQH_Device_List_Clear(tmpDeviceList);
|
||||||
|
}
|
||||||
|
v=next;
|
||||||
|
}
|
||||||
|
if (AQH_Device_List_GetCount(tmpDeviceList)) {
|
||||||
|
DBG_INFO(NULL, "Sending %d devices", AQH_Device_List_GetCount(tmpDeviceList));
|
||||||
|
_sendDeviceList(ep, tmpDeviceList, AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, refMsgId); /* send remaining */
|
||||||
|
}
|
||||||
|
AQH_Device_List_free(tmpDeviceList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
/* empty list */
|
||||||
|
_sendDeviceList(ep, NULL, AQH_MSGDATA_DEVICES_FLAGS_LASTMSG, refMsgId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +107,7 @@ void _sendDeviceList(AQH_OBJECT *ep, const AQH_DEVICE_LIST *vl, uint32_t flags,
|
|||||||
{
|
{
|
||||||
AQH_MESSAGE *msg;
|
AQH_MESSAGE *msg;
|
||||||
|
|
||||||
DBG_ERROR(NULL, "Sending msg (refMsgId=%d)", refMsgId);
|
DBG_INFO(NULL, "Sending msg (refMsgId=%d)", refMsgId);
|
||||||
msg=AQH_IpcdMessageDevices_new(AQH_MSGTYPE_IPC_DATA_GETDEVICES_RSP, AQH_Endpoint_GetNextMessageId(ep), refMsgId, flags, vl);
|
msg=AQH_IpcdMessageDevices_new(AQH_MSGTYPE_IPC_DATA_GETDEVICES_RSP, AQH_Endpoint_GetNextMessageId(ep), refMsgId, flags, vl);
|
||||||
AQH_Endpoint_AddMsgOut(ep, msg);
|
AQH_Endpoint_AddMsgOut(ep, msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,60 +47,58 @@ static void _sendValueList(AQH_OBJECT *ep, const AQH_VALUE_LIST *vl, uint32_t fl
|
|||||||
* ------------------------------------------------------------------------------------------------
|
* ------------------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void AqHomeDataServer_HandleGetValues(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg, const GWEN_TAG16_LIST *tagList)
|
void AqHomeDataServer_HandleGetValues(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg, GWEN_UNUSED const GWEN_TAG16_LIST *tagList)
|
||||||
{
|
{
|
||||||
if (tagList) {
|
AQHOME_SERVER *xo;
|
||||||
AQHOME_SERVER *xo;
|
|
||||||
|
|
||||||
xo=AqHomeDataServer_GetServerData(o);
|
xo=AqHomeDataServer_GetServerData(o);
|
||||||
if (xo) {
|
if (xo) {
|
||||||
const AQH_VALUE_LIST *origValueList;
|
const AQH_VALUE_LIST *origValueList;
|
||||||
|
|
||||||
uint32_t refMsgId;
|
uint32_t refMsgId;
|
||||||
|
|
||||||
refMsgId=AQH_IpcMessage_GetMsgId(msg);
|
refMsgId=AQH_IpcMessage_GetMsgId(msg);
|
||||||
|
|
||||||
DBG_INFO(NULL, "HandleGetValues");
|
DBG_INFO(NULL, "HandleGetValues");
|
||||||
origValueList=AQH_Storage_GetValueList(xo->storage);
|
origValueList=AQH_Storage_GetValueList(xo->storage);
|
||||||
if (origValueList) {
|
if (origValueList) {
|
||||||
DBG_INFO(NULL, "Have a list of %d values", AQH_Value_List_GetCount(origValueList));
|
DBG_INFO(NULL, "Have a list of %d values", AQH_Value_List_GetCount(origValueList));
|
||||||
if (AQH_Value_List_GetCount(origValueList)<AQHOMEDATA_VALUESPERMSG) {
|
if (AQH_Value_List_GetCount(origValueList)<AQHOMEDATA_VALUESPERMSG) {
|
||||||
DBG_INFO(NULL, "Sending all entries in one message");
|
DBG_INFO(NULL, "Sending all entries in one message");
|
||||||
_sendValueList(ep, origValueList, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId);
|
_sendValueList(ep, origValueList, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId);
|
||||||
}
|
|
||||||
else {
|
|
||||||
AQH_VALUE_LIST *tmpValueList;
|
|
||||||
const AQH_VALUE *v;
|
|
||||||
|
|
||||||
DBG_INFO(NULL, "Sending entries in multiple messages");
|
|
||||||
tmpValueList=AQH_Value_List_new();
|
|
||||||
v=AQH_Value_List_First(origValueList);
|
|
||||||
while(v) {
|
|
||||||
const AQH_VALUE *next;
|
|
||||||
AQH_VALUE *copyOfValue;
|
|
||||||
|
|
||||||
next=AQH_Value_List_Next(v);
|
|
||||||
copyOfValue=AQH_Value_dup(v);
|
|
||||||
AQH_Value_List_Add(copyOfValue, tmpValueList);
|
|
||||||
if (AQH_Value_List_GetCount(tmpValueList)>=AQHOMEDATA_VALUESPERMSG) {
|
|
||||||
DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList));
|
|
||||||
_sendValueList(ep, tmpValueList, next?0:AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId);
|
|
||||||
AQH_Value_List_Clear(tmpValueList);
|
|
||||||
}
|
|
||||||
v=next;
|
|
||||||
}
|
|
||||||
if (AQH_Value_List_GetCount(tmpValueList)) {
|
|
||||||
DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList));
|
|
||||||
_sendValueList(ep, tmpValueList, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId); /* send remaining */
|
|
||||||
}
|
|
||||||
AQH_Value_List_free(tmpValueList);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* empty list */
|
AQH_VALUE_LIST *tmpValueList;
|
||||||
_sendValueList(ep, NULL, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId);
|
const AQH_VALUE *v;
|
||||||
|
|
||||||
|
DBG_INFO(NULL, "Sending entries in multiple messages");
|
||||||
|
tmpValueList=AQH_Value_List_new();
|
||||||
|
v=AQH_Value_List_First(origValueList);
|
||||||
|
while(v) {
|
||||||
|
const AQH_VALUE *next;
|
||||||
|
AQH_VALUE *copyOfValue;
|
||||||
|
|
||||||
|
next=AQH_Value_List_Next(v);
|
||||||
|
copyOfValue=AQH_Value_dup(v);
|
||||||
|
AQH_Value_List_Add(copyOfValue, tmpValueList);
|
||||||
|
if (AQH_Value_List_GetCount(tmpValueList)>=AQHOMEDATA_VALUESPERMSG) {
|
||||||
|
DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList));
|
||||||
|
_sendValueList(ep, tmpValueList, next?0:AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId);
|
||||||
|
AQH_Value_List_Clear(tmpValueList);
|
||||||
|
}
|
||||||
|
v=next;
|
||||||
|
}
|
||||||
|
if (AQH_Value_List_GetCount(tmpValueList)) {
|
||||||
|
DBG_INFO(NULL, "Sending %d values", AQH_Value_List_GetCount(tmpValueList));
|
||||||
|
_sendValueList(ep, tmpValueList, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId); /* send remaining */
|
||||||
|
}
|
||||||
|
AQH_Value_List_free(tmpValueList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
/* empty list */
|
||||||
|
_sendValueList(ep, NULL, AQH_MSGDATA_VALUES_FLAGS_LASTMSG, refMsgId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,7 +108,7 @@ void _sendValueList(AQH_OBJECT *ep, const AQH_VALUE_LIST *vl, uint32_t flags, ui
|
|||||||
{
|
{
|
||||||
AQH_MESSAGE *msg;
|
AQH_MESSAGE *msg;
|
||||||
|
|
||||||
DBG_ERROR(NULL, "Sending msg (refMsgId=%d)", refMsgId);
|
DBG_INFO(NULL, "Sending msg (refMsgId=%d)", refMsgId);
|
||||||
msg=AQH_IpcdMessageValues_new(AQH_MSGTYPE_IPC_DATA_GETVALUES_RSP, AQH_Endpoint_GetNextMessageId(ep), refMsgId, flags, vl);
|
msg=AQH_IpcdMessageValues_new(AQH_MSGTYPE_IPC_DATA_GETVALUES_RSP, AQH_Endpoint_GetNextMessageId(ep), refMsgId, flags, vl);
|
||||||
AQH_Endpoint_AddMsgOut(ep, msg);
|
AQH_Endpoint_AddMsgOut(ep, msg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p)
|
|||||||
}
|
}
|
||||||
GWEN_DB_Group_free(xo->dbArgs);
|
GWEN_DB_Group_free(xo->dbArgs);
|
||||||
AQH_Storage_free(xo->storage);
|
AQH_Storage_free(xo->storage);
|
||||||
|
AQH_MsgRequest_free(xo->requestTree);
|
||||||
free(xo->pidFile);
|
free(xo->pidFile);
|
||||||
|
|
||||||
GWEN_FREE_OBJECT(xo);
|
GWEN_FREE_OBJECT(xo);
|
||||||
@@ -304,6 +305,24 @@ int _setupIpc(AQH_OBJECT *o, AQHOME_SERVER *xo, GWEN_DB_NODE *dbArgs)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
|
* fini
|
||||||
|
* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
|
*/
|
||||||
|
|
||||||
|
void AqHomeDataServer_Fini(AQH_OBJECT *o)
|
||||||
|
{
|
||||||
|
AQHOME_SERVER *xo;
|
||||||
|
|
||||||
|
xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQHOME_SERVER, o);
|
||||||
|
if (xo) {
|
||||||
|
if (xo->pidFile)
|
||||||
|
remove(xo->pidFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
/* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
* signal handler
|
* signal handler
|
||||||
* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||||
@@ -329,7 +348,7 @@ int _handleNewClient(AQH_OBJECT *o, AQH_OBJECT *clientEndpoint)
|
|||||||
|
|
||||||
xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQHOME_SERVER, o);
|
xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQHOME_SERVER, o);
|
||||||
if (xo) {
|
if (xo) {
|
||||||
DBG_ERROR(NULL, "New IPC client");
|
DBG_INFO(NULL, "New IPC client");
|
||||||
AQH_Object_AddLink(clientEndpoint, AQH_ENDPOINT_SIGNAL_CLOSED, AQH_AQHOME_SERVER_SLOT_CLOSED, o);
|
AQH_Object_AddLink(clientEndpoint, AQH_ENDPOINT_SIGNAL_CLOSED, AQH_AQHOME_SERVER_SLOT_CLOSED, o);
|
||||||
AQH_Object_List_Add(clientEndpoint, xo->tcpClientList);
|
AQH_Object_List_Add(clientEndpoint, xo->tcpClientList);
|
||||||
return 1; /* handled */
|
return 1; /* handled */
|
||||||
@@ -346,7 +365,7 @@ int _handleClientDown(AQH_OBJECT *o, AQH_OBJECT *clientEndpoint)
|
|||||||
|
|
||||||
xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQHOME_SERVER, o);
|
xo=GWEN_INHERIT_GETDATA(AQH_OBJECT, AQHOME_SERVER, o);
|
||||||
if (xo) {
|
if (xo) {
|
||||||
DBG_ERROR(NULL, "IPC client down");
|
DBG_INFO(NULL, "IPC client down");
|
||||||
AQH_Object_AddFlags(clientEndpoint, AQH_OBJECT_FLAGS_DELETE);
|
AQH_Object_AddFlags(clientEndpoint, AQH_OBJECT_FLAGS_DELETE);
|
||||||
return 1; /* handled */
|
return 1; /* handled */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
AQH_OBJECT *AqHomeDataServer_new(AQH_EVENT_LOOP *eventLoop);
|
AQH_OBJECT *AqHomeDataServer_new(AQH_EVENT_LOOP *eventLoop);
|
||||||
int AqHomeDataServer_Init(AQH_OBJECT *o, int argc, char **argv);
|
int AqHomeDataServer_Init(AQH_OBJECT *o, int argc, char **argv);
|
||||||
|
void AqHomeDataServer_Fini(AQH_OBJECT *o);
|
||||||
|
|
||||||
int AqHomeDataServer_GetTimeout(const AQH_OBJECT *o);
|
int AqHomeDataServer_GetTimeout(const AQH_OBJECT *o);
|
||||||
int AqHomeDataServer_GetClientNum(const AQH_OBJECT *o);
|
int AqHomeDataServer_GetClientNum(const AQH_OBJECT *o);
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
AQH_MqttLogServer_Fini(aqh);
|
AQH_MqttLogServer_Fini(aqh);
|
||||||
AQH_Object_free(aqh);
|
AQH_Object_free(aqh);
|
||||||
|
AQH_EventLoop_free(eventLoop);
|
||||||
|
|
||||||
GWEN_Gui_SetGui(NULL);
|
GWEN_Gui_SetGui(NULL);
|
||||||
GWEN_Gui_free(gui);
|
GWEN_Gui_free(gui);
|
||||||
|
|||||||
@@ -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,
|
static void _handleNumTopic(AQH_MQTTLOG_SERVER *xo, AQHMQTT_DEVICE *device,
|
||||||
AQHMQTT_TOPIC *topic, const char *rcvdValue);
|
AQHMQTT_TOPIC *topic, const char *rcvdValue);
|
||||||
static void _handleJsonTopic(AQH_MQTTLOG_SERVER *xo, AQHMQTT_DEVICE *device,
|
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) {
|
if (topic && value) {
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
rv=_handlePublish(o, topic, value);
|
rv=_handlePublish(o, xo, topic, value);
|
||||||
if (rv!=1) {
|
if (rv!=1) {
|
||||||
DBG_INFO(NULL, "New topic \"%s\", trying to register", topic);
|
DBG_INFO(NULL, "New topic \"%s\", trying to register", topic);
|
||||||
rv=_registerNewDeviceForTopic(xo, topic);
|
rv=_registerNewDeviceForTopic(xo, topic);
|
||||||
if (rv==1) {
|
if (rv==1) {
|
||||||
rv=_handlePublish(o, topic, value);
|
rv=_handlePublish(o, xo, topic, value);
|
||||||
if (rv!=1) {
|
if (rv!=1) {
|
||||||
DBG_ERROR(NULL, "Topic \"%s\" still not handled, SNH!", topic);
|
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) {
|
if (o && rcvdTopic && *rcvdTopic && xo && xo->registeredDeviceList) {
|
||||||
AQH_MQTTLOG_SERVER *xo;
|
AQHMQTT_DEVICE *device;
|
||||||
|
|
||||||
xo=AQH_MqttLogServer_GetServerData(o);
|
device=AQHMQTT_Device_List_First(xo->registeredDeviceList);
|
||||||
if (xo && xo->registeredDeviceList) {
|
while(device) {
|
||||||
AQHMQTT_DEVICE *device;
|
AQHMQTT_TOPIC_LIST *topicList;
|
||||||
|
const char *sDeviceName;
|
||||||
|
const char *sDeviceId;
|
||||||
|
|
||||||
device=AQHMQTT_Device_List_First(xo->registeredDeviceList);
|
sDeviceName=AQHMQTT_Device_GetName(device);
|
||||||
while(device) {
|
sDeviceId=AQHMQTT_Device_GetId(device);
|
||||||
AQHMQTT_TOPIC_LIST *topicList;
|
|
||||||
const char *sDeviceName;
|
|
||||||
const char *sDeviceId;
|
|
||||||
|
|
||||||
sDeviceName=AQHMQTT_Device_GetName(device);
|
topicList=AQHMQTT_Device_GetTopicList(device);
|
||||||
sDeviceId=AQHMQTT_Device_GetId(device);
|
if (topicList) {
|
||||||
|
AQHMQTT_TOPIC *topic;
|
||||||
|
|
||||||
topicList=AQHMQTT_Device_GetTopicList(device);
|
topic=_findTopicMatchingTopic(topicList, rcvdTopic, AQHMQTT_TopicDir_In);
|
||||||
if (topicList) {
|
|
||||||
AQHMQTT_TOPIC *topic;
|
|
||||||
|
|
||||||
topic=_findTopicMatchingTopic(topicList, rcvdTopic, AQHMQTT_TopicDir_In);
|
|
||||||
#if 0
|
#if 0
|
||||||
if (topic==NULL) {
|
if (topic==NULL) {
|
||||||
topic=_findMaskMatchingTopic(topicList, rcvdTopic, AQHMQTT_TopicDir_In);
|
topic=_findMaskMatchingTopic(topicList, rcvdTopic, AQHMQTT_TopicDir_In);
|
||||||
if (topic)
|
if (topic)
|
||||||
AQHMQTT_Topic_SetTopic(topic, rcvdTopic);
|
AQHMQTT_Topic_SetTopic(topic, rcvdTopic);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (topic) {
|
if (topic) {
|
||||||
DBG_INFO(AQH_LOGDOMAIN,
|
DBG_INFO(AQH_LOGDOMAIN,
|
||||||
"Handling topic \"%s\" for device type %s (id: %s)",
|
"Handling topic \"%s\" for device type %s (id: %s)",
|
||||||
rcvdTopic,
|
rcvdTopic,
|
||||||
sDeviceName, sDeviceId?sDeviceId:"<no id>");
|
sDeviceName, sDeviceId?sDeviceId:"<no id>");
|
||||||
if (AQHMQTT_Topic_GetTopicType(topic)==AQHMQTT_TopicType_Json)
|
if (AQHMQTT_Topic_GetTopicType(topic)==AQHMQTT_TopicType_Json)
|
||||||
_handleJsonTopic(xo, device, topic, rcvdValue);
|
_handleJsonTopic(xo, device, topic, rcvdValue);
|
||||||
else
|
else
|
||||||
_handleNumTopic(xo, device, topic, rcvdValue);
|
_handleNumTopic(xo, device, topic, rcvdValue);
|
||||||
return 1;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -282,7 +277,7 @@ void _sendAnnounceValueMessage(AQH_MQTTLOG_SERVER *xo, const AQHMQTT_DEVICE *dev
|
|||||||
AQH_Endpoint_GetNextMessageId(xo->brokerEndpoint), 0,
|
AQH_Endpoint_GetNextMessageId(xo->brokerEndpoint), 0,
|
||||||
0, msgValue);
|
0, msgValue);
|
||||||
if (pubMsg) {
|
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_Endpoint_AddMsgOut(xo->brokerEndpoint, pubMsg);
|
||||||
}
|
}
|
||||||
AQH_Value_free(msgValue);
|
AQH_Value_free(msgValue);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#define AQHOMEMQTT_S_PUBLISH_H
|
#define AQHOMEMQTT_S_PUBLISH_H
|
||||||
|
|
||||||
|
|
||||||
#include "./aqhome_mqtt.h"
|
#include "./server.h"
|
||||||
|
|
||||||
#include <aqhome/events2/object.h>
|
#include <aqhome/events2/object.h>
|
||||||
#include <aqhome/ipc2/message.h>
|
#include <aqhome/ipc2/message.h>
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
#include <gwenhywfar/debug.h>
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
|
||||||
#define DEBUG_DRY_RUN 1 /* don't actually set value if "1" */
|
#define DEBUG_DRY_RUN 0 /* don't actually set value if "1" */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -31,8 +31,7 @@
|
|||||||
|
|
||||||
static void _sendDataForDevice(AQH_MQTTLOG_SERVER *xo, const AQHMQTT_DEVICE *device,
|
static void _sendDataForDevice(AQH_MQTTLOG_SERVER *xo, const AQHMQTT_DEVICE *device,
|
||||||
const char *valueName, const char *valueData);
|
const char *valueName, const char *valueData);
|
||||||
static void _sendValueToMqtt(AQH_MQTTLOG_SERVER *xo, const char *deviceId,
|
static void _sendValueToMqtt(AQH_MQTTLOG_SERVER *xo, const char *deviceId, const AQHMQTT_TOPIC *topic, const char *valueData);
|
||||||
const AQHMQTT_TOPIC *topic, const char *valueData);
|
|
||||||
static GWEN_BUFFER *_createBufferForTopic(const char *deviceId, const AQHMQTT_TOPIC *topic);
|
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;
|
GWEN_BUFFER *buf;
|
||||||
#if !DEBUG_DRY_RUN
|
#if !DEBUG_DRY_RUN
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#define AQHOMEMQTT_S_SETDATA_H
|
#define AQHOMEMQTT_S_SETDATA_H
|
||||||
|
|
||||||
|
|
||||||
#include "./aqhome_mqtt.h"
|
#include "./server.h"
|
||||||
|
|
||||||
#include <aqhome/events2/object.h>
|
#include <aqhome/events2/object.h>
|
||||||
#include <aqhome/ipc2/message.h>
|
#include <aqhome/ipc2/message.h>
|
||||||
|
|||||||
@@ -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 _handleBrokerDown(AQH_MQTTLOG_SERVER *xo);
|
||||||
static int _handleMqttDown(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 _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 _createPidFile(const char *pidFilename);
|
||||||
static int _diffInSeconds(time_t t1, time_t t0);
|
static int _diffInSeconds(time_t t1, time_t t0);
|
||||||
@@ -156,8 +156,15 @@ void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p)
|
|||||||
|
|
||||||
AQH_Object_free(xo->mqttEndpoint);
|
AQH_Object_free(xo->mqttEndpoint);
|
||||||
AQH_Object_free(xo->brokerEndpoint);
|
AQH_Object_free(xo->brokerEndpoint);
|
||||||
|
AQHMQTT_Device_List_free(xo->availableDeviceList);
|
||||||
|
AQHMQTT_Device_List_free(xo->registeredDeviceList);
|
||||||
|
GWEN_DB_Group_free(xo->dbArgs);
|
||||||
|
free(xo->deviceFile);
|
||||||
|
free(xo->pidFile);
|
||||||
|
free(xo->mqttAddress);
|
||||||
|
free(xo->mqttClientId);
|
||||||
|
free(xo->brokerAddress);
|
||||||
|
free(xo->brokerClientId);
|
||||||
|
|
||||||
GWEN_FREE_OBJECT(xo);
|
GWEN_FREE_OBJECT(xo);
|
||||||
}
|
}
|
||||||
@@ -474,7 +481,7 @@ int _startBroker(AQH_OBJECT *o, AQH_MQTTLOG_SERVER *xo)
|
|||||||
DBG_ERROR(NULL, "Error connecting to broker: %d", rv);
|
DBG_ERROR(NULL, "Error connecting to broker: %d", rv);
|
||||||
return (rv<0)?rv:GWEN_ERROR_PERMISSIONS;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -658,7 +665,7 @@ void AQH_MqttLogServer_HandleBrokerMsgs(AQH_OBJECT *o)
|
|||||||
|
|
||||||
while( (msg=AQH_Endpoint_GetNextMsgIn(xo->brokerEndpoint)) ) {
|
while( (msg=AQH_Endpoint_GetNextMsgIn(xo->brokerEndpoint)) ) {
|
||||||
AQH_Message_SetObject(msg, xo->brokerEndpoint);
|
AQH_Message_SetObject(msg, xo->brokerEndpoint);
|
||||||
_handleMsgFromBroker(o, xo->brokerEndpoint, msg);
|
_handleMsgFromBroker(o, msg);
|
||||||
AQH_Message_free(msg);
|
AQH_Message_free(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -666,7 +673,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;
|
GWEN_TAG16_LIST *tagList;
|
||||||
|
|
||||||
@@ -762,14 +769,14 @@ void _handleMsgFromMqtt(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg)
|
|||||||
code=AQH_MqttMessage_GetTypeAndFlags(msg);
|
code=AQH_MqttMessage_GetTypeAndFlags(msg);
|
||||||
switch(code & 0xf0) {
|
switch(code & 0xf0) {
|
||||||
case (AQH_MQTTMSG_MSGTYPE_PUBLISH & 0xf0): AQH_MqttLogServer_HandlePublishMsg(o, ep, msg); break;
|
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;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void _handleMqttMsgPingRsp(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg)
|
void _handleMqttMsgPingRsp(void)
|
||||||
{
|
{
|
||||||
DBG_INFO(NULL, "PING response received");
|
DBG_INFO(NULL, "PING response received");
|
||||||
}
|
}
|
||||||
@@ -962,8 +969,9 @@ void AQH_MqttLogServer_LoadRuntimeDeviceFiles(AQH_OBJECT *o)
|
|||||||
|
|
||||||
DBG_INFO(NULL, "Loading registered devices from file \"%s\"", xo->deviceFile);
|
DBG_INFO(NULL, "Loading registered devices from file \"%s\"", xo->deviceFile);
|
||||||
deviceList=AQH_MqttLogServer_ReadDeviceFile(o, xo->deviceFile);
|
deviceList=AQH_MqttLogServer_ReadDeviceFile(o, xo->deviceFile);
|
||||||
if (deviceList)
|
if (deviceList==NULL)
|
||||||
AQH_MqttLogServer_SetRegisteredDeviceList(o, deviceList);
|
deviceList=AQHMQTT_Device_List_new();
|
||||||
|
AQH_MqttLogServer_SetRegisteredDeviceList(o, deviceList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -999,7 +1007,7 @@ int AQH_MqttLogServer_SaveRuntimeDeviceFiles(AQH_OBJECT *o)
|
|||||||
* xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
* 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;
|
AQH_MQTTLOG_SERVER *xo;
|
||||||
|
|
||||||
@@ -1100,11 +1108,11 @@ int _readArgs(int argc, char **argv, GWEN_DB_NODE *dbArgs)
|
|||||||
{ A_ARG, A_CHAR, "loglevel", 0, 1, "L", "loglevel", I18S("Specify loglevel"), NULL},
|
{ A_ARG, A_CHAR, "loglevel", 0, 1, "L", "loglevel", I18S("Specify loglevel"), NULL},
|
||||||
{ A_ARG, A_CHAR, "cfgdir", 0, 1, "D", "cfgdir", I18S("Specify the configuration folder"), NULL},
|
{ A_ARG, A_CHAR, "cfgdir", 0, 1, "D", "cfgdir", I18S("Specify the configuration folder"), NULL},
|
||||||
{ A_ARG, A_CHAR, "charset", 0, 1, NULL, "charset", I18S("Specify the output character set"), NULL},
|
{ A_ARG, A_CHAR, "charset", 0, 1, NULL, "charset", I18S("Specify the output character set"), NULL},
|
||||||
{ A_ARG, A_CHAR, "mqttAddress", 0, 1, "t", "mqttaddress", I18S("Address of MQTT server"), NULL},
|
{ A_ARG, A_CHAR, "mqttAddress", 0, 1, "ma", "mqttaddress", I18S("Address of MQTT server"), NULL},
|
||||||
{ A_ARG, A_INT, "mqttPort", 0, 1, "P", "mqttport", I18S("Port of MQTT server (default: 1883)"), NULL},
|
{ A_ARG, A_INT, "mqttPort", 0, 1, "mp", "mqttport", I18S("Port of MQTT server (default: 1883)"), NULL},
|
||||||
{ A_ARG, A_CHAR, "mqttClientId", 0, 1, NULL, "mqttclientid", I18S("MQTT client id"), NULL},
|
{ A_ARG, A_CHAR, "mqttClientId", 0, 1, NULL, "mqttclientid", I18S("MQTT client id"), NULL},
|
||||||
{ A_ARG, A_INT, "mqttKeepAlive", 0, 1, "P", "mqttkeepalive", I18S("MQTT keep-alive time"), NULL},
|
{ A_ARG, A_INT, "mqttKeepAlive", 0, 1, "P", "mqttkeepalive", I18S("MQTT keep-alive time"), NULL},
|
||||||
{ A_ARG, A_CHAR, "brokerAddress", 0, 1, "ba", "brokerddress", I18S("Broker address [127.0.0.1]"), NULL},
|
{ A_ARG, A_CHAR, "brokerAddress", 0, 1, "ba", "brokeraddress", I18S("Broker address [127.0.0.1]"), NULL},
|
||||||
{ A_ARG, A_INT, "brokerPort", 0, 1, "bp", "brokerport", I18S("Broker port [1899]"), NULL},
|
{ A_ARG, A_INT, "brokerPort", 0, 1, "bp", "brokerport", I18S("Broker port [1899]"), NULL},
|
||||||
{ A_ARG, A_CHAR, "brokerClientId", 0, 1, NULL, "brokerclientid", I18S("Broker client id"), NULL},
|
{ A_ARG, A_CHAR, "brokerClientId", 0, 1, NULL, "brokerclientid", I18S("Broker client id"), NULL},
|
||||||
{ A_ARG, A_CHAR, "deviceFile", 0, 1, "d", "devicefile", I18S("Device file"), NULL},
|
{ A_ARG, A_CHAR, "deviceFile", 0, 1, "d", "devicefile", I18S("Device file"), NULL},
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ AQHMQTT_DEVICE_LIST *AQH_MqttLogServer_ReadDeviceFile(AQH_OBJECT *o, const char
|
|||||||
deviceList=AQHMQTT_Device_List_new();
|
deviceList=AQHMQTT_Device_List_new();
|
||||||
rv=_readDeviceFileToList(sFilename, deviceList);
|
rv=_readDeviceFileToList(sFilename, deviceList);
|
||||||
if (rv<0) {
|
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);
|
AQHMQTT_Device_List_free(deviceList);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#define AQHOME_MQTTLOG_XMLREAD_H
|
#define AQHOME_MQTTLOG_XMLREAD_H
|
||||||
|
|
||||||
#include "aqhome-mqttlog/server.h"
|
#include "aqhome-mqttlog/server.h"
|
||||||
#include "aqhome-mqttlog/aqhome_mqtt.h"
|
|
||||||
#include "aqhome-mqttlog/types/device.h"
|
#include "aqhome-mqttlog/types/device.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "./xmlwrite.h"
|
#include "./xmlwrite.h"
|
||||||
#include "./aqhome_mqtt_p.h"
|
|
||||||
#include "aqhome-mqttlog/types/topic.h"
|
#include "aqhome-mqttlog/types/topic.h"
|
||||||
#include "aqhome-mqttlog/types/value.h"
|
#include "aqhome-mqttlog/types/value.h"
|
||||||
#include "aqhome-mqttlog/types/translation.h"
|
#include "aqhome-mqttlog/types/translation.h"
|
||||||
|
|||||||
@@ -10,7 +10,6 @@
|
|||||||
#define AQHOME_MQTTLOG_XMLWRITE_H
|
#define AQHOME_MQTTLOG_XMLWRITE_H
|
||||||
|
|
||||||
#include "aqhome-mqttlog/server.h"
|
#include "aqhome-mqttlog/server.h"
|
||||||
#include "aqhome-mqttlog/aqhome_mqtt.h"
|
|
||||||
#include "aqhome-mqttlog/types/device.h"
|
#include "aqhome-mqttlog/types/device.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,8 @@
|
|||||||
r_forward.h
|
r_forward.h
|
||||||
r_setaccmsggrps.h
|
r_setaccmsggrps.h
|
||||||
r_getnodes.h
|
r_getnodes.h
|
||||||
|
server.h
|
||||||
|
server_p.h
|
||||||
</headers>
|
</headers>
|
||||||
|
|
||||||
<sources>
|
<sources>
|
||||||
|
|||||||
@@ -117,6 +117,26 @@ void _handleMsgValue(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg)
|
|||||||
if (ni==NULL) {
|
if (ni==NULL) {
|
||||||
DBG_INFO(AQH_LOGDOMAIN, "Error handling message");
|
DBG_INFO(AQH_LOGDOMAIN, "Error handling message");
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
uint8_t valueId;
|
||||||
|
uint16_t val;
|
||||||
|
|
||||||
|
val=AQH_ValueMessage_GetValueNom(msg);
|
||||||
|
valueId=AQH_ValueMessage_GetValueId(msg);
|
||||||
|
|
||||||
|
switch(valueId) {
|
||||||
|
case AQH_ENDPOINT_VID_STATS_PACKETS_IN: AQH_NodeInfo_SetStatsPacketsIn(ni, val); AQH_NodeDb_SetModified(xo->nodeDb); break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_PACKETS_OUT: AQH_NodeInfo_SetStatsPacketsOut(ni, val); AQH_NodeDb_SetModified(xo->nodeDb); break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_ERRS_CONTENT: AQH_NodeInfo_SetStatsCrcErrors(ni, val); AQH_NodeDb_SetModified(xo->nodeDb); break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_ERRS_IO: AQH_NodeInfo_SetStatsIoErrors(ni, val); AQH_NodeDb_SetModified(xo->nodeDb); break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_ERRS_NOBUF: break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_ERRS_COLLISIONS: AQH_NodeInfo_SetStatsCollisions(ni, val); AQH_NodeDb_SetModified(xo->nodeDb); break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_ERRS_BUSY: AQH_NodeInfo_SetStatsBusy(ni, val); AQH_NodeDb_SetModified(xo->nodeDb); break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_HEAP_USED: break;
|
||||||
|
case AQH_ENDPOINT_VID_STATS_HEAP_FREE: break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -145,11 +165,13 @@ void _handleMsgComSendStat(AQH_NODE_SERVER *xo, const AQH_MESSAGE *msg)
|
|||||||
if (ni==NULL) {
|
if (ni==NULL) {
|
||||||
DBG_INFO(AQH_LOGDOMAIN, "Error handling message");
|
DBG_INFO(AQH_LOGDOMAIN, "Error handling message");
|
||||||
}
|
}
|
||||||
AQH_NodeInfo_SetStatsPacketsOut(ni, AQH_SendStatsMessage_GetPacketsOut(msg));
|
else {
|
||||||
AQH_NodeInfo_SetStatsCollisions(ni, AQH_SendStatsMessage_GetCollisions(msg));
|
AQH_NodeInfo_SetStatsPacketsOut(ni, AQH_SendStatsMessage_GetPacketsOut(msg));
|
||||||
AQH_NodeInfo_SetStatsBusy(ni, AQH_SendStatsMessage_GetBusyErrors(msg));
|
AQH_NodeInfo_SetStatsCollisions(ni, AQH_SendStatsMessage_GetCollisions(msg));
|
||||||
AQH_NodeDb_SetModified(xo->nodeDb);
|
AQH_NodeInfo_SetStatsBusy(ni, AQH_SendStatsMessage_GetBusyErrors(msg));
|
||||||
_updateTimestampLastChange(ni);
|
AQH_NodeDb_SetModified(xo->nodeDb);
|
||||||
|
_updateTimestampLastChange(ni);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -258,22 +280,24 @@ void _setDeviceName(AQH_VALUE *value, uint32_t uid)
|
|||||||
|
|
||||||
void _announceValue(AQH_NODE_SERVER *xo, uint32_t uid, const AQHNODE_VALUE *v)
|
void _announceValue(AQH_NODE_SERVER *xo, uint32_t uid, const AQHNODE_VALUE *v)
|
||||||
{
|
{
|
||||||
AQH_VALUE *value;
|
if (xo && xo->brokerEndpoint) {
|
||||||
AQH_MESSAGE *msg;
|
AQH_VALUE *value;
|
||||||
|
AQH_MESSAGE *msg;
|
||||||
|
|
||||||
value=AQH_Value_new();
|
value=AQH_Value_new();
|
||||||
_setDeviceName(value, uid);
|
_setDeviceName(value, uid);
|
||||||
AQH_Value_SetDriver(value, "nodes");
|
AQH_Value_SetDriver(value, "nodes");
|
||||||
AQH_Value_SetName(value, AQHNODE_Value_GetName(v));
|
AQH_Value_SetName(value, AQHNODE_Value_GetName(v));
|
||||||
AQH_Value_SetValueUnits(value, AQHNODE_Value_GetValueUnits(v));
|
AQH_Value_SetValueUnits(value, AQHNODE_Value_GetValueUnits(v));
|
||||||
AQH_Value_SetValueType(value, AQHNODE_Value_GetValueType(v));
|
AQH_Value_SetValueType(value, AQHNODE_Value_GetValueType(v));
|
||||||
AQH_Value_SetModality(value, AQHNODE_Value_GetModality(v));
|
AQH_Value_SetModality(value, AQHNODE_Value_GetModality(v));
|
||||||
|
|
||||||
msg=AQH_IpcdMessageValues_newForOne(AQH_MSGTYPE_IPC_DATA_ANNOUNCEVALUE,
|
msg=AQH_IpcdMessageValues_newForOne(AQH_MSGTYPE_IPC_DATA_ANNOUNCEVALUE,
|
||||||
AQH_Endpoint_GetNextMessageId(xo->brokerEndpoint), 0,
|
AQH_Endpoint_GetNextMessageId(xo->brokerEndpoint), 0,
|
||||||
0, value);
|
0, value);
|
||||||
AQH_Endpoint_AddMsgOut(xo->brokerEndpoint, msg);
|
AQH_Endpoint_AddMsgOut(xo->brokerEndpoint, msg);
|
||||||
AQH_Value_free(value);
|
AQH_Value_free(value);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -115,8 +115,9 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
_runService(aqh, eventLoop);
|
_runService(aqh, eventLoop);
|
||||||
|
|
||||||
//AQH_NodeServer_Fini(aqh);
|
AQH_NodeServer_Fini(aqh);
|
||||||
AQH_Object_free(aqh);
|
AQH_Object_free(aqh);
|
||||||
|
AQH_EventLoop_free(eventLoop);
|
||||||
|
|
||||||
GWEN_Gui_SetGui(NULL);
|
GWEN_Gui_SetGui(NULL);
|
||||||
GWEN_Gui_free(gui);
|
GWEN_Gui_free(gui);
|
||||||
@@ -149,13 +150,13 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop)
|
|||||||
now=time(NULL);
|
now=time(NULL);
|
||||||
|
|
||||||
if (_diffInSeconds(now, timeLastConnectionCleanup)>CONNCLEAN_INTERVAL_IN_SECS) {
|
if (_diffInSeconds(now, timeLastConnectionCleanup)>CONNCLEAN_INTERVAL_IN_SECS) {
|
||||||
DBG_ERROR(NULL, "Cleanup connections");
|
DBG_INFO(NULL, "Cleanup connections");
|
||||||
AQH_NodeServer_CleanupClients(aqh);
|
AQH_NodeServer_CleanupClients(aqh);
|
||||||
timeLastConnectionCleanup=now;
|
timeLastConnectionCleanup=now;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_diffInSeconds(now, timeLastConnCheck)>CONNCHECK_INTERVAL_IN_SECS) {
|
if (_diffInSeconds(now, timeLastConnCheck)>CONNCHECK_INTERVAL_IN_SECS) {
|
||||||
DBG_ERROR(NULL, "Check connections");
|
DBG_INFO(NULL, "Check connections");
|
||||||
AQH_NodeServer_CheckBrokerConnection(aqh);
|
AQH_NodeServer_CheckBrokerConnection(aqh);
|
||||||
AQH_NodeServer_CheckTtyConnection(aqh);
|
AQH_NodeServer_CheckTtyConnection(aqh);
|
||||||
timeLastConnCheck=now;
|
timeLastConnCheck=now;
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "aqhome/msg/ipc/m_ipc_connect.h"
|
#include "aqhome/msg/ipc/m_ipc_connect.h"
|
||||||
#include "aqhome/msg/ipc/m_ipc_result.h"
|
#include "aqhome/msg/ipc/m_ipc_result.h"
|
||||||
#include "aqhome/msg/ipc/m_ipc_tag16.h"
|
#include "aqhome/msg/ipc/m_ipc_tag16.h"
|
||||||
|
#include <aqhome/msg/node/m_node.h>
|
||||||
|
|
||||||
#include <gwenhywfar/debug.h>
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
@@ -54,6 +55,7 @@ void AQH_NodeServer_HandleForward(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSA
|
|||||||
AQH_Message_SetData(nodeMsg, ptr, len);
|
AQH_Message_SetData(nodeMsg, ptr, len);
|
||||||
AQH_Message_SetUsedSize(nodeMsg, len);
|
AQH_Message_SetUsedSize(nodeMsg, len);
|
||||||
AQH_Endpoint_AddMsgOut(xo->ttyEndpoint, nodeMsg);
|
AQH_Endpoint_AddMsgOut(xo->ttyEndpoint, nodeMsg);
|
||||||
|
DBG_ERROR(NULL, "Forwarding node message %d to node", AQH_NodeMessage_GetMsgType(nodeMsg));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG_ERROR(NULL, "TTY endpoint currently not connected");
|
DBG_ERROR(NULL, "TTY endpoint currently not connected");
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ AQH_MSG_REQUEST *_mkSubRequest_SetData(AQH_OBJECT *o, AQH_NODE_SERVER *xo,
|
|||||||
AQH_MsgRequest_SetRequestMsgId(rq, msgId);
|
AQH_MsgRequest_SetRequestMsgId(rq, msgId);
|
||||||
AQH_MsgRequest_SetTimestamps(rq, R_SETDATA_SUBREQUEST_EXPIRE_SECS);
|
AQH_MsgRequest_SetTimestamps(rq, R_SETDATA_SUBREQUEST_EXPIRE_SECS);
|
||||||
|
|
||||||
msgOut=AQH_ValueMessage_new(xo->nodeAddress, destAddr, AQH_MSG_TYPE_VALUE_SET, msgId, valueId, dataVal, dataDenom);
|
msgOut=AQH_ValueMessage_new(destAddr, xo->nodeAddress, AQH_MSG_TYPE_VALUE_SET, msgId, valueId, dataVal, dataDenom);
|
||||||
AQH_Endpoint_AddMsgOut(xo->ttyEndpoint, msgOut);
|
AQH_Endpoint_AddMsgOut(xo->ttyEndpoint, msgOut);
|
||||||
|
|
||||||
return rq;
|
return rq;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
#include <aqhome/ipc2/ipc_server.h>
|
#include <aqhome/ipc2/ipc_server.h>
|
||||||
#include <aqhome/ipc2/tcpd_object.h>
|
#include <aqhome/ipc2/tcpd_object.h>
|
||||||
#include <aqhome/ipc2/tty_endpoint.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/tcp_object.h>
|
||||||
#include <aqhome/ipc2/tcpd_object.h>
|
#include <aqhome/ipc2/tcpd_object.h>
|
||||||
#include <aqhome/ipc2/ipc_client.h>
|
#include <aqhome/ipc2/ipc_client.h>
|
||||||
@@ -178,6 +178,9 @@ void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p)
|
|||||||
AQH_Object_free(xo->ipcEndpoint);
|
AQH_Object_free(xo->ipcEndpoint);
|
||||||
AQH_Object_free(xo->ttyEndpoint);
|
AQH_Object_free(xo->ttyEndpoint);
|
||||||
AQH_Object_free(xo->brokerEndpoint);
|
AQH_Object_free(xo->brokerEndpoint);
|
||||||
|
AQHNODE_Device_List_free(xo->deviceDefList);
|
||||||
|
GWEN_DB_Group_free(xo->dbArgs);
|
||||||
|
AQH_MsgRequest_free(xo->requestTree);
|
||||||
|
|
||||||
AQH_NodeDb_free(xo->nodeDb);
|
AQH_NodeDb_free(xo->nodeDb);
|
||||||
free(xo->dbFile);
|
free(xo->dbFile);
|
||||||
@@ -445,6 +448,7 @@ void _readConfig(AQH_OBJECT *o, AQH_NODE_SERVER *xo, GWEN_DB_NODE *dbArgs)
|
|||||||
xo->dbArgs=dbArgs;
|
xo->dbArgs=dbArgs;
|
||||||
|
|
||||||
xo->timeout=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 0);
|
xo->timeout=GWEN_DB_GetIntValue(dbArgs, "timeout", 0, 0);
|
||||||
|
xo->noAttn=GWEN_DB_GetIntValue(dbArgs, "noAttn", 0, 0);
|
||||||
xo->nodeAddress=GWEN_DB_GetIntValue(dbArgs, "nodeAddress", 0, AQHOMED_DEFAULT_NODEADDR);
|
xo->nodeAddress=GWEN_DB_GetIntValue(dbArgs, "nodeAddress", 0, AQHOMED_DEFAULT_NODEADDR);
|
||||||
|
|
||||||
AQH_NodeServer_SetDbFile(o, GWEN_DB_GetCharValue(dbArgs, "dbfile", 0, NULL));
|
AQH_NodeServer_SetDbFile(o, GWEN_DB_GetCharValue(dbArgs, "dbfile", 0, NULL));
|
||||||
@@ -534,7 +538,7 @@ int _startTty(AQH_OBJECT *o, AQH_NODE_SERVER *xo)
|
|||||||
DBG_INFO(NULL, "here");
|
DBG_INFO(NULL, "here");
|
||||||
return GWEN_ERROR_IO;
|
return GWEN_ERROR_IO;
|
||||||
}
|
}
|
||||||
xo->ttyEndpoint=AQH_TtyEndpoint2_new(AQH_Object_GetEventLoop(o), fd);
|
xo->ttyEndpoint=AQH_TtyEndpoint2_new(AQH_Object_GetEventLoop(o), fd, xo->noAttn);
|
||||||
AQH_Object_AddLink(xo->ttyEndpoint, AQH_ENDPOINT_SIGNAL_CLOSED, AQH_NODE_SERVER_SLOT_TTYCLOSED, o);
|
AQH_Object_AddLink(xo->ttyEndpoint, AQH_ENDPOINT_SIGNAL_CLOSED, AQH_NODE_SERVER_SLOT_TTYCLOSED, o);
|
||||||
AQH_Object_Enable(xo->ttyEndpoint);
|
AQH_Object_Enable(xo->ttyEndpoint);
|
||||||
}
|
}
|
||||||
@@ -580,7 +584,7 @@ int _startBroker(AQH_OBJECT *o, AQH_NODE_SERVER *xo)
|
|||||||
DBG_ERROR(NULL, "Error connecting to broker: %d", rv);
|
DBG_ERROR(NULL, "Error connecting to broker: %d", rv);
|
||||||
return (rv<0)?rv:GWEN_ERROR_PERMISSIONS;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -793,6 +797,7 @@ void AQH_NodeServer_HandleTtyMsgs(AQH_OBJECT *o)
|
|||||||
AQH_MESSAGE *msg;
|
AQH_MESSAGE *msg;
|
||||||
|
|
||||||
while( (msg=AQH_Endpoint_GetNextMsgIn(xo->ttyEndpoint)) ) {
|
while( (msg=AQH_Endpoint_GetNextMsgIn(xo->ttyEndpoint)) ) {
|
||||||
|
_writeTtyMsgToLogFile(xo, msg);
|
||||||
AQH_Message_SetObject(msg, xo->ttyEndpoint);
|
AQH_Message_SetObject(msg, xo->ttyEndpoint);
|
||||||
if (AQH_Request_Tree2_HandleTtyMsg(xo->requestTree, xo->ttyEndpoint, msg)!=AQH_MSG_REQUEST_RESULT_HANDLED)
|
if (AQH_Request_Tree2_HandleTtyMsg(xo->requestTree, xo->ttyEndpoint, msg)!=AQH_MSG_REQUEST_RESULT_HANDLED)
|
||||||
_handleMsgFromTty(o, xo, msg);
|
_handleMsgFromTty(o, xo, msg);
|
||||||
@@ -808,9 +813,8 @@ void _handleMsgFromTty(AQH_OBJECT *o, AQH_NODE_SERVER *xo, const AQH_MESSAGE *ms
|
|||||||
uint8_t code;
|
uint8_t code;
|
||||||
|
|
||||||
code=AQH_NodeMessage_GetMsgType(msg);
|
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);
|
AQH_NodeServer_NodeMsgToDb(o, msg);
|
||||||
_writeTtyMsgToLogFile(xo, msg);
|
|
||||||
_forwardTtyMsgToBroker(o, xo, msg);
|
_forwardTtyMsgToBroker(o, xo, msg);
|
||||||
_forwardTtyMsgToClients(xo, msg);
|
_forwardTtyMsgToClients(xo, msg);
|
||||||
}
|
}
|
||||||
@@ -979,12 +983,12 @@ void _publishDouble(AQH_NODE_SERVER *xo, uint32_t uid, const char *vPath, int vM
|
|||||||
AQH_Endpoint_GetNextMessageId(xo->brokerEndpoint), 0,
|
AQH_Endpoint_GetNextMessageId(xo->brokerEndpoint), 0,
|
||||||
value, arrayToSend, 1);
|
value, arrayToSend, 1);
|
||||||
if (pubMsg) {
|
if (pubMsg) {
|
||||||
DBG_ERROR(AQH_LOGDOMAIN,
|
DBG_INFO(AQH_LOGDOMAIN,
|
||||||
"BROKER PUBLISH %s(%s/%s): %f",
|
"BROKER PUBLISH %s(%s/%s): %f",
|
||||||
AQH_Value_GetName(value),
|
AQH_Value_GetName(value),
|
||||||
AQH_Value_GetDeviceName(value),
|
AQH_Value_GetDeviceName(value),
|
||||||
AQH_Value_GetName(value),
|
AQH_Value_GetName(value),
|
||||||
v);
|
v);
|
||||||
AQH_Endpoint_AddMsgOut(xo->brokerEndpoint, pubMsg);
|
AQH_Endpoint_AddMsgOut(xo->brokerEndpoint, pubMsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1117,7 +1121,7 @@ void _handleMsgFromBroker(AQH_OBJECT *o, AQH_OBJECT *ep, const AQH_MESSAGE *msg)
|
|||||||
code=AQH_IpcMessage_GetCode(msg);
|
code=AQH_IpcMessage_GetCode(msg);
|
||||||
protoId=AQH_IpcMessage_GetProtoId(msg);
|
protoId=AQH_IpcMessage_GetProtoId(msg);
|
||||||
if (protoId==AQH_IPC_PROTOCOL_DATA_ID) {
|
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) {
|
switch(code) {
|
||||||
case AQH_MSGTYPE_IPC_DATA_SETDATA: AQH_NodeServer_HandleSetData(o, ep, msg); break;
|
case AQH_MSGTYPE_IPC_DATA_SETDATA: AQH_NodeServer_HandleSetData(o, ep, msg); break;
|
||||||
default: break;
|
default: break;
|
||||||
@@ -1410,6 +1414,7 @@ int _readArgs(int argc, char **argv, GWEN_DB_NODE *dbArgs)
|
|||||||
{ A_ARG, A_CHAR, "dbfile", 0, 1, "db", "dbfile", I18S("DB file to read/write node database"), NULL},
|
{ A_ARG, A_CHAR, "dbfile", 0, 1, "db", "dbfile", I18S("DB file to read/write node database"), NULL},
|
||||||
{ A_ARG, A_CHAR, "pidfile", 0, 1, "p", "pidfile", I18S("PID file"), NULL},
|
{ A_ARG, A_CHAR, "pidfile", 0, 1, "p", "pidfile", I18S("PID file"), NULL},
|
||||||
{ A_ARG, A_INT, "timeout", 0, 1, "T", NULL, I18S("timeout in seconds [0]"), NULL},
|
{ A_ARG, A_INT, "timeout", 0, 1, "T", NULL, I18S("timeout in seconds [0]"), NULL},
|
||||||
|
{ 0, A_INT, "noAttn", 0, 1, "N", "noattn", I18S("Don't use ATTN line (for T03 or newer)"), NULL},
|
||||||
{ A_END, A_INT, "help", 0, 0, "h", "help", I18S("Show this help screen"), NULL}
|
{ A_END, A_INT, "help", 0, 0, "h", "help", I18S("Show this help screen"), NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,18 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_PACKETS_IN 0xe0
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_PACKETS_OUT 0xe1
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_ERRS_CONTENT 0xe2
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_ERRS_IO 0xe3
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_ERRS_NOBUF 0xe4
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_ERRS_COLLISIONS 0xe5
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_ERRS_BUSY 0xe6
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_HEAP_USED 0xe7
|
||||||
|
#define AQH_ENDPOINT_VID_STATS_HEAP_FREE 0xe8
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AQH_OBJECT *AQH_NodeServer_new(AQH_EVENT_LOOP *eventLoop);
|
AQH_OBJECT *AQH_NodeServer_new(AQH_EVENT_LOOP *eventLoop);
|
||||||
int AQH_NodeServer_Init(AQH_OBJECT *o, int argc, char **argv);
|
int AQH_NodeServer_Init(AQH_OBJECT *o, int argc, char **argv);
|
||||||
void AQH_NodeServer_Fini(AQH_OBJECT *o);
|
void AQH_NodeServer_Fini(AQH_OBJECT *o);
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ struct AQH_NODE_SERVER {
|
|||||||
uint8_t protoId;
|
uint8_t protoId;
|
||||||
uint8_t protoVer;
|
uint8_t protoVer;
|
||||||
|
|
||||||
|
int noAttn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -103,6 +103,7 @@
|
|||||||
|
|
||||||
<headers dist="true" >
|
<headers dist="true" >
|
||||||
server.h
|
server.h
|
||||||
|
server_p.h
|
||||||
net_read.h
|
net_read.h
|
||||||
suntimes.h
|
suntimes.h
|
||||||
</headers>
|
</headers>
|
||||||
|
|||||||
@@ -14,13 +14,13 @@
|
|||||||
#include "./net_read.h"
|
#include "./net_read.h"
|
||||||
#include "aqhome-react/units/u_timer.h"
|
#include "aqhome-react/units/u_timer.h"
|
||||||
#include "aqhome-react/types/prgrule.h"
|
#include "aqhome-react/types/prgrule.h"
|
||||||
//#include "aqhome-react/types/prgrule-t.h"
|
#include "aqhome-react/types/prgrule-t.h"
|
||||||
|
|
||||||
#include "aqhome/aqhome.h"
|
#include "aqhome/aqhome.h"
|
||||||
#include "aqhome/data/path-t.h"
|
#include "aqhome/data/path-t.h"
|
||||||
#include "aqhome/data/vars-t.h"
|
#include "aqhome/data/vars-t.h"
|
||||||
//#include "aqhome/data/vars_dbread-t.h"
|
#include "aqhome/data/vars_dbread-t.h"
|
||||||
//#include "aqhome/data/vars_dbwrite-t.h"
|
#include "aqhome/data/vars_dbwrite-t.h"
|
||||||
|
|
||||||
#include <gwenhywfar/gwenhywfar.h>
|
#include <gwenhywfar/gwenhywfar.h>
|
||||||
#include <gwenhywfar/args.h>
|
#include <gwenhywfar/args.h>
|
||||||
@@ -69,7 +69,8 @@
|
|||||||
|
|
||||||
static void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop);
|
static void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop);
|
||||||
static int _diffInSeconds(time_t t1, time_t t0);
|
static int _diffInSeconds(time_t t1, time_t t0);
|
||||||
//static int _testModules(int argc, char **argv);
|
static int _testModules(int argc, char **argv);
|
||||||
|
static int _test(int argc, char **argv);
|
||||||
|
|
||||||
#ifdef HAVE_SIGNAL_H
|
#ifdef HAVE_SIGNAL_H
|
||||||
static int _setSignalHandlers(void);
|
static int _setSignalHandlers(void);
|
||||||
@@ -126,6 +127,26 @@ int main(int argc, char **argv)
|
|||||||
gui=GWEN_Gui_CGui_new();
|
gui=GWEN_Gui_CGui_new();
|
||||||
GWEN_Gui_SetGui(gui);
|
GWEN_Gui_SetGui(gui);
|
||||||
|
|
||||||
|
if (argc>1) {
|
||||||
|
const char *cmd;
|
||||||
|
|
||||||
|
cmd=argv[1];
|
||||||
|
if (cmd && *cmd) {
|
||||||
|
if (strcasecmp(cmd, "unittest")==0) {
|
||||||
|
rv=_testModules(argc, argv);
|
||||||
|
GWEN_Gui_SetGui(NULL);
|
||||||
|
GWEN_Gui_free(gui);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
else if (strcasecmp(cmd, "test")==0) {
|
||||||
|
rv=_test(argc, argv);
|
||||||
|
GWEN_Gui_SetGui(NULL);
|
||||||
|
GWEN_Gui_free(gui);
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
eventLoop=AQH_EventLoop_new();
|
eventLoop=AQH_EventLoop_new();
|
||||||
aqh=AQH_ReactServer_new(eventLoop);
|
aqh=AQH_ReactServer_new(eventLoop);
|
||||||
rv=AQH_ReactServer_Init(aqh, argc, argv);
|
rv=AQH_ReactServer_Init(aqh, argc, argv);
|
||||||
@@ -140,6 +161,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
AQH_ReactServer_Fini(aqh);
|
AQH_ReactServer_Fini(aqh);
|
||||||
AQH_Object_free(aqh);
|
AQH_Object_free(aqh);
|
||||||
|
AQH_EventLoop_free(eventLoop);
|
||||||
|
|
||||||
GWEN_Gui_SetGui(NULL);
|
GWEN_Gui_SetGui(NULL);
|
||||||
GWEN_Gui_free(gui);
|
GWEN_Gui_free(gui);
|
||||||
@@ -198,7 +220,7 @@ void _runService(AQH_OBJECT *aqh, AQH_EVENT_LOOP *eventLoop)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (_diffInSeconds(now, lastSaveTime)>AQHOME_REACT_SAVE_INTERVAL) {
|
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);
|
rv=AQH_ReactServer_WriteVarsFile(aqh);
|
||||||
if (rv<0) {
|
if (rv<0) {
|
||||||
DBG_INFO(NULL, "Error writing runtime data");
|
DBG_INFO(NULL, "Error writing runtime data");
|
||||||
@@ -287,7 +309,7 @@ void _signalHandler(int s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
int _testModules(int argc, char **argv)
|
int _testModules(int argc, char **argv)
|
||||||
{
|
{
|
||||||
GWEN_GUI *gui;
|
GWEN_GUI *gui;
|
||||||
@@ -344,7 +366,29 @@ int _testModules(int argc, char **argv)
|
|||||||
GWEN_Gui_free(gui);
|
GWEN_Gui_free(gui);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
int _test(int argc, char **argv)
|
||||||
|
{
|
||||||
|
if (argc>2) {
|
||||||
|
AQHREACT_PRGRULE_LIST *ruleList;
|
||||||
|
|
||||||
|
GWEN_Logger_SetLevel(0, GWEN_LoggerLevel_Info);
|
||||||
|
ruleList=AQHREACT_PrgRule_ReadRules(argv[2]);
|
||||||
|
if (ruleList==NULL) {
|
||||||
|
DBG_ERROR(NULL, "Error in rules");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
DBG_ERROR(NULL, "Rules ok (%d)", AQHREACT_PrgRule_List_GetCount(ruleList));
|
||||||
|
AQHREACT_PrgRule_List_free(ruleList);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
DBG_ERROR(NULL, "No rules");
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "./net_read.h"
|
#include "./net_read.h"
|
||||||
#include "./server_p.h"
|
#include "./server_p.h"
|
||||||
#include "aqhome-react/aqhome_react_p.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
#include "aqhome-react/units/u_module.h"
|
#include "aqhome-react/units/u_module.h"
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
#define AQHOMEREACT_NET_READ_H
|
#define AQHOMEREACT_NET_READ_H
|
||||||
|
|
||||||
|
|
||||||
#include "./aqhome_react.h"
|
#include "./server.h"
|
||||||
|
|
||||||
|
|
||||||
int AQH_ReactServer_ReadUnitNetFiles(AQH_OBJECT *aqh);
|
int AQH_ReactServer_ReadUnitNetFiles(AQH_OBJECT *aqh);
|
||||||
|
|||||||
@@ -150,7 +150,13 @@ void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p)
|
|||||||
xo=(AQH_REACT_SERVER*) p;
|
xo=(AQH_REACT_SERVER*) p;
|
||||||
|
|
||||||
AQH_Object_free(xo->brokerEndpoint);
|
AQH_Object_free(xo->brokerEndpoint);
|
||||||
|
GWEN_DB_Group_free(xo->dbArgs);
|
||||||
|
free(xo->pidFile);
|
||||||
|
free(xo->varsFile);
|
||||||
|
free(xo->brokerAddress);
|
||||||
|
free(xo->brokerClientId);
|
||||||
|
AQHREACT_Unit_List_free(xo->unitList);
|
||||||
|
AQH_Vars_free(xo->localVars);
|
||||||
|
|
||||||
GWEN_FREE_OBJECT(xo);
|
GWEN_FREE_OBJECT(xo);
|
||||||
}
|
}
|
||||||
@@ -496,7 +502,7 @@ int _startBroker(AQH_OBJECT *o, AQH_REACT_SERVER *xo)
|
|||||||
DBG_ERROR(NULL, "Error connecting to broker: %d", rv);
|
DBG_ERROR(NULL, "Error connecting to broker: %d", rv);
|
||||||
return (rv<0)?rv:GWEN_ERROR_PERMISSIONS;
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* This file is part of the project AqHome.
|
* This file is part of the project AqHome.
|
||||||
* AqHome (c) by 2023 Martin Preuss, all rights reserved.
|
* AqHome (c) by 2025 Martin Preuss, all rights reserved.
|
||||||
*
|
*
|
||||||
* The license for this file can be found in the file COPYING which you
|
* The license for this file can be found in the file COPYING which you
|
||||||
* should have received along with this file.
|
* should have received along with this file.
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include <gwenhywfar/list.h>
|
#include <gwenhywfar/list.h>
|
||||||
|
#include <gwenhywfar/buffer.h>
|
||||||
|
|
||||||
|
|
||||||
typedef struct AQHREACT_DATAOBJECT AQHREACT_DATAOBJECT;
|
typedef struct AQHREACT_DATAOBJECT AQHREACT_DATAOBJECT;
|
||||||
@@ -25,7 +26,7 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/aqhome_react.h"
|
#include "aqhome-react/server.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* This file is part of the project AqHome.
|
* This file is part of the project AqHome.
|
||||||
* AqHome (c) by 2024 Martin Preuss, all rights reserved.
|
* AqHome (c) by 2025 Martin Preuss, all rights reserved.
|
||||||
*
|
*
|
||||||
* The license for this file can be found in the file COPYING which you
|
* The license for this file can be found in the file COPYING which you
|
||||||
* should have received along with this file.
|
* should have received along with this file.
|
||||||
@@ -20,6 +20,9 @@ GWEN_LIST_FUNCTION_DEFS(AQHREACT_LINK, AQHREACT_Link)
|
|||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
#include "aqhome-react/types/port.h"
|
#include "aqhome-react/types/port.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/buffer.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AQHREACT_LINK *AQHREACT_Link_new();
|
AQHREACT_LINK *AQHREACT_Link_new();
|
||||||
void AQHREACT_Link_free(AQHREACT_LINK *lnk);
|
void AQHREACT_Link_free(AQHREACT_LINK *lnk);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
typedef struct AQHREACT_PARAM AQHREACT_PARAM;
|
typedef struct AQHREACT_PARAM AQHREACT_PARAM;
|
||||||
GWEN_LIST_FUNCTION_DEFS(AQHREACT_PARAM, AQHREACT_Param)
|
GWEN_LIST_FUNCTION_DEFS(AQHREACT_PARAM, AQHREACT_Param)
|
||||||
|
|
||||||
#include "aqhome-react/aqhome_react.h"
|
#include "aqhome-react/server.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,10 +16,11 @@ typedef struct AQHREACT_PORT AQHREACT_PORT;
|
|||||||
GWEN_LIST_FUNCTION_DEFS(AQHREACT_PORT, AQHREACT_Port)
|
GWEN_LIST_FUNCTION_DEFS(AQHREACT_PORT, AQHREACT_Port)
|
||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/link.h"
|
#include "aqhome-react/types/link.h"
|
||||||
#include "aqhome-react/types/dataobject.h"
|
#include "aqhome-react/types/dataobject.h"
|
||||||
|
|
||||||
|
#include <gwenhywfar/buffer.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AQHREACT_PORT *AQHREACT_Port_new();
|
AQHREACT_PORT *AQHREACT_Port_new();
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ const char *_readDouble(const char *s, double *ptrDouble)
|
|||||||
while(*s && isspace(*s))
|
while(*s && isspace(*s))
|
||||||
s++;
|
s++;
|
||||||
sStart=s;
|
sStart=s;
|
||||||
while(*s && (isdigit(*s) || *s=='.'))
|
while(*s && (isdigit(*s) || *s=='.' || *s=='+' || *s=='-'))
|
||||||
s++;
|
s++;
|
||||||
|
|
||||||
rv=GWEN_Text_StringToDouble(sStart, ptrDouble);
|
rv=GWEN_Text_StringToDouble(sStart, ptrDouble);
|
||||||
@@ -419,7 +419,7 @@ void _setBitField(uint64_t *ptrBitField, int startValue, int endValue)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
//#include "prgrule-t.c"
|
#include "prgrule-t.c"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* This file is part of the project AqHome.
|
* This file is part of the project AqHome.
|
||||||
* AqHome (c) by 2024 Martin Preuss, all rights reserved.
|
* AqHome (c) by 2025 Martin Preuss, all rights reserved.
|
||||||
*
|
*
|
||||||
* The license for this file can be found in the file COPYING which you
|
* The license for this file can be found in the file COPYING which you
|
||||||
* should have received along with this file.
|
* should have received along with this file.
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
#define AQHOME_REACT_PRGRULE_H
|
#define AQHOME_REACT_PRGRULE_H
|
||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/aqhome_react.h"
|
#include "aqhome-react/server.h"
|
||||||
|
|
||||||
#include <gwenhywfar/gwentime.h>
|
#include <gwenhywfar/gwentime.h>
|
||||||
#include <gwenhywfar/list.h>
|
#include <gwenhywfar/list.h>
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ void AQHREACT_Unit_free(AQHREACT_UNIT *unit)
|
|||||||
GWEN_INHERIT_FINI(AQHREACT_UNIT, unit);
|
GWEN_INHERIT_FINI(AQHREACT_UNIT, unit);
|
||||||
free(unit->typeName);
|
free(unit->typeName);
|
||||||
free(unit->description);
|
free(unit->description);
|
||||||
|
free(unit->id);
|
||||||
AQHREACT_Port_List_free(unit->outputPortList);
|
AQHREACT_Port_List_free(unit->outputPortList);
|
||||||
AQHREACT_Port_List_free(unit->inputPortList);
|
AQHREACT_Port_List_free(unit->inputPortList);
|
||||||
AQHREACT_Param_List_free(unit->paramList);
|
AQHREACT_Param_List_free(unit->paramList);
|
||||||
@@ -490,7 +491,7 @@ void AQHREACT_Unit_OutputData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, const AQ
|
|||||||
|
|
||||||
void AQHREACT_Unit_OutputDoubleData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, double data)
|
void AQHREACT_Unit_OutputDoubleData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, double data)
|
||||||
{
|
{
|
||||||
if (unit && unit->outputPortList) {
|
if (unit && port && unit->outputPortList) {
|
||||||
AQHREACT_DATAOBJECT *dataObject;
|
AQHREACT_DATAOBJECT *dataObject;
|
||||||
|
|
||||||
dataObject=AQHREACT_DataObject_new();
|
dataObject=AQHREACT_DataObject_new();
|
||||||
@@ -505,7 +506,7 @@ void AQHREACT_Unit_OutputDoubleData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, do
|
|||||||
|
|
||||||
void AQHREACT_Unit_OutputStringData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, const char *data)
|
void AQHREACT_Unit_OutputStringData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, const char *data)
|
||||||
{
|
{
|
||||||
if (unit && unit->outputPortList) {
|
if (unit && port && unit->outputPortList) {
|
||||||
AQHREACT_DATAOBJECT *dataObject;
|
AQHREACT_DATAOBJECT *dataObject;
|
||||||
|
|
||||||
dataObject=AQHREACT_DataObject_new();
|
dataObject=AQHREACT_DataObject_new();
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ GWEN_INHERIT_FUNCTION_DEFS(AQHREACT_UNIT)
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/port.h"
|
#include "aqhome-react/types/port.h"
|
||||||
#include "aqhome-react/types/param.h"
|
#include "aqhome-react/types/param.h"
|
||||||
#include "aqhome-react/types/dataobject.h"
|
#include "aqhome-react/types/dataobject.h"
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
#include <gwenhywfar/xml.h>
|
#include <gwenhywfar/xml.h>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* This file is part of the project AqHome.
|
* This file is part of the project AqHome.
|
||||||
* AqHome (c) by 2024 Martin Preuss, all rights reserved.
|
* AqHome (c) by 2025 Martin Preuss, all rights reserved.
|
||||||
*
|
*
|
||||||
* The license for this file can be found in the file COPYING which you
|
* The license for this file can be found in the file COPYING which you
|
||||||
* should have received along with this file.
|
* should have received along with this file.
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "./u_module.h"
|
#include "./u_module.h"
|
||||||
|
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
#include <gwenhywfar/list.h>
|
#include <gwenhywfar/list.h>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
#include <gwenhywfar/debug.h>
|
#include <gwenhywfar/debug.h>
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
#define AQHOMEREACT_UNIT_STABILIZE_PARAM_HOLDTIME_HIGH "holdTimeHigh"
|
#define AQHOMEREACT_UNIT_STABILIZE_PARAM_HOLDTIME_HIGH "holdTimeHigh"
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -246,8 +246,12 @@ int _hasDateChanged(AQHREACT_UNIT *unit)
|
|||||||
GWEN_DATE *today;
|
GWEN_DATE *today;
|
||||||
|
|
||||||
today=GWEN_Date_CurrentDate();
|
today=GWEN_Date_CurrentDate();
|
||||||
if (GWEN_Date_Compare(today, xunit->date)!=0)
|
|
||||||
|
if (GWEN_Date_Compare(today, xunit->date)!=0) {
|
||||||
|
GWEN_Date_free(today);
|
||||||
return 1;
|
return 1;
|
||||||
|
}
|
||||||
|
GWEN_Date_free(today);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include "./u_suntime.h"
|
#include "./u_suntime.h"
|
||||||
|
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
#include <gwenhywfar/gwentime.h>
|
#include <gwenhywfar/gwentime.h>
|
||||||
|
|||||||
@@ -29,6 +29,10 @@
|
|||||||
|
|
||||||
#define AQHOMEREACT_UNIT_TIMEPROGRAM_OUTSLOT_OUTPUT 0
|
#define AQHOMEREACT_UNIT_TIMEPROGRAM_OUTSLOT_OUTPUT 0
|
||||||
|
|
||||||
|
#define AQHOMEREACT_UNIT_TIMEPROGRAM_CREATEFORNEXT_MINS 60 /* 1h */
|
||||||
|
#define AQHOMEREACT_UNIT_TIMEPROGRAM_CREATEEVERY_SECS (15*60) /* 15m */
|
||||||
|
|
||||||
|
#define AQHOMEREACT_UNIT_TIMEPROGRAM_CHECKINTERVAL_SEC 60 /* 1m */
|
||||||
|
|
||||||
GWEN_INHERIT(AQHREACT_UNIT, AQHREACT_UNIT_TIMEPROGRAM);
|
GWEN_INHERIT(AQHREACT_UNIT, AQHREACT_UNIT_TIMEPROGRAM);
|
||||||
|
|
||||||
@@ -39,19 +43,17 @@ GWEN_INHERIT(AQHREACT_UNIT, AQHREACT_UNIT_TIMEPROGRAM);
|
|||||||
* ------------------------------------------------------------------------------------------------
|
* ------------------------------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static MODULE_TIMER_ACTION *ModuleTimerAction_new(int hourTime, double value);
|
static MODULE_TIMER_ACTION *ModuleTimerAction_new(int64_t triggerTime, double value);
|
||||||
static void ModuleTimerAction_free(MODULE_TIMER_ACTION *act);
|
static void ModuleTimerAction_free(MODULE_TIMER_ACTION *act);
|
||||||
|
|
||||||
static void GWENHYWFAR_CB _freeData(void *bp, void *p);
|
static void GWENHYWFAR_CB _freeData(void *bp, void *p);
|
||||||
static int _cbProcess(AQHREACT_UNIT *unit);
|
static int _cbProcess(AQHREACT_UNIT *unit);
|
||||||
static int _readRules(AQHREACT_UNIT *unit);
|
static int _readRules(AQHREACT_UNIT *unit);
|
||||||
|
|
||||||
static int _handleActionsForGivenTime(AQHREACT_UNIT *unit, int hourMins);
|
static int _checkAndAddActions(AQHREACT_UNIT *unit, AQHREACT_UNIT_TIMEPROGRAM *xunit);
|
||||||
static int _checkAndAddActions(AQHREACT_UNIT *unit);
|
static int _addActionsForNextMinutes(AQHREACT_UNIT_TIMEPROGRAM *xunit, int minutes,
|
||||||
static int _addActionsForGivenTime(const GWEN_TIME *ti,
|
const AQHREACT_PRGRULE_LIST *ruleList, MODULE_TIMER_ACTION_LIST *actionList);
|
||||||
int hour,
|
static int _handlePendingActions(AQHREACT_UNIT *unit, AQHREACT_UNIT_TIMEPROGRAM *xunit);
|
||||||
const AQHREACT_PRGRULE_LIST *ruleList,
|
|
||||||
MODULE_TIMER_ACTION_LIST *actionList);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -68,14 +70,14 @@ GWEN_LIST_FUNCTIONS(MODULE_TIMER_ACTION, ModuleTimerAction);
|
|||||||
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
*/
|
*/
|
||||||
|
|
||||||
MODULE_TIMER_ACTION *ModuleTimerAction_new(int hourTime, double value)
|
MODULE_TIMER_ACTION *ModuleTimerAction_new(int64_t triggerTime, double value)
|
||||||
{
|
{
|
||||||
MODULE_TIMER_ACTION *act;
|
MODULE_TIMER_ACTION *act;
|
||||||
|
|
||||||
GWEN_NEW_OBJECT(MODULE_TIMER_ACTION, act);
|
GWEN_NEW_OBJECT(MODULE_TIMER_ACTION, act);
|
||||||
GWEN_LIST_INIT(MODULE_TIMER_ACTION, act);
|
GWEN_LIST_INIT(MODULE_TIMER_ACTION, act);
|
||||||
|
|
||||||
act->hourMinutes=hourTime;
|
act->triggerTime=triggerTime;
|
||||||
act->value=value;
|
act->value=value;
|
||||||
|
|
||||||
return act;
|
return act;
|
||||||
@@ -112,6 +114,7 @@ AQHREACT_UNIT *AqHomeReact_UnitTimeProgram_new(AQH_OBJECT *aqh)
|
|||||||
GWEN_INHERIT_SETDATA(AQHREACT_UNIT, AQHREACT_UNIT_TIMEPROGRAM, unit, xunit, _freeData);
|
GWEN_INHERIT_SETDATA(AQHREACT_UNIT, AQHREACT_UNIT_TIMEPROGRAM, unit, xunit, _freeData);
|
||||||
|
|
||||||
xunit->actionList=ModuleTimerAction_List_new();
|
xunit->actionList=ModuleTimerAction_List_new();
|
||||||
|
xunit->lastActionHour=-1;
|
||||||
AQHREACT_Unit_SetProcessFn(unit, _cbProcess);
|
AQHREACT_Unit_SetProcessFn(unit, _cbProcess);
|
||||||
|
|
||||||
port=AQHREACT_Port_new();
|
port=AQHREACT_Port_new();
|
||||||
@@ -125,6 +128,8 @@ AQHREACT_UNIT *AqHomeReact_UnitTimeProgram_new(AQH_OBJECT *aqh)
|
|||||||
AQHREACT_Param_SetDataType(param, AQHREACT_DATAOBJECTTYPE_STRING);
|
AQHREACT_Param_SetDataType(param, AQHREACT_DATAOBJECTTYPE_STRING);
|
||||||
AQHREACT_Unit_AddParam(unit, param);
|
AQHREACT_Unit_AddParam(unit, param);
|
||||||
|
|
||||||
|
xunit->nextAddTime=GWEN_Timestamp_NowInLocalTime();
|
||||||
|
|
||||||
return unit;
|
return unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +143,7 @@ void GWENHYWFAR_CB _freeData(GWEN_UNUSED void *bp, void *p)
|
|||||||
|
|
||||||
ModuleTimerAction_List_free(xunit->actionList);
|
ModuleTimerAction_List_free(xunit->actionList);
|
||||||
AQHREACT_PrgRule_List_free(xunit->ruleList);
|
AQHREACT_PrgRule_List_free(xunit->ruleList);
|
||||||
|
GWEN_Timestamp_free(xunit->nextAddTime);
|
||||||
GWEN_FREE_OBJECT(xunit);
|
GWEN_FREE_OBJECT(xunit);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -155,6 +161,7 @@ int _cbProcess(AQHREACT_UNIT *unit)
|
|||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
if (xunit->ruleList==NULL) {
|
if (xunit->ruleList==NULL) {
|
||||||
|
DBG_INFO(NULL, "Reading rules");
|
||||||
rv=_readRules(unit);
|
rv=_readRules(unit);
|
||||||
if (rv<0) {
|
if (rv<0) {
|
||||||
DBG_INFO(NULL, "here (%d)", rv);
|
DBG_INFO(NULL, "here (%d)", rv);
|
||||||
@@ -163,7 +170,7 @@ int _cbProcess(AQHREACT_UNIT *unit)
|
|||||||
didSomething=1;
|
didSomething=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rv=_checkAndAddActions(unit);
|
rv=_checkAndAddActions(unit, xunit);
|
||||||
if (rv<0) {
|
if (rv<0) {
|
||||||
DBG_INFO(NULL, "here (%d)", rv);
|
DBG_INFO(NULL, "here (%d)", rv);
|
||||||
return rv;
|
return rv;
|
||||||
@@ -177,58 +184,40 @@ int _cbProcess(AQHREACT_UNIT *unit)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _checkAndAddActions(AQHREACT_UNIT *unit)
|
int _checkAndAddActions(AQHREACT_UNIT *unit, AQHREACT_UNIT_TIMEPROGRAM *xunit)
|
||||||
{
|
{
|
||||||
AQHREACT_UNIT_TIMEPROGRAM *xunit;
|
|
||||||
GWEN_TIME *ti;
|
|
||||||
int didSomething=0;
|
int didSomething=0;
|
||||||
|
|
||||||
xunit=GWEN_INHERIT_GETDATA(AQHREACT_UNIT, AQHREACT_UNIT_TIMEPROGRAM, unit);
|
xunit=GWEN_INHERIT_GETDATA(AQHREACT_UNIT, AQHREACT_UNIT_TIMEPROGRAM, unit);
|
||||||
ti=GWEN_CurrentTime();
|
if (xunit) {
|
||||||
if (ti) {
|
time_t now;
|
||||||
int hours;
|
|
||||||
int mins;
|
|
||||||
int secs;
|
|
||||||
int hourMins;
|
|
||||||
int rv;
|
int rv;
|
||||||
|
|
||||||
/* translate current time */
|
now=time(NULL);
|
||||||
rv=GWEN_Time_GetBrokenDownTime(ti, &hours, &mins, &secs);
|
if ((now-xunit->lastCreateTime)>AQHOMEREACT_UNIT_TIMEPROGRAM_CREATEEVERY_SECS) {
|
||||||
if (rv<0) {
|
rv=_addActionsForNextMinutes(xunit,
|
||||||
DBG_INFO(NULL, "here (%d)", rv);
|
AQHOMEREACT_UNIT_TIMEPROGRAM_CREATEFORNEXT_MINS,
|
||||||
GWEN_Time_free(ti);
|
xunit->ruleList,
|
||||||
return rv;
|
xunit->actionList);
|
||||||
}
|
if (rv<0) {
|
||||||
hourMins=(hours*60)+mins;
|
DBG_INFO(NULL, "here (%d)", rv);
|
||||||
|
return rv;
|
||||||
rv=GWEN_Time_AddSeconds(ti, 60*60); /* next hour */
|
}
|
||||||
if (rv<0) {
|
if (rv>0)
|
||||||
DBG_INFO(NULL, "here (%d)", rv);
|
didSomething=1;
|
||||||
GWEN_Time_free(ti);
|
xunit->lastCreateTime=now;
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rv=GWEN_Time_GetBrokenDownTime(ti, &hours, &mins, &secs);
|
if ((now-xunit->lastCheckTime)>AQHOMEREACT_UNIT_TIMEPROGRAM_CHECKINTERVAL_SEC) {
|
||||||
if (rv<0) {
|
rv=_handlePendingActions(unit, xunit);
|
||||||
DBG_INFO(NULL, "here (%d)", rv);
|
if (rv<0) {
|
||||||
GWEN_Time_free(ti);
|
DBG_INFO(NULL, "here (%d)", rv);
|
||||||
return rv;
|
return rv;
|
||||||
|
}
|
||||||
|
if (rv>0)
|
||||||
|
didSomething=1;
|
||||||
|
xunit->lastCheckTime=now;
|
||||||
}
|
}
|
||||||
if (hours!=xunit->lastActionHour) {
|
|
||||||
DBG_INFO(NULL, "Adding actions for next hour %02d", hours);
|
|
||||||
_addActionsForGivenTime(ti, hours, xunit->ruleList, xunit->actionList);
|
|
||||||
xunit->lastActionHour=hours;
|
|
||||||
didSomething=1;
|
|
||||||
}
|
|
||||||
GWEN_Time_free(ti);
|
|
||||||
|
|
||||||
rv=_handleActionsForGivenTime(unit, hourMins);
|
|
||||||
if (rv<0) {
|
|
||||||
DBG_INFO(NULL, "here (%d)", rv);
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
if (rv>0)
|
|
||||||
didSomething=1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return didSomething?1:0;
|
return didSomething?1:0;
|
||||||
@@ -236,64 +225,86 @@ int _checkAndAddActions(AQHREACT_UNIT *unit)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _handleActionsForGivenTime(AQHREACT_UNIT *unit, int hourMins)
|
int _handlePendingActions(AQHREACT_UNIT *unit, AQHREACT_UNIT_TIMEPROGRAM *xunit)
|
||||||
{
|
{
|
||||||
AQHREACT_UNIT_TIMEPROGRAM *xunit;
|
|
||||||
MODULE_TIMER_ACTION *action;
|
|
||||||
int valueSent=0;
|
int valueSent=0;
|
||||||
|
|
||||||
xunit=GWEN_INHERIT_GETDATA(AQHREACT_UNIT, AQHREACT_UNIT_TIMEPROGRAM, unit);
|
if (unit && xunit) {
|
||||||
action=ModuleTimerAction_List_First(xunit->actionList);
|
AQHREACT_PORT *outputPort;
|
||||||
while(action) {
|
|
||||||
MODULE_TIMER_ACTION *nextAction;
|
|
||||||
|
|
||||||
nextAction=ModuleTimerAction_List_Next(action);
|
outputPort=AQHREACT_Unit_GetOutputPortByIdForUnit(unit, AQHOMEREACT_UNIT_TIMEPROGRAM_OUTSLOT_OUTPUT);
|
||||||
if ((hourMins>action->hourMinutes) || (hourMins+(23*60))<action->hourMinutes) {
|
if (outputPort) {
|
||||||
ModuleTimerAction_List_Del(action);
|
GWEN_TIMESTAMP *ts;
|
||||||
DBG_INFO(NULL, "Sending output value %.2f", action->value);
|
int64_t nowInt64;
|
||||||
AQHREACT_Unit_OutputDoubleData(unit, AQHOMEREACT_UNIT_TIMEPROGRAM_OUTSLOT_OUTPUT, action->value);
|
MODULE_TIMER_ACTION *action;
|
||||||
ModuleTimerAction_free(action);
|
|
||||||
valueSent=1;
|
ts=GWEN_Timestamp_NowInLocalTime();
|
||||||
|
nowInt64=ts?GWEN_Timestamp_toInt64(ts):0;
|
||||||
|
GWEN_Timestamp_free(ts);
|
||||||
|
|
||||||
|
xunit=GWEN_INHERIT_GETDATA(AQHREACT_UNIT, AQHREACT_UNIT_TIMEPROGRAM, unit);
|
||||||
|
action=ModuleTimerAction_List_First(xunit->actionList);
|
||||||
|
while(action) {
|
||||||
|
MODULE_TIMER_ACTION *nextAction;
|
||||||
|
|
||||||
|
nextAction=ModuleTimerAction_List_Next(action);
|
||||||
|
if (action->triggerTime<nowInt64) {
|
||||||
|
ModuleTimerAction_List_Del(action);
|
||||||
|
DBG_ERROR(NULL, "Sending output value %.2f", action->value);
|
||||||
|
AQHREACT_Unit_OutputDoubleData(unit, outputPort, action->value);
|
||||||
|
ModuleTimerAction_free(action);
|
||||||
|
valueSent=1;
|
||||||
|
}
|
||||||
|
|
||||||
|
action=nextAction;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
action=nextAction;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return valueSent?1:0;
|
return valueSent?1:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _addActionsForGivenTime(const GWEN_TIME *ti, int hour, const AQHREACT_PRGRULE_LIST *ruleList, MODULE_TIMER_ACTION_LIST *actionList)
|
int _addActionsForNextMinutes(AQHREACT_UNIT_TIMEPROGRAM *xunit,
|
||||||
|
int minutes,
|
||||||
|
const AQHREACT_PRGRULE_LIST *ruleList,
|
||||||
|
MODULE_TIMER_ACTION_LIST *actionList)
|
||||||
{
|
{
|
||||||
int actionsAdded=0;
|
int actionsAdded=0;
|
||||||
GWEN_DATE *dt;
|
int i;
|
||||||
int dayOfMonth;
|
GWEN_TIMESTAMP *tsWork;
|
||||||
int month;
|
|
||||||
int dayOfWeek;
|
|
||||||
int mins;
|
|
||||||
|
|
||||||
dt=GWEN_Date_fromTime(ti);
|
tsWork=GWEN_Timestamp_NowInLocalTime();
|
||||||
month=GWEN_Date_GetMonth(dt);
|
for (i=0; i<minutes; i++) {
|
||||||
dayOfMonth=GWEN_Date_GetDay(dt);
|
if (GWEN_Timestamp_Compare(tsWork, xunit->nextAddTime)==1) {
|
||||||
dayOfWeek=GWEN_Date_WeekDay(dt);
|
int64_t triggerTime;
|
||||||
GWEN_Date_free(dt);
|
const AQHREACT_PRGRULE *rule;
|
||||||
|
|
||||||
for (mins=0; mins<60; mins++) {
|
triggerTime=GWEN_Timestamp_toInt64(tsWork);
|
||||||
const AQHREACT_PRGRULE *rule;
|
|
||||||
|
|
||||||
rule=AQHREACT_PrgRule_List_First(ruleList);
|
rule=AQHREACT_PrgRule_List_First(ruleList);
|
||||||
while(rule) {
|
while(rule) {
|
||||||
if (AQHREACT_PrgRule_Matches(rule, mins, hour, dayOfMonth, month, dayOfWeek)>0) {
|
if (AQHREACT_PrgRule_Matches(rule,
|
||||||
MODULE_TIMER_ACTION *act;
|
GWEN_Timestamp_GetMinute(tsWork),
|
||||||
|
GWEN_Timestamp_GetHour(tsWork),
|
||||||
|
GWEN_Timestamp_GetDay(tsWork),
|
||||||
|
GWEN_Timestamp_GetMonth(tsWork),
|
||||||
|
GWEN_Timestamp_GetWeekDay(tsWork))>0) {
|
||||||
|
MODULE_TIMER_ACTION *act;
|
||||||
|
|
||||||
act=ModuleTimerAction_new((hour*60)+mins, AQHREACT_PrgRule_GetValue(rule));
|
DBG_ERROR(NULL, "- rule matches for %s, creating action", GWEN_Timestamp_GetString(tsWork));
|
||||||
ModuleTimerAction_List_Add(act, actionList);
|
act=ModuleTimerAction_new(triggerTime, AQHREACT_PrgRule_GetValue(rule));
|
||||||
actionsAdded=1;
|
ModuleTimerAction_List_Add(act, actionList);
|
||||||
}
|
actionsAdded=1;
|
||||||
rule=AQHREACT_PrgRule_List_Next(rule);
|
}
|
||||||
|
rule=AQHREACT_PrgRule_List_Next(rule);
|
||||||
|
} /* while */
|
||||||
}
|
}
|
||||||
}
|
GWEN_Timestamp_AddSeconds(tsWork, 60); /* next min */
|
||||||
|
} /* for */
|
||||||
|
GWEN_Timestamp_free(xunit->nextAddTime);
|
||||||
|
xunit->nextAddTime=tsWork;
|
||||||
|
|
||||||
return actionsAdded?1:0;
|
return actionsAdded?1:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,14 @@
|
|||||||
|
|
||||||
#include "./u_timeprogram.h"
|
#include "./u_timeprogram.h"
|
||||||
|
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
#include "aqhome-react/types/prgrule.h"
|
#include "aqhome-react/types/prgrule.h"
|
||||||
|
|
||||||
#include <gwenhywfar/list.h>
|
#include <gwenhywfar/list.h>
|
||||||
|
#include <gwenhywfar/timestamp.h>
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -30,7 +33,7 @@ GWEN_LIST_FUNCTION_DEFS(MODULE_TIMER_ACTION, ModuleTimerAction)
|
|||||||
struct MODULE_TIMER_ACTION {
|
struct MODULE_TIMER_ACTION {
|
||||||
GWEN_LIST_ELEMENT(MODULE_TIMER_ACTION)
|
GWEN_LIST_ELEMENT(MODULE_TIMER_ACTION)
|
||||||
|
|
||||||
int hourMinutes;
|
int64_t triggerTime;
|
||||||
double value;
|
double value;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -41,6 +44,10 @@ struct AQHREACT_UNIT_TIMEPROGRAM {
|
|||||||
MODULE_TIMER_ACTION_LIST *actionList;
|
MODULE_TIMER_ACTION_LIST *actionList;
|
||||||
|
|
||||||
int lastActionHour;
|
int lastActionHour;
|
||||||
|
GWEN_TIMESTAMP *nextAddTime;
|
||||||
|
time_t lastCheckTime;
|
||||||
|
time_t lastCreateTime;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ void _cbInputData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, const AQHREACT_DATAO
|
|||||||
msgOut=_mkSetDataMsgString(brokerEndpoint, sValueName, dataObject);
|
msgOut=_mkSetDataMsgString(brokerEndpoint, sValueName, dataObject);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
DBG_INFO(NULL, "Unhandled data type (%d)", AQHREACT_DataObject_GetDataType(dataObject));
|
DBG_ERROR(NULL, "Unhandled data type (%d)", AQHREACT_DataObject_GetDataType(dataObject));
|
||||||
msgOut=NULL;
|
msgOut=NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,15 @@ void _cbInputData(AQHREACT_UNIT *unit, AQHREACT_PORT *port, const AQHREACT_DATAO
|
|||||||
GWEN_Buffer_free(dbuf);
|
GWEN_Buffer_free(dbuf);
|
||||||
AQH_Message_free(msgOut);
|
AQH_Message_free(msgOut);
|
||||||
#else
|
#else
|
||||||
DBG_INFO(NULL, "Sending data for value \"%s\"", sValueName);
|
GWEN_BUFFER *dbuf;
|
||||||
|
|
||||||
|
dbuf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||||
|
GWEN_Buffer_AppendArgs(dbuf, "Send: \"%s\" = ", sValueName);
|
||||||
|
AQHREACT_DataObject_Dump(dataObject, dbuf, 0);
|
||||||
|
DBG_ERROR(NULL, "%s\n", GWEN_Buffer_GetStart(dbuf));
|
||||||
|
GWEN_Buffer_free(dbuf);
|
||||||
|
|
||||||
|
// DBG_ERROR(NULL, "Sending data for value \"%s\"", sValueName);
|
||||||
AQH_Endpoint_AddMsgOut(brokerEndpoint, msgOut);
|
AQH_Endpoint_AddMsgOut(brokerEndpoint, msgOut);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
#include "aqhome/data/value.h"
|
#include "aqhome/data/value.h"
|
||||||
|
|||||||
@@ -12,14 +12,14 @@
|
|||||||
|
|
||||||
#include "./u_varset.h"
|
#include "./u_varset.h"
|
||||||
|
|
||||||
#include "aqhome/ipc/data/msg_data_set.h"
|
#include "aqhome/msg/ipc/data/m_ipcd_setdata.h"
|
||||||
#include "aqhome/ipc/data/ipc_data.h"
|
#include "aqhome/msg/ipc/data/m_ipcd.h"
|
||||||
|
|
||||||
#include <gwenhywfar/debug.h>
|
#include <gwenhywfar/debug.h>
|
||||||
#include <gwenhywfar/text.h>
|
#include <gwenhywfar/text.h>
|
||||||
|
|
||||||
|
|
||||||
#define DEBUG_DRY_RUN 1 /* don't actually set value if "1" */
|
#define DEBUG_DRY_RUN 0 /* don't actually set value if "1" */
|
||||||
|
|
||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ void _cbInputData(AQHREACT_UNIT *unit, GWEN_UNUSED AQHREACT_PORT *port, const AQ
|
|||||||
result=AQHREACT_Unit_GetParamValueString(unit, AQHOMEREACT_UNIT_VALUESET_PARAM_VALUE_ZERO, NULL);
|
result=AQHREACT_Unit_GetParamValueString(unit, AQHOMEREACT_UNIT_VALUESET_PARAM_VALUE_ZERO, NULL);
|
||||||
|
|
||||||
if (result && *result) {
|
if (result && *result) {
|
||||||
DBG_DEBUG(NULL, "Sending \"%s\" to output", result);
|
DBG_INFO(NULL, "Sending \"%s\" to output", result);
|
||||||
AQHREACT_Unit_OutputStringData(unit, outputPort, result);
|
AQHREACT_Unit_OutputStringData(unit, outputPort, result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "aqhome-react/server.h"
|
#include "aqhome-react/server.h"
|
||||||
#include "aqhome-react/aqhome_react.h"
|
|
||||||
#include "aqhome-react/types/unit.h"
|
#include "aqhome-react/types/unit.h"
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -493,7 +493,7 @@ AQH_MESSAGE *AQH_ToolClient_WaitForNodeMsg(AQH_OBJECT *o, int nodeSrcAddr, uint8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DBG_INFO(NULL, "Received unexpected message %d (%x), ignoring", code, code);
|
DBG_DEBUG(NULL, "Received unexpected message %d (%x), ignoring", code, code);
|
||||||
}
|
}
|
||||||
GWEN_Tag16_List_free(tagList);
|
GWEN_Tag16_List_free(tagList);
|
||||||
}
|
}
|
||||||
@@ -525,9 +525,9 @@ int AQH_ToolClient_HandleResultMsg(GWEN_UNUSED const AQH_MESSAGE *msg, const GWE
|
|||||||
|
|
||||||
text=AQH_IpcMessageResult_GetText(tagList);
|
text=AQH_IpcMessageResult_GetText(tagList);
|
||||||
DBG_ERROR(NULL, "ERROR: %d (%s)", result, text?text:"");
|
DBG_ERROR(NULL, "ERROR: %d (%s)", result, text?text:"");
|
||||||
return 3;
|
return GWEN_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ int AQH_Tool_AddDataPoint(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
|||||||
|
|
||||||
eventLoop=AQH_EventLoop_new();
|
eventLoop=AQH_EventLoop_new();
|
||||||
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
||||||
|
AQH_ToolClient_AddFlags(o, AQH_TOOL_CLIENT_CONNECTFLAGS_WITHCONNECTMSG);
|
||||||
AQH_ToolClient_SetCreateRequestMessageFn(o, _createRequestMessage);
|
AQH_ToolClient_SetCreateRequestMessageFn(o, _createRequestMessage);
|
||||||
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
||||||
if (rv!=0)
|
if (rv!=0)
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ int AQH_Tool_GetDataPoints(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
|||||||
|
|
||||||
eventLoop=AQH_EventLoop_new();
|
eventLoop=AQH_EventLoop_new();
|
||||||
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
||||||
|
AQH_ToolClient_AddFlags(o, AQH_TOOL_CLIENT_CONNECTFLAGS_WITHCONNECTMSG);
|
||||||
AQH_ToolClient_SetCreateRequestMessageFn(o, _createRequestMessage);
|
AQH_ToolClient_SetCreateRequestMessageFn(o, _createRequestMessage);
|
||||||
AQH_ToolClient_SetHandleResponseMessageFn(o, _handleResponseMessage);
|
AQH_ToolClient_SetHandleResponseMessageFn(o, _handleResponseMessage);
|
||||||
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ int AQH_Tool_GetDevices(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
|||||||
|
|
||||||
eventLoop=AQH_EventLoop_new();
|
eventLoop=AQH_EventLoop_new();
|
||||||
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
||||||
|
AQH_ToolClient_AddFlags(o, AQH_TOOL_CLIENT_CONNECTFLAGS_WITHCONNECTMSG);
|
||||||
AQH_ToolClient_SetCreateRequestMessageFn(o, _createRequestMessage);
|
AQH_ToolClient_SetCreateRequestMessageFn(o, _createRequestMessage);
|
||||||
AQH_ToolClient_SetHandleResponseMessageFn(o, _handleResponseMessage);
|
AQH_ToolClient_SetHandleResponseMessageFn(o, _handleResponseMessage);
|
||||||
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ int AQH_Tool_GetValues(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
|||||||
|
|
||||||
eventLoop=AQH_EventLoop_new();
|
eventLoop=AQH_EventLoop_new();
|
||||||
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
||||||
|
AQH_ToolClient_AddFlags(o, AQH_TOOL_CLIENT_CONNECTFLAGS_WITHCONNECTMSG);
|
||||||
AQH_ToolClient_SetCreateRequestMessageFn(o, _createRequestMessage);
|
AQH_ToolClient_SetCreateRequestMessageFn(o, _createRequestMessage);
|
||||||
AQH_ToolClient_SetHandleResponseMessageFn(o, _handleResponseMessage);
|
AQH_ToolClient_SetHandleResponseMessageFn(o, _handleResponseMessage);
|
||||||
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ int AQH_Tool_ModDevice(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
|||||||
|
|
||||||
eventLoop=AQH_EventLoop_new();
|
eventLoop=AQH_EventLoop_new();
|
||||||
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
||||||
|
AQH_ToolClient_AddFlags(o, AQH_TOOL_CLIENT_CONNECTFLAGS_WITHCONNECTMSG);
|
||||||
AQH_ToolClient_SetCreateRequestMessageFn(o, _createRequestMessage);
|
AQH_ToolClient_SetCreateRequestMessageFn(o, _createRequestMessage);
|
||||||
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
||||||
if (rv!=0)
|
if (rv!=0)
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ int AQH_Tool_SetData(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
|||||||
|
|
||||||
eventLoop=AQH_EventLoop_new();
|
eventLoop=AQH_EventLoop_new();
|
||||||
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
||||||
|
AQH_ToolClient_AddFlags(o, AQH_TOOL_CLIENT_CONNECTFLAGS_WITHCONNECTMSG);
|
||||||
AQH_ToolClient_SetCreateRequestMessageFn(o, _createRequestMessage);
|
AQH_ToolClient_SetCreateRequestMessageFn(o, _createRequestMessage);
|
||||||
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
||||||
if (rv!=0)
|
if (rv!=0)
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ int AQH_Tool_Watch(GWEN_DB_NODE *dbGlobalArgs, int argc, char **argv)
|
|||||||
|
|
||||||
eventLoop=AQH_EventLoop_new();
|
eventLoop=AQH_EventLoop_new();
|
||||||
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
o=AQH_ToolClient_new(eventLoop, AQH_IPC_PROTOCOL_DATA_ID, AQH_IPC_PROTOCOL_DATA_VERSION, dbGlobalArgs, args);
|
||||||
|
AQH_ToolClient_AddFlags(o, AQH_TOOL_CLIENT_CONNECTFLAGS_WITHCONNECTMSG);
|
||||||
AQH_ToolClient_AddFlags(o, AQH_ENDPOINT_FLAGS_WANTUPDATES);
|
AQH_ToolClient_AddFlags(o, AQH_ENDPOINT_FLAGS_WANTUPDATES);
|
||||||
AQH_ToolClient_SetHandleResponseMessageFn(o, _handleResponseMessage);
|
AQH_ToolClient_SetHandleResponseMessageFn(o, _handleResponseMessage);
|
||||||
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
rv=AQH_ToolClient_ReadLocalArgs(o, argc, argv);
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <gwenhywfar/i18n.h>
|
#include <gwenhywfar/i18n.h>
|
||||||
#include <gwenhywfar/debug.h>
|
#include <gwenhywfar/debug.h>
|
||||||
|
#include <gwenhywfar/text.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
@@ -45,9 +46,12 @@
|
|||||||
#define A_INT GWEN_ArgsType_Int
|
#define A_INT GWEN_ArgsType_Int
|
||||||
|
|
||||||
|
|
||||||
#define FLASH_TOOL_MAX_REPEAT 16
|
#define FLASH_TOOL_PAGESIZE 16
|
||||||
#define FLASH_TOOL_DEFAULT_TIMEOUTINSECS 5
|
|
||||||
#define FLASH_TOOL_WAITFORFLASHREADY_INSECS 30
|
#define FLASH_TOOL_MAX_REPEAT 16
|
||||||
|
#define FLASH_TOOL_DEFAULT_TIMEOUTINSECS 5
|
||||||
|
#define FLASH_TOOL_WAITFORFLASHREADY_INSECS 30
|
||||||
|
#define FLASH_TOOL_WAITFORFLASHRESPONSE_SECS 2
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -72,7 +76,7 @@ static int _flashData(AQH_OBJECT *o, uint32_t address, const uint8_t *ptr, uint3
|
|||||||
static int _flashEnd(AQH_OBJECT *o, int reason, int timeoutInSeconds);
|
static int _flashEnd(AQH_OBJECT *o, int reason, int timeoutInSeconds);
|
||||||
|
|
||||||
/** frees msg! */
|
/** frees msg! */
|
||||||
static int _trySendMsgAndWaitForFlasgResponse(AQH_OBJECT *o, AQH_MESSAGE *msg, const char *msgInfo, int timeoutInSeconds);
|
static int _trySendMsgAndWaitForFlashResponse(AQH_OBJECT *o, AQH_MESSAGE *msg, const char *msgInfo, int timeoutInSeconds);
|
||||||
static int _waitForFlashResponse(AQH_OBJECT *o, int timeoutInSeconds);
|
static int _waitForFlashResponse(AQH_OBJECT *o, int timeoutInSeconds);
|
||||||
static AQH_FLASHRECORD_LIST *_readHexfileIntoFlashRecordList(const char *hexFilename);
|
static AQH_FLASHRECORD_LIST *_readHexfileIntoFlashRecordList(const char *hexFilename);
|
||||||
|
|
||||||
@@ -189,7 +193,8 @@ int doFlash(AQH_OBJECT *o)
|
|||||||
AQH_Message_free(msg);
|
AQH_Message_free(msg);
|
||||||
|
|
||||||
/* perform flash */
|
/* perform flash */
|
||||||
rv=_performFlashProcedure(o, uid, flashRecordList, pageSize, timeoutInSeconds);
|
// rv=_performFlashProcedure(o, uid, flashRecordList, pageSize, timeoutInSeconds);
|
||||||
|
rv=_performFlashProcedure(o, uid, flashRecordList, FLASH_TOOL_PAGESIZE, timeoutInSeconds);
|
||||||
if (rv<0) {
|
if (rv<0) {
|
||||||
if (rv<0) {
|
if (rv<0) {
|
||||||
DBG_INFO(NULL, "here (%d)", rv);
|
DBG_INFO(NULL, "here (%d)", rv);
|
||||||
@@ -209,15 +214,16 @@ int _rebootNode(AQH_OBJECT *o, unsigned int uid, int timeoutInSeconds)
|
|||||||
AQH_MESSAGE *nodeMsg;
|
AQH_MESSAGE *nodeMsg;
|
||||||
|
|
||||||
/* send REBOOT_REQUEST message */
|
/* send REBOOT_REQUEST message */
|
||||||
fprintf(stdout, "- sending REBOOT request\n");
|
fprintf(stdout, "- Sending REBOOT request\n");
|
||||||
DBG_INFO(NULL, "Sending REBOOT REQUEST message");
|
DBG_INFO(NULL, "Sending REBOOT REQUEST message");
|
||||||
nodeMsg=AQH_RebootMessage_new(0, 0xff, AQH_MSG_TYPE_REBOOT_REQ, uid);
|
nodeMsg=AQH_RebootMessage_new(0xff, 0x00, AQH_MSG_TYPE_REBOOT_REQ, uid);
|
||||||
if (nodeMsg==NULL) {
|
if (nodeMsg==NULL) {
|
||||||
DBG_ERROR(NULL, "Error creating message");
|
DBG_ERROR(NULL, "Error creating message");
|
||||||
return GWEN_ERROR_GENERIC;
|
return GWEN_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
AQH_ToolClient_SendNodeMsg(o, nodeMsg);
|
AQH_ToolClient_SendNodeMsg(o, nodeMsg);
|
||||||
|
#if 0
|
||||||
nodeMsg=AQH_ToolClient_WaitForNodeMsg(o, 0, AQH_MSG_TYPE_REBOOT_RSP, timeoutInSeconds);
|
nodeMsg=AQH_ToolClient_WaitForNodeMsg(o, 0, AQH_MSG_TYPE_REBOOT_RSP, timeoutInSeconds);
|
||||||
if (nodeMsg==NULL) {
|
if (nodeMsg==NULL) {
|
||||||
DBG_INFO(NULL, "Bad or no reboot response received.");
|
DBG_INFO(NULL, "Bad or no reboot response received.");
|
||||||
@@ -226,6 +232,7 @@ int _rebootNode(AQH_OBJECT *o, unsigned int uid, int timeoutInSeconds)
|
|||||||
|
|
||||||
DBG_INFO(NULL, "REBOOT_RESPONSE message received");
|
DBG_INFO(NULL, "REBOOT_RESPONSE message received");
|
||||||
AQH_Message_free(nodeMsg);
|
AQH_Message_free(nodeMsg);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,12 +279,12 @@ int _flashStart(AQH_OBJECT *o, unsigned int uid, int timeoutInSeconds)
|
|||||||
{
|
{
|
||||||
AQH_MESSAGE *nodeMsg;
|
AQH_MESSAGE *nodeMsg;
|
||||||
|
|
||||||
nodeMsg=AQH_FlashStartMessage_new(0, 0xc1, AQH_MSG_TYPE_FLASH_START, uid);
|
nodeMsg=AQH_FlashStartMessage_new(0xc1, 0x00, AQH_MSG_TYPE_FLASH_START, uid);
|
||||||
if (nodeMsg==NULL) {
|
if (nodeMsg==NULL) {
|
||||||
DBG_ERROR(NULL, "Error creating message");
|
DBG_ERROR(NULL, "Error creating message");
|
||||||
return GWEN_ERROR_GENERIC;
|
return GWEN_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
return _trySendMsgAndWaitForFlasgResponse(o, nodeMsg, "FLASH_START", timeoutInSeconds);
|
return _trySendMsgAndWaitForFlashResponse(o, nodeMsg, "FLASH_START", timeoutInSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -294,13 +301,16 @@ int _flashRecord(AQH_OBJECT *o,
|
|||||||
ptr=AQH_FlashRecord_GetDataPointer(flashRecord);
|
ptr=AQH_FlashRecord_GetDataPointer(flashRecord);
|
||||||
len=AQH_FlashRecord_GetDataLength(flashRecord);
|
len=AQH_FlashRecord_GetDataLength(flashRecord);
|
||||||
address=AQH_FlashRecord_GetAddress(flashRecord);
|
address=AQH_FlashRecord_GetAddress(flashRecord);
|
||||||
DBG_ERROR(NULL, "Sending record: addr=%04x, len=%d, pagesize=%d", address, len, pageSize);
|
DBG_INFO(NULL, "Sending record: addr=%04x, len=%d, pagesize=%d", address, len, pageSize);
|
||||||
|
fprintf(stdout, "- sending record: addr=%04x, len=%d, pagesize=%d\n", address, len, pageSize);
|
||||||
while(ptr && len) {
|
while(ptr && len) {
|
||||||
int rv;
|
int rv;
|
||||||
uint32_t sendLen;
|
uint32_t sendLen;
|
||||||
|
|
||||||
usleep(100000);
|
|
||||||
sendLen=(len>pageSize)?pageSize:len;
|
sendLen=(len>pageSize)?pageSize:len;
|
||||||
|
fprintf(stdout, " - sending page: addr=%04x, len=%d (%d bytes left)\n", address, sendLen, len);
|
||||||
|
// GWEN_Text_DumpString((const char*)ptr, sendLen, 5);
|
||||||
|
|
||||||
rv=_flashData(o, address, ptr, sendLen, timeoutInSeconds);
|
rv=_flashData(o, address, ptr, sendLen, timeoutInSeconds);
|
||||||
if (rv<0) {
|
if (rv<0) {
|
||||||
DBG_INFO(NULL, "here (%d)", rv);
|
DBG_INFO(NULL, "here (%d)", rv);
|
||||||
@@ -326,12 +336,22 @@ int _flashData(AQH_OBJECT *o, uint32_t address, const uint8_t *ptr, uint32_t len
|
|||||||
GWEN_Buffer_AppendString(dbuf, "FLASH_DATA (");
|
GWEN_Buffer_AppendString(dbuf, "FLASH_DATA (");
|
||||||
GWEN_Buffer_AppendArgs(dbuf, "addr=%04x, data len=%d)", address, len);
|
GWEN_Buffer_AppendArgs(dbuf, "addr=%04x, data len=%d)", address, len);
|
||||||
|
|
||||||
nodeMsg=AQH_FlashDataMessage_new(0, 0xc1, AQH_MSG_TYPE_FLASH_DATA, address, ptr, len);
|
nodeMsg=AQH_FlashDataMessage_new(0xc1, 0x00, AQH_MSG_TYPE_FLASH_DATA, address, ptr, len);
|
||||||
if (nodeMsg==NULL) {
|
if (nodeMsg==NULL) {
|
||||||
DBG_ERROR(NULL, "Error creating message");
|
DBG_ERROR(NULL, "Error creating message");
|
||||||
return GWEN_ERROR_GENERIC;
|
return GWEN_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
rv=_trySendMsgAndWaitForFlasgResponse(o, nodeMsg, GWEN_Buffer_GetStart(dbuf), timeoutInSeconds);
|
|
||||||
|
if (0) {
|
||||||
|
GWEN_BUFFER *dbuf;
|
||||||
|
|
||||||
|
dbuf=GWEN_Buffer_new(0, 256, 0, 1);
|
||||||
|
AQH_NodeMessage_DumpToBuffer(nodeMsg, dbuf, "sent");
|
||||||
|
fprintf(stderr, "%s\n", GWEN_Buffer_GetStart(dbuf));
|
||||||
|
GWEN_Buffer_free(dbuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
rv=_trySendMsgAndWaitForFlashResponse(o, nodeMsg, GWEN_Buffer_GetStart(dbuf), timeoutInSeconds);
|
||||||
GWEN_Buffer_free(dbuf);
|
GWEN_Buffer_free(dbuf);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
@@ -342,17 +362,17 @@ int _flashEnd(AQH_OBJECT *o, int reason, int timeoutInSeconds)
|
|||||||
{
|
{
|
||||||
AQH_MESSAGE *nodeMsg;
|
AQH_MESSAGE *nodeMsg;
|
||||||
|
|
||||||
nodeMsg=AQH_FlashEndMessage_new(0, 0xc1, AQH_MSG_TYPE_FLASH_END, reason);
|
nodeMsg=AQH_FlashEndMessage_new(0xc1, 0x00, AQH_MSG_TYPE_FLASH_END, reason);
|
||||||
if (nodeMsg==NULL) {
|
if (nodeMsg==NULL) {
|
||||||
DBG_ERROR(NULL, "Error creating message");
|
DBG_ERROR(NULL, "Error creating message");
|
||||||
return GWEN_ERROR_GENERIC;
|
return GWEN_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
return _trySendMsgAndWaitForFlasgResponse(o, nodeMsg, "FLASH_END", timeoutInSeconds);
|
return _trySendMsgAndWaitForFlashResponse(o, nodeMsg, "FLASH_END", timeoutInSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int _trySendMsgAndWaitForFlasgResponse(AQH_OBJECT *o, AQH_MESSAGE *msg, const char *msgInfo, int timeoutInSeconds)
|
int _trySendMsgAndWaitForFlashResponse(AQH_OBJECT *o, AQH_MESSAGE *msg, const char *msgInfo, int timeoutInSeconds)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -363,11 +383,11 @@ int _trySendMsgAndWaitForFlasgResponse(AQH_OBJECT *o, AQH_MESSAGE *msg, const ch
|
|||||||
if (i)
|
if (i)
|
||||||
fprintf(stdout, " - retry sending %s (retry %d)\n", msgInfo, i);
|
fprintf(stdout, " - retry sending %s (retry %d)\n", msgInfo, i);
|
||||||
|
|
||||||
/* send FLASH_START message */
|
/* send message */
|
||||||
nodeMsg=AQH_Message_dup(msg);
|
nodeMsg=AQH_Message_dup(msg);
|
||||||
DBG_INFO(NULL, "Sending %s message (%d)", msgInfo, i);
|
DBG_INFO(NULL, "Sending %s message (%d)", msgInfo, i);
|
||||||
AQH_ToolClient_SendNodeMsg(o, nodeMsg);
|
AQH_ToolClient_SendNodeMsg(o, nodeMsg);
|
||||||
rv=_waitForFlashResponse(o, timeoutInSeconds);
|
rv=_waitForFlashResponse(o, FLASH_TOOL_WAITFORFLASHRESPONSE_SECS);
|
||||||
if (rv==0) {
|
if (rv==0) {
|
||||||
AQH_Message_free(msg);
|
AQH_Message_free(msg);
|
||||||
return 0;
|
return 0;
|
||||||
@@ -396,7 +416,7 @@ int _waitForFlashResponse(AQH_OBJECT *o, int timeoutInSeconds)
|
|||||||
|
|
||||||
result=AQH_FlashResponseMessage_GetCode(nodeMsg);
|
result=AQH_FlashResponseMessage_GetCode(nodeMsg);
|
||||||
AQH_Message_free(nodeMsg);
|
AQH_Message_free(nodeMsg);
|
||||||
if (AQH_FlashResponseMessage_GetCode(nodeMsg)!=0) {
|
if (result!=0) {
|
||||||
DBG_ERROR(NULL, "Negative FLASH_RESPONSE received (%d)", result);
|
DBG_ERROR(NULL, "Negative FLASH_RESPONSE received (%d)", result);
|
||||||
return GWEN_ERROR_GENERIC;
|
return GWEN_ERROR_GENERIC;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,7 +170,13 @@ void _printNode(const AQH_NODE_INFO *ni, int printAll)
|
|||||||
fprintf(stdout, ", firmware=%d.%d.%d (%d), ",
|
fprintf(stdout, ", firmware=%d.%d.%d (%d), ",
|
||||||
(u>>16) & 0xff, (u>>8) & 0xff, u & 0xff, (u>>24) & 0xff);
|
(u>>16) & 0xff, (u>>8) & 0xff, u & 0xff, (u>>24) & 0xff);
|
||||||
if (ts)
|
if (ts)
|
||||||
fprintf(stdout, "last seen %s, ", GWEN_Timestamp_GetString(ts));
|
fprintf(stdout, "last seen %04d/%02d/%02d-%02d:%02d:%02d, ",
|
||||||
|
GWEN_Timestamp_GetYear(ts),
|
||||||
|
GWEN_Timestamp_GetMonth(ts),
|
||||||
|
GWEN_Timestamp_GetDay(ts),
|
||||||
|
GWEN_Timestamp_GetHour(ts),
|
||||||
|
GWEN_Timestamp_GetMinute(ts),
|
||||||
|
GWEN_Timestamp_GetSecond(ts));
|
||||||
fprintf(stdout, "pkg out: %d, pkg in: %d, collisions: %d, busy: %d, crc: %d, io: %d\n",
|
fprintf(stdout, "pkg out: %d, pkg in: %d, collisions: %d, busy: %d, crc: %d, io: %d\n",
|
||||||
AQH_NodeInfo_GetStatsPacketsOut(ni),
|
AQH_NodeInfo_GetStatsPacketsOut(ni),
|
||||||
AQH_NodeInfo_GetStatsPacketsIn(ni),
|
AQH_NodeInfo_GetStatsPacketsIn(ni),
|
||||||
|
|||||||
184
aqhome-mqtt.devices.old
Normal file
184
aqhome-mqtt.devices.old
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
<devices>
|
||||||
|
<device id="plug01" name="tasmotaplug" driver="mqtt">
|
||||||
|
<mqtttopics>
|
||||||
|
<mqtttopic type="json" direction="in" name="sensor">
|
||||||
|
<topic>tele/tasmota/plug01/SENSOR</topic>
|
||||||
|
<mask>tele/tasmota/*/SENSOR</mask>
|
||||||
|
<beforeId>tele/tasmota/</beforeId>
|
||||||
|
<afterId>/SENSOR</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="powerusage" units="W" path="ENERGY/POWER" type="sensor"></value>
|
||||||
|
<value name="totalenergy" units="kWh" path="ENERGY/TOTAL" type="sensor"></value>
|
||||||
|
<value name="apparentpower" units="VA" path="ENERGY/ApparentPower" type="sensor"></value>
|
||||||
|
<value name="reactivepower" units="VAr" path="ENERGY/ReactivePower" type="sensor"></value>
|
||||||
|
<value name="powerfactor" path="ENERGY/Factor" type="sensor"></value>
|
||||||
|
<value name="voltage" units="V" path="ENERGY/Voltage" type="sensor"></value>
|
||||||
|
<value name="current" units="A" path="ENERGY/Current" type="sensor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
<mqtttopic type="num" direction="out" name="power">
|
||||||
|
<beforeId>cmnd/tasmota/</beforeId>
|
||||||
|
<afterId>/Power</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="power" type="actor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
</mqtttopics>
|
||||||
|
</device>
|
||||||
|
<device id="plug02" name="tasmotaplug" driver="mqtt">
|
||||||
|
<mqtttopics>
|
||||||
|
<mqtttopic type="json" direction="in" name="sensor">
|
||||||
|
<topic>tele/tasmota/plug02/SENSOR</topic>
|
||||||
|
<mask>tele/tasmota/*/SENSOR</mask>
|
||||||
|
<beforeId>tele/tasmota/</beforeId>
|
||||||
|
<afterId>/SENSOR</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="powerusage" units="W" path="ENERGY/POWER" type="sensor"></value>
|
||||||
|
<value name="totalenergy" units="kWh" path="ENERGY/TOTAL" type="sensor"></value>
|
||||||
|
<value name="apparentpower" units="VA" path="ENERGY/ApparentPower" type="sensor"></value>
|
||||||
|
<value name="reactivepower" units="VAr" path="ENERGY/ReactivePower" type="sensor"></value>
|
||||||
|
<value name="powerfactor" path="ENERGY/Factor" type="sensor"></value>
|
||||||
|
<value name="voltage" units="V" path="ENERGY/Voltage" type="sensor"></value>
|
||||||
|
<value name="current" units="A" path="ENERGY/Current" type="sensor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
<mqtttopic type="num" direction="out" name="power">
|
||||||
|
<beforeId>cmnd/tasmota/</beforeId>
|
||||||
|
<afterId>/Power</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="power" type="actor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
</mqtttopics>
|
||||||
|
</device>
|
||||||
|
<device id="plug03" name="tasmotaplug" driver="mqtt">
|
||||||
|
<mqtttopics>
|
||||||
|
<mqtttopic type="json" direction="in" name="sensor">
|
||||||
|
<topic>tele/tasmota/plug03/SENSOR</topic>
|
||||||
|
<mask>tele/tasmota/*/SENSOR</mask>
|
||||||
|
<beforeId>tele/tasmota/</beforeId>
|
||||||
|
<afterId>/SENSOR</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="powerusage" units="W" path="ENERGY/POWER" type="sensor"></value>
|
||||||
|
<value name="totalenergy" units="kWh" path="ENERGY/TOTAL" type="sensor"></value>
|
||||||
|
<value name="apparentpower" units="VA" path="ENERGY/ApparentPower" type="sensor"></value>
|
||||||
|
<value name="reactivepower" units="VAr" path="ENERGY/ReactivePower" type="sensor"></value>
|
||||||
|
<value name="powerfactor" path="ENERGY/Factor" type="sensor"></value>
|
||||||
|
<value name="voltage" units="V" path="ENERGY/Voltage" type="sensor"></value>
|
||||||
|
<value name="current" units="A" path="ENERGY/Current" type="sensor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
<mqtttopic type="num" direction="out" name="power">
|
||||||
|
<beforeId>cmnd/tasmota/</beforeId>
|
||||||
|
<afterId>/Power</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="power" type="actor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
</mqtttopics>
|
||||||
|
</device>
|
||||||
|
<device id="109C2F" name="tasmotaplug" driver="mqtt">
|
||||||
|
<mqtttopics>
|
||||||
|
<mqtttopic type="json" direction="in" name="sensor">
|
||||||
|
<topic>tele/tasmota_109C2F/SENSOR</topic>
|
||||||
|
<mask>tele/tasmota_*/SENSOR</mask>
|
||||||
|
<beforeId>tele/tasmota_</beforeId>
|
||||||
|
<afterId>/SENSOR</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="powerusage" units="W" path="ENERGY/POWER" type="sensor"></value>
|
||||||
|
<value name="totalenergy" units="kWh" path="ENERGY/TOTAL" type="sensor"></value>
|
||||||
|
<value name="apparentpower" units="VA" path="ENERGY/ApparentPower" type="sensor"></value>
|
||||||
|
<value name="reactivepower" units="VAr" path="ENERGY/ReactivePower" type="sensor"></value>
|
||||||
|
<value name="powerfactor" path="ENERGY/Factor" type="sensor"></value>
|
||||||
|
<value name="voltage" units="V" path="ENERGY/Voltage" type="sensor"></value>
|
||||||
|
<value name="current" units="A" path="ENERGY/Current" type="sensor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
<mqtttopic type="num" direction="out" name="power">
|
||||||
|
<beforeId>cmnd/tasmota/</beforeId>
|
||||||
|
<afterId>/Power</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="power" type="actor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
</mqtttopics>
|
||||||
|
</device>
|
||||||
|
<device id="10359B" name="tasmotaplug" driver="mqtt">
|
||||||
|
<mqtttopics>
|
||||||
|
<mqtttopic type="json" direction="in" name="sensor">
|
||||||
|
<topic>tele/tasmota_10359B/SENSOR</topic>
|
||||||
|
<mask>tele/tasmota_*/SENSOR</mask>
|
||||||
|
<beforeId>tele/tasmota_</beforeId>
|
||||||
|
<afterId>/SENSOR</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="powerusage" units="W" path="ENERGY/POWER" type="sensor"></value>
|
||||||
|
<value name="totalenergy" units="kWh" path="ENERGY/TOTAL" type="sensor"></value>
|
||||||
|
<value name="apparentpower" units="VA" path="ENERGY/ApparentPower" type="sensor"></value>
|
||||||
|
<value name="reactivepower" units="VAr" path="ENERGY/ReactivePower" type="sensor"></value>
|
||||||
|
<value name="powerfactor" path="ENERGY/Factor" type="sensor"></value>
|
||||||
|
<value name="voltage" units="V" path="ENERGY/Voltage" type="sensor"></value>
|
||||||
|
<value name="current" units="A" path="ENERGY/Current" type="sensor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
<mqtttopic type="num" direction="out" name="power">
|
||||||
|
<beforeId>cmnd/tasmota_</beforeId>
|
||||||
|
<afterId>/Power</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="power" type="actor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
</mqtttopics>
|
||||||
|
</device>
|
||||||
|
<device id="0F25C2" name="tasmotaplug" driver="mqtt">
|
||||||
|
<mqtttopics>
|
||||||
|
<mqtttopic type="json" direction="in" name="sensor">
|
||||||
|
<topic>tele/tasmota_0F25C2/SENSOR</topic>
|
||||||
|
<mask>tele/tasmota_*/SENSOR</mask>
|
||||||
|
<beforeId>tele/tasmota_</beforeId>
|
||||||
|
<afterId>/SENSOR</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="powerusage" units="W" path="ENERGY/POWER" type="sensor"></value>
|
||||||
|
<value name="totalenergy" units="kWh" path="ENERGY/TOTAL" type="sensor"></value>
|
||||||
|
<value name="apparentpower" units="VA" path="ENERGY/ApparentPower" type="sensor"></value>
|
||||||
|
<value name="reactivepower" units="VAr" path="ENERGY/ReactivePower" type="sensor"></value>
|
||||||
|
<value name="powerfactor" path="ENERGY/Factor" type="sensor"></value>
|
||||||
|
<value name="voltage" units="V" path="ENERGY/Voltage" type="sensor"></value>
|
||||||
|
<value name="current" units="A" path="ENERGY/Current" type="sensor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
<mqtttopic type="num" direction="out" name="power">
|
||||||
|
<beforeId>cmnd/tasmota_</beforeId>
|
||||||
|
<afterId>/Power</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="power" type="actor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
</mqtttopics>
|
||||||
|
</device>
|
||||||
|
<device id="10A4B7" name="tasmotaplug" driver="mqtt">
|
||||||
|
<mqtttopics>
|
||||||
|
<mqtttopic type="json" direction="in" name="sensor">
|
||||||
|
<topic>tele/tasmota_10A4B7/SENSOR</topic>
|
||||||
|
<mask>tele/tasmota_*/SENSOR</mask>
|
||||||
|
<beforeId>tele/tasmota_</beforeId>
|
||||||
|
<afterId>/SENSOR</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="powerusage" units="W" path="ENERGY/POWER" type="sensor"></value>
|
||||||
|
<value name="totalenergy" units="kWh" path="ENERGY/TOTAL" type="sensor"></value>
|
||||||
|
<value name="apparentpower" units="VA" path="ENERGY/ApparentPower" type="sensor"></value>
|
||||||
|
<value name="reactivepower" units="VAr" path="ENERGY/ReactivePower" type="sensor"></value>
|
||||||
|
<value name="powerfactor" path="ENERGY/Factor" type="sensor"></value>
|
||||||
|
<value name="voltage" units="V" path="ENERGY/Voltage" type="sensor"></value>
|
||||||
|
<value name="current" units="A" path="ENERGY/Current" type="sensor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
<mqtttopic type="num" direction="out" name="power">
|
||||||
|
<beforeId>cmnd/tasmota_</beforeId>
|
||||||
|
<afterId>/Power</afterId>
|
||||||
|
<values>
|
||||||
|
<value name="power" type="actor"></value>
|
||||||
|
</values>
|
||||||
|
</mqtttopic>
|
||||||
|
</mqtttopics>
|
||||||
|
</device>
|
||||||
|
</devices>
|
||||||
@@ -10,4 +10,5 @@ export LD_LIBRARY_PATH="0-build/aqhome/:$LD_LIBRARY_PATH"
|
|||||||
# 0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -ma 192.168.117.192 -mp 1883 -t 127.0.0.1 -p aqhomed.pid
|
# 0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -ma 192.168.117.192 -mp 1883 -t 127.0.0.1 -p aqhomed.pid
|
||||||
|
|
||||||
# 0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -p aqhomed.pid -W /tmp/aqhome/aqhomed -ma 192.168.117.192 -mp 1883 -t 127.0.0.1 --mqttclientid=AQHOMEMQTTLOGTEST1
|
# 0-build/apps/aqhomed/aqhomed -l aqhome.log -db aqhome.db -p aqhomed.pid -W /tmp/aqhome/aqhomed -ma 192.168.117.192 -mp 1883 -t 127.0.0.1 --mqttclientid=AQHOMEMQTTLOGTEST1
|
||||||
0-build/apps/aqhome-nodes/aqhome-nodes -l aqhome-nodes.log -db aqhome-nodes.db -p aqhome-nodes.pid -t 127.0.0.1 -ba 127.0.0.1 "$@"
|
0-build/apps/aqhome-nodes/aqhome-nodes -N -l aqhome-nodes.log -db aqhome-nodes.db -p aqhome-nodes.pid -t 127.0.0.1 -ba 127.0.0.1 "$@"
|
||||||
|
#0-build/apps/aqhome-nodes/aqhome-nodes -l aqhome-nodes.log -db aqhome-nodes.db -p aqhome-nodes.pid -t 127.0.0.1 -ba 127.0.0.1 "$@"
|
||||||
|
|||||||
@@ -3,5 +3,4 @@
|
|||||||
# export AQHOME_LOGLEVEL=info
|
# export AQHOME_LOGLEVEL=info
|
||||||
export LD_LIBRARY_PATH="0-build/aqhome/:$LD_LIBRARY_PATH"
|
export LD_LIBRARY_PATH="0-build/aqhome/:$LD_LIBRARY_PATH"
|
||||||
|
|
||||||
0-build/apps/aqhome-react/aqhome-react -p ./aqhome-react.pid "$@"
|
0-build/apps/aqhome-react/aqhome-react "$@" -p ./aqhome-react.pid -V ./aqhome-react.vars
|
||||||
|
|
||||||
|
|||||||
0
aqhome-react.vars
Normal file
0
aqhome-react.vars
Normal file
238
aqhome-react.vg
Normal file
238
aqhome-react.vg
Normal file
@@ -0,0 +1,238 @@
|
|||||||
|
==2732905== Memcheck, a memory error detector
|
||||||
|
==2732905== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
|
||||||
|
==2732905== Using Valgrind-3.19.0-8d3c8034b8-20220411 and LibVEX; rerun with -h for copyright info
|
||||||
|
==2732905== Command: 0-build/apps/aqhome-react/aqhome-react -p ./aqhome-react.pid -V ./aqhome-react.vars -ba 127.0.0.1 -T 350
|
||||||
|
==2732905== Parent PID: 2732904
|
||||||
|
==2732905==
|
||||||
|
--2732905--
|
||||||
|
--2732905-- Valgrind options:
|
||||||
|
--2732905-- --tool=memcheck
|
||||||
|
--2732905-- --trace-children=yes
|
||||||
|
--2732905-- -v
|
||||||
|
--2732905-- --log-file=aqhome-react.vg
|
||||||
|
--2732905-- --leak-check=full
|
||||||
|
--2732905-- --show-reachable=yes
|
||||||
|
--2732905-- --track-origins=yes
|
||||||
|
--2732905-- --num-callers=50
|
||||||
|
--2732905-- --keep-stacktraces=alloc-and-free
|
||||||
|
--2732905-- Contents of /proc/version:
|
||||||
|
--2732905-- Linux version 6.1.0-31-amd64 (debian-kernel@lists.debian.org) (gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT_DYNAMIC Debian 6.1.128-1 (2025-02-07)
|
||||||
|
--2732905--
|
||||||
|
--2732905-- Arch and hwcaps: AMD64, LittleEndian, amd64-cx16-lzcnt-rdtscp-sse3-ssse3-avx-avx2-bmi-f16c-rdrand-rdseed
|
||||||
|
--2732905-- Page sizes: currently 4096, max supported 4096
|
||||||
|
--2732905-- Valgrind library directory: /usr/libexec/valgrind
|
||||||
|
--2732905-- Reading syms from /home/martin/projekte/c/0_current/hausbus/aqhome/0-build/apps/aqhome-react/aqhome-react
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
|
||||||
|
--2732905-- Considering /usr/lib/debug/.build-id/f4/bc47db467906580a47640e01e6d901e2642a7b.debug ..
|
||||||
|
--2732905-- .. build-id is valid
|
||||||
|
--2732905-- Reading syms from /usr/libexec/valgrind/memcheck-amd64-linux
|
||||||
|
--2732905-- Considering /usr/lib/debug/.build-id/82/26c2aa6b808ebd5a6fafb694a7fb3287f33590.debug ..
|
||||||
|
--2732905-- .. build-id is valid
|
||||||
|
--2732905-- object doesn't have a dynamic symbol table
|
||||||
|
--2732905-- Scheduler: using generic scheduler lock implementation.
|
||||||
|
--2732905-- Reading suppressions file: /usr/libexec/valgrind/default.supp
|
||||||
|
==2732905== embedded gdbserver: reading from /tmp/vgdb-pipe-from-vgdb-to-2732905-by-martin-on-???
|
||||||
|
==2732905== embedded gdbserver: writing to /tmp/vgdb-pipe-to-vgdb-from-2732905-by-martin-on-???
|
||||||
|
==2732905== embedded gdbserver: shared mem /tmp/vgdb-pipe-shared-mem-vgdb-2732905-by-martin-on-???
|
||||||
|
==2732905==
|
||||||
|
==2732905== TO CONTROL THIS PROCESS USING vgdb (which you probably
|
||||||
|
==2732905== don't want to do, unless you know exactly what you're doing,
|
||||||
|
==2732905== or are doing some strange experiment):
|
||||||
|
==2732905== /usr/bin/vgdb --pid=2732905 ...command...
|
||||||
|
==2732905==
|
||||||
|
==2732905== TO DEBUG THIS PROCESS USING GDB: start GDB like this
|
||||||
|
==2732905== /path/to/gdb 0-build/apps/aqhome-react/aqhome-react
|
||||||
|
==2732905== and then give GDB the following command
|
||||||
|
==2732905== target remote | /usr/bin/vgdb --pid=2732905
|
||||||
|
==2732905== --pid is optional if only one valgrind process is running
|
||||||
|
==2732905==
|
||||||
|
--2732905-- REDIR: 0x40238e0 (ld-linux-x86-64.so.2:strlen) redirected to 0x580bb0e2 (vgPlain_amd64_linux_REDIR_FOR_strlen)
|
||||||
|
--2732905-- REDIR: 0x40220c0 (ld-linux-x86-64.so.2:index) redirected to 0x580bb0fc (vgPlain_amd64_linux_REDIR_FOR_index)
|
||||||
|
--2732905-- Reading syms from /usr/libexec/valgrind/vgpreload_core-amd64-linux.so
|
||||||
|
--2732905-- Considering /usr/lib/debug/.build-id/ad/f1388be4d8781737b0c83fe111a5a9c6e930aa.debug ..
|
||||||
|
--2732905-- .. build-id is valid
|
||||||
|
--2732905-- Reading syms from /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so
|
||||||
|
--2732905-- Considering /usr/lib/debug/.build-id/d8/ec66cffcb23a75c3f15940674d6028709121f8.debug ..
|
||||||
|
--2732905-- .. build-id is valid
|
||||||
|
==2732905== WARNING: new redirection conflicts with existing -- ignoring it
|
||||||
|
--2732905-- old: 0x040238e0 (strlen ) R-> (0000.0) 0x580bb0e2 vgPlain_amd64_linux_REDIR_FOR_strlen
|
||||||
|
--2732905-- new: 0x040238e0 (strlen ) R-> (2007.0) 0x048468a0 strlen
|
||||||
|
--2732905-- REDIR: 0x40222e0 (ld-linux-x86-64.so.2:strcmp) redirected to 0x4847780 (strcmp)
|
||||||
|
--2732905-- REDIR: 0x4021550 (ld-linux-x86-64.so.2:mempcpy) redirected to 0x484b1a0 (mempcpy)
|
||||||
|
--2732905-- Reading syms from /home/martin/projekte/c/0_current/hausbus/aqhome/0-build/aqhome/libaqhome.so.0.0.8
|
||||||
|
--2732905-- Reading syms from /usr/local/lib/libgwenhywfar.so.79.12.0
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/libm.so.6
|
||||||
|
--2732905-- Considering /usr/lib/debug/.build-id/6d/201df2cb50847f0ed42da4158c3a608d578f03.debug ..
|
||||||
|
--2732905-- .. build-id is valid
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/libc.so.6
|
||||||
|
--2732905-- Considering /usr/lib/debug/.build-id/c0/47672cae7964324658491e7dee26748ae5d2f8.debug ..
|
||||||
|
--2732905-- .. build-id is valid
|
||||||
|
==2732905== WARNING: new redirection conflicts with existing -- ignoring it
|
||||||
|
--2732905-- old: 0x04bad5d0 (memalign ) R-> (1011.0) 0x04845bc0 memalign
|
||||||
|
--2732905-- new: 0x04bad5d0 (memalign ) R-> (1017.0) 0x04845b90 aligned_alloc
|
||||||
|
==2732905== WARNING: new redirection conflicts with existing -- ignoring it
|
||||||
|
--2732905-- old: 0x04bad5d0 (memalign ) R-> (1011.0) 0x04845bc0 memalign
|
||||||
|
--2732905-- new: 0x04bad5d0 (memalign ) R-> (1017.0) 0x04845b60 aligned_alloc
|
||||||
|
==2732905== WARNING: new redirection conflicts with existing -- ignoring it
|
||||||
|
--2732905-- old: 0x04bad5d0 (memalign ) R-> (1011.0) 0x04845bc0 memalign
|
||||||
|
--2732905-- new: 0x04bad5d0 (memalign ) R-> (1017.0) 0x04845b90 aligned_alloc
|
||||||
|
==2732905== WARNING: new redirection conflicts with existing -- ignoring it
|
||||||
|
--2732905-- old: 0x04bad5d0 (memalign ) R-> (1011.0) 0x04845bc0 memalign
|
||||||
|
--2732905-- new: 0x04bad5d0 (memalign ) R-> (1017.0) 0x04845b60 aligned_alloc
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/libgpg-error.so.0.33.1
|
||||||
|
--2732905-- object doesn't have a symbol table
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/libgcrypt.so.20.4.1
|
||||||
|
--2732905-- object doesn't have a symbol table
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/libgnutls.so.30.34.3
|
||||||
|
--2732905-- object doesn't have a symbol table
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.3.0
|
||||||
|
--2732905-- object doesn't have a symbol table
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/libidn2.so.0.3.8
|
||||||
|
--2732905-- object doesn't have a symbol table
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/libunistring.so.2.2.0
|
||||||
|
--2732905-- object doesn't have a symbol table
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/libtasn1.so.6.6.3
|
||||||
|
--2732905-- object doesn't have a symbol table
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/libnettle.so.8.6
|
||||||
|
--2732905-- object doesn't have a symbol table
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/libhogweed.so.6.6
|
||||||
|
--2732905-- object doesn't have a symbol table
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/libgmp.so.10.4.1
|
||||||
|
--2732905-- object doesn't have a symbol table
|
||||||
|
--2732905-- Reading syms from /usr/lib/x86_64-linux-gnu/libffi.so.8.1.2
|
||||||
|
--2732905-- object doesn't have a symbol table
|
||||||
|
--2732905-- REDIR: 0x4bb3510 (libc.so.6:strnlen) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb35a0 (libc.so.6:strpbrk) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb16c0 (libc.so.6:strcmp) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bc64a0 (libc.so.6:wcsnlen) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb0800 (libc.so.6:memset) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bc4de0 (libc.so.6:wcslen) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bafe30 (libc.so.6:memcpy@@GLIBC_2.14) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bc4c10 (libc.so.6:wcschr) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb15b0 (libc.so.6:index) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb35d0 (libc.so.6:rindex) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bc4ca0 (libc.so.6:wcscmp) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb0a40 (libc.so.6:stpncpy) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bc51f0 (libc.so.6:wmemchr) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb33c0 (libc.so.6:strncmp) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb0ab0 (libc.so.6:strcasecmp) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb2920 (libc.so.6:strcspn) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bc4d30 (libc.so.6:wcscpy) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb1530 (libc.so.6:strcat) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb32b0 (libc.so.6:strncasecmp_l) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bafd40 (libc.so.6:bcmp) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb0770 (libc.so.6:memrchr) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb1630 (libc.so.6:strchrnul) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb28a0 (libc.so.6:strcpy) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb0b50 (libc.so.6:strcasecmp_l) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb3180 (libc.so.6:strlen) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb3460 (libc.so.6:strncpy) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb09c0 (libc.so.6:stpcpy) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb0550 (libc.so.6:memmove) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
==2732905== Preferring higher priority redirection:
|
||||||
|
--2732905-- old: 0x04c66940 (__memcpy_avx_unalign) R-> (2018.0) 0x04848a60 __memcpy_avx_unaligned_erms
|
||||||
|
--2732905-- new: 0x04c66940 (__memcpy_avx_unalign) R-> (2018.1) 0x0484a2b0 memmove
|
||||||
|
--2732905-- REDIR: 0x4bafcc0 (libc.so.6:memchr) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb3790 (libc.so.6:strspn) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb0660 (libc.so.6:mempcpy) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb3210 (libc.so.6:strncasecmp) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb0900 (libc.so.6:rawmemchr) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4bb3350 (libc.so.6:strncat) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4c2a050 (libc.so.6:__memcpy_chk) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
--2732905-- REDIR: 0x4c2a160 (libc.so.6:__memmove_chk) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
==2732905== WARNING: new redirection conflicts with existing -- ignoring it
|
||||||
|
--2732905-- old: 0x04c66900 (__memcpy_chk_avx_una) R-> (2030.0) 0x0484b290 __memcpy_chk
|
||||||
|
--2732905-- new: 0x04c66900 (__memcpy_chk_avx_una) R-> (2024.0) 0x0484ac30 __memmove_chk
|
||||||
|
--2732905-- REDIR: 0x4bb3f30 (libc.so.6:strstr) redirected to 0x48371b0 (_vgnU_ifunc_wrapper)
|
||||||
|
==2732905== WARNING: new redirection conflicts with existing -- ignoring it
|
||||||
|
--2732905-- old: 0x04c66900 (__memcpy_chk_avx_una) R-> (2030.0) 0x0484b290 __memcpy_chk
|
||||||
|
--2732905-- new: 0x04c66900 (__memcpy_chk_avx_una) R-> (2024.0) 0x0484ac30 __memmove_chk
|
||||||
|
--2732905-- REDIR: 0x4c6ca10 (libc.so.6:__strrchr_avx2) redirected to 0x48462e0 (rindex)
|
||||||
|
--2732905-- REDIR: 0x4c6a0c0 (libc.so.6:__strlen_avx2) redirected to 0x4846780 (strlen)
|
||||||
|
--2732905-- REDIR: 0x4c661e0 (libc.so.6:__memcmp_avx2_movbe) redirected to 0x4849aa0 (bcmp)
|
||||||
|
--2732905-- REDIR: 0x4c6b790 (libc.so.6:__strncmp_avx2) redirected to 0x4846ed0 (strncmp)
|
||||||
|
--2732905-- REDIR: 0x4c693a0 (libc.so.6:__strchr_avx2) redirected to 0x4846460 (index)
|
||||||
|
--2732905-- REDIR: 0x4c697d0 (libc.so.6:__strcmp_avx2) redirected to 0x4847680 (strcmp)
|
||||||
|
--2732905-- REDIR: 0x4bac8f0 (libc.so.6:malloc) redirected to 0x4840740 (malloc)
|
||||||
|
--2732905-- REDIR: 0x4c66940 (libc.so.6:__memcpy_avx_unaligned_erms) redirected to 0x484a2b0 (memmove)
|
||||||
|
--2732905-- REDIR: 0x4bad6a0 (libc.so.6:calloc) redirected to 0x4845540 (calloc)
|
||||||
|
--2732905-- REDIR: 0x4c66900 (libc.so.6:__memcpy_chk_avx_unaligned_erms) redirected to 0x484b290 (__memcpy_chk)
|
||||||
|
--2732905-- REDIR: 0x4baceb0 (libc.so.6:free) redirected to 0x4843110 (free)
|
||||||
|
--2732905-- REDIR: 0x4c68320 (libc.so.6:__strcasecmp_avx2) redirected to 0x4847050 (strcasecmp)
|
||||||
|
--2732905-- REDIR: 0x4c65f40 (libc.so.6:__memchr_avx2) redirected to 0x4847800 (memchr)
|
||||||
|
--2732905-- REDIR: 0x4bc41b0 (libc.so.6:__strstr_sse2_unaligned) redirected to 0x484b3a0 (strstr)
|
||||||
|
--2732905-- REDIR: 0x4bad0f0 (libc.so.6:realloc) redirected to 0x48457b0 (realloc)
|
||||||
|
--2732905-- REDIR: 0x4c67480 (libc.so.6:__rawmemchr_avx2) redirected to 0x484acd0 (rawmemchr)
|
||||||
|
--2732905-- REDIR: 0x4c695e0 (libc.so.6:__strchrnul_avx2) redirected to 0x484aca0 (strchrnul)
|
||||||
|
--2732905-- REDIR: 0x4c668f0 (libc.so.6:__mempcpy_avx_unaligned_erms) redirected to 0x484adb0 (mempcpy)
|
||||||
|
--2732905-- REDIR: 0x4c67340 (libc.so.6:__memset_avx2_unaligned_erms) redirected to 0x484a1c0 (memset)
|
||||||
|
--2732905-- REDIR: 0x4c675e0 (libc.so.6:__stpcpy_avx2) redirected to 0x4849b60 (stpcpy)
|
||||||
|
--2732905-- REDIR: 0x4c6c740 (libc.so.6:__strnlen_avx2) redirected to 0x4846720 (strnlen)
|
||||||
|
==2732905==
|
||||||
|
==2732905== HEAP SUMMARY:
|
||||||
|
==2732905== in use at exit: 192 bytes in 12 blocks
|
||||||
|
==2732905== total heap usage: 8,221 allocs, 8,209 frees, 1,218,973 bytes allocated
|
||||||
|
==2732905==
|
||||||
|
==2732905== Searching for pointers to 12 not-freed blocks
|
||||||
|
==2732905== Checked 279,376 bytes
|
||||||
|
==2732905==
|
||||||
|
==2732905== 48 bytes in 6 blocks are still reachable in loss record 1 of 2
|
||||||
|
==2732905== at 0x48407B4: malloc (vg_replace_malloc.c:381)
|
||||||
|
==2732905== by 0x4D323C0: ??? (in /usr/lib/x86_64-linux-gnu/libgcrypt.so.20.4.1)
|
||||||
|
==2732905== by 0x4D33B9F: ??? (in /usr/lib/x86_64-linux-gnu/libgcrypt.so.20.4.1)
|
||||||
|
==2732905== by 0x4E112D6: ??? (in /usr/lib/x86_64-linux-gnu/libgcrypt.so.20.4.1)
|
||||||
|
==2732905== by 0x4D32339: ??? (in /usr/lib/x86_64-linux-gnu/libgcrypt.so.20.4.1)
|
||||||
|
==2732905== by 0x4D333DE: ??? (in /usr/lib/x86_64-linux-gnu/libgcrypt.so.20.4.1)
|
||||||
|
==2732905== by 0x4D2E788: gcry_control (in /usr/lib/x86_64-linux-gnu/libgcrypt.so.20.4.1)
|
||||||
|
==2732905== by 0x4943601: GWEN_Crypt3_ModuleInit (cryptkey.c:36)
|
||||||
|
==2732905== by 0x49234C9: GWEN_Init (gwenhywfar.c:265)
|
||||||
|
==2732905== by 0x4921F98: GWEN_LibInit (init.c:48)
|
||||||
|
==2732905== by 0x40049CD: call_init (dl-init.c:74)
|
||||||
|
==2732905== by 0x40049CD: call_init (dl-init.c:26)
|
||||||
|
==2732905== by 0x4004AB3: _dl_init (dl-init.c:121)
|
||||||
|
==2732905== by 0x401AA7F: ??? (in /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
|
||||||
|
==2732905== by 0x8: ???
|
||||||
|
==2732905== by 0x1FFF000212: ???
|
||||||
|
==2732905== by 0x1FFF000239: ???
|
||||||
|
==2732905== by 0x1FFF00023C: ???
|
||||||
|
==2732905== by 0x1FFF00024F: ???
|
||||||
|
==2732905== by 0x1FFF000252: ???
|
||||||
|
==2732905== by 0x1FFF000266: ???
|
||||||
|
==2732905== by 0x1FFF00026A: ???
|
||||||
|
==2732905== by 0x1FFF000274: ???
|
||||||
|
==2732905== by 0x1FFF000277: ???
|
||||||
|
==2732905==
|
||||||
|
==2732905== 144 bytes in 6 blocks are still reachable in loss record 2 of 2
|
||||||
|
==2732905== at 0x48407B4: malloc (vg_replace_malloc.c:381)
|
||||||
|
==2732905== by 0x4D323C0: ??? (in /usr/lib/x86_64-linux-gnu/libgcrypt.so.20.4.1)
|
||||||
|
==2732905== by 0x4D33B9F: ??? (in /usr/lib/x86_64-linux-gnu/libgcrypt.so.20.4.1)
|
||||||
|
==2732905== by 0x4E112C9: ??? (in /usr/lib/x86_64-linux-gnu/libgcrypt.so.20.4.1)
|
||||||
|
==2732905== by 0x4D32339: ??? (in /usr/lib/x86_64-linux-gnu/libgcrypt.so.20.4.1)
|
||||||
|
==2732905== by 0x4D333DE: ??? (in /usr/lib/x86_64-linux-gnu/libgcrypt.so.20.4.1)
|
||||||
|
==2732905== by 0x4D2E788: gcry_control (in /usr/lib/x86_64-linux-gnu/libgcrypt.so.20.4.1)
|
||||||
|
==2732905== by 0x4943601: GWEN_Crypt3_ModuleInit (cryptkey.c:36)
|
||||||
|
==2732905== by 0x49234C9: GWEN_Init (gwenhywfar.c:265)
|
||||||
|
==2732905== by 0x4921F98: GWEN_LibInit (init.c:48)
|
||||||
|
==2732905== by 0x40049CD: call_init (dl-init.c:74)
|
||||||
|
==2732905== by 0x40049CD: call_init (dl-init.c:26)
|
||||||
|
==2732905== by 0x4004AB3: _dl_init (dl-init.c:121)
|
||||||
|
==2732905== by 0x401AA7F: ??? (in /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2)
|
||||||
|
==2732905== by 0x8: ???
|
||||||
|
==2732905== by 0x1FFF000212: ???
|
||||||
|
==2732905== by 0x1FFF000239: ???
|
||||||
|
==2732905== by 0x1FFF00023C: ???
|
||||||
|
==2732905== by 0x1FFF00024F: ???
|
||||||
|
==2732905== by 0x1FFF000252: ???
|
||||||
|
==2732905== by 0x1FFF000266: ???
|
||||||
|
==2732905== by 0x1FFF00026A: ???
|
||||||
|
==2732905== by 0x1FFF000274: ???
|
||||||
|
==2732905== by 0x1FFF000277: ???
|
||||||
|
==2732905==
|
||||||
|
==2732905== LEAK SUMMARY:
|
||||||
|
==2732905== definitely lost: 0 bytes in 0 blocks
|
||||||
|
==2732905== indirectly lost: 0 bytes in 0 blocks
|
||||||
|
==2732905== possibly lost: 0 bytes in 0 blocks
|
||||||
|
==2732905== still reachable: 192 bytes in 12 blocks
|
||||||
|
==2732905== suppressed: 0 bytes in 0 blocks
|
||||||
|
==2732905==
|
||||||
|
==2732905== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
|
||||||
@@ -64,29 +64,21 @@
|
|||||||
|
|
||||||
<subdirs>
|
<subdirs>
|
||||||
msg
|
msg
|
||||||
ipc
|
|
||||||
ipc2
|
ipc2
|
||||||
nodes
|
nodes
|
||||||
mqtt
|
|
||||||
hexfile
|
hexfile
|
||||||
data
|
data
|
||||||
events
|
|
||||||
events2
|
events2
|
||||||
client
|
|
||||||
</subdirs>
|
</subdirs>
|
||||||
|
|
||||||
|
|
||||||
<useTargets>
|
<useTargets>
|
||||||
aqhmsg
|
aqhmsg
|
||||||
aqhipc
|
|
||||||
aqhipc2
|
aqhipc2
|
||||||
aqhnodes
|
aqhnodes
|
||||||
aqhmqtt
|
|
||||||
aqhhexfile
|
aqhhexfile
|
||||||
aqhdata
|
aqhdata
|
||||||
aqhevents
|
|
||||||
aqhevents2
|
aqhevents2
|
||||||
aqhclient
|
|
||||||
</useTargets>
|
</useTargets>
|
||||||
|
|
||||||
<libraries>
|
<libraries>
|
||||||
|
|||||||
@@ -261,6 +261,12 @@ int AQH_ValueModality_fromString(const char *s)
|
|||||||
return AQH_ValueModality_RGBW;
|
return AQH_ValueModality_RGBW;
|
||||||
else if (strcasecmp(s, "motion")==0)
|
else if (strcasecmp(s, "motion")==0)
|
||||||
return AQH_ValueModality_Motion;
|
return AQH_ValueModality_Motion;
|
||||||
|
else if (strcasecmp(s, "co2")==0)
|
||||||
|
return AQH_ValueModality_Co2;
|
||||||
|
else if (strcasecmp(s, "tvoc")==0)
|
||||||
|
return AQH_ValueModality_TVOC;
|
||||||
|
else if (strcasecmp(s, "stats")==0)
|
||||||
|
return AQH_ValueModality_Stats;
|
||||||
}
|
}
|
||||||
return AQH_ValueModality_Unknown;
|
return AQH_ValueModality_Unknown;
|
||||||
}
|
}
|
||||||
@@ -276,6 +282,9 @@ const char *AQH_ValueModality_toString(int i)
|
|||||||
case AQH_ValueModality_RGB: return "rgb";
|
case AQH_ValueModality_RGB: return "rgb";
|
||||||
case AQH_ValueModality_RGBW: return "rgbw";
|
case AQH_ValueModality_RGBW: return "rgbw";
|
||||||
case AQH_ValueModality_Motion: return "motion";
|
case AQH_ValueModality_Motion: return "motion";
|
||||||
|
case AQH_ValueModality_Co2: return "co2";
|
||||||
|
case AQH_ValueModality_TVOC: return "tvoc";
|
||||||
|
case AQH_ValueModality_Stats: return "stats";
|
||||||
case AQH_ValueModality_Unknown:
|
case AQH_ValueModality_Unknown:
|
||||||
default: return "unknown";
|
default: return "unknown";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,10 @@ enum {
|
|||||||
AQH_ValueModality_Door,
|
AQH_ValueModality_Door,
|
||||||
AQH_ValueModality_RGB,
|
AQH_ValueModality_RGB,
|
||||||
AQH_ValueModality_RGBW,
|
AQH_ValueModality_RGBW,
|
||||||
AQH_ValueModality_Motion
|
AQH_ValueModality_Motion,
|
||||||
|
AQH_ValueModality_Co2,
|
||||||
|
AQH_ValueModality_TVOC,
|
||||||
|
AQH_ValueModality_Stats
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
<?xml?>
|
|
||||||
|
|
||||||
<gwbuild>
|
|
||||||
|
|
||||||
<target type="ConvenienceLibrary" name="aqhclient" >
|
|
||||||
|
|
||||||
<includes type="c" >
|
|
||||||
$(gwenhywfar_cflags)
|
|
||||||
-I$(topsrcdir)
|
|
||||||
-I$(topbuilddir)
|
|
||||||
</includes>
|
|
||||||
|
|
||||||
<includes type="tm2" >
|
|
||||||
--include=$(builddir)
|
|
||||||
--include=$(srcdir)
|
|
||||||
</includes>
|
|
||||||
|
|
||||||
|
|
||||||
<define name="BUILDING_AQHOME" />
|
|
||||||
|
|
||||||
<setVar name="local/cflags">$(visibility_cflags)</setVar>
|
|
||||||
|
|
||||||
|
|
||||||
<setVar name="tm2flags" >
|
|
||||||
--api=AQHOME_API
|
|
||||||
</setVar>
|
|
||||||
|
|
||||||
<setVar name="local/typefiles" >
|
|
||||||
</setVar>
|
|
||||||
|
|
||||||
<setVar name="local/built_sources" >
|
|
||||||
</setVar>
|
|
||||||
|
|
||||||
<setVar name="local/built_headers_pub">
|
|
||||||
</setVar>
|
|
||||||
|
|
||||||
|
|
||||||
<setVar name="local/built_headers_priv" >
|
|
||||||
</setVar>
|
|
||||||
|
|
||||||
|
|
||||||
<headers dist="false" install="$(pkgincludedir)/client" >
|
|
||||||
$(local/built_headers_pub)
|
|
||||||
</headers>
|
|
||||||
|
|
||||||
|
|
||||||
<headers dist="true" install="$(pkgincludedir)/client" >
|
|
||||||
connection.h
|
|
||||||
</headers>
|
|
||||||
|
|
||||||
|
|
||||||
<headers dist="true" >
|
|
||||||
</headers>
|
|
||||||
|
|
||||||
|
|
||||||
<sources>
|
|
||||||
$(local/typefiles)
|
|
||||||
|
|
||||||
connection.c
|
|
||||||
</sources>
|
|
||||||
|
|
||||||
|
|
||||||
<extradist>
|
|
||||||
</extradist>
|
|
||||||
|
|
||||||
|
|
||||||
<useTargets>
|
|
||||||
</useTargets>
|
|
||||||
|
|
||||||
<subdirs>
|
|
||||||
</subdirs>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</target>
|
|
||||||
|
|
||||||
</gwbuild>
|
|
||||||
@@ -1,175 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* This file is part of the project AqHome.
|
|
||||||
* AqHome (c) by 2024 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 "./connection.h"
|
|
||||||
|
|
||||||
#include "aqhome/ipc/endpoint_ipc.h"
|
|
||||||
#include "aqhome/ipc/endpoint_ipcclient.h"
|
|
||||||
#include "aqhome/ipc/data/ipc_data.h"
|
|
||||||
#include "aqhome/ipc/data/msg_data_connect.h"
|
|
||||||
#include "aqhome/ipc/msg_ipc_result.h"
|
|
||||||
|
|
||||||
#include <gwenhywfar/endpoint_tcpc.h>
|
|
||||||
#include <gwenhywfar/endpoint_multilayer.h>
|
|
||||||
#include <gwenhywfar/msg_ipc.h>
|
|
||||||
#include <gwenhywfar/debug.h>
|
|
||||||
#include <gwenhywfar/timestamp.h>
|
|
||||||
#include <gwenhywfar/db.h>
|
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GWEN_MSG_ENDPOINT *_physConnectToBroker(const char *addr, int port, const char *clientId, uint32_t flags);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int AQH_BrokerConnection_FlushOutMessageQueue(GWEN_MSG_ENDPOINT *epTcp, int timeoutInSeconds)
|
|
||||||
{
|
|
||||||
time_t startTime;
|
|
||||||
|
|
||||||
startTime=time(NULL);
|
|
||||||
|
|
||||||
while(GWEN_MsgEndpoint_HaveMessageToSend(epTcp)) {
|
|
||||||
time_t now;
|
|
||||||
|
|
||||||
GWEN_MsgEndpoint_IoLoop(epTcp, 1000); /* 1000 ms */
|
|
||||||
now=time(NULL);
|
|
||||||
if (now-startTime>timeoutInSeconds) {
|
|
||||||
DBG_INFO(AQH_LOGDOMAIN, "Timeout");
|
|
||||||
return GWEN_ERROR_TIMEOUT;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GWEN_MSG *AQH_BrokerConnection_WaitForSpecificMessage(GWEN_MSG_ENDPOINT *epTcp, int msgCode, int timeoutInSeconds)
|
|
||||||
{
|
|
||||||
time_t startTime;
|
|
||||||
|
|
||||||
startTime=time(NULL);
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
GWEN_MSG *msg;
|
|
||||||
time_t now;
|
|
||||||
|
|
||||||
GWEN_MsgEndpoint_IoLoop(epTcp, 1000); /* 1000 ms */
|
|
||||||
msg=GWEN_MsgEndpoint_TakeFirstReceivedMessage(epTcp);
|
|
||||||
if (msg) {
|
|
||||||
uint16_t code;
|
|
||||||
|
|
||||||
code=GWEN_IpcMsg_GetCode(msg);
|
|
||||||
if (code==msgCode) {
|
|
||||||
DBG_INFO(AQH_LOGDOMAIN, "Received expected IPC message");
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
else if (code==AQH_MSGTYPE_IPC_DATA_RESULT) {
|
|
||||||
DBG_INFO(AQH_LOGDOMAIN, "Received IPC result message");
|
|
||||||
return msg;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
DBG_INFO(AQH_LOGDOMAIN, "Received unexpected message %d (%x)", code, code);
|
|
||||||
}
|
|
||||||
GWEN_Msg_free(msg);
|
|
||||||
}
|
|
||||||
now=time(NULL);
|
|
||||||
if (now-startTime>timeoutInSeconds) {
|
|
||||||
DBG_INFO(AQH_LOGDOMAIN, "Timeout");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GWEN_MSG_ENDPOINT *AQH_BrokerConnection_OpenConnection(const char *addr, int port,
|
|
||||||
const char *clientId,
|
|
||||||
const char *userId, const char *passwd,
|
|
||||||
uint32_t flags,
|
|
||||||
int timeoutInSeconds)
|
|
||||||
{
|
|
||||||
GWEN_MSG_ENDPOINT *epTcp;
|
|
||||||
GWEN_MSG *msgOut;
|
|
||||||
GWEN_MSG *msgIn;
|
|
||||||
uint32_t result;
|
|
||||||
|
|
||||||
epTcp=_physConnectToBroker(addr, port, clientId, 0);
|
|
||||||
if (epTcp==NULL) {
|
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "ERROR creating TCP connection");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
msgOut=AQH_ConnectDataIpcMsg_new(AQH_MSGTYPE_IPC_DATA_CONNECT_REQ,
|
|
||||||
GWEN_MsgEndpoint_GetNextMessageId(epTcp), 0,
|
|
||||||
clientId, userId, passwd, flags);
|
|
||||||
if (msgOut==NULL) {
|
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "Error creating message");
|
|
||||||
GWEN_MsgEndpoint_free(epTcp);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
GWEN_MsgEndpoint_AddSendMessage(epTcp, msgOut);
|
|
||||||
|
|
||||||
msgIn=AQH_BrokerConnection_WaitForSpecificMessage(epTcp, AQH_MSGTYPE_IPC_DATA_RESULT, timeoutInSeconds);
|
|
||||||
if (msgIn==NULL) {
|
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "No response received");
|
|
||||||
GWEN_MsgEndpoint_free(epTcp);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
result=AQH_ResultIpcMsg_GetResultCode(msgIn);
|
|
||||||
GWEN_Msg_free(msgIn);
|
|
||||||
|
|
||||||
if (result!=AQH_MSG_IPC_SUCCESS) {
|
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "Response: %d", result);
|
|
||||||
GWEN_MsgEndpoint_free(epTcp);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return epTcp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GWEN_MSG_ENDPOINT *_physConnectToBroker(const char *addr, int port, const char *clientId, uint32_t flags)
|
|
||||||
{
|
|
||||||
GWEN_MSG_ENDPOINT *ep;
|
|
||||||
GWEN_MSG_ENDPOINT *ipcBaseEndpoint;
|
|
||||||
int rv;
|
|
||||||
|
|
||||||
ep=AQH_ClientIpcEndpoint_new("brokerIpcClient", 0);
|
|
||||||
GWEN_MsgEndpoint_AddFlags(ep, flags);
|
|
||||||
|
|
||||||
ipcBaseEndpoint=AQH_IpcEndpoint_CreateIpcTcpClient(addr, port, "brokerPhysEndpoint", 0);
|
|
||||||
AQH_IpcEndpoint_SetServiceName(ipcBaseEndpoint, clientId);
|
|
||||||
GWEN_MsgEndpoint_Tree2_AddChild(ep, ipcBaseEndpoint);
|
|
||||||
|
|
||||||
rv=GWEN_MultilayerEndpoint_StartConnect(ep);
|
|
||||||
if (rv<0 && rv!=GWEN_ERROR_IN_PROGRESS) {
|
|
||||||
DBG_ERROR(AQH_LOGDOMAIN, "Error connecting to broker server %s:%d (%d)", addr, port, rv);
|
|
||||||
GWEN_MsgEndpoint_free(ep);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ep;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* This file is part of the project AqHome.
|
|
||||||
* AqHome (c) by 2024 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 AQHOME_CLIENT_CONNECTION_H
|
|
||||||
#define AQHOME_CLIENT_CONNECTION_H
|
|
||||||
|
|
||||||
|
|
||||||
#include <aqhome/api.h>
|
|
||||||
|
|
||||||
#include <gwenhywfar/endpoint.h>
|
|
||||||
|
|
||||||
|
|
||||||
GWEN_MSG_ENDPOINT *AQH_BrokerConnection_OpenConnection(const char *addr, int port,
|
|
||||||
const char *clientId,
|
|
||||||
const char *userId, const char *passwd,
|
|
||||||
uint32_t flags,
|
|
||||||
int timeoutInSeconds);
|
|
||||||
int AQH_BrokerConnection_FlushOutMessageQueue(GWEN_MSG_ENDPOINT *epTcp, int timeoutInSeconds);
|
|
||||||
GWEN_MSG *AQH_BrokerConnection_WaitForSpecificMessage(GWEN_MSG_ENDPOINT *epTcp, int msgCode, int timeoutInSeconds);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user