discovery

package
v0.5.37 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 17 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 MakeSessionDataChunks added in v0.5.11

func MakeSessionDataChunks(fromSession, toSession string, data []byte) [][]byte

MakeSessionDataChunks splits data into BLE chunk frames carrying explicit sender and recipient session IDs. This lets platforms that can only broadcast notifications filter messages locally.

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)

type SessionChunkAssembler added in v0.5.11

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

SessionChunkAssembler reassembles session-addressed BLE chunks by sender. Not goroutine-safe — the caller must serialize Feed calls per instance.

func NewSessionChunkAssembler added in v0.5.11

func NewSessionChunkAssembler() *SessionChunkAssembler

func (*SessionChunkAssembler) Feed added in v0.5.11

func (a *SessionChunkAssembler) Feed(localSession string, chunk []byte) (string, []byte, bool)

Feed processes one raw session BLE chunk. It returns the sender session ID, assembled data, and done=true only when the chunk targets localSession and a full message has been reassembled.

func (*SessionChunkAssembler) Reset added in v0.5.11

func (a *SessionChunkAssembler) Reset(sessionID string)

Jump to

Keyboard shortcuts

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