Skip to content

Commit

Permalink
fixed issue with non working rssilist.cgi with CCU firmware 3.41.x and
Browse files Browse the repository at this point in the history
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 59d1764
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 13 deletions.
36 changes: 36 additions & 0 deletions xmlapi/common.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
16 changes: 10 additions & 6 deletions xmlapi/mastervalue.cgi
Original file line number Diff line number Diff line change
@@ -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: *

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

read_interfaces

set devids [split $device_id ,]
if { $requested_names == "" } {
set allMasterValues "*"
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 10 additions & 6 deletions xmlapi/mastervaluechange.cgi
Original file line number Diff line number Diff line change
@@ -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: *

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

read_interfaces

set rec_devids [split $device_id "\,"]
set rec_mvaluename [split $name "\,"]
set rec_mvaluevalue [split $value "\,"]
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion xmlapi/rssilist.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 59d1764

Please sign in to comment.