A Go-language library for accessing UPnP AV devices
ianr0bkny / go-sonos Goto Github PK
View Code? Open in Web Editor NEWA Go-language library for accessing UPnP AV devices
License: Other
A Go-language library for accessing UPnP AV devices
License: Other
ssdpUnicastDiscoverImpl
& ssdpMulticastDiscoverImpl
depend on IPV4 address but don't ensure IPV4 addresses are used.
The code currently grabs the first entry returned by net.Interface.Addrs()
and on my machine the following is returned:
Addr[0] = fe80::72cd:60ff:fef3:75ad/64
Addr[1] = 192.168.1.68/24
Since the first entry is an IPV6 entry the code issues a panic and fails to complete discovery.
I am trying to identify sono devices on my network.
But I am getting an error.
2016/03/08 14:50:22 http: panic serving [::1]:56561: listen udp [xxxx::xxxx:xxxz:xxxx:xxxx]:11209: bind: can't assign requested address
goroutine 8 [running]:
net/http.(*conn).serve.func1(0xc820116b80)
/Users/jesus/.gvm/gos/go1.6/src/net/http/server.go:1389 +0xc1
panic(0x394bc0, 0xc820016d70)
/Users/jesus/.gvm/gos/go1.6/src/runtime/panic.go:426 +0x4e9
github.com/ianr0bkny/go-sonos/ssdp.(*ssdpDefaultManager).ssdpDiscoverImpl(0xc82001f0e0, 0x3ea9e0, 0x3, 0x3e85b0, 0x5, 0xc82001f000)
/Users/jesus/.gvm/pkgsets/go1.6/global/src/github.com/ianr0bkny/go-sonos/ssdp/ssdp.go:921 +0xe6
github.com/ianr0bkny/go-sonos/ssdp.(*ssdpDefaultManager).Discover(0xc82001f0e0, 0x3ea9e0, 0x3, 0x3e85b0, 0x5, 0x0, 0x0, 0x0)
/Users/jesus/.gvm/pkgsets/go1.6/global/src/github.com/ianr0bkny/go-sonos/ssdp/ssdp.go:347 +0x60
main.findSonos()
/Users/jesus/.gvm/pkgsets/go1.6/global/src/github.com/jesusjjf/slacksonos/main.go:51 +0x3dc
main.slackHandler(0x1205808, 0xc820067790, 0xc8200f22a0)
I can see the device on my network when I arp -a
...
sonoszp (10.1.1.155) at 0:x:xx:xx:xx:xx on en0 ifscope [ethernet]
...
My code
func findSonos() {
fmt.Println("go-sonos example discovery")
mgr := ssdp.MakeManager()
if err := mgr.Discover("en0", "11209", false); err != nil {
fmt.Println(err)
}
i := 0
dev_map := mgr.Devices()
for _, dev := range dev_map {
fmt.Printf("[%02d] %s %s %s %s %s\n", i, dev.Product(), dev.ProductVersion(), dev.Name(), dev.Location(), dev.UUID())
i++
}
mgr.Close()
}
Hi,
I have been trying to workout how to use the library in its current form. Could you give a brief description please?
Dan
Heya just trying out this library and it seems to freezing during discovery for some reason.
Anyone else had this issue?
I have this line in my code but it never returns.
unit := sonos.Connect(player, reactor, sonos.SVC_CONTENT_DIRECTORY|sonos.SVC_AV_TRANSPORT|sonos.SVC_RENDERING_CONTROL)
With this code:
{
exit_chan := make(chan bool)
reactor := sonos.MakeReactor(SONOS_IFNAME, SONOS_EVENTING_PORT)
go handleSonosEvent(reactor, exit_chan)
}
func handleSonosEvent(reactor upnp.Reactor, c chan bool) {
for {
select {
case evt := <-reactor.Channel():
switch evt.Type() {
case upnp.AVTransport_EventType:
log.Printf("Got Event!")
}
}
}
}
This exception is thrown:
panic: reflect.Value.Interface: cannot return value obtained from unexported field or method
goroutine 5 [running]:
panic(0x2958e0, 0xc420324b20)
/usr/local/Cellar/go/1.7.3/libexec/src/runtime/panic.go:500 +0x1a1
reflect.valueInterface(0x2c1e00, 0xc42020cb90, 0x1d9, 0x1, 0x1, 0xc4203244e0)
/usr/local/Cellar/go/1.7.3/libexec/src/reflect/value.go:918 +0x1be
reflect.Value.Interface(0x2c1e00, 0xc42020cb90, 0x1d9, 0x1d9, 0x2c1e00)
/usr/local/Cellar/go/1.7.3/libexec/src/reflect/value.go:907 +0x44
encoding/xml.(*Decoder).unmarshal(0xc4201f3a20, 0x2ffda0, 0xc42020cb90, 0x199, 0xc420356480, 0xc42020cb90, 0x199)
/usr/local/Cellar/go/1.7.3/libexec/src/encoding/xml/read.go:412 +0x1f5e
encoding/xml.(*Decoder).unmarshalPath(0xc4201f3a20, 0xc420236da0, 0x2c1d60, 0xc42020cb70, 0x199, 0x0, 0x0, 0x0, 0xc420356480, 0x1, ...)
/usr/local/Cellar/go/1.7.3/libexec/src/encoding/xml/read.go:627 +0x6a9
encoding/xml.(*Decoder).unmarshal(0xc4201f3a20, 0x2c1d60, 0xc42020cb70, 0x199, 0xc420356380, 0x199, 0x2ca2eea3)
/usr/local/Cellar/go/1.7.3/libexec/src/encoding/xml/read.go:479 +0x10aa
encoding/xml.(*Decoder).DecodeElement(0xc4201f3a20, 0x286500, 0xc42020cb70, 0x0, 0xc420362a01, 0x7c0078)
/usr/local/Cellar/go/1.7.3/libexec/src/encoding/xml/read.go:133 +0x10b
encoding/xml.(*Decoder).Decode(0xc4201f3a20, 0x286500, 0xc42020cb70, 0xc420051d40, 0xc420322401)
/usr/local/Cellar/go/1.7.3/libexec/src/encoding/xml/read.go:121 +0x48
encoding/xml.Unmarshal(0xc420362a00, 0x13bd, 0x1500, 0x286500, 0xc42020cb70, 0x1500, 0x0)
/usr/local/Cellar/go/1.7.3/libexec/src/encoding/xml/read.go:115 +0x1c3
github.com/ianr0bkny/go-sonos/upnp.(*AVTransport).HandleProperty(0xc42020cb70, 0xc4201faa90, 0xc42034c000, 0x189c, 0xc420074a20, 0x7d801, 0x18)
/Users/dsully/dev/sonos-go-tools/vendor/src/github.com/ianr0bkny/go-sonos/upnp/AVTransport.go:132 +0x1c9
github.com/ianr0bkny/go-sonos/upnp.(*upnpDefaultReactor).maybePostEvent(0xc420074900, 0xc420322390)
/Users/dsully/dev/sonos-go-tools/vendor/src/github.com/ianr0bkny/go-sonos/upnp/event.go:203 +0xe6
github.com/ianr0bkny/go-sonos/upnp.(*upnpDefaultReactor).run(0xc420074900)
/Users/dsully/dev/sonos-go-tools/vendor/src/github.com/ianr0bkny/go-sonos/upnp/event.go:218 +0x126
created by github.com/ianr0bkny/go-sonos/upnp.(*upnpDefaultReactor).Init
/Users/dsully/dev/sonos-go-tools/vendor/src/github.com/ianr0bkny/go-sonos/upnp/event.go:151 +0x359
If I comment out:
xml.Unmarshal([]byte(doc.LastChange), &this.AVTransportState.LastChange)
upnp/AVTransport.go line 132, the code continues. I'm not familiar enough with golang to understand fully what's going on here.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.