discovery

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdvertiseSSDP

func AdvertiseSSDP(ctx context.Context, nickname, ip string, port int, peerID string) (stop func(), err error)

AdvertiseSSDP announces this peer on the local network. ip should be a routable interface address (not 0.0.0.0); peerID is the libp2p host ID so receivers can construct a full multiaddr and dial back.

func BLECentralSendData added in v0.4.0

func BLECentralSendData(peripheralUUID string, data []byte)

func BLECentralSendSDP added in v0.3.0

func BLECentralSendSDP(_ string, _ string)

func BLEPeripheralSendDataTo added in v0.4.0

func BLEPeripheralSendDataTo(_ string, _ []byte)

func BLEPeripheralSendSDP added in v0.3.0

func BLEPeripheralSendSDP(_ string)

func BrowseBonjour

func BrowseBonjour(ctx context.Context, mgr *Manager) (stop func(), err error)

func ListenWSD

func ListenWSD(ctx context.Context, mgr *Manager) error

func MakeDataChunks added in v0.4.0

func MakeDataChunks(data []byte) [][]byte

MakeDataChunks splits data into BLE chunk frames for DataChar transmission. Each chunk: [type(1)][idx_hi(1)][idx_lo(1)][total_hi(1)][total_lo(1)][payload...]

func RegisterBonjour

func RegisterBonjour(nickname string, port int, fullAddrs []multiaddr.Multiaddr) (*zeroconf.Server, error)

func SearchSSDP

func SearchSSDP(ctx context.Context, mgr *Manager) (stop func(), err error)

func SendWSDHello

func SendWSDHello(ctx context.Context, nickname string, port int) error

func SetBLECallbacks added in v0.3.0

func SetBLECallbacks(_ func(string, string), _ func(string, string, bool), _ func(string))

func SetBLEDataCallback added in v0.4.0

func SetBLEDataCallback(onData func(peerUUID string, data []byte))

func StartBLE

func StartBLE(ctx context.Context, nickname string, mgr *Manager) error

Types

type ChunkAssembler added in v0.4.0

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

ChunkAssembler reassembles BLE DataChar chunk sequences per peer. Not goroutine-safe — the caller must serialize Feed calls per instance.

func NewChunkAssembler added in v0.4.0

func NewChunkAssembler() *ChunkAssembler

func (*ChunkAssembler) Feed added in v0.4.0

func (a *ChunkAssembler) Feed(peerKey string, chunk []byte) ([]byte, bool)

Feed processes one raw BLE notification chunk for the given peer key. Returns (assembled data, true) when all chunks for a sequence have arrived.

func (*ChunkAssembler) Reset added in v0.4.0

func (a *ChunkAssembler) Reset(peerKey string)

Reset discards any partial assembly state for peerKey. Call when a peer disconnects to prevent stale buffer accumulation.

type DiscoveredPeer

type DiscoveredPeer struct {
	ID       peer.ID
	Nickname string
	Addrs    []multiaddr.Multiaddr
	Addr     string // fallback for non-libp2p proximity signals (BLE)
	Source   string // "mdns", "ssdp", "wsd", "ble", "dht"
}

type Manager

type Manager struct {
	OnPeerFound func(DiscoveredPeer)
	OnPeerLost  func(DiscoveredPeer)
	// contains filtered or unexported fields
}

func NewManager

func NewManager(nickname string) *Manager

func (*Manager) Forget

func (m *Manager) Forget(key string)

func (*Manager) Notify

func (m *Manager) Notify(p DiscoveredPeer)

Jump to

Keyboard shortcuts

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