diff options
author | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2012-12-17 12:05:14 +0100 |
---|---|---|
committer | Stefan Wintermeyer <stefan.wintermeyer@amooma.de> | 2012-12-17 12:05:14 +0100 |
commit | eaad37485fe59d0306c37cc038dda6d210052910 (patch) | |
tree | 072c4b0e33d442528555b82c415f5e7a1712b2b0 /misc/freeswitch/scripts/phones/siemens.lua | |
parent | 3e706c2025ecc5523e81ad649639ef2ff75e7bac (diff) | |
parent | b80bd744ad873f6fc43018bc4bfb90677de167bd (diff) |
Merge branch 'develop'
Diffstat (limited to 'misc/freeswitch/scripts/phones/siemens.lua')
-rw-r--r-- | misc/freeswitch/scripts/phones/siemens.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/phones/siemens.lua b/misc/freeswitch/scripts/phones/siemens.lua new file mode 100644 index 0000000..71bb40a --- /dev/null +++ b/misc/freeswitch/scripts/phones/siemens.lua @@ -0,0 +1,45 @@ +-- Gemeinschaft 5 module: general siemens model class +-- (c) AMOOMA GmbH 2012 +-- + +module(...,package.seeall) + +Siemens = {} + +-- create siemens object +function Siemens.new(self, arg) + arg = arg or {} + object = arg.object or {} + setmetatable(object, self); + self.__index = self; + self.log = arg.log; + self.PHONE_HTTP_PORT = 8085; + return object; +end + +-- send reload message to phone +function Siemens.resync(self, arg) + if arg.ip_address then + return self:resync_http(arg.ip_address, arg.http_user, arg.http_password, arg.http_port); + end + + return false; +end + +-- send reload message to ip +function Siemens.resync_http(self, ip_address, http_user, http_password, http_port) + local port_str = ''; + if tonumber(http_port) then + port_str = ':' .. http_port; + end + + get_command = 'wget --no-proxy -q -O /dev/null -o /dev/null -b --tries=2 --timeout=10 --user="' .. (http_user or '') .. '" --password="' .. (http_password or '') .. '"' .. + ' wget http://' .. tostring(ip_address):gsub('[^0-9%.]', '') .. ':' .. (tonumber(http_port) or self.PHONE_HTTP_PORT) .. '/contact_dls.html/ContactDLS' .. + ' 1>>/dev/null 2>>/dev/null &'; + + result = os.execute(get_command); + + if result and tonumber(result) == 0 then + return true; + end +end |