brutella / hc

hc is a lightweight framework to develop HomeKit accessories in Go.
Apache License 2.0
1.74k stars 189 forks source link

NewIPTransport seems not to work. #135

Closed cpp closed 5 years ago

cpp commented 5 years ago

When I try the lightbulb example I get the following error:

github.com/brutella/hc

../../../github.com/brutella/hc/ip_transport.go:296:12: undefined: dnssd.Config ../../../github.com/brutella/hc/ip_transport.go:304:15: assignment mismatch: 2 variables but 1 values ../../../github.com/brutella/hc/ip_transport.go:304:34: not enough arguments in call to dnssd.NewService

brutella commented 5 years ago

Run go get -u all and try again. https://golang.org/cmd/go/#hdr-Download_and_install_packages_and_dependencies

cpp commented 5 years ago

That did not change anything. I had installed the packages manually before. When I remove hc and dnssd and run go get there is the same error:

go get -v
github.com/brutella/hc (download)
github.com/brutella/hc
# github.com/brutella/hc
../../../github.com/brutella/hc/ip_transport.go:296:12: undefined: dnssd.Config
../../../github.com/brutella/hc/ip_transport.go:304:15: assignment mismatch: 2 variables but 1 values
../../../github.com/brutella/hc/ip_transport.go:304:34: not enough arguments in call to dnssd.NewService

But dnssd was not installed. I had to add it manually again and on executing go run the error appears again. Seems like it cant find the package somehow.

brutella commented 5 years ago

OK, I've fixed it by updating the dnssd library in the vendor directory. Please check out the latest master.

cpp commented 5 years ago

The program is running now, thanks. But when I change the Switch trough my iPhone it chrashes with the following error:

2019/04/03 18:20:49 http: panic serving 192.168.0.178:50626: interface conversion: interface {} is float64, not bool
goroutine 41 [running]:
net/http.(*conn).serve.func1(0x96cd20)
        /usr/local/go/src/net/http/server.go:1746 +0x9c
panic(0x304508, 0x92de60)
        /usr/local/go/src/runtime/panic.go:513 +0x194
github.com/brutella/hc/characteristic.(*Bool).OnValueRemoteUpdate.func1(0x3a4a18, 0x947900, 0x8ce700, 0x2f2b40, 0xad2708, 0x2f2840, 0x584e18)
        /home/stefan/golang/src/github.com/brutella/hc/characteristic/bool.go:38 +0x50
github.com/brutella/hc/characteristic.(*Characteristic).onValueUpdateFromConn(0x8ce700, 0x878a80, 0x2, 0x2, 0x3a4a18, 0x947900, 0x2f2b40, 0xad2708, 0x2f2840, 0x584e18)
        /home/stefan/golang/src/github.com/brutella/hc/characteristic/characteristic.go:194 +0x64
github.com/brutella/hc/characteristic.(*Characteristic).updateValue(0x8ce700, 0x2f2b40, 0xad2708, 0x3a4a18, 0x947900, 0x878a01)
        /home/stefan/golang/src/github.com/brutella/hc/characteristic/characteristic.go:180 +0x1c4
github.com/brutella/hc/characteristic.(*Characteristic).UpdateValueFromConnection(0x8ce700, 0x2f2b40, 0xad2708, 0x3a4a18, 0x947900)
        /home/stefan/golang/src/github.com/brutella/hc/characteristic/characteristic.go:87 +0x44
github.com/brutella/hc/hap/controller.(*CharacteristicController).HandleUpdateCharacteristics(0x948018, 0xa383f0d8, 0x8993e0, 0x3a4a18, 0x947900, 0x1, 0x1)
        /home/stefan/golang/src/github.com/brutella/hc/hap/controller/characteristic_controller.go:86 +0x244
github.com/brutella/hc/hap/endpoint.(*Characteristics).ServeHTTP(0x9460c0, 0x3a3d58, 0x87f950, 0x8cf280)
        /home/stefan/golang/src/github.com/brutella/hc/hap/endpoint/characteristics.go:51 +0x3d0
net/http.(*ServeMux).ServeHTTP(0x946040, 0x3a3d58, 0x87f950, 0x8cf280)
        /usr/local/go/src/net/http/server.go:2361 +0x108
net/http.serverHandler.ServeHTTP(0x956180, 0x3a3d58, 0x87f950, 0x8cf280)
        /usr/local/go/src/net/http/server.go:2741 +0x74
net/http.(*conn).serve(0x96cd20, 0x3a3e58, 0x92d4c0)
        /usr/local/go/src/net/http/server.go:1847 +0x58c
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:2851 +0x290
DEBUG 2019/04/03 18:20:49 Close connection and remove session
DEBUG 2019/04/03 18:20:49 Decryption failed: read tcp 192.168.0.59:12345->192.168.0.178:50626: use of closed network connection
brutella commented 5 years ago

Which version of Go are you using?

cpp commented 5 years ago

go version go1.11.5 linux/arm

brutella commented 5 years ago

I've just pushed a possible fix for this issue. dde85b5fdca57bad8f2439bbe5c57c4321e5555e

Please check out the master branch.

cpp commented 5 years ago

That fixed it.

peet86 commented 5 years ago

@brutella Can you please release this bugfix? Right now the hklight and switch example (example folder) you provide are failing when you turn on/off something from the Homekit App. (go1.12.5)

brutella commented 5 years ago

@brutella Can you please release this bugfix? Right now the hklight and switch example (example folder) you provide are failing when you turn on/off something from the Homekit App. (go1.12.5)

I've just tested the hklight and switch example and both work for me.

peet86 commented 5 years ago

Sorry, maybe it was only on my machine.. (First with v1.1.0 version I had the same issue like cpp but after I checked out the master branch the issue went away and now everything works fine)