Skip to content

Commit 8259054

Browse files
added Proximity Control
1 parent 7d9fb75 commit 8259054

10 files changed

Lines changed: 224 additions & 0 deletions

File tree

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Cisco Systems
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Handy samples for xAPI In-Room Controls & Macros
2+
3+
This repo regroups a set of macros and controls, check the related folder.
4+
5+
Hereafter I present the commands I happen to often use when coding against the xAPI.
6+
Simply SSH to your Collaboration Device and start a TSH (t-shell) to run these commands.
7+
8+
## Listen to events
9+
10+
```shell
11+
# Listen to all notifications (events, status, commands)
12+
xfeedback register /
13+
```
14+
15+
```shell
16+
# Listen to in-room control events
17+
xfeedback register /Event/UserInterface/Extensions
18+
```
19+
20+
```shell
21+
# Stop listening
22+
xfeedback deregisterall
23+
```

controls/hackercorner/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Play an interactive game
2+
3+
Navigate bling in a maze, look for the treasure.
4+
5+
![](./maze.png)
6+
7+
8+
Hit 'Help' to check your current position against the Maze map.
9+
10+
![](./help.png)

controls/hackercorner/help.png

184 KB
Loading

controls/hackercorner/maze.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
//
2+
// Copyright (c) 2017 Cisco Systems
3+
// Licensed under the MIT License
4+
//
5+
16
function debug(entry) {
27
console.log(entry)
38
};

controls/hackercorner/maze.png

104 KB
Loading

controls/proximity/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Helper panel to switch Proximity Mode on/off
2+
3+
![](./ultrasound.png)

controls/proximity/ultrasound.js

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
//
2+
// Copyright (c) 2017 Cisco Systems
3+
// Licensed under the MIT License
4+
//
5+
6+
/**
7+
* Macro companion to the Ultrasound Control
8+
* - lets users toggle Proximity Mode to On/Off
9+
* - displays the current MaxVolume level
10+
*/
11+
12+
const xapi = require('xapi')
13+
14+
15+
// Change proximity mode to "On" or "Off"
16+
function switchProximityMode(mode) {
17+
console.debug(`switching proximity mode to: ${mode}`)
18+
19+
xapi.config.set('Proximity Mode', mode)
20+
.then(() => {
21+
console.info(`turned proximity mode: ${mode}`)
22+
})
23+
.catch((err) => {
24+
console.error(`could not turn proximity mode: ${mode}`)
25+
})
26+
}
27+
28+
// React to UI events
29+
function onGui(event) {
30+
// Proximity Mode Switch
31+
if ((event.Type == 'changed') && (event.WidgetId == 'proximity_switch')) {
32+
switchProximityMode(event.Value)
33+
return;
34+
}
35+
}
36+
xapi.event.on('UserInterface Extensions Widget Action', onGui);
37+
38+
39+
//
40+
// Proximity Services Availability
41+
//
42+
43+
// Update Toogle if proximity mode changes
44+
function updateProximityToggle(mode) {
45+
console.debug(`switching toggle to ${mode}`)
46+
47+
xapi.command("UserInterface Extensions Widget SetValue", {
48+
WidgetId: "proximity_switch",
49+
Value: mode
50+
})
51+
}
52+
xapi.config.on("Proximity Mode", mode => {
53+
console.log(`proximity mode changed to: ${mode}`)
54+
55+
// Update toggle
56+
// [WORKAROUND] Configuration is On or Off, needs to be turned to lowercase
57+
updateProximityToggle(mode.toLowerCase())
58+
})
59+
60+
// Refresh Toggle state
61+
function refreshProximityToggle() {
62+
xapi.status.get("Proximity Services Availability")
63+
.then(availability => {
64+
console.debug(`current proximity mode is ${availability}`)
65+
switch (availability) {
66+
case 'Available':
67+
updateProximityToggle('on')
68+
return;
69+
70+
case 'Disabled':
71+
default:
72+
updateProximityToggle('off')
73+
return;
74+
}
75+
})
76+
.catch((err) => {
77+
console.error(`could not read current proximity mode, err: ${err.message}`)
78+
})
79+
}
80+
81+
//
82+
// Audio Ultrasound MaxVolume
83+
//
84+
function updateUltrasoundMaxVolume(volume) {
85+
console.debug(`updating Ultrasound text to: ${volume}`)
86+
87+
xapi.command("UserInterface Extensions Widget SetValue", {
88+
WidgetId: "ultrasound_maxvolume",
89+
Value: volume
90+
})
91+
}
92+
xapi.config.on("Audio Ultrasound MaxVolume", volume => {
93+
console.log(`Ultrasound maxVolume changed to: ${volume}`)
94+
95+
// Update toggle
96+
// [WORKAROUND] Configuration is On or Off, needs to be turned to lowercase
97+
updateUltrasoundMaxVolume(volume)
98+
})
99+
100+
function refreshUltrasoundMaxVolume() {
101+
xapi.config.get("Audio Ultrasound MaxVolume")
102+
.then(volume => updateUltrasoundMaxVolume(volume))
103+
}
104+
105+
106+
//
107+
// Reset UI
108+
//
109+
110+
// Initialize at macro startup
111+
function refreshUserInterface() {
112+
refreshProximityToggle()
113+
refreshUltrasoundMaxVolume()
114+
}
115+
refreshUserInterface()
116+
117+
// Initialize at widget deployment
118+
xapi.event.on('UserInterface Extensions Widget LayoutUpdated', (event) => {
119+
console.debug("layout updated, let's refresh our toogle")
120+
refreshUserInterface()
121+
});

controls/proximity/ultrasound.png

21.7 KB
Loading

controls/proximity/ultrasound.xml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<Extensions>
2+
<Version>1.4</Version>
3+
<Panel>
4+
<Icon>Microphone</Icon>
5+
<Type>Statusbar</Type>
6+
<Page>
7+
<Name>UltraSound Configuration</Name>
8+
<Row>
9+
<Name>Proximity</Name>
10+
<Widget>
11+
<WidgetId>proximity_switch</WidgetId>
12+
<Type>ToggleButton</Type>
13+
<Options>size=1</Options>
14+
</Widget>
15+
<Widget>
16+
<WidgetId>unused</WidgetId>
17+
<Name> </Name>
18+
<Type>Text</Type>
19+
<Options>size=3</Options>
20+
</Widget>
21+
</Row>
22+
<Row>
23+
<Name>MaxVolume</Name>
24+
<Widget>
25+
<WidgetId>ultrasound_maxvolume</WidgetId>
26+
<Name> </Name>
27+
<Type>Text</Type>
28+
<Options>size=1;fontSize=normal;align=center</Options>
29+
</Widget>
30+
<Widget>
31+
<WidgetId>unused</WidgetId>
32+
<Name>(0 to 90)</Name>
33+
<Type>Text</Type>
34+
<Options>size=3;align=left;fontSize=normal</Options>
35+
</Widget>
36+
</Row>
37+
<Options/>
38+
</Page>
39+
<Name>Configuration</Name>
40+
</Panel>
41+
</Extensions>

0 commit comments

Comments
 (0)