transport

package
v0.1.0-alpha.13 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: GPL-3.0 Imports: 17 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 (
	// BrowserBluetoothName is the diagnostics transport name for browser-owned BLE.
	BrowserBluetoothName = "browser_bluetooth_hsp"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppendPointsCommand

type AppendPointsCommand struct {
	StreamID string       `json:"stream_id"`
	Points   []TimedPoint `json:"points"`
}

AppendPointsCommand appends timed points to a stream.

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) Snapshot

Snapshot returns the current safe bridge status.

func (*BrowserBluetoothBridge) UpdateClient

UpdateClient records a browser status or heartbeat.

type BrowserBluetoothBridgeAck

type BrowserBluetoothBridgeAck 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"`
}

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"`
}

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"`
}

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 struct {
	ReverseDirection bool
}

BrowserBluetoothOptions controls browser-owned BLE dispatch mapping.

type BrowserBluetoothTransport

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

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.

func (*BrowserBluetoothTransport) AppendPoints

AppendPoints sends timed points through browser-owned Handy HSP.

func (*BrowserBluetoothTransport) 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 (*BrowserBluetoothTransport) Diagnostics

Diagnostics returns a safe browser Bluetooth diagnostics snapshot.

func (*BrowserBluetoothTransport) MotionSamplingCapabilities

func (*BrowserBluetoothTransport) MotionSamplingCapabilities() MotionSamplingCapabilities

MotionSamplingCapabilities reports the Handy BLE HSP protobuf's native 0..1000 point encoding.

func (*BrowserBluetoothTransport) Play

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

func (*BrowserBluetoothTransport) PlaybackStartTime

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

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

func (*BrowserBluetoothTransport) ReadState

ReadState reads browser Bluetooth HSP state.

func (*BrowserBluetoothTransport) SetStrokeWindow

SetStrokeWindow sends a stroke envelope command through the browser bridge.

func (*BrowserBluetoothTransport) Stop

Stop sends an HSP stop command through the 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.

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 only to reduce redundant wire knots; 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) 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.

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 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 (*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.

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 WithLatency

func WithLatency(latency time.Duration) FakeOption

WithLatency sets the fake transport latency reported in command results.

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 Intiface

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

Intiface owns one persistent Buttplug v3 websocket session and linear pacer.

func NewIntiface

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

NewIntiface validates options and returns a disconnected Intiface owner.

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 all session goroutines.

func (*Intiface) Connect

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

Connect opens the websocket and completes the Buttplug v3 handshake and device list request.

func (*Intiface) Devices

func (i *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) 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) PlaybackStartTime

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

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

func (*Intiface) SelectDevice

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

SelectDevice selects one discovered device and one of its linear actuators.

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 (i *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 (i *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"`
}

IntifaceDevice is a safe snapshot of a discovered Buttplug device.

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 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 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 MotionSamplingCapabilities

type MotionSamplingCapabilities struct {
	PositionResolutionPercent   float64
	ResolutionAfterStrokeWindow bool
	MaximumPointsPerAppend      int
}

MotionSamplingCapabilities describes owner encoding limits that affect how the shared engine reduces a semantic frame before the owner quantizes it.

type MotionSamplingCapabilitiesProvider

type MotionSamplingCapabilitiesProvider interface {
	MotionSamplingCapabilities() MotionSamplingCapabilities
}

MotionSamplingCapabilitiesProvider exposes optional output-resolution constraints without moving curve processing into a transport 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
	// 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 PlayCommand

type PlayCommand struct {
	StreamID         string `json:"stream_id"`
	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 {
	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 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.

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.

Jump to

Keyboard shortcuts

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