summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--.gitreview5
-rw-r--r--app/HVAC.qml11
-rw-r--r--app/api/Binding.qml15
-rw-r--r--binding/hvac-demo-binding.c34
-rw-r--r--package/config.xml2
6 files changed, 61 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index 89f64c7..616713c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,6 @@
*.pro.*
+.*.sw*
+.qmake.*
+app/config.log
+package/*.wgt
+package/root/
diff --git a/.gitreview b/.gitreview
new file mode 100644
index 0000000..7decc5c
--- /dev/null
+++ b/.gitreview
@@ -0,0 +1,5 @@
+[gerrit]
+host=gerrit.automotivelinux.org
+port=29418
+project=apps/hvac
+defaultbranch=master
diff --git a/app/HVAC.qml b/app/HVAC.qml
index f5cd76b..41cf7fa 100644
--- a/app/HVAC.qml
+++ b/app/HVAC.qml
@@ -46,6 +46,9 @@ ApplicationWindow {
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
+ from: 0.0
+ to: 255.0
+ stepSize: 1.0
onValueChanged: {
binding.fanSpeed = value
}
@@ -72,6 +75,10 @@ ApplicationWindow {
}
HeatDegree {
enabled: leftSeat.headLevel > 0
+ onCurrentItemChanged: {
+ console.log("Left Temp changed",degree)
+ binding.leftTemperature = degree
+ }
}
}
ColumnLayout {
@@ -121,6 +128,10 @@ ApplicationWindow {
}
HeatDegree {
enabled: rightSeat.headLevel > 0
+ onCurrentItemChanged: {
+ console.log("Right Temp changed",degree)
+ binding.rightTemperature = degree
+ }
}
}
}
diff --git a/app/api/Binding.qml b/app/api/Binding.qml
index 834bdf8..93da6f4 100644
--- a/app/api/Binding.qml
+++ b/app/api/Binding.qml
@@ -25,6 +25,8 @@ WebSocket {
property string statusString: "waiting..."
property real fanSpeed: 0.0
+ property real leftTemperature: 21.0
+ property real rightTemperature: 21.0
property Connections c : Connections {
target: root
@@ -33,17 +35,28 @@ WebSocket {
console.debug(JSON.stringify(json))
sendTextMessage(JSON.stringify(json))
}
+ onLeftTemperatureChanged: {
+ var json = [MessageId.call, '9999', 'hvac/set', {'LeftTemperature': leftTemperature}]
+ console.debug(JSON.stringify(json))
+ sendTextMessage(JSON.stringify(json))
+ }
+ onRightTemperatureChanged: {
+ var json = [MessageId.call, '9999', 'hvac/set', {'RightTemperature': rightTemperature}]
+ console.debug(JSON.stringify(json))
+ sendTextMessage(JSON.stringify(json))
+ }
}
onTextMessageReceived: {
var json = JSON.parse(message)
var request = json[2].request
var response = json[2].response
+ console.log("HVAC Binding Message: ",message)
switch (json[0]) {
case MessageId.call:
break
case MessageId.retok:
- root.statusString = request.info
+ root.statusString = request.status
break
case MessageId.reterr:
root.statusString = "Bad return value, binding probably not installed"
diff --git a/binding/hvac-demo-binding.c b/binding/hvac-demo-binding.c
index fe20880..14af56b 100644
--- a/binding/hvac-demo-binding.c
+++ b/binding/hvac-demo-binding.c
@@ -24,6 +24,7 @@
#include <sys/ioctl.h>
#include <net/if.h>
#include <linux/can.h>
+#include <math.h>
#include <json-c/json.h>
@@ -159,12 +160,17 @@ static int write_can()
txCanFrame.data[6] = 0;
txCanFrame.data[7] = 0;
+ DEBUG(interface, "%s: %d %d [%02x %02x %02x %02x %02x %02x %02x %02x]\n",
#if defined(SIMULATE_HVAC)
- DEBUG(interface, "WRITING CAN: %d %d [%02x %02x %02x %02x %02x %02x %02x %02x]\n",
+ "FAKE CAN FRAME",
+#else
+ "SENDING CAN FRAME",
+#endif
txCanFrame.can_id, txCanFrame.can_dlc,
txCanFrame.data[0], txCanFrame.data[1], txCanFrame.data[2], txCanFrame.data[3],
txCanFrame.data[4], txCanFrame.data[5], txCanFrame.data[6], txCanFrame.data[7]);
-#else
+
+#if !defined(SIMULATE_HVAC)
rc = sendto(can_handler.socket, &txCanFrame, sizeof(struct can_frame), 0,
(struct sockaddr*)&can_handler.txAddress, sizeof(can_handler.txAddress));
if (rc < 0)
@@ -269,6 +275,7 @@ static void get(struct afb_req request)
static void set(struct afb_req request)
{
int i, rc, x, changed;
+ double d;
struct json_object *query, *val;
uint8_t values[sizeof hvac_values / sizeof *hvac_values];
uint8_t saves[sizeof hvac_values / sizeof *hvac_values];
@@ -292,15 +299,21 @@ static void set(struct afb_req request)
DEBUG(interface, "Searching... query: %s, i: %d, comp: %s", json_object_to_json_string(query), i, hvac_values[i].name);
if (json_object_object_get_ex(query, hvac_values[i].name, &val))
{
- DEBUG(interface, "We got it. Tests if it is an int or not.");
- if (!json_object_is_type(val, json_type_int))
- {
+ DEBUG(interface, "We got it. Tests if it is an int or double.");
+ if (json_object_is_type(val, json_type_int)) {
+ x = json_object_get_int(val);
+ DEBUG(interface, "We get an int: %d",x);
+ }
+ else if (json_object_is_type(val, json_type_double)) {
+ d = json_object_get_double(val);
+ x = (int)round(d);
+ DEBUG(interface, "We get a double: %f => %d",d,x);
+ }
+ else {
afb_req_fail_f(request, "bad-request",
- "argument '%s' isn't integer", hvac_values[i].name);
+ "argument '%s' isn't integer or double", hvac_values[i].name);
return;
}
- DEBUG(interface, "We get an 'int'. Hail for the int: %d", x);
- x = json_object_get_int(val);
if (x < 0 || x > 255)
{
afb_req_fail_f(request, "bad-request",
@@ -310,9 +323,12 @@ static void set(struct afb_req request)
if (values[i] != x) {
values[i] = (uint8_t)x;
changed = 1;
+ DEBUG(interface,"%s changed to %d",hvac_values[i].name,x);
}
}
- DEBUG(interface, "Not found !");
+ else {
+ DEBUG(interface, "%s not found in query!",hvac_values[i].name);
+ }
}
/* attemps to set new values */
diff --git a/package/config.xml b/package/config.xml
index bd374b6..ac34f80 100644
--- a/package/config.xml
+++ b/package/config.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<widget xmlns="http://www.w3.org/ns/widgets" id="HVAC" version="0.1">
+<widget xmlns="http://www.w3.org/ns/widgets" id="hvac" version="0.1">
<name>HVAC</name>
<icon src="icon.svg"/>
<content src="bin/hvac" type="application/vnd.agl.native"/>