Code Monkey home page Code Monkey logo

Comments (10)

bahlo avatar bahlo commented on June 24, 2024 2

@srizzling You can just expand the slice with ... (more info):

t, err := hc.NewIPTransport(config, nil, accs...)

from hc.

brutella avatar brutella commented on June 24, 2024

The second argument of NewIPTransport() is a variable length array of devices.

You can add multiple devices by calling hap.NewIPTransport("00102003", switch.Accessory, outlet.Accessory)

from hc.

bahlo avatar bahlo commented on June 24, 2024

Okay, thank you very much!

from hc.

0x6368 avatar 0x6368 commented on June 24, 2024

I get the same error when I run _example/example.go even though no other process listens to port 5353. At least this is what the Terminal command lsof -i udp:5353 tells me. Any idea what the problem might be?

from hc.

brutella avatar brutella commented on June 24, 2024

The error output comes from here
mDNS uses the same port for IPv4 and IPv6

from hc.

0x6368 avatar 0x6368 commented on June 24, 2024

Does this mean I can just ignore it, because it already listens on the IPv4 address?

from hc.

brutella avatar brutella commented on June 24, 2024

Yes

from hc.

srizzling avatar srizzling commented on June 24, 2024

@brutella How would I go about adding multiple devices dynamically if I have a list of switches in a slice?

I'm new to Golang, and I'm not sure how I'll add a slice.

For example, here is my code:

for _, e := range *aliases {
		switchInfo := accessory.Info{
			Name: e,
		}

		acc := accessory.NewSwitch(switchInfo)
		accs = append(accs, acc.Accessory)

	}

	// TODO: figure out how to get generate this
	config := hc.Config{Pin: "12344321", Port: "12345", StoragePath: "./db"}
	t, err := hc.NewIPTransport(config, nil, accs)

I want to be able to dynamically add accessories

from hc.

brutella avatar brutella commented on June 24, 2024

This should do the trick.

t, err := hc.NewIPTransport(config, accs...)

from hc.

srizzling avatar srizzling commented on June 24, 2024

Ah cheers.. I should have probably read the slices doc. Thanks!

from hc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.