Skip to content
Permalink
Browse files

fixed issue with non working rssilist.cgi with CCU firmware 3.41.x and

modified xmlrpc calls to read the interface urls from Interfaces.xml
dynamically. This fixes #23.
  • Loading branch information...
jens-maus committed Nov 26, 2018
1 parent d617ad9 commit 59d1764411f9ec449ab709e918b94a11df8e4152
Showing with 58 additions and 13 deletions.
  1. +36 −0 xmlapi/common.tcl
  2. +10 −6 xmlapi/mastervalue.cgi
  3. +10 −6 xmlapi/mastervaluechange.cgi
  4. +2 −1 xmlapi/rssilist.cgi
@@ -154,3 +154,39 @@ proc uniq {liste} {

return $u_list
}

set INTERFACES_FILE "/etc/config/InterfacesList.xml"
array set interfaces ""
array set interface_descriptions ""

proc read_interfaces {} {
global interfaces interface_descriptions INTERFACES_FILE env
set retval 1
if { [ info exist env(BIDCOS_SERVICE) ] } {
set interfaces(default) "$env(BIDCOS_SERVICE)"
set interface_descriptions(default) "Default BidCoS Interface"
} else {
set fd -1
catch {set fd [open $INTERFACES_FILE r]}
if { $fd >=0 } {
set contents [read $fd]
while { [regexp -indices {</ipc[^>]*>} $contents range] } {
set section [string range $contents 0 [lindex $range 1]]
set contents [string range $contents [expr [lindex $range 1] + 1] end]
if {
[regexp {<name[^>]*>([^<]+)</name} $section dummy name] &&
[regexp {<url[^>]*>([^<]+)</url} $section dummy url] &&
[regexp {<info[^>]*>([^<]+)</info} $section dummy description ]
} {
array set interfaces [list $name $url]
array set interface_descriptions [list $name $description]
}
}
close $fd
} else {
puts "Could not open interface file"
set retval 0
}
}
return $retval
}
@@ -1,6 +1,8 @@
#!/bin/tclsh
load tclrega.so
load tclrpc.so
source common.tcl

puts -nonewline {Content-Type: text/xml
Access-Control-Allow-Origin: *

@@ -22,6 +24,8 @@ catch {
}
}

read_interfaces

set devids [split $device_id ,]
if { $requested_names == "" } {
set allMasterValues "*"
@@ -50,12 +54,12 @@ foreach devid $devids {

puts -nonewline $values(STDOUT)

if {[string first "HM-CC-VG-" $deviceType] >= 0} {
set ausgabe [xmlrpc http://127.0.0.1:9292/groups getParamset [list string $deviceAddress] [list string "MASTER"] ]
} elseif {[string first "HMIP-" $deviceType] >= 0} {
set ausgabe [xmlrpc http://127.0.0.1:2010/ getParamset [list string $deviceAddress] [list string "MASTER"] ]
} else {
set ausgabe [xmlrpc http://127.0.0.1:2001/ getParamset [list string $deviceAddress] [list string "MASTER"] ]
if {[string compare -nocase -length 9 "HM-CC-VG-" $deviceType] == 0} {
set ausgabe [xmlrpc $interfaces(VirtualDevices) getParamset [list string $deviceAddress] [list string "MASTER"] ]
} elseif {[string compare -nocase -length 5 "HMIP-" $deviceType] == 0} {
set ausgabe [xmlrpc $interfaces(HmIP-RF) getParamset [list string $deviceAddress] [list string "MASTER"] ]
} else {
set ausgabe [xmlrpc $interfaces(BidCos-RF) getParamset [list string $deviceAddress] [list string "MASTER"] ]
}

foreach { bezeichnung wert } $ausgabe {
@@ -1,6 +1,8 @@
#!/bin/tclsh
load tclrega.so
load tclrpc.so
source common.tcl

puts -nonewline {Content-Type: text/xml
Access-Control-Allow-Origin: *

@@ -20,6 +22,8 @@ catch {
}
}

read_interfaces

set rec_devids [split $device_id "\,"]
set rec_mvaluename [split $name "\,"]
set rec_mvaluevalue [split $value "\,"]
@@ -50,13 +54,13 @@ for {set counter 0} {$counter<[llength $rec_devids]} {incr counter} {
set deviceType $values(deviceType)

puts -nonewline $values(STDOUT)
if {[string first "HM-CC-VG-" $deviceType] >= 0} {
set ausgabe [xmlrpc http://127.0.0.1:9292/groups putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
} elseif {[string first "HMIP-" $deviceType] >= 0} {
set ausgabe [xmlrpc http://127.0.0.1:2010/ putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]

if {[string compare -nocase -length 9 "HM-CC-VG-" $deviceType] == 0} {
set ausgabe [xmlrpc $interfaces(VirtualDevices) putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
} elseif {[string compare -nocase -length 5 "HMIP-" $deviceType] == 0} {
set ausgabe [xmlrpc $interfaces(HmIP-RF) putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
} else {
set ausgabe [xmlrpc http://127.0.0.1:2001/ putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
set ausgabe [xmlrpc $interfaces(BidCos-RF) putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
}
puts -nonewline {<mastervalue name='}
puts -nonewline $item
@@ -24,7 +24,8 @@ set RSSI_BAD -120.0
set RSSI_MEDIUM -100.0
set RSSI_GOOD -20.0

set url "xmlrpc_bin://127.0.0.1:2001"
read_interfaces
set url $interfaces(BidCos-RF)

if { [ catch {
#check if the interface supports rssi

0 comments on commit 59d1764

Please sign in to comment.
You can’t perform that action at this time.