finder

package
v0.0.0-...-7a59755 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 18, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcast

type Broadcast struct {
	// contains filtered or unexported fields
}

Broadcast represents a broadcast message sent by a Robomaster robot.

func ParseBroadcast

func ParseBroadcast(data []byte) (*Broadcast, error)

ParseBroadcast parses the given data as a BroadcastMessage. It returns the associated BroadcastMessage instance pointer and a nil error on success and a nil BroadcastMessage and a non-nil error on failure.

func (*Broadcast) AppId

func (b *Broadcast) AppId() uint64

func (*Broadcast) IsPairing

func (b *Broadcast) IsPairing() bool

func (*Broadcast) SourceIp

func (b *Broadcast) SourceIp() net.IP

func (*Broadcast) SourceMac

func (b *Broadcast) SourceMac() net.HardwareAddr

func (*Broadcast) String

func (b *Broadcast) String() string

type Finder

type Finder struct {
	// contains filtered or unexported fields
}

Finder provides an interface for finding a robot broadcasting its ip in the network.

func New

func New(appID uint64, l *logger.Logger) *Finder

New returns a new Finder instance. If appID is zero, consider any robots detected in the network regardless of their pairing status or appID. If appID is non-zero, returns only robots with the given appID and that are not in pairing mode.

func (*Finder) Find

func (f *Finder) Find(timeout time.Duration) (*Broadcast, error)

Find waits for a robot to broadcast its IP address in the network. It returns a non-nil error if no robot is found in the given timeout.

func (*Finder) SendACK

func (f *Finder) SendACK(ip net.IP, appID uint64)

SendACK sends an ACK message to the given IP address. This is used to acknowledge a pairing request.

func (*Finder) StartFinding

func (f *Finder) StartFinding(ch chan<- *Broadcast) error

StartFinding starts listening for Robomaster broadcast messages in the network. It returns a non-nil error if it is already looking for robots.

func (*Finder) StopFinding

func (f *Finder) StopFinding() error

StopFinding stops listening for Robomaster broadcast messages in the network. It returns a non-nil error if it is not currently looking for robots.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL