Skip to content

Commit eda337a

Browse files
committed
Remove reference to storage
1 parent 78ee8bb commit eda337a

File tree

3 files changed

+13
-24
lines changed

3 files changed

+13
-24
lines changed

_example/tv/main.go

+13-14
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ package main
22

33
import (
44
"fmt"
5+
56
"github.com/brutella/hc"
67
"github.com/brutella/hc/accessory"
78
"github.com/brutella/hc/characteristic"
89
"github.com/brutella/hc/log"
910
"github.com/brutella/hc/service"
10-
"github.com/brutella/hc/util"
1111
)
1212

13-
func addInputSource(t *accessory.Television, id int, name string, inputSourceType int, storage util.Storage) {
13+
func addInputSource(t *accessory.Television, id int, name string, inputSourceType int) {
1414
in := service.NewInputSource()
1515

1616
in.Identifier.SetValue(id)
@@ -22,15 +22,8 @@ func addInputSource(t *accessory.Television, id int, name string, inputSourceTyp
2222
t.AddService(in.Service)
2323
t.Television.AddLinkedService(in.Service)
2424

25-
key := fmt.Sprintf("input-%d", id)
26-
if b, err := storage.Get(key); err == nil && len(b) > 0 {
27-
fmt.Println("restore configured name", string(b))
28-
in.ConfiguredName.SetValue(string(b))
29-
}
30-
3125
in.ConfiguredName.OnValueRemoteUpdate(func(str string) {
3226
fmt.Printf(" %s configured name => %s\n", name, str)
33-
storage.Set(key, []byte(str))
3427
})
3528
in.InputSourceType.OnValueRemoteUpdate(func(v int) {
3629
fmt.Printf(" %s source type => %v\n", name, v)
@@ -143,11 +136,17 @@ func main() {
143136
config := hc.Config{Pin: "12344321", StoragePath: "./db"}
144137
t, err := hc.NewIPTransport(config, acc.Accessory)
145138

146-
addInputSource(acc, 1, "HDMI 1", characteristic.InputSourceTypeHdmi, t.Storage())
147-
addInputSource(acc, 2, "HDMI 2", characteristic.InputSourceTypeHdmi, t.Storage())
148-
addInputSource(acc, 3, "Netflix", characteristic.InputSourceTypeApplication, t.Storage())
149-
addInputSource(acc, 4, "YouTube", characteristic.InputSourceTypeApplication, t.Storage())
150-
addInputSource(acc, 5, "Twitter", characteristic.InputSourceTypeApplication, t.Storage())
139+
addInputSource(acc, 1, "HDMI 1", characteristic.InputSourceTypeHdmi)
140+
addInputSource(acc, 2, "HDMI 2", characteristic.InputSourceTypeHdmi)
141+
addInputSource(acc, 3, "Netflix", characteristic.InputSourceTypeApplication)
142+
addInputSource(acc, 4, "YouTube", characteristic.InputSourceTypeApplication)
143+
addInputSource(acc, 5, "Twitter", characteristic.InputSourceTypeApplication)
144+
addInputSource(acc, 6, "Composite Video", characteristic.InputSourceTypeCompositeVideo)
145+
addInputSource(acc, 7, "S-Video", characteristic.InputSourceTypeSVideo)
146+
addInputSource(acc, 8, "Component Video", characteristic.InputSourceTypeComponentVideo)
147+
addInputSource(acc, 9, "Dvi", characteristic.InputSourceTypeDvi)
148+
addInputSource(acc, 10, "Airplay", characteristic.InputSourceTypeAirplay)
149+
addInputSource(acc, 11, "Usb", characteristic.InputSourceTypeUsb)
151150

152151
if err != nil {
153152
log.Info.Panic(err)

ip_transport.go

-4
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,6 @@ func (t *ipTransport) Handle(ev interface{}) {
280280
}
281281
}
282282

283-
func (t *ipTransport) Storage() util.Storage {
284-
return t.storage
285-
}
286-
287283
func newService(config *Config) dnssd.Service {
288284
// 2016-03-14(brutella): Replace whitespaces (" ") from service name
289285
// with underscores ("_")to fix invalid http host header field value

transport.go

-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package hc
22

3-
import (
4-
"github.com/brutella/hc/util"
5-
)
6-
73
// Transport provides accessories over a network.
84
type Transport interface {
95
// Start starts the transport
@@ -12,6 +8,4 @@ type Transport interface {
128
// Stop stops the transport
139
// Use the returned channel to wait until the transport is fully stopped.
1410
Stop() <-chan struct{}
15-
16-
Storage() util.Storage
1711
}

0 commit comments

Comments
 (0)