-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCisco_Webex.lua
133 lines (120 loc) · 3.06 KB
/
Cisco_Webex.lua
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
-- Control module for Cisco Webex
-- Initialise
ssh = Ssh.New()
address = Controls.ipAddress.String
port = Controls.port.Value
username = Controls.username.String
password = Controls.password.String
monitor_mode = Controls.monitors
mic = Controls.micMute
standby = Controls.standby
timer = Timer.New()
-- Feedback
function parseReturnCommand(message, ltable)
-- standby state
msg, _ = string.find(message, "Standby State:")
if msg ~= nil then
if ltable[4] == 'Off' or ltable[4] == 'Halfwake' then
Controls.standby.Boolean = false
else
Controls.standby.Boolean = true
end
end
-- mic mute control
msg, _ = string.find(message, "Audio Microphones Mute:")
if msg ~= nil then
if ltable[5] == 'On' then
Controls.micMute.Boolean = true
else if ltable[5] == 'Off' then
Controls.micMute.Boolean = false
end
end
-- incall status
msg, _ = string.find(message, "NumberOfActiveCalls:")
if msg ~= nil then
if ltable[5] > 0 then
Controls.callState.Boolean = true
else
Controls.callState.Boolean = false
end
end
end
end
-- Start the subscription services
function startSubscriptions()
Send("xFeedback Register /Status/Audio/Microphones/Mute")
Send("xFeedback Register /Status/SystemUnit/State/NumberOfActiveCalls")
Send("xFeedback Register Status/Standby/State")
end
-- Sync controls to the same state at the webex
function getStartupStates()
Send("xStatus Audio Microphones Mute")
Send("xStatus SystemUnit State NumberOfActiveCalls")
Send("xStatus Standby State")
end
-- ssh socket
ssh.Connected = function()
print("ssh connected")
startSubscriptions()
getStartupStates()
timer:Start(10)
end
ssh.Reconnect = function()
print("ssh reconnect")
end
ssh.Data = function()
print("ssh data")
line = ssh:ReadLine(TcpSocket.EOL.Any)
while line do
print(line)
ltable = {}
for i in string.gmatch( line, "%S+" ) do
table.insert( ltable, i )
end
parseReturnCommand(line, ltable)
line = ssh:ReadLine(TcpSocket.EOL.Any)
end
end
ssh.Closed = function()
print("ssh closed")
timer:Stop()
end
ssh.Error = function(s, err)
print("ssh error", err)
end
ssh.Timeout = function()
print("ssh timeout")
end
ssh.LoginFailed = function()
print("ssh LoginFailed")
end
-- Standby Button
standby.EventHandler = function()
if standby.Boolean == true then
Send("xCommand Standby Activate")
else
Send("xCommand Standby Deactivate")
end
end
-- Mic Mute Button
mic.EventHandler = function()
if mic.Boolean == true then
Send("xCommand Audio Microphones Mute")
else
Send("xCommand Audio Microphones Unmute")
end
end
-- initialise monitors dropdown
monitorModes = {"Auto", "Dual", "DualPresentationOnly", "Single", "Triple", "TriplePresentationOnly"}
monitor_mode.Choices = monitorModes
-- monitor control
monitor_mode.EventHandler = function ()
Send("xConfiguration Video Monitors: "..monitor_mode.String)
end
function Send(str)
if ssh.IsConnected then
ssh:Write(str.."\n")
print("Sent "..str)
end
end
ssh:Connect(address, port, username, password)