aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--nbproject/configurations.xml336
-rw-r--r--nbproject/project.xml26
-rw-r--r--plugin/most_unicens.c60
-rw-r--r--plugin/ucs2-vol/inc/device_value.h9
-rw-r--r--plugin/ucs2-vol/inc/libmostvolume.h3
-rw-r--r--plugin/ucs2-vol/inc/setup.h2
-rw-r--r--plugin/ucs2-vol/src/device_container.cpp23
-rw-r--r--plugin/ucs2-vol/src/device_value.cpp31
-rw-r--r--plugin/ucs2-vol/src/setup.cpp26
-rw-r--r--plugin/wrap_unicens.c40
-rw-r--r--plugin/wrap_unicens.h2
-rw-r--r--plugin/wrap_volume.c3
13 files changed, 500 insertions, 62 deletions
diff --git a/.gitignore b/.gitignore
index 567609b..2d6a731 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
build/
+nbproject/private/
diff --git a/nbproject/configurations.xml b/nbproject/configurations.xml
new file mode 100644
index 0000000..58366d2
--- /dev/null
+++ b/nbproject/configurations.xml
@@ -0,0 +1,336 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configurationDescriptor version="100">
+ <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">
+ <df root="." name="0">
+ <df name="afb-helpers">
+ <in>curl-wrap.c</in>
+ <in>escape.c</in>
+ <in>filescan-utils.c</in>
+ <in>qafbwebsocketclient.cpp</in>
+ <in>wrap-json.c</in>
+ </df>
+ <df name="app-controller">
+ <df name="ctl-lib">
+ <in>ctl-action.c</in>
+ <in>ctl-config.c</in>
+ <in>ctl-control.c</in>
+ <in>ctl-event.c</in>
+ <in>ctl-lua-utils.c</in>
+ <in>ctl-lua.c</in>
+ <in>ctl-onload.c</in>
+ <in>ctl-plugin.c</in>
+ <in>ctl-timer.c</in>
+ </df>
+ </df>
+ <df name="plugin">
+ <df name="ucs2-vol">
+ <df name="src">
+ <in>device_container.cpp</in>
+ <in>device_value.cpp</in>
+ <in>libmostvolume.cpp</in>
+ <in>setup.cpp</in>
+ </df>
+ </df>
+ <in>most_unicens.c</in>
+ <in>wrap_unicens.c</in>
+ <in>wrap_volume.c</in>
+ </df>
+ </df>
+ <logicalFolder name="ExternalFiles"
+ displayName="Important Files"
+ projectFiles="false"
+ kind="IMPORTANT_FILES_FOLDER">
+ <itemPath>CMakeLists.txt</itemPath>
+ <itemPath>Makefile</itemPath>
+ <itemPath>nbproject/private/launcher.properties</itemPath>
+ </logicalFolder>
+ </logicalFolder>
+ <sourceFolderFilter>^(nbproject)$</sourceFolderFilter>
+ <sourceRootList>
+ <Elem>.</Elem>
+ </sourceRootList>
+ <projectmakefile>Makefile</projectmakefile>
+ <confs>
+ <conf name="Default" type="0">
+ <toolsSet>
+ <compilerSet>default</compilerSet>
+ <dependencyChecking>false</dependencyChecking>
+ <rebuildPropChanged>false</rebuildPropChanged>
+ </toolsSet>
+ <flagsDictionary>
+ <element flagsID="0" commonFlags="-O3 -fPIC -fPIC -O2"/>
+ <element flagsID="1" commonFlags="-std=c++14"/>
+ </flagsDictionary>
+ <codeAssistance>
+ </codeAssistance>
+ <makefileType>
+ <makeTool>
+ <buildCommandWorkingDir>./build</buildCommandWorkingDir>
+ <buildCommand>${MAKE} -f Makefile</buildCommand>
+ <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>
+ <executablePath></executablePath>
+ </makeTool>
+ <preBuild>
+ <preBuildCommandWorkingDir>./build</preBuildCommandWorkingDir>
+ <preBuildCommand>cmake ..</preBuildCommand>
+ </preBuild>
+ </makefileType>
+ <item path="afb-helpers/curl-wrap.c" ex="false" tool="0" flavor2="2">
+ </item>
+ <item path="afb-helpers/escape.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="0">
+ <incDir>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>/opt/AGL/include</pElem>
+ <pElem>/usr/include/p11-kit-1</pElem>
+ <pElem>/usr/include/uuid</pElem>
+ <pElem>/usr/include/alsa</pElem>
+ <pElem>/usr/include/lua5.3</pElem>
+ <pElem>afb-helpers</pElem>
+ <pElem>build/afb-helpers</pElem>
+ </incDir>
+ <preprocessorList>
+ <Elem>AFB_BINDING_VERSION=3</Elem>
+ <Elem>AFB_BINDING_WANT_DYNAPI=1</Elem>
+ <Elem>CONTROL_CONFIG_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/conf.d/project/etc:/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/build/package/etc:/usr/local/4a-hal/etc"</Elem>
+ <Elem>CONTROL_LUA_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/conf.d/project/lua.d:/usr/local/4a-hal/var"</Elem>
+ <Elem>CONTROL_PLUGIN_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/build/package/lib/plugins:/usr/local/4a-hal/lib/plugins"</Elem>
+ <Elem>CTL_PLUGIN_MAGIC=7053042648</Elem>
+ <Elem>NDEBUG</Elem>
+ <Elem>SUSE_LUA_INCDIR</Elem>
+ <Elem>_FORTIFY_SOURCE=2</Elem>
+ </preprocessorList>
+ </cTool>
+ </item>
+ <item path="afb-helpers/filescan-utils.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="0">
+ <incDir>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>/opt/AGL/include</pElem>
+ <pElem>/usr/include/p11-kit-1</pElem>
+ <pElem>/usr/include/uuid</pElem>
+ <pElem>/usr/include/alsa</pElem>
+ <pElem>/usr/include/lua5.3</pElem>
+ <pElem>afb-helpers</pElem>
+ <pElem>build/afb-helpers</pElem>
+ </incDir>
+ <preprocessorList>
+ <Elem>AFB_BINDING_VERSION=3</Elem>
+ <Elem>AFB_BINDING_WANT_DYNAPI=1</Elem>
+ <Elem>CONTROL_CONFIG_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/conf.d/project/etc:/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/build/package/etc:/usr/local/4a-hal/etc"</Elem>
+ <Elem>CONTROL_LUA_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/conf.d/project/lua.d:/usr/local/4a-hal/var"</Elem>
+ <Elem>CONTROL_PLUGIN_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/build/package/lib/plugins:/usr/local/4a-hal/lib/plugins"</Elem>
+ <Elem>CTL_PLUGIN_MAGIC=7053042648</Elem>
+ <Elem>NDEBUG</Elem>
+ <Elem>SUSE_LUA_INCDIR</Elem>
+ <Elem>_FORTIFY_SOURCE=2</Elem>
+ </preprocessorList>
+ </cTool>
+ </item>
+ <item path="afb-helpers/qafbwebsocketclient.cpp"
+ ex="false"
+ tool="1"
+ flavor2="11">
+ <ccTool flags="1">
+ </ccTool>
+ </item>
+ <item path="afb-helpers/wrap-json.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="0">
+ <incDir>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>/opt/AGL/include</pElem>
+ <pElem>/usr/include/p11-kit-1</pElem>
+ <pElem>/usr/include/uuid</pElem>
+ <pElem>/usr/include/alsa</pElem>
+ <pElem>/usr/include/lua5.3</pElem>
+ <pElem>afb-helpers</pElem>
+ <pElem>build/afb-helpers</pElem>
+ </incDir>
+ <preprocessorList>
+ <Elem>AFB_BINDING_VERSION=3</Elem>
+ <Elem>AFB_BINDING_WANT_DYNAPI=1</Elem>
+ <Elem>CONTROL_CONFIG_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/conf.d/project/etc:/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/build/package/etc:/usr/local/4a-hal/etc"</Elem>
+ <Elem>CONTROL_LUA_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/conf.d/project/lua.d:/usr/local/4a-hal/var"</Elem>
+ <Elem>CONTROL_PLUGIN_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/build/package/lib/plugins:/usr/local/4a-hal/lib/plugins"</Elem>
+ <Elem>CTL_PLUGIN_MAGIC=7053042648</Elem>
+ <Elem>NDEBUG</Elem>
+ <Elem>SUSE_LUA_INCDIR</Elem>
+ <Elem>_FORTIFY_SOURCE=2</Elem>
+ </preprocessorList>
+ </cTool>
+ </item>
+ <item path="app-controller/ctl-lib/ctl-action.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="app-controller/ctl-lib/ctl-config.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="app-controller/ctl-lib/ctl-control.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="app-controller/ctl-lib/ctl-event.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="app-controller/ctl-lib/ctl-lua-utils.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="app-controller/ctl-lib/ctl-lua.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="app-controller/ctl-lib/ctl-onload.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="app-controller/ctl-lib/ctl-plugin.c"
+ ex="false"
+ tool="0"
+ flavor2="0">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="app-controller/ctl-lib/ctl-timer.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <folder path="0/app-controller">
+ <cTool>
+ <incDir>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>/opt/AGL/include</pElem>
+ <pElem>/usr/include/p11-kit-1</pElem>
+ <pElem>/usr/include/uuid</pElem>
+ <pElem>/usr/include/alsa</pElem>
+ <pElem>/usr/include/lua5.3</pElem>
+ <pElem>app-controller/ctl-lib</pElem>
+ <pElem>afb-helpers</pElem>
+ <pElem>build/app-controller/ctl-lib</pElem>
+ </incDir>
+ <preprocessorList>
+ <Elem>AFB_BINDING_VERSION=3</Elem>
+ <Elem>AFB_BINDING_WANT_DYNAPI=1</Elem>
+ <Elem>CONTROL_CONFIG_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/conf.d/project/etc:/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/build/package/etc:/usr/local/4a-hal/etc"</Elem>
+ <Elem>CONTROL_LUA_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/conf.d/project/lua.d:/usr/local/4a-hal/var"</Elem>
+ <Elem>CONTROL_PLUGIN_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/build/package/lib/plugins:/usr/local/4a-hal/lib/plugins"</Elem>
+ <Elem>CONTROL_SUPPORT_LUA</Elem>
+ <Elem>CTL_PLUGIN_MAGIC=7053042648</Elem>
+ <Elem>NDEBUG</Elem>
+ <Elem>SUSE_LUA_INCDIR</Elem>
+ <Elem>_FORTIFY_SOURCE=2</Elem>
+ </preprocessorList>
+ </cTool>
+ </folder>
+ <folder path="0/plugin">
+ <cTool>
+ <incDir>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>/opt/AGL/include</pElem>
+ <pElem>/usr/include/p11-kit-1</pElem>
+ <pElem>/usr/include/uuid</pElem>
+ <pElem>/usr/include/alsa</pElem>
+ <pElem>/usr/include/lua5.3</pElem>
+ <pElem>app-controller/ctl-lib</pElem>
+ <pElem>4a-hal/4a-hal-controllers</pElem>
+ <pElem>4a-hal/4a-hal-manager</pElem>
+ <pElem>4a-hal/4a-hal-utilities</pElem>
+ <pElem>plugin/ucs2-vol/inc</pElem>
+ <pElem>afb-helpers</pElem>
+ <pElem>build/plugin</pElem>
+ </incDir>
+ <preprocessorList>
+ <Elem>AFB_BINDING_VERSION=3</Elem>
+ <Elem>AFB_BINDING_WANT_DYNAPI=1</Elem>
+ <Elem>CONTROL_CONFIG_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/conf.d/project/etc:/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/build/package/etc:/usr/local/4a-hal/etc"</Elem>
+ <Elem>CONTROL_LUA_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/conf.d/project/lua.d:/usr/local/4a-hal/var"</Elem>
+ <Elem>CONTROL_PLUGIN_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/build/package/lib/plugins:/usr/local/4a-hal/lib/plugins"</Elem>
+ <Elem>CTL_PLUGIN_MAGIC=7053042648</Elem>
+ <Elem>NDEBUG</Elem>
+ <Elem>SUSE_LUA_INCDIR</Elem>
+ <Elem>_FORTIFY_SOURCE=2</Elem>
+ <Elem>hal_unicens_EXPORTS</Elem>
+ </preprocessorList>
+ </cTool>
+ <ccTool>
+ <incDir>
+ <pElem>/usr/include/json-c</pElem>
+ <pElem>/opt/AGL/include</pElem>
+ <pElem>/usr/include/p11-kit-1</pElem>
+ <pElem>/usr/include/uuid</pElem>
+ <pElem>/usr/include/alsa</pElem>
+ <pElem>/usr/include/lua5.3</pElem>
+ <pElem>plugin/ucs2-vol/inc</pElem>
+ <pElem>build/plugin/ucs2-vol/src</pElem>
+ </incDir>
+ <preprocessorList>
+ <Elem>AFB_BINDING_VERSION=3</Elem>
+ <Elem>AFB_BINDING_WANT_DYNAPI=1</Elem>
+ <Elem>CONTROL_CONFIG_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/conf.d/project/etc:/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/build/package/etc:/usr/local/4a-hal/etc"</Elem>
+ <Elem>CONTROL_LUA_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/conf.d/project/lua.d:/usr/local/4a-hal/var"</Elem>
+ <Elem>CONTROL_PLUGIN_PATH="/home/M21106/Development/agl/git/4a-hal-integration/4a-hal-unicens/build/package/lib/plugins:/usr/local/4a-hal/lib/plugins"</Elem>
+ <Elem>CTL_PLUGIN_MAGIC=7053042648</Elem>
+ <Elem>NDEBUG</Elem>
+ <Elem>SUSE_LUA_INCDIR</Elem>
+ <Elem>_FORTIFY_SOURCE=2</Elem>
+ </preprocessorList>
+ </ccTool>
+ </folder>
+ <item path="plugin/most_unicens.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="plugin/ucs2-vol/src/device_container.cpp"
+ ex="false"
+ tool="1"
+ flavor2="0">
+ <ccTool flags="0">
+ </ccTool>
+ </item>
+ <item path="plugin/ucs2-vol/src/device_value.cpp"
+ ex="false"
+ tool="1"
+ flavor2="0">
+ <ccTool flags="0">
+ </ccTool>
+ </item>
+ <item path="plugin/ucs2-vol/src/libmostvolume.cpp"
+ ex="false"
+ tool="1"
+ flavor2="0">
+ <ccTool flags="0">
+ </ccTool>
+ </item>
+ <item path="plugin/ucs2-vol/src/setup.cpp" ex="false" tool="1" flavor2="0">
+ <ccTool flags="0">
+ </ccTool>
+ </item>
+ <item path="plugin/wrap_unicens.c" ex="false" tool="0" flavor2="0">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ <item path="plugin/wrap_volume.c" ex="false" tool="0" flavor2="2">
+ <cTool flags="0">
+ </cTool>
+ </item>
+ </conf>
+ </confs>
+</configurationDescriptor>
diff --git a/nbproject/project.xml b/nbproject/project.xml
new file mode 100644
index 0000000..1ef2f4f
--- /dev/null
+++ b/nbproject/project.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://www.netbeans.org/ns/project/1">
+ <type>org.netbeans.modules.cnd.makeproject</type>
+ <configuration>
+ <data xmlns="http://www.netbeans.org/ns/make-project/1">
+ <name>4a-hal-unicens</name>
+ <c-extensions>c</c-extensions>
+ <cpp-extensions>cpp,cxx</cpp-extensions>
+ <header-extensions>h,hpp</header-extensions>
+ <sourceEncoding>UTF-8</sourceEncoding>
+ <make-dep-projects/>
+ <sourceRootList>
+ <sourceRootElem>.</sourceRootElem>
+ </sourceRootList>
+ <confList>
+ <confElem>
+ <name>Default</name>
+ <type>0</type>
+ </confElem>
+ </confList>
+ <formatting>
+ <project-formatting-style>false</project-formatting-style>
+ </formatting>
+ </data>
+ </configuration>
+</project>
diff --git a/plugin/most_unicens.c b/plugin/most_unicens.c
index dc92857..b182c50 100644
--- a/plugin/most_unicens.c
+++ b/plugin/most_unicens.c
@@ -42,7 +42,7 @@ static uint8_t initialized = 0;
// Call at initialisation time
CTLP_ONLOAD(plugin, callbacks)
{
- AFB_ApiNotice(plugin->api, "Hal-Unicens Plugin Register: uid='%s' 'info='%s'", plugin->uid, plugin->info);
+ AFB_ApiNotice(plugin->api, "OWN REPO HAL !!! Hal-Unicens Plugin Register: uid='%s' 'info='%s'", plugin->uid, plugin->info);
unicensHalApiHandle = plugin->api;
@@ -55,7 +55,7 @@ CTLP_CAPI(MasterVol, source, argsJ, queryJ)
json_object *valueJ;
- AFB_ApiNotice(source->api, "Hal-Unicens: MasterVolume=%s", json_object_to_json_string(queryJ));
+ AFB_ApiNotice(source->api, "OWN REPO HAL !!! Hal-Unicens: MasterVolume=%s", json_object_to_json_string(queryJ));
if(! initialized) {
AFB_ApiWarning(source->api, "%s: Link to unicens binder is not initialized, can't set master volume, value=%s", __func__, json_object_get_string(queryJ));
@@ -84,7 +84,7 @@ CTLP_CAPI(MasterSwitch, source, argsJ, queryJ)
json_bool master_switch;
json_object *valueJ;
- AFB_ApiNotice(source->api, "Hal-Unicens: MasterSwitch=%s", json_object_to_json_string(queryJ));
+ AFB_ApiNotice(source->api, "OWN REPO HAL !!! Hal-Unicens: MasterSwitch=%s", json_object_to_json_string(queryJ));
if(! initialized) {
AFB_ApiWarning(source->api, "%s: Link to unicens binder is not initialized, can't set master switch, value=%s", __func__, json_object_get_string(queryJ));
@@ -125,7 +125,7 @@ CTLP_CAPI(PCMVol, source, argsJ, queryJ)
json_object *valueJ;
- AFB_ApiNotice(source->api, "Hal-Unicens: PCMVolume=%s", json_object_to_json_string(queryJ));
+ AFB_ApiNotice(source->api, "OWN REPO HAL !!! Hal-Unicens: PCMVolume=%s", json_object_to_json_string(queryJ));
if(! initialized) {
AFB_ApiWarning(source->api, "%s: Link to unicens binder is not initialized, can't set PCM volume, value=%s", __func__, json_object_get_string(queryJ));
@@ -160,26 +160,26 @@ CTLP_CAPI(PCMVol, source, argsJ, queryJ)
CTLP_CAPI(Init, source, argsJ, queryJ)
{
int err = 0;
- int pcm_volume[PCM_MAX_CHANNELS] = { 80, 80, 80, 80, 80, 80 };
-
- AFB_ApiNotice(source->api, "Initializing HAL-MOST-UNICENS-BINDING");
-
- if((err = wrap_ucs_subscribe_sync(source->api))) {
- AFB_ApiError(source->api, "Failed to subscribe to UNICENS binding");
- return err;
- }
+ //int pcm_volume[PCM_MAX_CHANNELS] = { 80, 80, 80, 80, 80, 80 };
+ AFB_ApiNotice(source->api, "OWN REPO HAL !!! Initializing HAL-MOST-UNICENS-BINDING");
+
if((err = wrap_volume_init())) {
AFB_ApiError(source->api, "Failed to initialize wrapper for volume library");
return err;
}
+
+ if((err = wrap_ucs_subscribe_sync(source->api))) {
+ AFB_ApiError(source->api, "Failed to subscribe to UNICENS binding");
+ return err;
+ }
// Set output volume to pre-defined level in order to
// avoid muted volume to be persistent after boot.
- wrap_volume_master(source->api, 80);
- wrap_volume_pcm(source->api, pcm_volume, PCM_MAX_CHANNELS);
+ //wrap_volume_master(source->api, 80);
+ //wrap_volume_pcm(source->api, pcm_volume, PCM_MAX_CHANNELS);
- AFB_ApiNotice(source->api, "Initializing HAL-MOST-UNICENS-BINDING done..");
+ AFB_ApiNotice(source->api, "OWN REPO HAL !!! Initializing HAL-MOST-UNICENS-BINDING done..");
initialized = 1;
@@ -191,45 +191,35 @@ CTLP_CAPI(Events, source, argsJ, queryJ)
{
uint16_t node = 0U;
bool available = false;
- bool error = false;
+ int error = false;
json_object *j_tmp = NULL;
+ if (initialized == 0) {
+ AFB_ApiError(source->api, "Hal-Unicens: Not initialized while receiving event query=%s", json_object_to_json_string(queryJ));
+ return 0;
+ }
+
if (json_object_object_get_ex(queryJ, "node", &j_tmp)) {
node = (uint16_t)json_object_get_int(j_tmp);
}
else {
- error = true;
+ error = -1;
}
if (json_object_object_get_ex(queryJ, "available", &j_tmp)) {
available = (bool)json_object_get_boolean(j_tmp);
}
else {
- error = true;
+ error = -2;
}
if(!error) {
- AFB_ApiNotice(source->api, "Node-Availability: node=0x%03X, available=%d", node, available);
+ AFB_ApiNotice(source->api, "OWN REPO HAL !!! Node-Availability: node=0x%03X, available=%d", node, available);
wrap_volume_node_avail(source->api, node, available);
}
else {
AFB_ApiError(source->api, "Hal-Unicens: Failed to parse events query=%s", json_object_to_json_string(queryJ));
}
- return 0;
+ return error;
}
-
-// This is the former implementation receiving UNICENS events,
-// wrap_json_unpack() seems not to work as expected.
-/*CTLP_CAPI(Events, source, argsJ, queryJ)
-{
- int node;
- int available;
-
- if(wrap_json_unpack(queryJ, "{s:i,s:b}", "node", &node, "available", &available)) {
- AFB_ApiNotice(source->api, "Node-Availability: node=0x%03X, available=%d", node, available);
- wrap_volume_node_avail(source->api, node, available);
- }
-
- return 0;
-}*/
diff --git a/plugin/ucs2-vol/inc/device_value.h b/plugin/ucs2-vol/inc/device_value.h
index fe6d3a5..ef57003 100644
--- a/plugin/ucs2-vol/inc/device_value.h
+++ b/plugin/ucs2-vol/inc/device_value.h
@@ -53,13 +53,14 @@ struct STxMessage {
enum DeviceValueType {
DEVICE_VAL_MASTER = 0,
DEVICE_VAL_LEFT = 1,
- DEVICE_VAL_RIGHT = 2
+ DEVICE_VAL_RIGHT = 2,
+ DEVICE_VAL_FIBERDYNE_MASTER = 3
};
class CDeviceValue {
public:
- CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key);
+ CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key, bool is_i2c);
virtual ~CDeviceValue();
uint16_t GetKey(){return _key;}
@@ -72,7 +73,8 @@ public:
bool FireUpdateMessage(lib_most_volume_writei2c_cb_t writei2c_fptr,
lib_most_volume_writei2c_result_cb_t result_fptr,
void *result_user_ptr);// fires message & updates actual value
-
+ bool FireControlMessage(lib_most_volume_sendmessage_cb_t sendmsg_fptr);
+
void SetAvailable(bool active){this->_is_available = active; _actual_value = 0x01u;}
bool IsAvailable() {return this->_is_available;}
uint16_t GetAddress() {return this->_address;}
@@ -84,6 +86,7 @@ private:
bool _is_available; // related node is available
bool _is_busy; // do not update while busy
+ bool _is_i2c;
DeviceValueType _type; // determines the remote i2c command
uint16_t _key; // lookup key
uint16_t _address; // target node/group address
diff --git a/plugin/ucs2-vol/inc/libmostvolume.h b/plugin/ucs2-vol/inc/libmostvolume.h
index 1147993..5335754 100644
--- a/plugin/ucs2-vol/inc/libmostvolume.h
+++ b/plugin/ucs2-vol/inc/libmostvolume.h
@@ -63,9 +63,12 @@ typedef int (*lib_most_volume_writei2c_cb_t)(uint16_t node, uint8_t *data_ptr, u
lib_most_volume_writei2c_result_cb_t result_fptr,
void *result_user_ptr);
+typedef int (*lib_most_volume_sendmessage_cb_t)(uint16_t node, uint16_t msgid, uint8_t *data_ptr, uint8_t data_sz);
+
typedef struct lib_most_volume_init_ {
lib_most_volume_service_cb_t service_cb;
lib_most_volume_writei2c_cb_t writei2c_cb;
+ lib_most_volume_sendmessage_cb_t sendmsg_cb;
} lib_most_volume_init_t;
diff --git a/plugin/ucs2-vol/inc/setup.h b/plugin/ucs2-vol/inc/setup.h
index e7cda01..3be8bf4 100644
--- a/plugin/ucs2-vol/inc/setup.h
+++ b/plugin/ucs2-vol/inc/setup.h
@@ -51,6 +51,8 @@ private:
CDeviceValue _volume_amp_272_m;
CDeviceValue _volume_amp_272_l;
CDeviceValue _volume_amp_272_r;
+
+ CDeviceValue _volume_amp_510_m;
CDeviceContainer _value_container;
lib_most_volume_init_t init_data;
diff --git a/plugin/ucs2-vol/src/device_container.cpp b/plugin/ucs2-vol/src/device_container.cpp
index 0639c10..f804a42 100644
--- a/plugin/ucs2-vol/src/device_container.cpp
+++ b/plugin/ucs2-vol/src/device_container.cpp
@@ -119,18 +119,25 @@ void CDeviceContainer::Update()
if (_values_pptr[_idx_processing]->RequiresUpdate())
{
- if (_values_pptr[_idx_processing]->FireUpdateMessage(this->_init_ptr->writei2c_cb,
- &OnI2cResult,
- this))
+ if (_values_pptr[_idx_processing]->GetType() == DEVICE_VAL_FIBERDYNE_MASTER)
{
- this->_tx_busy = true;
- error = false;
- break;
+ _values_pptr[_idx_processing]->FireControlMessage(this->_init_ptr->sendmsg_cb);
}
else
{
- error = true;
- break;
+ if (_values_pptr[_idx_processing]->FireUpdateMessage(this->_init_ptr->writei2c_cb,
+ &OnI2cResult,
+ this))
+ {
+ this->_tx_busy = true;
+ error = false;
+ break;
+ }
+ else
+ {
+ error = true;
+ break;
+ }
}
}
}
diff --git a/plugin/ucs2-vol/src/device_value.cpp b/plugin/ucs2-vol/src/device_value.cpp
index b6ec4d5..4031778 100644
--- a/plugin/ucs2-vol/src/device_value.cpp
+++ b/plugin/ucs2-vol/src/device_value.cpp
@@ -32,11 +32,12 @@
#define CONTROL_CH_1 0x08U
#define CONTROL_CH_2 0x09U
-CDeviceValue::CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key)
+CDeviceValue::CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key, bool is_i2c)
{
this->_is_available = false;
this->_is_busy = false;
this->_address = address;
+ this->_is_i2c = is_i2c;
this->_target_value = 0x01u;
this->_actual_value = 0x01u;
@@ -49,7 +50,11 @@ CDeviceValue::CDeviceValue(uint16_t address, DeviceValueType type, uint16_t key)
_tx_payload[0] = CONTROL_MASTER;// 7: master, 8: channel 1, 9: Channel 2
_tx_payload[1] = MUTE_VALUE_HB; //HB:Volume
_tx_payload[2] = MUTE_VALUE_LB; //LB:Volume
- _tx_payload_sz = 3u;
+
+ if (type == DEVICE_VAL_FIBERDYNE_MASTER)
+ _tx_payload_sz = 2u;
+ else
+ _tx_payload_sz = 3u;
}
CDeviceValue::~CDeviceValue()
@@ -60,6 +65,14 @@ void CDeviceValue::ApplyMostValue(uint8_t value, DeviceValueType type, uint8_t t
{
uint16_t tmp = MUTE_VALUE;
+ if (type == DEVICE_VAL_FIBERDYNE_MASTER)
+ {
+ tx_payload[0] = 0x00U;
+ tx_payload[1] = value;
+
+ return;
+ }
+
switch (type)
{
case DEVICE_VAL_LEFT:
@@ -97,6 +110,20 @@ bool CDeviceValue::RequiresUpdate()
return false;
}
+bool CDeviceValue::FireControlMessage(lib_most_volume_sendmessage_cb_t sendmsg_fptr)
+{
+ ApplyMostValue(this->_target_value, _type, _tx_payload);
+
+ if (this->_is_available && !this->_is_busy)
+ {
+ sendmsg_fptr(this->_address, 0x100U, _tx_payload, _tx_payload_sz);
+
+ this->_actual_value = this->_target_value;
+ }
+
+ return true;
+}
+
bool CDeviceValue::FireUpdateMessage(lib_most_volume_writei2c_cb_t writei2c_fptr,
lib_most_volume_writei2c_result_cb_t result_fptr,
void *result_user_ptr)
diff --git a/plugin/ucs2-vol/src/setup.cpp b/plugin/ucs2-vol/src/setup.cpp
index dd6675b..ad841ab 100644
--- a/plugin/ucs2-vol/src/setup.cpp
+++ b/plugin/ucs2-vol/src/setup.cpp
@@ -43,18 +43,19 @@ void CSetup::Release() {
}
CSetup::CSetup()
- : _volume_amp_270_m(0x270U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER),
- _volume_amp_270_l(0x270U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_FRONT_LEFT),
- _volume_amp_270_r(0x270U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_FRONT_RIGHT),
- _volume_amp_271_m(0x271U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER),
- _volume_amp_271_l(0x271U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_REAR_LEFT),
- _volume_amp_271_r(0x271U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_REAR_RIGHT),
- _volume_amp_272_m(0x272U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER),
- _volume_amp_272_l(0x272U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_CENTER),
- _volume_amp_272_r(0x272U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_SUB),
+ : _volume_amp_270_m(0x270U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER, true),
+ _volume_amp_270_l(0x270U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_FRONT_LEFT, true),
+ _volume_amp_270_r(0x270U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_FRONT_RIGHT, true),
+ _volume_amp_271_m(0x271U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER, true),
+ _volume_amp_271_l(0x271U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_REAR_LEFT, true),
+ _volume_amp_271_r(0x271U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_REAR_RIGHT, true),
+ _volume_amp_272_m(0x272U, DEVICE_VAL_MASTER, LIB_MOST_VOLUME_MASTER, true),
+ _volume_amp_272_l(0x272U, DEVICE_VAL_LEFT, LIB_MOST_VOLUME_CH_CENTER, true),
+ _volume_amp_272_r(0x272U, DEVICE_VAL_RIGHT, LIB_MOST_VOLUME_CH_SUB, true),
+ _volume_amp_510_m(0x510U, DEVICE_VAL_FIBERDYNE_MASTER, LIB_MOST_VOLUME_MASTER, false),
_value_container()
{
- static CDeviceValue* value_list[9] = { &_volume_amp_270_m,
+ static CDeviceValue* value_list[10] = { &_volume_amp_270_m,
&_volume_amp_270_l,
&_volume_amp_270_r,
&_volume_amp_271_m,
@@ -62,9 +63,10 @@ CSetup::CSetup()
&_volume_amp_271_r,
&_volume_amp_272_m,
&_volume_amp_272_l,
- &_volume_amp_272_r};
+ &_volume_amp_272_r,
+ &_volume_amp_510_m};
- _value_container.RegisterValues(value_list, 9U);
+ _value_container.RegisterValues(value_list, 10U);
}
CSetup::~CSetup()
diff --git a/plugin/wrap_unicens.c b/plugin/wrap_unicens.c
index 1b9a913..82d4cb4 100644
--- a/plugin/wrap_unicens.c
+++ b/plugin/wrap_unicens.c
@@ -108,8 +108,45 @@ extern int wrap_ucs_i2cwrite_sync(AFB_ApiT apiHandle, uint16_t node, uint8_t *da
return 0;
}
-/* ---------------------------- ASYNCHRONOUS API ---------------------------- */
+extern int wrap_ucs_sendmessage_sync(uint16_t src_addr, uint16_t msg_id, uint8_t *data_ptr, uint8_t data_sz) {
+
+ json_object *j_query, *j_response = NULL;
+ int err = 1;
+ int node = (int)src_addr;
+ int msgid = (int)msg_id;
+ size_t data_size = (size_t)data_sz;
+
+ AFB_ApiNotice(unicensHalApiHandle, "--- HAL triggering send message ---");
+ goto OnErrorExit;
+
+
+ /* skip data attribute if possible, wrap_json_unpack may fail to deal with
+ * an empty Base64 string */
+ if (data_size > 0)
+ wrap_json_pack(&j_query, "{s:i, s:i, s:Y}", "node", node, "msgid", msgid, "data", data_ptr, data_size);
+ else
+ wrap_json_pack(&j_query, "{s:i, s:i}", "node", node, "msgid", msgid);
+
+ AFB_ApiNotice(unicensHalApiHandle, "wrap_ucs_sendmessage: jquery=%s", json_object_to_json_string(j_query));
+
+ /* err = AFB_ServiceSync(unicensHalApiHandle, "UNICENS", "sendmessage", j_query, &j_response); */
+
+ if (err) {
+ AFB_ERROR("Failed to call wrap_ucs_sendmessage");
+ goto OnErrorExit;
+ }
+ else {
+ AFB_INFO("Called wrap_ucs_sendmessage, res=%s", json_object_to_json_string(j_response));
+ json_object_put(j_response);
+ }
+
+ //j_query = NULL;
+
+OnErrorExit:
+ return err;
+}
+/* ---------------------------- ASYNCHRONOUS API ---------------------------- */
static void wrap_ucs_i2cwrite_cb(void *closure, int status, struct json_object *j_result, AFB_ApiT apiHandle)
{
async_job_t *job_ptr;
@@ -172,3 +209,4 @@ extern int wrap_ucs_i2cwrite(uint16_t node,
AFB_ServiceCall(unicensHalApiHandle, "UNICENS", "writei2c", j_query, wrap_ucs_i2cwrite_cb, job_ptr);
return 0;
}
+
diff --git a/plugin/wrap_unicens.h b/plugin/wrap_unicens.h
index aeb0da9..6199476 100644
--- a/plugin/wrap_unicens.h
+++ b/plugin/wrap_unicens.h
@@ -41,3 +41,5 @@ extern int wrap_ucs_i2cwrite(uint16_t node,
/* Synchronous API: functions */
extern int wrap_ucs_subscribe_sync(AFB_ApiT apiHandle);
extern int wrap_ucs_i2cwrite_sync(AFB_ApiT apiHandle, uint16_t node, uint8_t *data_ptr, uint8_t data_sz);
+extern int wrap_ucs_sendmessage_sync(uint16_t src_addr, uint16_t msg_id, uint8_t *data_ptr, uint8_t data_sz);
+
diff --git a/plugin/wrap_volume.c b/plugin/wrap_volume.c
index 61b752f..9c3d7a1 100644
--- a/plugin/wrap_volume.c
+++ b/plugin/wrap_volume.c
@@ -87,7 +87,8 @@ extern int wrap_volume_init(void)
lib_most_volume_init_t mv_init;
mv_init.writei2c_cb = &wrap_ucs_i2cwrite;
- mv_init.service_cb = wrap_volume_service_cb;
+ mv_init.service_cb = &wrap_volume_service_cb;
+ mv_init.sendmsg_cb = &wrap_ucs_sendmessage_sync;
ret = lib_most_volume_init(&mv_init);