workerproto

package
v0.1.0-alpha.78 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: GPL-3.0 Imports: 1 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package workerproto defines the NDJSON protocol between the MagicHandy core and the native Bluetooth worker process. The worker is a thin radio pipe: it connects, writes the bytes the core composed and reports what the device sends back. Every protocol decision stays in the core.

Index

Constants

View Source
const (
	TypeHello      = "hello"
	TypeDiscover   = "discover"
	TypeConnect    = "connect"
	TypeWrite      = "write"
	TypeBattery    = "battery"
	TypeLastWill   = "last_will"
	TypeDisconnect = "disconnect"
	TypeShutdown   = "shutdown"

	TypeConnected    = "connected"
	TypeDiscovered   = "discovered"
	TypeWritten      = "written"
	TypeNotify       = "notify"
	TypeDisconnected = "disconnected"
	TypeError        = "error"
)

Message types. Requests flow core to worker; replies carry the request ID. Unsolicited events carry no ID.

View Source
const (
	CodeNotFound     = "not_found"
	CodeUnavailable  = "bluetooth_unavailable"
	CodeUnsupported  = "unsupported_device"
	CodeNotConnected = "not_connected"
	CodeBusy         = "busy"
	CodeWriteFailed  = "write_failed"
	CodeConnect      = "connect_failed"
	CodeDiscovery    = "discovery_failed"
	CodeBadRequest   = "bad_request"
	CodeAmbiguous    = "ambiguous_device"
)

Error codes reported by the worker.

View Source
const MaxLineBytes = 64 * 1024

MaxLineBytes bounds one protocol line in either direction.

View Source
const Version = 4

Version is the protocol version both sides must agree on in hello.

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	Type                 string          `json:"type"`
	ID                   string          `json:"id,omitempty"`
	Protocol             int             `json:"protocol,omitempty"`
	Worker               string          `json:"worker,omitempty"`
	Profile              string          `json:"profile,omitempty"`
	Profiles             []string        `json:"profiles,omitempty"`
	MaxWriteBytes        int             `json:"max_write_bytes,omitempty"`
	UnacknowledgedWrites bool            `json:"unacknowledged_writes,omitempty"`
	Platform             string          `json:"platform,omitempty"`
	Name                 string          `json:"name,omitempty"`
	Address              string          `json:"address,omitempty"`
	SelectedAddress      bool            `json:"selected_address,omitempty"`
	Candidates           []ble.Candidate `json:"candidates,omitempty"`
	ConnectTimeout       int             `json:"connect_timeout_ms,omitempty"`
	ScanTimeout          int             `json:"scan_timeout_ms,omitempty"`
	Data                 string          `json:"data,omitempty"`
	// Ack selects GATT Write With Response. Every write carrying an ID gets
	// a worker completion reply, including Write Without Response.
	Ack     bool   `json:"ack,omitempty"`
	Percent *int   `json:"percent,omitempty"`
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`
	Reason  string `json:"reason,omitempty"`
}

Message is one protocol line. Data is hex-encoded bytes.

Jump to

Keyboard shortcuts

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