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
}
}
HeatDegree {
enabled: leftSeat.headLevel > 0
+ onCurrentItemChanged: {
+ console.log("Left Temp changed",degree)
+ binding.leftTemperature = degree
+ }
}
}
ColumnLayout {
}
HeatDegree {
enabled: rightSeat.headLevel > 0
+ onCurrentItemChanged: {
+ console.log("Right Temp changed",degree)
+ binding.rightTemperature = degree
+ }
}
}
}
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
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"
#include <sys/ioctl.h>
#include <net/if.h>
#include <linux/can.h>
+#include <math.h>
#include <json-c/json.h>
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)
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];
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",
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 */