transport

package
v0.1.0-alpha.91 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: GPL-3.0 Imports: 24 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 transport defines Handy transport contracts and deterministic fake implementations used before real device integration exists.

Index

Constants

View Source
const (
	AutoblowUltraDevice = "autoblow"
	VacuGlideDevice     = "vacuglide"
)

Device IDs of Autoblow's cloud devices, as playback participants know them.

View Source
const (
	// BrowserBluetoothName is the diagnostics transport name for browser-owned BLE.
	BrowserBluetoothName = "browser_bluetooth_hsp"
)
View Source
const NativeBluetoothName = "native_bluetooth_hsp"

NativeBluetoothName identifies native Handy HSP diagnostics.

Variables

View Source
var ErrAirRejected = errors.New("air adjustment was not admitted")

ErrAirRejected is a refused semantic air request, without a transport failure.

View Source
var ErrTempoUnavailable = errors.New("no device in this run plays tempo; include the VacuGlide in playback")

ErrTempoUnavailable means no active device in this run plays tempo.

View Source
var ErrVibrationUnavailable = errors.New("no active vibrator remains in this run")

ErrVibrationUnavailable means no active scalar recipient remains in this run. It is not a failure of the healthy linear participants.

Functions

This section is empty.

Types

type AirAdjustment

type AirAdjustment struct {
	Revision uint64 `json:"revision"`
	Steps    int    `json:"steps"`
}

AirAdjustment is an engine-admitted relative step, fenced against replay.

type AlignedPlayer

type AlignedPlayer interface {
	PlayAligned(ctx context.Context, command PlayCommand, start time.Time) (CommandResult, error)
}

AlignedPlayer starts a companion on another participant's clock: stream millisecond 0 is start, so it never renders against its own provisional anchor before a linked session aligns it.

type AppendPointsCommand

type AppendPointsCommand struct {
	StreamID string       `json:"stream_id"`
	Points   []TimedPoint `json:"points"`
	// Vibration carries engine-sampled relative drive; owners without that
	// output ignore it. An empty linear frame updates only this output.
	Vibration     *VibrationFrame `json:"vibration,omitempty"`
	VibrationOnly bool            `json:"vibration_only,omitempty"`
	// Tempo carries engine-sampled tempo for owners that make their own
	// strokes (ADR 0071); other owners ignore it. A frame without points
	// updates only the tempo owners.
	Tempo     *TempoFrame `json:"tempo,omitempty"`
	TempoOnly bool        `json:"tempo_only,omitempty"`
	// Air is a one-time relative adjustment on the same admitted stream.
	// It is never inferred from positions or replayed with an envelope refill.
	Air *AirAdjustment `json:"air,omitempty"`
	// SpeedPercent is the plan's commanded pace, 1..100, when it has one. A
	// vibrator reads it as The Handy's intensity until a model chooses its
	// level (ADR 0061); other owners ignore it.
	SpeedPercent int `json:"speed_percent,omitempty"`
}

AppendPointsCommand appends timed points to a stream.

type AutoblowConfig

type AutoblowConfig struct {
	Token        string
	OffsetMillis int
	// The VacuGlide's Tempo range: the motor speeds tempo 1 and 100 play
	// at, in percent, and whether motion may step its valves (ADR 0071).
	TempoMinPercent float64
	TempoMaxPercent float64
	MotionAir       bool
}

AutoblowConfig is what the user saved for one device.

type AutoblowOptions

type AutoblowOptions struct {
	Client autoblow.Options
	// Simulated names the transport as simulated in diagnostics.
	Simulated bool
	Clock     func() time.Time
	// Tick overrides the pacer interval in tests.
	Tick time.Duration
	// HealthInterval overrides how often the device's state is read.
	HealthInterval time.Duration
	// OnButton receives the device's button presses while it is connected.
	// It runs on the event goroutine and must return quickly.
	OnButton func(device, button string)
}

AutoblowOptions configures an Autoblow owner.

type AutoblowStatus

type AutoblowStatus struct {
	Device             string   `json:"device"`
	Connected          bool     `json:"connected"`
	Connecting         bool     `json:"connecting"`
	Simulated          bool     `json:"simulated"`
	TokenSet           bool     `json:"token_set"`
	Cluster            string   `json:"cluster,omitempty"`
	FirmwareVersion    float64  `json:"firmware_version,omitempty"`
	FirmwareStatus     string   `json:"firmware_status,omitempty"`
	OperationalMode    string   `json:"operational_mode,omitempty"`
	PlaybackState      string   `json:"playback_state"`
	RoundTripMillis    int64    `json:"round_trip_ms"`
	CommandedPercent   *float64 `json:"commanded_percent,omitempty"`
	Testing            bool     `json:"testing"`
	ButtonEvents       bool     `json:"button_events"`
	LastButton         string   `json:"last_button,omitempty"`
	RequestsSent       uint64   `json:"requests_sent"`
	RequestFailures    uint64   `json:"request_failures"`
	RateLimited        uint64   `json:"rate_limited"`
	RateLimitRemaining *int     `json:"rate_limit_remaining,omitempty"`
	LateSegments       uint64   `json:"late_segments,omitempty"`
	StrokeSteps        int      `json:"stroke_steps"`
	MotionAir          bool     `json:"motion_air,omitempty"`
	MotionAirSteps     int      `json:"motion_air_steps,omitempty"`
	ValveOpen          string   `json:"valve_open,omitempty"`
	LastError          string   `json:"last_error,omitempty"`
}

AutoblowStatus is a safe snapshot. Commanded values are what MagicHandy last sent, not measurements: neither device reports its position.

type AutoblowUltra

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

AutoblowUltra owns one Autoblow Ultra through Autoblow's cloud. It is a position owner like the Handy owners: the engine's neutral frame enters through AppendPoints and leaves as go-to commands, one per stroke leg, each timed to arrive as its leg begins (ADR 0069). The cloud is the only path to the device, so Stop reaches it only while the cloud does.

func NewAutoblowUltra

func NewAutoblowUltra(options AutoblowOptions) *AutoblowUltra

NewAutoblowUltra returns a disconnected owner.

func (*AutoblowUltra) AlignPlaybackStart

func (u *AutoblowUltra) AlignPlaybackStart(start time.Time)

AlignPlaybackStart re-anchors a playing stream on another owner's start.

func (*AutoblowUltra) AppendPoints

func (u *AutoblowUltra) AppendPoints(ctx context.Context, command AppendPointsCommand) (CommandResult, error)

AppendPoints stores the stream's neutral points. The owner reads them; it never reshapes the frame.

func (*AutoblowUltra) BeginEmergencyStop

func (u *AutoblowUltra) BeginEmergencyStop() func() error

BeginEmergencyStop stops the Ultra beside the engine's Stop and returns a wait. A disconnected Ultra has nothing to stop.

func (*AutoblowUltra) Close

func (u *AutoblowUltra) Close() error

Close disconnects and refuses later connections.

func (*AutoblowUltra) Configure

func (u *AutoblowUltra) Configure(config AutoblowConfig)

Configure applies the saved token and timing offset. A new token takes effect at the next Connect.

func (*AutoblowUltra) Connect

func (u *AutoblowUltra) Connect(ctx context.Context) (AutoblowStatus, error)

Connect opens the cloud connection and stops the Ultra.

func (*AutoblowUltra) Connected

func (b *AutoblowUltra) Connected() bool

Connected reports whether a cloud connection is open.

func (*AutoblowUltra) ControlGeneration

func (b *AutoblowUltra) ControlGeneration() uint64

ControlGeneration fences a test or valve step against a later Stop.

func (*AutoblowUltra) Diagnostics

func (u *AutoblowUltra) Diagnostics() TransportDiagnostics

Diagnostics returns the snapshot the engine reads for playback health.

func (*AutoblowUltra) Disconnect

func (u *AutoblowUltra) Disconnect() (AutoblowStatus, error)

Disconnect stops the Ultra, then closes the connection.

func (*AutoblowUltra) MotionSamplingCapabilities

func (u *AutoblowUltra) MotionSamplingCapabilities() MotionSamplingCapabilities

MotionSamplingCapabilities asks for sparse curves: every go-to is a cloud request, and positions are whole percent after the window.

func (*AutoblowUltra) MotionTimingCapabilities

func (u *AutoblowUltra) MotionTimingCapabilities() MotionTimingCapabilities

MotionTimingCapabilities asks for legs no shorter than the Ultra can make and enough frame ahead for the lookahead, the preroll and the cloud.

func (*AutoblowUltra) MotionTransport

func (u *AutoblowUltra) MotionTransport() (Transport, error)

MotionTransport admits an engine bound to the current connection.

func (*AutoblowUltra) Play

func (u *AutoblowUltra) Play(ctx context.Context, command PlayCommand) (CommandResult, error)

Play starts the prepared stream after a preroll that brings the slider to its first point.

func (*AutoblowUltra) PlayAligned

func (u *AutoblowUltra) PlayAligned(ctx context.Context, command PlayCommand, start time.Time) (CommandResult, error)

PlayAligned starts on a linked session's clock.

func (*AutoblowUltra) PlaybackStartTime

func (u *AutoblowUltra) PlaybackStartTime() time.Time

PlaybackStartTime reports the local time of stream millisecond 0.

func (*AutoblowUltra) SessionID

func (b *AutoblowUltra) SessionID() uint64

SessionID changes only at connection boundaries.

func (*AutoblowUltra) SetStrokeWindow

func (u *AutoblowUltra) SetStrokeWindow(ctx context.Context, command StrokeWindowCommand) (CommandResult, error)

SetStrokeWindow applies the physical window host-side, exactly once, like the Intiface owner: the Ultra has no window of its own.

func (*AutoblowUltra) Status

func (u *AutoblowUltra) Status() AutoblowStatus

Status returns a safe snapshot.

func (*AutoblowUltra) Stop

func (u *AutoblowUltra) Stop(ctx context.Context, command StopCommand) (CommandResult, error)

Stop ends the stream and stops the Ultra whatever it is doing.

func (*AutoblowUltra) TestAt

func (u *AutoblowUltra) TestAt(generation uint64) error

TestAt strokes gently for a few seconds while motion is idle. generation fences a test requested before a Stop.

type BrowserBluetoothBridge

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

BrowserBluetoothBridge is a synchronous server-side bridge for a browser-owned Web Bluetooth Handy link.

func NewBrowserBluetoothBridge

func NewBrowserBluetoothBridge(options ...BrowserBluetoothBridgeOption) *BrowserBluetoothBridge

NewBrowserBluetoothBridge returns a browser-owned Bluetooth bridge.

func (*BrowserBluetoothBridge) Acknowledge

Acknowledge records a browser command result.

func (*BrowserBluetoothBridge) ConnectClient

ConnectClient marks a browser tab as the active Bluetooth owner.

func (*BrowserBluetoothBridge) DisconnectClient

func (b *BrowserBluetoothBridge) DisconnectClient(clientID string, message string) BrowserBluetoothBridgeSnapshot

DisconnectClient marks the active browser owner as disconnected.

func (*BrowserBluetoothBridge) NextCommands

NextCommands returns pending commands for a browser long poll.

func (*BrowserBluetoothBridge) SendCommand

func (b *BrowserBluetoothBridge) SendCommand(ctx context.Context, kind CommandKind, path string, body map[string]any) BrowserBluetoothBridgeAck

SendCommand queues a command for the active browser and waits for its result.

func (*BrowserBluetoothBridge) SessionID

func (b *BrowserBluetoothBridge) SessionID() uint64

SessionID identifies the current browser connection, including same-tab reconnects.

func (*BrowserBluetoothBridge) Snapshot

Snapshot returns the current safe bridge status.

func (*BrowserBluetoothBridge) UpdateClient

UpdateClient records a browser status or heartbeat.

type BrowserBluetoothBridgeAck

type BrowserBluetoothBridgeAck = HandyBluetoothAck

BrowserBluetoothBridgeAck is the browser command result shape.

type BrowserBluetoothBridgeCommand

type BrowserBluetoothBridgeCommand struct {
	ID        string         `json:"id"`
	Path      string         `json:"path"`
	Kind      CommandKind    `json:"kind,omitempty"`
	Body      map[string]any `json:"body,omitempty"`
	CreatedAt string         `json:"created_at"`
}

BrowserBluetoothBridgeCommand is the command shape consumed by the browser.

type BrowserBluetoothBridgeOption

type BrowserBluetoothBridgeOption func(*BrowserBluetoothBridge)

BrowserBluetoothBridgeOption configures a browser-owned Bluetooth bridge.

func WithBrowserBluetoothClock

func WithBrowserBluetoothClock(clock func() time.Time) BrowserBluetoothBridgeOption

WithBrowserBluetoothClock sets the bridge clock for tests.

func WithBrowserBluetoothCommandTimeout

func WithBrowserBluetoothCommandTimeout(timeout time.Duration) BrowserBluetoothBridgeOption

WithBrowserBluetoothCommandTimeout sets the bridge command timeout.

func WithBrowserBluetoothStaleAfter

func WithBrowserBluetoothStaleAfter(timeout time.Duration) BrowserBluetoothBridgeOption

WithBrowserBluetoothStaleAfter sets the bridge stale-tab window.

type BrowserBluetoothBridgeSnapshot

type BrowserBluetoothBridgeSnapshot struct {
	Transport         string                         `json:"transport"`
	Connected         bool                           `json:"connected"`
	Ready             bool                           `json:"ready"`
	Supported         bool                           `json:"supported"`
	Stale             bool                           `json:"stale"`
	Status            string                         `json:"status"`
	Message           string                         `json:"message"`
	DeviceName        string                         `json:"device_name,omitempty"`
	DeviceID          string                         `json:"device_id,omitempty"`
	Protocol          string                         `json:"protocol,omitempty"`
	ClientID          string                         `json:"client_id,omitempty"`
	Pending           int                            `json:"pending"`
	Inflight          int                            `json:"inflight"`
	LastSeenAgeMillis *float64                       `json:"last_seen_age_ms,omitempty"`
	LastError         string                         `json:"last_error,omitempty"`
	LastAck           *BrowserBluetoothBridgeAck     `json:"last_ack,omitempty"`
	HSPState          *BrowserBluetoothPlaybackState `json:"hsp_state,omitempty"`
}

BrowserBluetoothBridgeSnapshot is a safe bridge status view.

type BrowserBluetoothClientStatus

type BrowserBluetoothClientStatus struct {
	ClientID   string                         `json:"client_id"`
	Connected  *bool                          `json:"connected,omitempty"`
	Supported  *bool                          `json:"supported,omitempty"`
	Status     string                         `json:"status,omitempty"`
	Message    string                         `json:"message,omitempty"`
	DeviceName string                         `json:"device_name,omitempty"`
	DeviceID   string                         `json:"device_id,omitempty"`
	Protocol   string                         `json:"protocol,omitempty"`
	Error      string                         `json:"error,omitempty"`
	HSPState   *BrowserBluetoothPlaybackState `json:"hsp_state,omitempty"`
}

BrowserBluetoothClientStatus is a browser tab status update.

type BrowserBluetoothError

type BrowserBluetoothError struct {
	Status  string
	Message string
}

BrowserBluetoothError classifies bridge, browser, and device failures.

func (BrowserBluetoothError) Error

func (e BrowserBluetoothError) Error() string

Error returns the safe Bluetooth transport failure message.

type BrowserBluetoothOptions

type BrowserBluetoothOptions = HandyBluetoothOptions

BrowserBluetoothOptions is retained for the browser transport API.

type BrowserBluetoothPlaybackState

type BrowserBluetoothPlaybackState struct {
	Sequence             uint64 `json:"sequence"`
	CommandID            string `json:"command_id"`
	StreamID             int    `json:"stream_id"`
	PlayState            string `json:"play_state"`
	Points               int    `json:"points"`
	CurrentPoint         int    `json:"current_point"`
	CurrentTimeMillis    int64  `json:"current_time_ms"`
	TailPointStreamIndex int    `json:"tail_point_stream_index"`
}

BrowserBluetoothPlaybackState contains only playback telemetry from Handy notifications. Sequence orders concurrent HTTP reports within one gateway connection; stream_id prevents a delayed notification reviving an old run.

type BrowserBluetoothTransport

type BrowserBluetoothTransport = HandyBluetoothTransport

BrowserBluetoothTransport dispatches HSP commands through a browser BLE bridge.

func NewBrowserBluetoothTransport

func NewBrowserBluetoothTransport(bridge *BrowserBluetoothBridge, options BrowserBluetoothOptions) (*BrowserBluetoothTransport, error)

NewBrowserBluetoothTransport returns a transport backed by a browser bridge.

type CloudAuthMetadata

type CloudAuthMetadata struct {
	ApplicationID    string `json:"application_id"`
	ConnectionKey    string `json:"-"`
	ConnectionKeySet bool   `json:"connection_key_set"`
	FirmwareMajor    int    `json:"firmware_major"`
	APIMajor         int    `json:"api_major"`
}

CloudAuthMetadata is safe to serialize; the private connection key is omitted.

func BuildCloudAuthMetadata

func BuildCloudAuthMetadata(prerequisites CloudPrerequisites) (CloudAuthMetadata, error)

BuildCloudAuthMetadata validates firmware v4/API v3/HSP auth metadata.

type CloudBuildOptions

type CloudBuildOptions struct {
	ReverseDirection bool
}

CloudBuildOptions controls physical transport-boundary mapping.

type CloudEndpointConfig

type CloudEndpointConfig struct {
	BaseURL string
}

CloudEndpointConfig controls the Cloud REST endpoint paths used by the client.

func (CloudEndpointConfig) Validate

func (endpoint CloudEndpointConfig) Validate() error

Validate checks the Cloud API endpoint without constructing a transport.

type CloudHSPPoint

type CloudHSPPoint struct {
	X int   `json:"x"`
	T int64 `json:"t"`
}

CloudHSPPoint is the Cloud REST HSP timed-point payload shape.

type CloudPrerequisites

type CloudPrerequisites struct {
	ApplicationID string
	ConnectionKey string
	FirmwareMajor int
	APIMajor      int
	HSPAvailable  bool
}

CloudPrerequisites describes the Cloud REST prerequisites needed before live dispatch.

type CloudRESTBuilder

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

CloudRESTBuilder shapes HSP Cloud REST requests without sending them.

func NewCloudRESTBuilder

func NewCloudRESTBuilder(prerequisites CloudPrerequisites, options CloudBuildOptions) (*CloudRESTBuilder, error)

NewCloudRESTBuilder validates prerequisites and returns a pure request shaper.

func (*CloudRESTBuilder) BuildConnectionCheck

func (b *CloudRESTBuilder) BuildConnectionCheck() CloudRequest

BuildConnectionCheck shapes a Cloud REST request that checks HSP availability.

func (*CloudRESTBuilder) BuildHSPAdd

func (b *CloudRESTBuilder) BuildHSPAdd(command AppendPointsCommand) (CloudRequest, error)

BuildHSPAdd shapes a Cloud REST request that appends HSP timed points.

func (*CloudRESTBuilder) BuildHSPEvents

func (b *CloudRESTBuilder) BuildHSPEvents() CloudRequest

BuildHSPEvents shapes a Cloud REST request that opens the HSP event stream.

func (*CloudRESTBuilder) BuildHSPPlay

func (b *CloudRESTBuilder) BuildHSPPlay(command PlayCommand) (CloudRequest, error)

BuildHSPPlay shapes a Cloud REST request that starts or resumes an HSP stream.

func (*CloudRESTBuilder) BuildHSPSetup

func (b *CloudRESTBuilder) BuildHSPSetup(command HSPSetupCommand) (CloudRequest, error)

BuildHSPSetup shapes a Cloud REST request that prepares an HSP stream.

func (*CloudRESTBuilder) BuildHSPState

func (b *CloudRESTBuilder) BuildHSPState() CloudRequest

BuildHSPState shapes a Cloud REST request that reads HSP state.

func (*CloudRESTBuilder) BuildSliderState

func (b *CloudRESTBuilder) BuildSliderState() CloudRequest

BuildSliderState shapes a read-only Cloud REST slider-state request.

func (*CloudRESTBuilder) BuildStop

func (b *CloudRESTBuilder) BuildStop() CloudRequest

BuildStop shapes a Cloud REST stop request without exposing free-form reasons.

func (*CloudRESTBuilder) BuildStrokeWindow

func (b *CloudRESTBuilder) BuildStrokeWindow(command StrokeWindowCommand) (CloudRequest, error)

BuildStrokeWindow shapes the HSP stroke-window Cloud REST request.

func (*CloudRESTBuilder) BuildStrokeWindowState

func (b *CloudRESTBuilder) BuildStrokeWindowState() CloudRequest

BuildStrokeWindowState shapes a read-only Cloud REST stroke-window request.

type CloudRESTTransport

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

CloudRESTTransport dispatches HSP commands over Handy Cloud REST when called.

func NewCloudRESTTransport

func NewCloudRESTTransport(prerequisites CloudPrerequisites, options CloudBuildOptions, endpoint CloudEndpointConfig, client *http.Client) (*CloudRESTTransport, error)

NewCloudRESTTransport validates prerequisites and creates a live Cloud REST transport.

func (*CloudRESTTransport) AppendPoints

func (t *CloudRESTTransport) AppendPoints(ctx context.Context, command AppendPointsCommand) (CommandResult, error)

AppendPoints sends timed points through Cloud REST HSP.

func (*CloudRESTTransport) CheckConnection

func (t *CloudRESTTransport) CheckConnection(ctx context.Context) (ConnectionCheckResult, error)

CheckConnection probes Cloud REST HSP state without sending motion.

func (*CloudRESTTransport) Diagnostics

func (t *CloudRESTTransport) Diagnostics() TransportDiagnostics

Diagnostics returns a safe Cloud REST diagnostics snapshot.

func (*CloudRESTTransport) ListenStateEvents

func (t *CloudRESTTransport) ListenStateEvents(ctx context.Context, onEvent func(HSPStateEvent)) error

ListenStateEvents reads an HSP server-sent event stream until the context ends.

func (*CloudRESTTransport) MotionSamplingCapabilities

func (*CloudRESTTransport) MotionSamplingCapabilities() MotionSamplingCapabilities

MotionSamplingCapabilities reports API v3's whole-percent HSP endpoint resolution. The shared engine uses this to fit wire knots and verify startup; CloudRESTTransport remains a mapping/dispatch owner.

func (*CloudRESTTransport) MotionTimingCapabilities

func (*CloudRESTTransport) MotionTimingCapabilities() MotionTimingCapabilities

MotionTimingCapabilities reserves enough accepted HSP coverage for Cloud round trips and the engine's dispatch tick. Interactive motion keeps a short horizon for responsive retargets. Clock-locked media uses a deeper horizon because starving HSP playback is user-visible as a stop at a script knot.

func (*CloudRESTTransport) Play

Play starts or resumes timed-point playback through Cloud REST HSP.

func (*CloudRESTTransport) PlayAligned

func (t *CloudRESTTransport) PlayAligned(ctx context.Context, command PlayCommand, start time.Time) (CommandResult, error)

PlayAligned joins the linked stream's elapsed time after this connection's clock refresh. This avoids accumulating a full setup round trip of phase lag per Cloud companion; physical simultaneity is still an estimate.

func (*CloudRESTTransport) PlaybackStartTime

func (t *CloudRESTTransport) PlaybackStartTime() time.Time

PlaybackStartTime reports the estimated stream origin at the successful Play request midpoint. This excludes Cloud setup and prebuffer latency from the engine's playback clock.

func (*CloudRESTTransport) ReadMotionStartupState

ReadMotionStartupState reads the physical slider position and active stroke window under one transport admission. A concurrent Stop invalidates the read before a later startup command can use stale geometry.

func (*CloudRESTTransport) ReadState

ReadState reads Cloud REST HSP state without sending motion.

func (*CloudRESTTransport) SetStrokeWindow

func (t *CloudRESTTransport) SetStrokeWindow(ctx context.Context, command StrokeWindowCommand) (CommandResult, error)

SetStrokeWindow sends a Cloud REST stroke-window command.

func (*CloudRESTTransport) Stop

Stop sends a Cloud REST stop command.

type CloudRequest

type CloudRequest struct {
	Transport string            `json:"transport"`
	Operation string            `json:"operation"`
	Method    string            `json:"method"`
	Path      string            `json:"path"`
	Auth      CloudAuthMetadata `json:"auth"`
	Body      any               `json:"body,omitempty"`
	// contains filtered or unexported fields
}

CloudRequest is a safe, deterministic request shape for Cloud REST dispatch.

type Command

type Command struct {
	ID           string               `json:"id"`
	Kind         CommandKind          `json:"kind"`
	IssuedAt     string               `json:"issued_at"`
	Stop         *StopCommand         `json:"stop,omitempty"`
	StrokeWindow *StrokeWindowCommand `json:"stroke_window,omitempty"`
	HSPSetup     *HSPSetupCommand     `json:"hsp_setup,omitempty"`
	PointsAdd    *AppendPointsCommand `json:"points_add,omitempty"`
	PointsPlay   *PlayCommand         `json:"points_play,omitempty"`
}

Command is the safe serialized transport command shape used for diagnostics.

func SafeCommand

func SafeCommand(command Command) Command

SafeCommand returns a diagnostics-safe copy of command.

type CommandKind

type CommandKind string

CommandKind identifies the physical transport command family.

const (
	// CommandKindConnectionCheck checks Cloud REST/HSP availability without moving the device.
	CommandKindConnectionCheck CommandKind = "connection_check"
	// CommandKindHSPState reads Cloud REST HSP state without moving the device.
	CommandKindHSPState CommandKind = "hsp_state"
	// CommandKindHSPEvents reads Cloud REST HSP state events without moving the device.
	CommandKindHSPEvents CommandKind = "hsp_events"
	// CommandKindSliderState reads the current physical slider position without moving the device.
	CommandKindSliderState CommandKind = "slider_state"
	// CommandKindStrokeWindowState reads the current physical stroke window without moving the device.
	CommandKindStrokeWindowState CommandKind = "stroke_window_state"
	// CommandKindHSPSetup prepares an HSP stream before timed points are sent.
	CommandKindHSPSetup CommandKind = "hsp_setup"
	// CommandKindStop stops active transport playback.
	CommandKindStop CommandKind = "stop"
	// CommandKindStrokeWindow applies a physical stroke envelope.
	CommandKindStrokeWindow CommandKind = "stroke_window"
	// CommandKindPointsAdd appends timed points to a stream.
	CommandKindPointsAdd CommandKind = "points_add"
	// CommandKindPointsPlay starts or resumes a timed-point stream.
	CommandKindPointsPlay CommandKind = "points_play"
)

type CommandResult

type CommandResult struct {
	CommandID     string      `json:"command_id"`
	Kind          CommandKind `json:"kind"`
	Transport     string      `json:"transport"`
	OK            bool        `json:"ok"`
	Status        string      `json:"status"`
	LatencyMillis int64       `json:"latency_ms"`
	Error         string      `json:"error,omitempty"`
	CompletedAt   string      `json:"completed_at"`
}

CommandResult captures safe transport command outcome details.

func SafeCommandResult

func SafeCommandResult(result CommandResult) CommandResult

SafeCommandResult returns a diagnostics-safe copy of result.

func (CommandResult) ConfirmsStop

func (r CommandResult) ConfirmsStop() bool

ConfirmsStop reports an actual acknowledgement from an owner that received Stop.

type ConnectionCheckResult

type ConnectionCheckResult struct {
	OK            bool                 `json:"ok"`
	Status        string               `json:"status"`
	StatusCode    int                  `json:"status_code,omitempty"`
	HSPAvailable  bool                 `json:"hsp_available"`
	PlaybackState string               `json:"playback_state,omitempty"`
	LatencyMillis int64                `json:"latency_ms"`
	Message       string               `json:"message,omitempty"`
	Diagnostics   TransportDiagnostics `json:"diagnostics"`
}

ConnectionCheckResult is the safe result of a Cloud REST connection check.

type Coyote

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

Coyote owns one DG-LAB Coyote 3.0 connection. It is a dispatch owner like the Handy owners: the engine's neutral frame enters through AppendPoints and leaves as two-channel pulse frames through a fixed 100 ms pacer. It also owns the user's strength handshake, which nothing automated can raise.

func NewCoyote

func NewCoyote(options CoyoteOptions) *Coyote

NewCoyote returns a disconnected owner.

func (*Coyote) AdjustStrength

func (c *Coyote) AdjustStrength(channel estim.Channel, delta int) (CoyoteStatus, error)

AdjustStrength only queues a strength step. It never starts waveform output.

func (*Coyote) AdjustStrengthAt

func (c *Coyote) AdjustStrengthAt(ctx context.Context, generation uint64, channel estim.Channel, delta int) (CoyoteStatus, error)

AdjustStrengthAt applies a host request only in the generation that admitted it. Lowering remains available as a safety action and never starts output.

func (*Coyote) AlignPlaybackStart

func (c *Coyote) AlignPlaybackStart(start time.Time)

AlignPlaybackStart re-anchors a playing stream to another owner's start, so the Coyote follows the Handy when both run together.

func (*Coyote) AppendPoints

func (c *Coyote) AppendPoints(ctx context.Context, command AppendPointsCommand) (CommandResult, error)

AppendPoints stores the stream's neutral points. The owner only samples them; it never reshapes the frame.

func (*Coyote) BeginEmergencyStop

func (c *Coyote) BeginEmergencyStop() func() error

BeginEmergencyStop closes admission immediately and keeps it closed until the server has stopped every output. The returned function waits for zero, releases this hold, and reports its result. Zero can run beside a slow Handy Stop without allowing a fresh increase or test in that interval.

func (*Coyote) Close

func (c *Coyote) Close() error

Close disconnects and refuses later connections.

func (*Coyote) Configure

func (c *Coyote) Configure(config CoyoteConfig) error

Configure applies user settings. A connected device receives the new BF ceilings immediately; the profile and offset apply from the next packet.

func (*Coyote) Connect

func (c *Coyote) Connect(ctx context.Context) (CoyoteStatus, error)

Connect opens the device, re-sends the ceilings (the device does not confirm BF, so every connection writes it) and sets both channels to zero: a new connection always starts disarmed.

func (*Coyote) ConnectAddress

func (c *Coyote) ConnectAddress(ctx context.Context, address string) (CoyoteStatus, error)

ConnectAddress connects only the explicitly selected discovery candidate. Service verification occurs before arm can write limits or zero commands.

func (*Coyote) ControlGeneration

func (c *Coyote) ControlGeneration() uint64

ControlGeneration fences a control request admitted before Stop, disconnect or a ceiling transition, including requests still reading their HTTP body.

func (*Coyote) Diagnostics

func (c *Coyote) Diagnostics() TransportDiagnostics

Diagnostics returns the safe transport snapshot the engine reads for playback health.

func (*Coyote) Disconnect

func (c *Coyote) Disconnect() (CoyoteStatus, error)

Disconnect queues a zero before closing the link. Write Without Response cannot establish delivery; a device report is the only confirmed strength.

func (*Coyote) EmergencyZero

func (c *Coyote) EmergencyZero() error

EmergencyZero is the Coyote half of the global Stop: it invalidates every queued packet, ends any stream or reference pulse and sets both channels to zero. The zero is never superseded by an ordinary pause/Stop packet.

func (*Coyote) MotionReady

func (c *Coyote) MotionReady() error

MotionReady checks admission without creating a session.

func (*Coyote) MotionTimingCapabilities

func (c *Coyote) MotionTimingCapabilities() MotionTimingCapabilities

MotionTimingCapabilities asks the engine to keep enough of the frame ahead for the render lead and the largest negative timing offset.

func (*Coyote) MotionTransport

func (c *Coyote) MotionTransport() (Transport, error)

MotionTransport admits a new engine only after limits and strength are known. A known zero is a valid, silent baseline, not a readiness failure.

func (*Coyote) Play

func (c *Coyote) Play(ctx context.Context, command PlayCommand) (CommandResult, error)

Play starts the prepared stream. Output fades in from its first frame.

func (*Coyote) PlayAligned

func (c *Coyote) PlayAligned(ctx context.Context, command PlayCommand, start time.Time) (CommandResult, error)

PlayAligned starts playback on a linked session's clock: stream millisecond 0 is start, so no packet renders against a provisional anchor first.

func (*Coyote) PlaybackStartTime

func (c *Coyote) PlaybackStartTime() time.Time

PlaybackStartTime reports the local time of stream millisecond 0.

func (*Coyote) SessionID

func (c *Coyote) SessionID() uint64

SessionID changes only at link boundaries, independently of pause/Stop.

func (*Coyote) SetStrokeWindow

func (c *Coyote) SetStrokeWindow(ctx context.Context, command StrokeWindowCommand) (CommandResult, error)

SetStrokeWindow is accepted for contract compatibility. The Handy's physical window does not apply to stimulation: the profile reads the semantic span directly.

func (*Coyote) Status

func (c *Coyote) Status() CoyoteStatus

Status returns a safe snapshot.

func (*Coyote) Stop

func (c *Coyote) Stop(ctx context.Context, command StopCommand) (CommandResult, error)

Stop ends the stream and silences the device. It never touches strength: Pause also arrives here, and the global Stop zeroes through EmergencyZero.

func (*Coyote) TestChannel

func (c *Coyote) TestChannel(ctx context.Context, generation uint64, channel estim.Channel) (CoyoteStatus, error)

TestChannel starts the existing bounded calibration waveform only on an explicit host action. The shared dispatch pacer owns its timing, and Stop invalidates it just like a motion packet. Strength is never changed here.

type CoyoteConfig

type CoyoteConfig struct {
	Limits            estim.Limits
	Profile           estim.Profile
	OffsetMillis      int
	RememberedAddress string
}

CoyoteConfig is the user configuration a connection applies: the device ceilings and balance parameters (BF), the conversion profile and timing.

type CoyoteOptions

type CoyoteOptions struct {
	Connector estim.Connector
	Clock     func() time.Time
	// Tick overrides the pacer interval in tests.
	Tick time.Duration
}

CoyoteOptions configures the owner.

type CoyoteStatus

type CoyoteStatus struct {
	Connected             bool   `json:"connected"`
	Connecting            bool   `json:"connecting"`
	Simulated             bool   `json:"simulated"`
	DeviceName            string `json:"device_name,omitempty"`
	Address               string `json:"address,omitempty"`
	BatteryPercent        *int   `json:"battery_percent,omitempty"`
	StrengthA             int    `json:"strength_a"`
	StrengthB             int    `json:"strength_b"`
	StrengthKnown         bool   `json:"strength_known"`
	StrengthSource        string `json:"strength_source"`
	StrengthPending       bool   `json:"strength_pending"`
	LimitsApplied         bool   `json:"limits_applied"`
	CeilingA              int    `json:"ceiling_a"`
	CeilingB              int    `json:"ceiling_b"`
	PlaybackState         string `json:"playback_state"`
	ReferencePulse        bool   `json:"reference_pulse"`
	CommandedA            int    `json:"commanded_a"`
	CommandedB            int    `json:"commanded_b"`
	PacketsSent           uint64 `json:"packets_sent"`
	WriteFailures         uint64 `json:"write_failures"`
	StarvedPackets        uint64 `json:"starved_packets"`
	MaxSendLatenessMillis int64  `json:"max_send_lateness_ms"`
	LastError             string `json:"last_error,omitempty"`
	// SilentReason says why a connected Coyote cannot be felt, even while
	// motion plays: "ceiling_zero" (no strength is allowed) or
	// "strength_zero" (the device reported both channels at zero).
	SilentReason string `json:"silent_reason,omitempty"`
}

CoyoteStatus is a safe connection, strength and output snapshot. Output levels are the pulse widths MagicHandy last commanded, not a measurement.

type DiagnosticsProvider

type DiagnosticsProvider interface {
	Diagnostics() TransportDiagnostics
}

DiagnosticsProvider exposes a safe transport diagnostics snapshot.

type Fake

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

Fake is an in-memory Handy simulator that records commands and diagnostics.

func NewFake

func NewFake(options ...FakeOption) *Fake

NewFake returns a fake transport with deterministic command recording.

func NewSimulator

func NewSimulator() *Fake

NewSimulator creates a runtime fake that retains the latest 64 commands and results. Lifetime counters also cover the commands evicted from either ring.

func (*Fake) AppendPoints

func (f *Fake) AppendPoints(ctx context.Context, command AppendPointsCommand) (CommandResult, error)

AppendPoints records a timed-point append command.

func (*Fake) Commands

func (f *Fake) Commands() []Command

Commands returns the recorded safe command snapshots.

func (*Fake) Diagnostics

func (f *Fake) Diagnostics() TransportDiagnostics

Diagnostics returns the current fake transport diagnostics.

func (*Fake) Play

func (f *Fake) Play(ctx context.Context, command PlayCommand) (CommandResult, error)

Play records a timed-point play command.

func (*Fake) Results

func (f *Fake) Results() []CommandResult

Results returns the recorded command results.

func (*Fake) SetStrokeWindow

func (f *Fake) SetStrokeWindow(ctx context.Context, command StrokeWindowCommand) (CommandResult, error)

SetStrokeWindow records a stroke-window command.

func (*Fake) Stop

func (f *Fake) Stop(ctx context.Context, command StopCommand) (CommandResult, error)

Stop records a transport stop command.

func (*Fake) TakesTempo

func (f *Fake) TakesTempo() bool

TakesTempo reports whether the fake plays the tempo channel.

type FakeOption

type FakeOption func(*Fake)

FakeOption configures the deterministic fake transport.

func WithClock

func WithClock(clock func() time.Time) FakeOption

WithClock sets the fake transport clock.

func WithHistoryLimit

func WithHistoryLimit(limit int) FakeOption

WithHistoryLimit retains the most recent commands and results in bounded rings. NewFake without this option keeps the complete history for deterministic tests.

func WithLatency

func WithLatency(latency time.Duration) FakeOption

WithLatency sets the fake transport latency reported in command results.

func WithTempo

func WithTempo() FakeOption

WithTempo makes the fake a tempo owner, like the VacuGlide (ADR 0071).

type FanOut

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

FanOut is one linked playback session. The first participant is the run clock: companions start on its playback origin. Sampling honors all owners and each telemetry-capable slider prepares independently. A fault latches, so reconnecting cannot silently rejoin an existing run.

func (*FanOut) AppendPoints

func (f *FanOut) AppendPoints(ctx context.Context, command AppendPointsCommand) (CommandResult, error)

AppendPoints sends the shared engine's points to each active participant.

func (*FanOut) Diagnostics

func (f *FanOut) Diagnostics() TransportDiagnostics

Diagnostics is sampled by the engine's existing health loop. It has no independent dispatch goroutine and cannot resume a failed session.

func (*FanOut) LinkedSessionStatus

func (f *FanOut) LinkedSessionStatus() LinkedSessionStatus

LinkedSessionStatus reports this run's latched failure/retirement state.

func (*FanOut) MotionSamplingCapabilities

func (f *FanOut) MotionSamplingCapabilities() MotionSamplingCapabilities

MotionSamplingCapabilities honors every participant's encoding limits.

func (*FanOut) MotionStartupParticipants

func (f *FanOut) MotionStartupParticipants() []LinkedParticipant

MotionStartupParticipants lets the shared engine position each physical slider from its own telemetry. A primary's lead-in is never broadcast to another slider that may be resting at a different position.

func (*FanOut) MotionTimingCapabilities

func (f *FanOut) MotionTimingCapabilities() MotionTimingCapabilities

MotionTimingCapabilities takes the strictest value of each limit.

func (*FanOut) Play

func (f *FanOut) Play(ctx context.Context, command PlayCommand) (CommandResult, error)

Play establishes one clock, then starts the companions concurrently at its current position. All starts drain before failure rollback or return.

func (*FanOut) PlaybackStartTime

func (f *FanOut) PlaybackStartTime() time.Time

PlaybackStartTime is the clock chosen by the last successful Play. When a failed clock is retired, a later resume must report the surviving clock to the engine as well as to its companions.

func (*FanOut) SetStrokeWindow

func (f *FanOut) SetStrokeWindow(ctx context.Context, command StrokeWindowCommand) (CommandResult, error)

SetStrokeWindow applies the shared stroke window to each active participant.

func (*FanOut) Stop

func (f *FanOut) Stop(ctx context.Context, command StopCommand) (CommandResult, error)

Stop always reaches every participant, even if one fails or was retired. Fault stops zero electrical outputs; an ordinary Pause retains strength.

func (*FanOut) TakesTempo

func (f *FanOut) TakesTempo() bool

TakesTempo reports whether any active participant plays tempo.

type HSPSetupCommand

type HSPSetupCommand struct {
	StreamID uint32 `json:"stream_id"`
}

HSPSetupCommand prepares the active HSP stream on API v3 transports.

type HSPStateEvent

type HSPStateEvent struct {
	Event string          `json:"event,omitempty"`
	Data  json.RawMessage `json:"data,omitempty"`
}

HSPStateEvent is one event from the HSP state event stream.

type HSPStateSnapshot

type HSPStateSnapshot struct {
	Available     bool            `json:"available"`
	PlaybackState string          `json:"playback_state,omitempty"`
	Raw           json.RawMessage `json:"raw,omitempty"`
}

HSPStateSnapshot is a safe snapshot of Cloud REST HSP state.

type HSPUnavailableError

type HSPUnavailableError struct {
	Code       string `json:"code"`
	Field      string `json:"field,omitempty"`
	Message    string `json:"message"`
	Action     string `json:"action"`
	NoFallback bool   `json:"no_fallback"`
}

HSPUnavailableError reports failed v4/API v3/HSP prerequisites without fallback.

func (HSPUnavailableError) Error

func (e HSPUnavailableError) Error() string

Error returns the human-readable HSP prerequisite error.

type HandyBluetoothAck

type HandyBluetoothAck struct {
	ID            string         `json:"id,omitempty"`
	OK            bool           `json:"ok"`
	Status        string         `json:"status,omitempty"`
	Transport     string         `json:"transport"`
	ElapsedMillis float64        `json:"elapsed_ms,omitempty"`
	Error         string         `json:"error,omitempty"`
	Response      map[string]any `json:"response,omitempty"`
}

HandyBluetoothAck describes command completion. OK acknowledges dispatch; firmware response data, if present, is reported separately in Response.

type HandyBluetoothOptions

type HandyBluetoothOptions struct {
	ReverseDirection bool
}

HandyBluetoothOptions controls both native and browser Handy BLE mapping.

type HandyBluetoothTransport

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

HandyBluetoothTransport maps shared-engine points to either Handy BLE channel.

func (*HandyBluetoothTransport) AppendPoints

AppendPoints sends timed points through Handy HSP.

func (*HandyBluetoothTransport) CheckConnection

CheckConnection reports browser Bluetooth bridge readiness without sending a device command. Some Handy BLE commands are write-only in practice, and a state probe can destabilize an otherwise-ready browser-owned GATT link.

func (*HandyBluetoothTransport) Diagnostics

Diagnostics returns a safe Handy Bluetooth diagnostics snapshot.

func (*HandyBluetoothTransport) MotionSamplingCapabilities

func (*HandyBluetoothTransport) MotionSamplingCapabilities() MotionSamplingCapabilities

MotionSamplingCapabilities reports the Handy BLE HSP protobuf's integer percent encoding. Point.x above 100 clamps at the endpoint on firmware.

func (*HandyBluetoothTransport) MotionTimingCapabilities

func (*HandyBluetoothTransport) MotionTimingCapabilities() MotionTimingCapabilities

MotionTimingCapabilities covers the browser round trip and serialized GATT writes. Media can prebuffer more deeply without delaying interactive edits.

func (*HandyBluetoothTransport) Play

Play starts or resumes timed-point playback through Handy HSP.

func (*HandyBluetoothTransport) PlayAligned

func (t *HandyBluetoothTransport) PlayAligned(ctx context.Context, command PlayCommand, start time.Time) (CommandResult, error)

PlayAligned follows the shared timeline, with GATT delivery latency remaining a physical estimate rather than a synchronization guarantee.

func (*HandyBluetoothTransport) PlaybackStartTime

func (t *HandyBluetoothTransport) PlaybackStartTime() time.Time

PlaybackStartTime reports the estimated stream origin at the successful browser bridge Play acknowledgement midpoint.

func (*HandyBluetoothTransport) ReadState

ReadState reads browser Bluetooth HSP state.

func (*HandyBluetoothTransport) SetStrokeWindow

func (t *HandyBluetoothTransport) SetStrokeWindow(ctx context.Context, command StrokeWindowCommand) (CommandResult, error)

SetStrokeWindow sends a stroke envelope command through the Handy command channel.

func (*HandyBluetoothTransport) Stop

Stop sends an HSP stop command through the Handy command channel.

type Intiface

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

Intiface is the linear owner: one selected LinearCmd actuator and its pacer, bound to a Buttplug v3 session. Session fields are promoted from the embedded session; selection and diagnostics share its lock.

func NewIntiface

func NewIntiface(options IntifaceOptions) (*Intiface, error)

NewIntiface validates options and returns a disconnected Intiface owner with its own session.

func (*Intiface) AppendPoints

func (i *Intiface) AppendPoints(_ context.Context, command AppendPointsCommand) (CommandResult, error)

AppendPoints validates and queues point-pair LinearCmd segments without resampling.

func (*Intiface) Close

func (i *Intiface) Close() error

Close stops pacing, attempts a device stop, and tears down the session.

func (*Intiface) Connect

func (i *Intiface) Connect(ctx context.Context) error

Connect opens the owner's session; the linear pacer starts once it is ready.

func (Intiface) Devices

func (s Intiface) Devices() []IntifaceDevice

Devices returns the current safe discovered-device snapshot.

func (*Intiface) Diagnostics

func (i *Intiface) Diagnostics() TransportDiagnostics

Diagnostics returns a redacted transport diagnostics snapshot.

func (Intiface) EmergencyStop

func (s Intiface) EmergencyStop(ctx context.Context) error

EmergencyStop closes admission, invalidates every owner's playback and sends StopAllDevices, which stops every device the server has, including ones no owner selected. Admission stays closed until the Stop completes, so no owner write can follow it. A Stop that cannot be confirmed closes the session: the server then stops its devices because the client is gone.

func (*Intiface) MotionSamplingCapabilities

func (i *Intiface) MotionSamplingCapabilities() MotionSamplingCapabilities

MotionSamplingCapabilities reports the selected actuator's physical step resolution. The engine scales it back through the active stroke window before reducing semantic samples.

func (*Intiface) MotionTimingCapabilities

func (i *Intiface) MotionTimingCapabilities() MotionTimingCapabilities

MotionTimingCapabilities returns the selected device's command timing floor.

func (*Intiface) Play

func (i *Intiface) Play(ctx context.Context, command PlayCommand) (CommandResult, error)

Play starts immediate-mode pacing for the selected device and queued stream.

func (*Intiface) PlayAligned

func (i *Intiface) PlayAligned(ctx context.Context, command PlayCommand, start time.Time) (CommandResult, error)

PlayAligned starts the selected linear output at the shared stream's current position. The existing anchor and paced-command safety path remain in use.

func (*Intiface) PlaybackStartTime

func (i *Intiface) PlaybackStartTime() time.Time

PlaybackStartTime reports the post-anchor stream origin for engine clock alignment.

func (*Intiface) Release

func (i *Intiface) Release(ctx context.Context) error

Release stops and forgets the selected actuator while the session stays open for other outputs. A Stop that cannot be confirmed fails the session, because the server then stops its devices.

func (*Intiface) Select

func (i *Intiface) Select(ctx context.Context, deviceIndex, actuatorIndex uint32) error

Select chooses a linear actuator for playback. The device is claimed for this owner, and both the previous and the new device are stopped before the selection is ready, so neither keeps moving from an earlier command.

func (*Intiface) SelectDevice

func (i *Intiface) SelectDevice(deviceIndex, actuatorIndex uint32) error

SelectDevice selects one discovered device and one of its linear actuators without commanding it. Production selection uses Select, which also stops the device first.

func (*Intiface) SetStrokeWindow

func (i *Intiface) SetStrokeWindow(_ context.Context, command StrokeWindowCommand) (CommandResult, error)

SetStrokeWindow atomically updates host-side projection and direction mapping.

func (Intiface) StartScanning

func (s Intiface) StartScanning(ctx context.Context) error

StartScanning asks Intiface to begin device discovery.

func (*Intiface) Status

func (i *Intiface) Status() IntifaceStatus

Status returns a safe device, selection, and playback snapshot.

func (*Intiface) Stop

func (i *Intiface) Stop(ctx context.Context, command StopCommand) (CommandResult, error)

Stop preempts queued motion and sends Buttplug StopDeviceCmd.

func (Intiface) StopScanning

func (s Intiface) StopScanning(ctx context.Context) error

StopScanning asks Intiface to end device discovery.

type IntifaceDevice

type IntifaceDevice struct {
	DeviceIndex                  uint32                   `json:"device_index"`
	DeviceName                   string                   `json:"device_name"`
	DeviceMessageTimingGapMillis uint32                   `json:"device_message_timing_gap_ms"`
	LinearActuators              []IntifaceLinearActuator `json:"linear_actuators"`
	ScalarActuators              []IntifaceScalarActuator `json:"scalar_actuators"`
}

IntifaceDevice is a safe snapshot of a discovered Buttplug device. Both actuator lists are always present, empty when the device has none.

type IntifaceDispatchStatus

type IntifaceDispatchStatus struct {
	DeviceIndex                 uint32 `json:"device_index"`
	ActuatorIndex               uint32 `json:"actuator_index"`
	StartupAnchor               bool   `json:"startup_anchor,omitempty"`
	RelativeScheduledTimeMillis int64  `json:"relative_scheduled_time_ms"`
	ActualSendTime              string `json:"actual_send_time"`
	LatenessMillis              int64  `json:"lateness_ms"`
	EffectiveDurationMillis     int64  `json:"effective_duration_ms"`
	ACKLatencyMillis            *int64 `json:"ack_latency_ms,omitempty"`
	Status                      string `json:"status"`
}

IntifaceDispatchStatus is a bounded, protocol-safe paced-dispatch record.

type IntifaceHub

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

IntifaceHub is one Intiface Central connection shared by every output it reaches. Intiface Central serves a single client, so the linear owner (a stroker) and any other output reached through the same server bind to this one session. The hub never paces motion itself.

func NewIntifaceHub

func NewIntifaceHub(options IntifaceOptions) (*IntifaceHub, error)

NewIntifaceHub validates options and returns a disconnected hub with its linear and vibrator outputs bound.

func (*IntifaceHub) Close

func (h *IntifaceHub) Close() error

Close stops every bound output's playback and device, then closes the session.

func (*IntifaceHub) Connect

func (h *IntifaceHub) Connect(ctx context.Context) error

Connect opens the shared session; bound outputs start once it is ready.

func (*IntifaceHub) EmergencyStop

func (h *IntifaceHub) EmergencyStop(ctx context.Context) error

EmergencyStop stops every device the server has, behind a barrier that no bound output's write can pass until the Stop completes.

func (*IntifaceHub) Linear

func (h *IntifaceHub) Linear() *Intiface

Linear returns the stroker output bound to this session.

func (*IntifaceHub) LinearFor

func (h *IntifaceHub) LinearFor(id string) *Intiface

LinearFor binds a named stroker to the same socket and device-claim registry. It can be added after connection; each output still has its own queue/lease.

func (*IntifaceHub) RemoveLinear

func (h *IntifaceHub) RemoveLinear(ctx context.Context, id string) error

RemoveLinear stops and removes only this output; other hub leases survive.

func (*IntifaceHub) StartScanning

func (h *IntifaceHub) StartScanning(ctx context.Context) error

StartScanning asks Intiface to begin device discovery.

func (*IntifaceHub) Status

func (h *IntifaceHub) Status() IntifaceHubStatus

Status returns the shared connection's state and discovered devices.

func (*IntifaceHub) StopScanning

func (h *IntifaceHub) StopScanning(ctx context.Context) error

StopScanning asks Intiface to end device discovery.

func (*IntifaceHub) Vibrator

func (h *IntifaceHub) Vibrator() *IntifaceVibrator

Vibrator returns the vibrator output bound to this session.

type IntifaceHubStatus

type IntifaceHubStatus struct {
	Connected         bool  `json:"connected"`
	Scanning          bool  `json:"scanning"`
	MaxPingTimeMillis int64 `json:"max_ping_time_ms"`
	// PingWatchdog reports whether the server stops its devices when this
	// client stops answering its keepalive. Without it, only a closed
	// connection stops them.
	PingWatchdog bool             `json:"ping_watchdog"`
	Devices      []IntifaceDevice `json:"devices"`
}

IntifaceHubStatus is the shared connection's safe snapshot.

type IntifaceLinearActuator

type IntifaceLinearActuator struct {
	Index             uint32 `json:"index"`
	FeatureDescriptor string `json:"feature_descriptor,omitempty"`
	ActuatorType      string `json:"actuator_type,omitempty"`
	StepCount         uint32 `json:"step_count,omitempty"`
}

IntifaceLinearActuator describes one selectable Buttplug LinearCmd feature.

type IntifaceOptions

type IntifaceOptions struct {
	Address       string
	ClientName    string
	QueueCapacity int
	HTTPClient    *http.Client
}

IntifaceOptions configures the connection to a user-owned Intiface server.

type IntifaceScalarActuator

type IntifaceScalarActuator struct {
	Index             uint32 `json:"index"`
	FeatureDescriptor string `json:"feature_descriptor,omitempty"`
	ActuatorType      string `json:"actuator_type"`
	StepCount         uint32 `json:"step_count,omitempty"`
}

IntifaceScalarActuator describes one Buttplug ScalarCmd feature. Index is its position in the device's full ScalarCmd list, which is how ScalarCmd addresses it, so it is kept when callers filter by actuator type.

type IntifaceStatus

type IntifaceStatus struct {
	Connected                 bool                     `json:"connected"`
	Scanning                  bool                     `json:"scanning"`
	PlaybackState             string                   `json:"playback_state"`
	MaxPingTimeMillis         int64                    `json:"max_ping_time_ms"`
	QueueDepth                int                      `json:"queue_depth"`
	QueueCoverageMillis       int64                    `json:"queue_coverage_ms"`
	PendingACKs               int                      `json:"pending_acks"`
	LinearSentCount           uint64                   `json:"linear_sent_count"`
	LinearACKedCount          uint64                   `json:"linear_acked_count"`
	LinearRejectedCount       uint64                   `json:"linear_rejected_count"`
	LinearTimeoutCount        uint64                   `json:"linear_timeout_count"`
	LastACKLatencyMillis      int64                    `json:"last_ack_latency_ms"`
	MaxACKLatencyMillis       int64                    `json:"max_ack_latency_ms"`
	LastSendLatenessMillis    int64                    `json:"last_send_lateness_ms"`
	MaxSendLatenessMillis     int64                    `json:"max_send_lateness_ms"`
	CoalescedSegments         uint64                   `json:"coalesced_segments"`
	RecentDispatchesDropped   uint64                   `json:"recent_dispatches_dropped"`
	LastWireDurationMillis    int64                    `json:"last_wire_duration_ms"`
	SelectedResolutionPercent float64                  `json:"selected_resolution_percent"`
	LastPacerFailure          string                   `json:"last_pacer_failure,omitempty"`
	RecentDispatches          []IntifaceDispatchStatus `json:"recent_dispatches"`
	SelectedDeviceIndex       *uint32                  `json:"selected_device_index,omitempty"`
	SelectedActuatorIndex     *uint32                  `json:"selected_actuator_index,omitempty"`
	Devices                   []IntifaceDevice         `json:"devices"`
}

IntifaceStatus is a safe connection, selection, and pacer snapshot.

type IntifaceVibrator

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

IntifaceVibrator drives one Buttplug device's Vibrate actuators from the shared motion frame through a conversion profile. It binds to the shared Intiface session. The model may choose the level under the user's Max; only a person lifts the suspension that Stop leaves (ADR 0061).

func (*IntifaceVibrator) AlignPlaybackStart

func (v *IntifaceVibrator) AlignPlaybackStart(start time.Time)

AlignPlaybackStart re-anchors a playing stream to another owner's start.

func (*IntifaceVibrator) AppendPoints

func (v *IntifaceVibrator) AppendPoints(ctx context.Context, command AppendPointsCommand) (CommandResult, error)

AppendPoints stores the stream's neutral points. The owner only samples them; it never reshapes the frame.

func (*IntifaceVibrator) Configure

func (v *IntifaceVibrator) Configure(config VibratorConfig)

Configure applies the user's vibration settings. A lower Max or a change of model control applies at the next send, without waiting for the pacer.

func (*IntifaceVibrator) ControlGeneration

func (v *IntifaceVibrator) ControlGeneration() uint64

ControlGeneration names the vibrator state a request was prepared against.

func (*IntifaceVibrator) Diagnostics

func (v *IntifaceVibrator) Diagnostics() TransportDiagnostics

Diagnostics returns the safe transport snapshot the engine reads for playback health.

func (*IntifaceVibrator) Events

func (v *IntifaceVibrator) Events() ([]VibratorEvent, uint64)

Events returns a detached snapshot for diagnostic exports. Ordinary status polling only carries the current levels, not this history.

func (*IntifaceVibrator) ManualResumePermit

func (v *IntifaceVibrator) ManualResumePermit() (VibratorResumePermit, bool)

ManualResumePermit offers to lift Stop's suspension without playing anything. Only the application may attach it to a fresh admitted manual chat request.

func (*IntifaceVibrator) ModelLevel

func (v *IntifaceVibrator) ModelLevel() float64

ModelLevel reports the level as a fraction of Max: the model's choice, or The Handy's intensity until it chooses.

func (*IntifaceVibrator) MotionReady

func (v *IntifaceVibrator) MotionReady() error

MotionReady checks vibrator selection without binding a run.

func (*IntifaceVibrator) MotionTimingCapabilities

func (v *IntifaceVibrator) MotionTimingCapabilities() MotionTimingCapabilities

MotionTimingCapabilities declares only a buffered lead covering the timing offset and lookahead. The vibrator samples the frame itself, so it never coarsens a stroker's sampling with a point interval.

func (*IntifaceVibrator) MotionTransport

func (v *IntifaceVibrator) MotionTransport() (Transport, error)

MotionTransport admits a new engine bound to the current selection. A reselected or reconnected vibrator ends the old binding, so an old engine cannot append, play or stop the new device.

func (*IntifaceVibrator) Play

Play starts the stream on its own clock: stream millisecond 0 lands after a short pre-roll.

func (*IntifaceVibrator) PlayAligned

func (v *IntifaceVibrator) PlayAligned(ctx context.Context, command PlayCommand, start time.Time) (CommandResult, error)

PlayAligned starts the stream on a linked session's clock, so no level is rendered against a provisional anchor first.

func (*IntifaceVibrator) PlaybackStartTime

func (v *IntifaceVibrator) PlaybackStartTime() time.Time

PlaybackStartTime reports the local time of stream millisecond 0.

func (*IntifaceVibrator) Release

func (v *IntifaceVibrator) Release(ctx context.Context) error

Release stops and forgets the vibrator while the session stays open for other outputs. A Stop that cannot be confirmed fails the session, because the server then stops its devices.

func (*IntifaceVibrator) ResumeAt

func (v *IntifaceVibrator) ResumeAt(generation uint64) error

ResumeAt lifts Stop's suspension for a human action prepared at generation. It plays nothing by itself; a later run vibrates as usual.

func (*IntifaceVibrator) ResumeForManualRequest

func (v *IntifaceVibrator) ResumeForManualRequest(permit VibratorResumePermit) (func(), error)

ResumeForManualRequest lifts the suspension for a fresh manual request. It does not play anything; the existing engine start path must accept a new target. The returned rollback suspends again after a failed start, unless a newer human action has resumed or rebound the vibrator meanwhile.

func (*IntifaceVibrator) ResumePermitCurrent

func (v *IntifaceVibrator) ResumePermitCurrent(permit VibratorResumePermit) bool

ResumePermitCurrent rejects another Stop, reconnection and reselection.

func (*IntifaceVibrator) Select

func (v *IntifaceVibrator) Select(ctx context.Context, deviceIndex uint32) error

Select chooses the vibrator device. The device is claimed for this output, and both the previous and the new device are stopped before it is ready. Choosing a device is a human action, so it lifts Stop's suspension.

func (*IntifaceVibrator) SelectionEpoch

func (v *IntifaceVibrator) SelectionEpoch() uint64

SelectionEpoch changes with every selection, release and lost device, so an engine built for an older binding is rebuilt.

func (*IntifaceVibrator) SetModelLevel

func (v *IntifaceVibrator) SetModelLevel(fraction float64, glide bool) error

SetModelLevel records the model's level as a fraction of Max. With glide, output moves toward it at a bounded rate; otherwise it applies at once. A lower level always applies. A higher one is refused while Stop's suspension stands, so a stale or autonomous request cannot revive the vibrator.

func (*IntifaceVibrator) SetStrokeWindow

func (v *IntifaceVibrator) SetStrokeWindow(_ context.Context, command StrokeWindowCommand) (CommandResult, error)

SetStrokeWindow is accepted and ignored: the stroke window is a stroker's physical envelope, and the vibrator follows the semantic frame.

func (*IntifaceVibrator) Status

Status returns the vibrator's safe snapshot.

func (*IntifaceVibrator) Stop

Stop ends the stream and silences the device: a zero level for its motors, then StopDeviceCmd. Pause arrives here too. A Stop that cannot be confirmed fails the session, because the server then stops its devices.

func (*IntifaceVibrator) Test

func (v *IntifaceVibrator) Test() error

Test plays one second at the lower of Max and 25% while motion is idle.

func (*IntifaceVibrator) TestAt

func (v *IntifaceVibrator) TestAt(generation uint64) error

TestAt starts a test for a request prepared at generation. The check and the start share one lock, so a Stop between them cannot be missed.

type IntifaceVibratorMotor

type IntifaceVibratorMotor struct {
	Index             uint32 `json:"index"`
	FeatureDescriptor string `json:"feature_descriptor,omitempty"`
	StepCount         int    `json:"step_count"`
	LevelPercent      int    `json:"level_percent"`
}

IntifaceVibratorMotor is one Vibrate actuator the vibrator drives.

type IntifaceVibratorStatus

type IntifaceVibratorStatus struct {
	TestAvailable           bool                    `json:"test_available"`
	Selected                bool                    `json:"selected"`
	DeviceIndex             *uint32                 `json:"device_index,omitempty"`
	DeviceName              string                  `json:"device_name,omitempty"`
	Motors                  []IntifaceVibratorMotor `json:"motors"`
	CeilingPercent          int                     `json:"ceiling_percent"`
	EffectiveCeilingPercent int                     `json:"effective_ceiling_percent"`
	ModelControl            bool                    `json:"model_control"`
	ModelLevelPercent       int                     `json:"model_level_percent"`
	// LevelSource is "model" once a model chose the level, otherwise "handy":
	// the level follows The Handy's intensity.
	LevelSource string `json:"level_source"`
	// PreviousLevelPercent is the last nonzero model level while it is 0, so
	// "back on" has a fact to return to.
	PreviousLevelPercent int    `json:"previous_level_percent,omitempty"`
	Suspended            bool   `json:"suspended,omitempty"`
	LevelPercent         int    `json:"level_percent"`
	PlaybackState        string `json:"playback_state"`
	Testing              bool   `json:"testing"`
	CommandedCount       uint64 `json:"commanded_count"`
	AcknowledgedCount    uint64 `json:"acknowledged_count"`
	RejectedCount        uint64 `json:"rejected_count"`
	TimeoutCount         uint64 `json:"timeout_count"`
	LastError            string `json:"last_error,omitempty"`
	SilentReason         string `json:"silent_reason,omitempty"`
}

IntifaceVibratorStatus is the vibrator's safe snapshot. Percentages are whole numbers. The ceiling is the user's Max; the effective ceiling is the highest level the motors can deliver at or below it. The model level is a percentage of Max.

type LinkedParticipant

type LinkedParticipant struct {
	ID        string
	Label     string
	Transport Transport
}

LinkedParticipant is one device in a linked playback session. ID is the stable singleton or named-instance identifier; Label names it in errors and warnings.

type LinkedSessionStatus

type LinkedSessionStatus struct {
	Status          string   `json:"status"`
	ContinueHealthy bool     `json:"continue_healthy"`
	RetiredDevices  []string `json:"retired_devices"`
	// IdleDevices are selected participants that this scalar-only run does not
	// drive. The UI must not describe them as following the active device.
	IdleDevices []string `json:"idle_devices"`
}

LinkedSessionStatus distinguishes saved playback choices from participants retired during this run. It contains no device identifiers or raw errors.

type LinkedSessionStatusProvider

type LinkedSessionStatusProvider interface {
	LinkedSessionStatus() LinkedSessionStatus
}

LinkedSessionStatusProvider exposes state only; it never polls or commands.

type MotionSamplingCapabilities

type MotionSamplingCapabilities struct {
	PositionResolutionPercent   float64
	ResolutionAfterStrokeWindow bool
	MaximumPointsPerAppend      int
	// PreferredPointInterval reduces optional points on generated curves for
	// owners that respond poorly to frequent position updates. It is a fitting
	// preference, not a limit: authored reversals still use MinimumPointInterval.
	// Zero preserves the ordinary fit. Imported media does not use this preference.
	PreferredPointInterval time.Duration
	// PreferSparseGeneratedMotion requests fewer optional curve points on
	// buffered firmware. The engine chooses bounded, scale-aware precision;
	// authored media and motion limits are unaffected. Multi-device fan-out
	// retains its existing fit until separately accepted on physical devices.
	PreferSparseGeneratedMotion bool
}

MotionSamplingCapabilities describes owner encoding limits that affect how the shared engine reduces a semantic frame and verifies startup endpoints. The owner still performs the actual encoding at dispatch.

type MotionSamplingCapabilitiesProvider

type MotionSamplingCapabilitiesProvider interface {
	MotionSamplingCapabilities() MotionSamplingCapabilities
}

MotionSamplingCapabilitiesProvider exposes optional output-resolution constraints without moving curve processing into a transport owner.

type MotionStartupParticipantsProvider

type MotionStartupParticipantsProvider interface {
	MotionStartupParticipants() []LinkedParticipant
}

MotionStartupParticipantsProvider exposes individual owners only for the engine's existing startup sequence; ordinary playback uses the linked owner.

type MotionStartupState

type MotionStartupState struct {
	PositionWithinStrokePercent float64
	PositionAbsolute            float64
	SpeedAbsolute               float64
	StrokeMinPercent            float64
	StrokeMaxPercent            float64
	StrokeMinAbsolute           float64
	StrokeMaxAbsolute           float64
}

MotionStartupState is the physical device state needed to anchor the first timed point without an implicit reposition. Stroke bounds use full physical travel; PositionWithinStrokePercent is relative to those active bounds and may extrapolate below 0 or above 100 when the slider is parked outside them. The absolute fields share one device coordinate system and are authoritative for reconstructing full-travel position, independent of semantic direction.

type MotionStartupStateProvider

type MotionStartupStateProvider interface {
	ReadMotionStartupState(context.Context) (MotionStartupState, MotionStartupStateResults, error)
}

MotionStartupStateProvider exposes an optional read-only startup snapshot. The shared engine, not the owner, decides whether and how to create a timed lead-in from this state.

type MotionStartupStateResults

type MotionStartupStateResults struct {
	Slider CommandResult
	Stroke CommandResult
}

MotionStartupStateResults preserves both read outcomes for motion traces.

type MotionTimingCapabilities

type MotionTimingCapabilities struct {
	MinimumPointInterval time.Duration
	// MinimumBufferedLead is the minimum accepted timed-point coverage a
	// buffered owner needs ahead of playback. The engine prebuffers to this
	// duration before Play and maintains it while the stream is active.
	MinimumBufferedLead time.Duration
	// RefillArrivalMargin is the interactive coverage the owner wants left at
	// append arrival. The scheduler budgets polling and delivery time before
	// that deadline. It does not extend edit batches or fixed-media queues.
	RefillArrivalMargin time.Duration
	// MinimumMediaBufferedLead is the longer accepted coverage required for a
	// clock-locked media stream. Interactive targets retain
	// MinimumBufferedLead so retargets do not inherit media-sized latency.
	MinimumMediaBufferedLead time.Duration
}

MotionTimingCapabilities describes transport timing limits that the shared engine must honor before producing its transport-neutral frame.

type MotionTimingCapabilitiesProvider

type MotionTimingCapabilitiesProvider interface {
	MotionTimingCapabilities() MotionTimingCapabilities
}

MotionTimingCapabilitiesProvider exposes optional device timing constraints.

type NativeBluetoothOwner

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

NativeBluetoothOwner owns the host's Handy connection, independently of any browser tab or playback run. Each transport captures its connection generation.

func NewNativeBluetoothOwner

func NewNativeBluetoothOwner(connector ble.Connector) *NativeBluetoothOwner

NewNativeBluetoothOwner creates a disconnected host-owned Handy connection.

func (*NativeBluetoothOwner) Close

func (o *NativeBluetoothOwner) Close() error

Close performs bounded shutdown of this connection owner.

func (*NativeBluetoothOwner) Connect

Connect returns private device information only to the host-owned settings layer for remembering the selected address. It never starts playback.

func (*NativeBluetoothOwner) Disconnect

func (o *NativeBluetoothOwner) Disconnect(ctx context.Context) error

Disconnect cancels setup or stops and closes an established connection.

func (*NativeBluetoothOwner) Interrupt

func (o *NativeBluetoothOwner) Interrupt()

Interrupt also cancels connection setup, so a global Stop cannot be followed by an old pending connection becoming ready.

func (*NativeBluetoothOwner) NewTransport

NewTransport binds shared HSP mapping to the current native connection.

func (*NativeBluetoothOwner) SessionID

func (o *NativeBluetoothOwner) SessionID() uint64

SessionID identifies the current connection generation.

func (*NativeBluetoothOwner) Status

Status returns backend connection state without hardware identifiers.

type NativeBluetoothStatus

type NativeBluetoothStatus struct {
	Connected     bool   `json:"connected"`
	Connecting    bool   `json:"connecting"`
	Simulated     bool   `json:"simulated"`
	Status        string `json:"status"`
	Message       string `json:"message"`
	DeviceName    string `json:"device_name,omitempty"`
	ClockSynced   bool   `json:"clock_synced"`
	WriteBytes    int    `json:"write_bytes"`
	PlaybackState string `json:"playback_state"`
}

NativeBluetoothStatus is backend-authoritative and contains no hardware address.

type PlayCommand

type PlayCommand struct {
	// Resume continues the same logical session on a fresh stream. Relative
	// actuator limits survive Pause/Resume; a new Play starts a new budget.
	Resume           bool   `json:"resume,omitempty"`
	StreamID         string `json:"stream_id"`
	VibrationOnly    bool   `json:"vibration_only,omitempty"`
	TempoOnly        bool   `json:"tempo_only,omitempty"`
	StartTimeMillis  int64  `json:"start_time_ms"`
	ServerTimeMillis int64  `json:"server_time_ms,omitempty"`
}

PlayCommand starts or resumes playback of a timed-point stream.

type PlaybackStartTimeProvider

type PlaybackStartTimeProvider interface {
	PlaybackStartTime() time.Time
}

PlaybackStartTimeProvider reports when transport playback actually began. Owners that perform a pre-roll use this to align the shared engine clock.

type StopCommand

type StopCommand struct {
	// Fault marks recovery/failed startup: electrical outputs also zero strength.
	Fault  bool   `json:"fault,omitempty"`
	Reason string `json:"reason"`
}

StopCommand requests transport stop.

type StrokeWindowCommand

type StrokeWindowCommand struct {
	MinPercent       int  `json:"min_percent"`
	MaxPercent       int  `json:"max_percent"`
	ReverseDirection bool `json:"reverse_direction,omitempty"`
}

StrokeWindowCommand applies the physical stroke envelope at transport level.

type TempoFrame

type TempoFrame struct {
	Revision uint64       `json:"revision"`
	Points   []TimedLevel `json:"points"`
}

TempoFrame is engine-sampled tempo in percent of the person's Tempo range: 0 stops the motor and 1..100 span the range. It replaces what the owner holds from its first point onward.

type TempoOutput

type TempoOutput interface {
	TakesTempo() bool
}

TempoOutput is implemented by owners that play the engine's tempo channel: strokers that make their own strokes (ADR 0071).

type TimedLevel

type TimedLevel struct {
	TimeMillis   int64   `json:"time_ms"`
	LevelPercent float64 `json:"level_percent"`
}

TimedLevel is engine-sampled vibration drive in percent of Max, 0..100.

type TimedPoint

type TimedPoint struct {
	PositionPercent float64 `json:"position_percent"`
	TimeMillis      int64   `json:"time_ms"`
}

TimedPoint is a single transport-neutral timed point. Position is expressed as 0..100.

type Transport

Transport is the deterministic boundary used by motion code to command playback without knowing the concrete dispatch owner.

func NewFanOut

func NewFanOut(primary, companion Transport) Transport

NewFanOut creates a Handy + Coyote linked session with stop-all failure handling.

func NewFanOutWithPolicy

func NewFanOutWithPolicy(primary, companion Transport, continueHealthy bool) Transport

NewFanOutWithPolicy creates a Handy + Coyote linked session that optionally retires a failed participant during playback.

func NewLeasedTransport

func NewLeasedTransport(owner Transport, current func() bool) Transport

NewLeasedTransport fences commands to one connection incarnation.

func NewLinkedSession

func NewLinkedSession(participants []LinkedParticipant, continueHealthy bool) Transport

NewLinkedSession links participants in run-clock order. With continueHealthy, an established run retires a failed participant while any other stays healthy; startup still requires every participant, and a retired participant cannot hot-join.

type TransportDiagnostics

type TransportDiagnostics struct {
	Name              string         `json:"name"`
	Connected         bool           `json:"connected"`
	PlaybackState     string         `json:"playback_state"`
	CommandCount      int            `json:"command_count"`
	LastLatencyMillis int64          `json:"last_latency_ms"`
	LastCommand       *Command       `json:"last_command,omitempty"`
	LastResult        *CommandResult `json:"last_result,omitempty"`
	LastError         string         `json:"last_error,omitempty"`
}

TransportDiagnostics is a safe snapshot of transport command and playback state.

type VacuGlide

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

VacuGlide owns one VacuGlide through Autoblow's cloud. It has no position input: a crank-driven piston moves air that strokes the sleeve, so the motor sets the tempo, and the air sealed in the sleeve sets how long and tight each stroke is (ADRs 0069 and 0071). The owner plays the engine's tempo channel across the person's Tempo range; it never derives motion itself.

func NewVacuGlide

func NewVacuGlide(options AutoblowOptions) *VacuGlide

NewVacuGlide returns a disconnected owner.

func (*VacuGlide) AlignPlaybackStart

func (v *VacuGlide) AlignPlaybackStart(start time.Time)

AlignPlaybackStart re-anchors a playing stream on another owner's start.

func (*VacuGlide) AppendPoints

func (v *VacuGlide) AppendPoints(ctx context.Context, command AppendPointsCommand) (CommandResult, error)

AppendPoints stores the stream's tempo. The VacuGlide makes its own strokes, so it reads only the tempo channel and ignores positions.

func (*VacuGlide) BeginEmergencyStop

func (v *VacuGlide) BeginEmergencyStop() func() error

BeginEmergencyStop stops the motor beside the engine's Stop and returns a wait.

func (*VacuGlide) Close

func (v *VacuGlide) Close() error

Close disconnects and refuses later connections.

func (*VacuGlide) Configure

func (v *VacuGlide) Configure(config AutoblowConfig)

Configure applies the saved token, offset, Tempo range and air permission. A new token takes effect at the next Connect.

func (*VacuGlide) Connect

func (v *VacuGlide) Connect(ctx context.Context) (AutoblowStatus, error)

Connect opens the cloud connection, stops the motor and closes both valves.

func (*VacuGlide) Connected

func (b *VacuGlide) Connected() bool

Connected reports whether a cloud connection is open.

func (*VacuGlide) ControlGeneration

func (b *VacuGlide) ControlGeneration() uint64

ControlGeneration fences a test or valve step against a later Stop.

func (*VacuGlide) Diagnostics

func (v *VacuGlide) Diagnostics() TransportDiagnostics

Diagnostics returns the snapshot the engine reads for playback health.

func (*VacuGlide) Disconnect

func (v *VacuGlide) Disconnect() (AutoblowStatus, error)

Disconnect stops the motor and closes the valves, then the connection.

func (*VacuGlide) MotionSamplingCapabilities

func (v *VacuGlide) MotionSamplingCapabilities() MotionSamplingCapabilities

MotionSamplingCapabilities places no limit: positions are not read.

func (*VacuGlide) MotionTimingCapabilities

func (v *VacuGlide) MotionTimingCapabilities() MotionTimingCapabilities

MotionTimingCapabilities keeps the cloud's lead covered.

func (*VacuGlide) MotionTransport

func (v *VacuGlide) MotionTransport() (Transport, error)

MotionTransport admits an engine bound to the current connection.

func (*VacuGlide) Play

func (v *VacuGlide) Play(ctx context.Context, command PlayCommand) (CommandResult, error)

Play starts following the prepared stream.

func (*VacuGlide) PlayAligned

func (v *VacuGlide) PlayAligned(ctx context.Context, command PlayCommand, start time.Time) (CommandResult, error)

PlayAligned starts on a linked session's clock.

func (*VacuGlide) PlaybackStartTime

func (v *VacuGlide) PlaybackStartTime() time.Time

PlaybackStartTime reports the local time of stream millisecond 0.

func (*VacuGlide) SessionID

func (b *VacuGlide) SessionID() uint64

SessionID changes only at connection boundaries.

func (*VacuGlide) SetStrokeWindow

func (v *VacuGlide) SetStrokeWindow(ctx context.Context, command StrokeWindowCommand) (CommandResult, error)

SetStrokeWindow is accepted for contract compatibility: the VacuGlide's stroke comes from its air, not a position window.

func (*VacuGlide) Status

func (v *VacuGlide) Status() AutoblowStatus

Status returns a safe snapshot.

func (*VacuGlide) Stop

func (v *VacuGlide) Stop(ctx context.Context, command StopCommand) (CommandResult, error)

Stop ends the stream, stops the motor and closes any open valve.

func (*VacuGlide) StrokeStepAt

func (v *VacuGlide) StrokeStepAt(generation uint64, longer bool) error

StrokeStepAt opens one valve for a short pulse: longer draws air out of the sleeve for a longer, tighter stroke; shorter lets air in. It works whether or not motion plays, and Stop closes the valve if it is still open.

func (*VacuGlide) TakesTempo

func (v *VacuGlide) TakesTempo() bool

TakesTempo marks the VacuGlide as a tempo owner (ADR 0071).

func (*VacuGlide) TestAt

func (v *VacuGlide) TestAt(generation uint64) error

TestAt runs the motor slowly for a few seconds while motion is idle.

type VibrationFrame

type VibrationFrame struct {
	Revision uint64 `json:"revision"`
	Follow   bool   `json:"follow,omitempty"`
	// A follow frame's range in percent of Max; zero max follows at the
	// owner's level.
	FollowMinPercent float64      `json:"follow_min_percent,omitempty"`
	FollowMaxPercent float64      `json:"follow_max_percent,omitempty"`
	Points           []TimedLevel `json:"points,omitempty"`
}

VibrationFrame replaces a short, covered envelope on the shared stream clock. Revision changes fence any level prepared from an older semantic envelope.

type VibratorConfig

type VibratorConfig struct {
	Profile      vibration.Profile
	Minimum      float64
	Ceiling      float64
	OffsetMillis int
	ModelControl bool
	// FollowOnly is the user's explicit override. ModelControl describes the
	// current chat vocabulary; an independently capable planner can still send
	// an envelope when chat has no level control. FollowOnly overrides both.
	FollowOnly bool
	// The saved speed band in percent, for The Handy's intensity under the
	// depth and steady profiles.
	SpeedMinPercent int
	SpeedMaxPercent int
}

VibratorConfig is the user's vibration settings. Levels are fractions of the device range; Ceiling is the user's Max. ModelControl is effective control: the setting is on and the chat model has a vibration vocabulary. Without it, movement-following vibration runs at Max.

type VibratorEvent

type VibratorEvent struct {
	At                string               `json:"at"`
	Kind              string               `json:"kind"`
	Command           uint64               `json:"command,omitempty"`
	Generation        uint64               `json:"generation"`
	ModelLevelPercent int                  `json:"model_level_percent"`
	CeilingPercent    int                  `json:"ceiling_percent"`
	Suspended         bool                 `json:"suspended,omitempty"`
	State             string               `json:"state"`
	Levels            []VibratorMotorLevel `json:"levels,omitempty"`
}

VibratorEvent records only bounded operational facts, never model text, device names/addresses, credentials, or raw server errors. Command is a local sequence joining a scalar write to its acknowledgement.

type VibratorMotorLevel

type VibratorMotorLevel struct {
	Index   uint32  `json:"index"`
	Percent float64 `json:"percent"`
}

VibratorMotorLevel is a commanded, quantized estimate, not motor telemetry.

type VibratorResumePermit

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

VibratorResumePermit binds a manual request to the same stopped device. Its fields cannot be supplied by a model.

Jump to

Keyboard shortcuts

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