-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcore.js
102 lines (90 loc) · 1.97 KB
/
core.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
configure('core.kiosk', (kiosk) => {
kiosk.entry('resources/qml/main.qml');
kiosk.platform('wayland');
kiosk.core = reactive({
snapshot: reactive({
image: "",
capture: function() {
use("camera").takeB64Snapshot((image) => {
this.image = image;
});
}
}),
clip: reactive({
left: 0,
top: 0,
right: 0,
bottom: 0
}),
sign: reactive({
ring: function() {
use("core.sip").call("kai123@sip.linphone.org");
},
street: {
number: "1",
name: "Bienenweg"
},
family: {
name: "Fam. Schoch"
}
}),
debug: reactive({
fotobox: true,
fullscreen: true,
}),
light: reactive({
state: false,
toogle: function() {
kiosk.core.light.state = !kiosk.core.light.state;
}
}),
unlock: function(pin) {
return pin === "ABCDEF"
}
})
});
configure(!"core.mqtt", (mqtt) => {
mqtt.auth("username", "password");
mqtt.broker("broker.hivemq.com:1883");
mqtt.subscribe(["dieklingel/core/system/state"], (topic, message) => {
console.log(topic, message);
});
});
configure(!"core.web", (web) => {
web.auth("username", "password");
web.port(80);
});
configure("core.sip", (sip) => {
sip.auth("username", "password");
sip.proxy("sip.linphone.org");
sip.transport(["tls"]);
});
configure(!"audio", (audio) => {
audio.playback("PulseAudio Unknown: Echo-Cancel Sink");
audio.capture("PulseAudio Unknown: Echo-Cancel Source");
});
configure(!"gpio", (gpios) => {
gpios.input(17, (state) => {
// handel state changes in here
})
gpios.output(23).low();
});
configure(!"camera", (camera) => {
});
/*
* Some experimental utility functions, not yet supported by the Setup yet.
*/
function reactive(obj) {
const props = Object.keys(obj).map((key) => `property var ${key}`).join('\n');
const object = Qt.createQmlObject(
`
import QtQuick 2.0
QtObject {
${props}
}`,
Qt.application, 'reactive');
for (const [key, value] of Object.entries(obj)) {
object[key] = value;
}
return object;
}