Documentation
¶
Overview ¶
Package schema contains the Buttplug message schema for version 3.
Index ¶
- func IsInternalMessage(m Message) bool
- type ClientID
- type ClientMessage
- type Device
- type DeviceAddedMessage
- type DeviceIndex
- type DeviceListMessage
- type DeviceMessages
- type DeviceName
- type DeviceRemovedMessage
- type ErrorMessage
- type InternalMessage
- type LinearCmdInfo
- type LinearCmdMessage
- type Message
- type MessageType
- type NullMessageAttributes
- type OKMessage
- type Payload
- type PingMessage
- type RawMessageAttributes
- type RawReadCmdMessage
- type RawReadingMessage
- type RawSubscribeCmdMessage
- type RawUnsubscribeCmdMessage
- type RawWriteCmdMessage
- type RequestDeviceListMessage
- type RequestServerInfoMessage
- type RotateCmdInfo
- type RotateCmdMessage
- type Rotation
- type Scalar
- type ScalarCmdInfo
- type ScalarCmdMessage
- type ScanningFinishedMessage
- type SensorReadCmdItem
- type SensorReadCmdMessage
- type SensorReadingMessage
- type SensorSubscribeCmdItem
- type SensorSubscribeCmdMessage
- type SensorUnsubscribeCmdMessage
- type ServerID
- type ServerInfoMessage
- type ServerMessage
- type StartScanningMessage
- type StepCount
- type StopAllDevicesMessage
- type StopDeviceCmdMessage
- type StopScanningMessage
- type SystemID
- type Vector
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsInternalMessage ¶
IsInternalMessage returns whether the message is an internal-only message.
Types ¶
type ClientID ¶
type ClientID int
ClientID: user-set id for the message. 0 denotes system message and is reserved.
type ClientMessage ¶
type ClientMessage interface {
Message
// ClientID returns the ID field of the message.
ClientID() ClientID
// WithID sets the ID field of the shallow-copied message and returns the modified message.
WithID(id ClientID) ClientMessage
// contains filtered or unexported methods
}
ClientMessage represents a message that can be sent from the client to the server. It extends Message with a way to set the client ID to be used when sending the message.
The following messages are defined:
- DeviceListMessage
- LinearCmdMessage
- OKMessage
- PingMessage
- RawReadCmdMessage
- RawSubscribeCmdMessage
- RawUnsubscribeCmdMessage
- RawWriteCmdMessage
- RequestDeviceListMessage
- RequestServerInfoMessage
- RotateCmdMessage
- ScalarCmdMessage
- SensorReadCmdMessage
- SensorSubscribeCmdMessage
- SensorUnsubscribeCmdMessage
- ServerInfoMessage
- StartScanningMessage
- StopAllDevicesMessage
- StopDeviceCmdMessage
- StopScanningMessage
type Device ¶ added in v0.0.6
type Device struct {
// DeviceName: name of the device.
DeviceName DeviceName `json:"DeviceName"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
// DeviceMessages: a list of the messages a device will accept on this
// server implementation.
DeviceMessages DeviceMessages `json:"DeviceMessages"`
DeviceDisplayName ptr.Optional[string] `json:"DeviceDisplayName,omitzero"`
DeviceMessageTimingGap ptr.Optional[int] `json:"DeviceMessageTimingGap,omitzero"`
}
type DeviceAddedMessage ¶
type DeviceAddedMessage struct {
// ID: used for non-direct-reply messages that can only be sent from server
// to client, using the reserved system message Id of 0.
ID SystemID `json:"Id"`
// DeviceName: name of the device.
DeviceName DeviceName `json:"DeviceName"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
// DeviceMessages: a list of the messages a device will accept on this
// server implementation.
DeviceMessages DeviceMessages `json:"DeviceMessages"`
DeviceDisplayName ptr.Optional[string] `json:"DeviceDisplayName,omitzero"`
DeviceMessageTimingGap ptr.Optional[int] `json:"DeviceMessageTimingGap,omitzero"`
}
DeviceAddedMessage: notifies client that a device of a certain type has been added to the server.
func (*DeviceAddedMessage) LogValue ¶
func (d *DeviceAddedMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*DeviceAddedMessage) Type ¶
func (d *DeviceAddedMessage) Type() MessageType
Type returns MessageTypeDeviceAdded.
type DeviceIndex ¶
type DeviceIndex int
DeviceIndex: index used for referencing the device in device messages.
type DeviceListMessage ¶
type DeviceListMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// Devices: array of device ids and names.
Devices []Device `json:"Devices"`
}
DeviceListMessage: list of all available devices known to the system.
func (*DeviceListMessage) ClientID ¶
func (d *DeviceListMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*DeviceListMessage) LogValue ¶
func (d *DeviceListMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*DeviceListMessage) Type ¶
func (d *DeviceListMessage) Type() MessageType
Type returns MessageTypeDeviceList.
func (*DeviceListMessage) WithID ¶
func (d *DeviceListMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type DeviceMessages ¶
type DeviceMessages struct {
LinearCmd []LinearCmdInfo `json:"LinearCmd,omitzero"`
// RawReadCmd: attributes for raw device messages.
RawReadCmd ptr.Optional[RawMessageAttributes] `json:"RawReadCmd,omitzero"`
// RawSubscribeCmd: attributes for raw device messages.
RawSubscribeCmd ptr.Optional[RawMessageAttributes] `json:"RawSubscribeCmd,omitzero"`
// RawWriteCmd: attributes for raw device messages.
RawWriteCmd ptr.Optional[RawMessageAttributes] `json:"RawWriteCmd,omitzero"`
RotateCmd []RotateCmdInfo `json:"RotateCmd,omitzero"`
ScalarCmd []ScalarCmdInfo `json:"ScalarCmd,omitzero"`
SensorReadCmd []SensorReadCmdItem `json:"SensorReadCmd,omitzero"`
SensorSubscribeCmd []SensorSubscribeCmdItem `json:"SensorSubscribeCmd,omitzero"`
// StopDeviceCmd: attributes for device message that have no attributes.
StopDeviceCmd ptr.Optional[NullMessageAttributes] `json:"StopDeviceCmd,omitzero"`
}
DeviceMessages: a list of the messages a device will accept on this server implementation.
type DeviceRemovedMessage ¶
type DeviceRemovedMessage struct {
// ID: used for non-direct-reply messages that can only be sent from server
// to client, using the reserved system message Id of 0.
ID SystemID `json:"Id"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
}
DeviceRemovedMessage: notifies client that a device of a certain type has been removed from the server.
func (*DeviceRemovedMessage) LogValue ¶
func (d *DeviceRemovedMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*DeviceRemovedMessage) Type ¶
func (d *DeviceRemovedMessage) Type() MessageType
Type returns MessageTypeDeviceRemoved.
type ErrorMessage ¶
type ErrorMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ServerID `json:"Id"`
ErrorMessage string `json:"ErrorMessage"`
ErrorCode float64 `json:"ErrorCode"`
}
ErrorMessage: signifies the server encountered an error while processing the message indicated by the id.
func (*ErrorMessage) LogValue ¶
func (e *ErrorMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*ErrorMessage) ServerID ¶
func (e *ErrorMessage) ServerID() ServerID
ServerID implements ServerMessage
func (*ErrorMessage) Type ¶
func (e *ErrorMessage) Type() MessageType
Type returns MessageTypeError.
type InternalMessage ¶
type InternalMessage struct{}
InternalMessage is a special type that the library uses for internal-only messages. Messages of this type were never emitted from the server.
func (InternalMessage) MarshalJSON ¶
func (m InternalMessage) MarshalJSON() ([]byte, error)
MarshalJSON returns an error because internal messages cannot be marshaled.
func (InternalMessage) Type ¶
func (m InternalMessage) Type() MessageType
Type returns an empty string for internal messages.
type LinearCmdInfo ¶ added in v0.0.8
type LinearCmdInfo struct {
// ActuatorType: denotes type of actuator (Vibrator, Linear, Oscillator,
// etc...).
ActuatorType ptr.Optional[string] `json:"ActuatorType,omitzero"`
FeatureDescriptor ptr.Optional[string] `json:"FeatureDescriptor,omitzero"`
// StepCount: specifies granularity of each feature on the device.
StepCount ptr.Optional[StepCount] `json:"StepCount,omitzero"`
}
LinearCmdInfo: attributes for device messages.
type LinearCmdMessage ¶
type LinearCmdMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
// Vectors: device linear movement times (milliseconds) and positions
// (floating point, 0 < x < 1) keyed on linear actuator number, stepping
// will be device specific.
Vectors []Vector `json:"Vectors"`
}
LinearCmdMessage: sends a linear movement command to a device that supports linear movements.
func (*LinearCmdMessage) ClientID ¶
func (l *LinearCmdMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*LinearCmdMessage) LogValue ¶
func (l *LinearCmdMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*LinearCmdMessage) Type ¶
func (l *LinearCmdMessage) Type() MessageType
Type returns MessageTypeLinearCmd.
func (*LinearCmdMessage) WithID ¶
func (l *LinearCmdMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type Message ¶
type Message interface {
// Type returns the message type of the message.
Type() MessageType
// contains filtered or unexported methods
}
Message represents a single message in the buttplug.io protocol.
The following messages are defined:
- DeviceAddedMessage
- DeviceListMessage
- DeviceRemovedMessage
- ErrorMessage
- LinearCmdMessage
- OKMessage
- PingMessage
- RawReadCmdMessage
- RawReadingMessage
- RawSubscribeCmdMessage
- RawUnsubscribeCmdMessage
- RawWriteCmdMessage
- RequestDeviceListMessage
- RequestServerInfoMessage
- RotateCmdMessage
- ScalarCmdMessage
- ScanningFinishedMessage
- SensorReadCmdMessage
- SensorReadingMessage
- SensorSubscribeCmdMessage
- SensorUnsubscribeCmdMessage
- ServerInfoMessage
- StartScanningMessage
- StopAllDevicesMessage
- StopDeviceCmdMessage
- StopScanningMessage
type MessageType ¶
type MessageType string
MessageType is the type string used to identify a buttplug.io message from the wire.
const ( // MessageTypeDeviceAdded is the type string for a [DeviceAddedMessage]. MessageTypeDeviceAdded MessageType = "DeviceAdded" // MessageTypeDeviceList is the type string for a [DeviceListMessage]. MessageTypeDeviceList MessageType = "DeviceList" // MessageTypeDeviceRemoved is the type string for a [DeviceRemovedMessage]. MessageTypeDeviceRemoved MessageType = "DeviceRemoved" // MessageTypeError is the type string for a [ErrorMessage]. MessageTypeError MessageType = "Error" // MessageTypeLinearCmd is the type string for a [LinearCmdMessage]. MessageTypeLinearCmd MessageType = "LinearCmd" // MessageTypeOK is the type string for a [OKMessage]. MessageTypeOK MessageType = "Ok" // MessageTypePing is the type string for a [PingMessage]. MessageTypePing MessageType = "Ping" // MessageTypeRawReadCmd is the type string for a [RawReadCmdMessage]. MessageTypeRawReadCmd MessageType = "RawReadCmd" // MessageTypeRawReading is the type string for a [RawReadingMessage]. MessageTypeRawReading MessageType = "RawReading" // MessageTypeRawSubscribeCmd is the type string for a [RawSubscribeCmdMessage]. MessageTypeRawSubscribeCmd MessageType = "RawSubscribeCmd" // MessageTypeRawUnsubscribeCmd is the type string for a [RawUnsubscribeCmdMessage]. MessageTypeRawUnsubscribeCmd MessageType = "RawUnsubscribeCmd" // MessageTypeRawWriteCmd is the type string for a [RawWriteCmdMessage]. MessageTypeRawWriteCmd MessageType = "RawWriteCmd" // MessageTypeRequestDeviceList is the type string for a [RequestDeviceListMessage]. MessageTypeRequestDeviceList MessageType = "RequestDeviceList" // MessageTypeRequestServerInfo is the type string for a [RequestServerInfoMessage]. MessageTypeRequestServerInfo MessageType = "RequestServerInfo" // MessageTypeRotateCmd is the type string for a [RotateCmdMessage]. MessageTypeRotateCmd MessageType = "RotateCmd" // MessageTypeScalarCmd is the type string for a [ScalarCmdMessage]. MessageTypeScalarCmd MessageType = "ScalarCmd" // MessageTypeScanningFinished is the type string for a [ScanningFinishedMessage]. MessageTypeScanningFinished MessageType = "ScanningFinished" // MessageTypeSensorReadCmd is the type string for a [SensorReadCmdMessage]. MessageTypeSensorReadCmd MessageType = "SensorReadCmd" // MessageTypeSensorReading is the type string for a [SensorReadingMessage]. MessageTypeSensorReading MessageType = "SensorReading" // MessageTypeSensorSubscribeCmd is the type string for a [SensorSubscribeCmdMessage]. MessageTypeSensorSubscribeCmd MessageType = "SensorSubscribeCmd" // MessageTypeSensorUnsubscribeCmd is the type string for a [SensorUnsubscribeCmdMessage]. MessageTypeSensorUnsubscribeCmd MessageType = "SensorUnsubscribeCmd" // MessageTypeServerInfo is the type string for a [ServerInfoMessage]. MessageTypeServerInfo MessageType = "ServerInfo" // MessageTypeStartScanning is the type string for a [StartScanningMessage]. MessageTypeStartScanning MessageType = "StartScanning" // MessageTypeStopAllDevices is the type string for a [StopAllDevicesMessage]. MessageTypeStopAllDevices MessageType = "StopAllDevices" // MessageTypeStopDeviceCmd is the type string for a [StopDeviceCmdMessage]. MessageTypeStopDeviceCmd MessageType = "StopDeviceCmd" // MessageTypeStopScanning is the type string for a [StopScanningMessage]. MessageTypeStopScanning MessageType = "StopScanning" )
All defined message types.
type NullMessageAttributes ¶
type NullMessageAttributes struct{}
NullMessageAttributes: attributes for device message that have no attributes.
type OKMessage ¶
type OKMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
}
OKMessage: signifies successful processing of the message indicated by the id.
func (*OKMessage) ClientID ¶
ClientID implements ClientMessage
func (*OKMessage) LogValue ¶
LogValue implements slog.LogValuer.
func (*OKMessage) WithID ¶
func (o *OKMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type Payload ¶
type Payload []Message
Payload is a list of messages sent from the buttplug.io websocket server. Use this type to parse each message in the payload.
func (Payload) LogValue ¶
LogValue implements slog.LogValuer.
func (Payload) MarshalJSONTo ¶
MarshalJSONTo writes the payload as the JSON websocket wire protocol.
func (*Payload) UnmarshalJSONFrom ¶
UnmarshalJSONFrom implements json.UnmarshalerFrom. It consumes one full array of messages from the given JSON decoder.
type PingMessage ¶
type PingMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
}
PingMessage: connection keep-alive message.
func (*PingMessage) ClientID ¶
func (p *PingMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*PingMessage) LogValue ¶
func (p *PingMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*PingMessage) WithID ¶
func (p *PingMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type RawMessageAttributes ¶
type RawMessageAttributes struct {
Endpoints []string `json:"Endpoints,omitzero"`
}
RawMessageAttributes: attributes for raw device messages.
type RawReadCmdMessage ¶
type RawReadCmdMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// Endpoint (from device config file) from which the data was retrieved.
Endpoint string `json:"Endpoint"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
// Length: amount of data to read from device, 0 to exhaust whatever is in
// immediate buffer.
Length int `json:"Length"`
// WaitForData: if true, then wait until Length amount of data is available.
WaitForData bool `json:"WaitForData"`
}
RawReadCmdMessage: request a raw byte array from a device. Should only be used for testing/development.
func (*RawReadCmdMessage) ClientID ¶
func (r *RawReadCmdMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*RawReadCmdMessage) LogValue ¶
func (r *RawReadCmdMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*RawReadCmdMessage) Type ¶
func (r *RawReadCmdMessage) Type() MessageType
Type returns MessageTypeRawReadCmd.
func (*RawReadCmdMessage) WithID ¶
func (r *RawReadCmdMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type RawReadingMessage ¶
type RawReadingMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ServerID `json:"Id"`
// Endpoint (from device config file) from which the data was retrieved.
Endpoint string `json:"Endpoint"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
// Data: raw byte string received from device.
Data []int `json:"Data"`
}
RawReadingMessage: raw byte array received from a device. Should only be used for testing/development.
func (*RawReadingMessage) LogValue ¶
func (r *RawReadingMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*RawReadingMessage) ServerID ¶
func (r *RawReadingMessage) ServerID() ServerID
ServerID implements ServerMessage
func (*RawReadingMessage) Type ¶
func (r *RawReadingMessage) Type() MessageType
Type returns MessageTypeRawReading.
type RawSubscribeCmdMessage ¶
type RawSubscribeCmdMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// Endpoint (from device config file) from which the data was retrieved.
Endpoint string `json:"Endpoint"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
}
RawSubscribeCmdMessage: subscribe to an endpoint on a device to receive raw info back.
func (*RawSubscribeCmdMessage) ClientID ¶
func (r *RawSubscribeCmdMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*RawSubscribeCmdMessage) LogValue ¶
func (r *RawSubscribeCmdMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*RawSubscribeCmdMessage) Type ¶
func (r *RawSubscribeCmdMessage) Type() MessageType
Type returns MessageTypeRawSubscribeCmd.
func (*RawSubscribeCmdMessage) WithID ¶
func (r *RawSubscribeCmdMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type RawUnsubscribeCmdMessage ¶
type RawUnsubscribeCmdMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// Endpoint (from device config file) from which the data was retrieved.
Endpoint string `json:"Endpoint"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
}
RawUnsubscribeCmdMessage: unsubscribe to an endpoint on a device.
func (*RawUnsubscribeCmdMessage) ClientID ¶
func (r *RawUnsubscribeCmdMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*RawUnsubscribeCmdMessage) LogValue ¶
func (r *RawUnsubscribeCmdMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*RawUnsubscribeCmdMessage) Type ¶
func (r *RawUnsubscribeCmdMessage) Type() MessageType
Type returns MessageTypeRawUnsubscribeCmd.
func (*RawUnsubscribeCmdMessage) WithID ¶
func (r *RawUnsubscribeCmdMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type RawWriteCmdMessage ¶
type RawWriteCmdMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// Endpoint (from device config file) to send command to.
Endpoint string `json:"Endpoint"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
// Data: raw byte string to send to device.
Data []int `json:"Data"`
// WriteWithResponse: if true, BLE writes will use WriteWithResponse.
// Value ignored for all other types.
WriteWithResponse bool `json:"WriteWithResponse"`
}
RawWriteCmdMessage: sends a raw byte array to a device. Should only be used for testing/development.
func (*RawWriteCmdMessage) ClientID ¶
func (r *RawWriteCmdMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*RawWriteCmdMessage) LogValue ¶
func (r *RawWriteCmdMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*RawWriteCmdMessage) Type ¶
func (r *RawWriteCmdMessage) Type() MessageType
Type returns MessageTypeRawWriteCmd.
func (*RawWriteCmdMessage) WithID ¶
func (r *RawWriteCmdMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type RequestDeviceListMessage ¶
type RequestDeviceListMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
}
RequestDeviceListMessage: request for the server to send a list of devices to the client.
func (*RequestDeviceListMessage) ClientID ¶
func (r *RequestDeviceListMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*RequestDeviceListMessage) LogValue ¶
func (r *RequestDeviceListMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*RequestDeviceListMessage) Type ¶
func (r *RequestDeviceListMessage) Type() MessageType
Type returns MessageTypeRequestDeviceList.
func (*RequestDeviceListMessage) WithID ¶
func (r *RequestDeviceListMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type RequestServerInfoMessage ¶
type RequestServerInfoMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// ClientName: name of the client software.
ClientName string `json:"ClientName"`
// MessageVersion: message template version of the client software.
MessageVersion int `json:"MessageVersion"`
}
RequestServerInfoMessage: request server version, and relay client name.
func (*RequestServerInfoMessage) ClientID ¶
func (r *RequestServerInfoMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*RequestServerInfoMessage) LogValue ¶
func (r *RequestServerInfoMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*RequestServerInfoMessage) Type ¶
func (r *RequestServerInfoMessage) Type() MessageType
Type returns MessageTypeRequestServerInfo.
func (*RequestServerInfoMessage) WithID ¶
func (r *RequestServerInfoMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type RotateCmdInfo ¶ added in v0.0.8
type RotateCmdInfo struct {
// ActuatorType: denotes type of actuator (Vibrator, Linear, Oscillator,
// etc...).
ActuatorType ptr.Optional[string] `json:"ActuatorType,omitzero"`
FeatureDescriptor ptr.Optional[string] `json:"FeatureDescriptor,omitzero"`
// StepCount: specifies granularity of each feature on the device.
StepCount ptr.Optional[StepCount] `json:"StepCount,omitzero"`
}
RotateCmdInfo: attributes for device messages.
type RotateCmdMessage ¶
type RotateCmdMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
// Rotations: device rotation speeds (floating point, 0 < x < 1) keyed on
// rotator number, stepping will be device specific.
Rotations []Rotation `json:"Rotations"`
}
RotateCmdMessage: sends a rotate command to a device that supports rotation.
func (*RotateCmdMessage) ClientID ¶
func (r *RotateCmdMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*RotateCmdMessage) LogValue ¶
func (r *RotateCmdMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*RotateCmdMessage) Type ¶
func (r *RotateCmdMessage) Type() MessageType
Type returns MessageTypeRotateCmd.
func (*RotateCmdMessage) WithID ¶
func (r *RotateCmdMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type Rotation ¶ added in v0.0.6
type Rotation struct {
// Index: rotator number.
Index int `json:"Index"`
// Speed: rotation speed (floating point, 0 < x < 1), stepping will be
// device specific.
Speed float64 `json:"Speed"`
// Clockwise: rotation direction (boolean). Not all devices have a concept
// of actual clockwise.
Clockwise bool `json:"Clockwise"`
}
type Scalar ¶ added in v0.0.6
type Scalar struct {
// Index: actuator index.
Index int `json:"Index"`
// Scalar: actuator scalar (floating point, range can vary), stepping will
// be device specific.
Scalar float64 `json:"Scalar"`
// ActuatorType: actuator type that is expected to be controlled with this
// subcommand.
ActuatorType string `json:"ActuatorType"`
}
type ScalarCmdInfo ¶ added in v0.0.8
type ScalarCmdInfo struct {
// ActuatorType: denotes type of actuator (Vibrator, Linear, Oscillator,
// etc...).
ActuatorType ptr.Optional[string] `json:"ActuatorType,omitzero"`
FeatureDescriptor ptr.Optional[string] `json:"FeatureDescriptor,omitzero"`
// StepCount: specifies granularity of each feature on the device.
StepCount ptr.Optional[StepCount] `json:"StepCount,omitzero"`
}
ScalarCmdInfo: attributes for device messages.
type ScalarCmdMessage ¶
type ScalarCmdMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
// Scalars: device actution scalar (floating point, range can vary) keyed on
// acutator index, stepping will be device specific.
Scalars []Scalar `json:"Scalars"`
}
ScalarCmdMessage: sends a generic scalar command to a device.
func (*ScalarCmdMessage) ClientID ¶
func (s *ScalarCmdMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*ScalarCmdMessage) LogValue ¶
func (s *ScalarCmdMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*ScalarCmdMessage) Type ¶
func (s *ScalarCmdMessage) Type() MessageType
Type returns MessageTypeScalarCmd.
func (*ScalarCmdMessage) WithID ¶
func (s *ScalarCmdMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type ScanningFinishedMessage ¶
type ScanningFinishedMessage struct {
// ID: used for non-direct-reply messages that can only be sent from server
// to client, using the reserved system message Id of 0.
ID SystemID `json:"Id"`
}
ScanningFinishedMessage: server notification to client that scanning has ended.
func (*ScanningFinishedMessage) LogValue ¶
func (s *ScanningFinishedMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*ScanningFinishedMessage) Type ¶
func (s *ScanningFinishedMessage) Type() MessageType
Type returns MessageTypeScanningFinished.
type SensorReadCmdItem ¶
type SensorReadCmdItem struct {
SensorType string `json:"SensorType"`
FeatureDescriptor string `json:"FeatureDescriptor"`
SensorRange [][2]int `json:"SensorRange"`
}
SensorReadCmdItem: attributes for sensor device messages.
type SensorReadCmdMessage ¶
type SensorReadCmdMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
SensorIndex int `json:"SensorIndex"`
SensorType string `json:"SensorType"`
}
SensorReadCmdMessage: sends a request to read a sensor value.
func (*SensorReadCmdMessage) ClientID ¶
func (s *SensorReadCmdMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*SensorReadCmdMessage) LogValue ¶
func (s *SensorReadCmdMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*SensorReadCmdMessage) Type ¶
func (s *SensorReadCmdMessage) Type() MessageType
Type returns MessageTypeSensorReadCmd.
func (*SensorReadCmdMessage) WithID ¶
func (s *SensorReadCmdMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type SensorReadingMessage ¶
type SensorReadingMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ServerID `json:"Id"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
SensorIndex int `json:"SensorIndex"`
SensorType string `json:"SensorType"`
Data []int `json:"Data"`
}
SensorReadingMessage: returns from either a sensor read request or a subscribed sensor event.
func (*SensorReadingMessage) LogValue ¶
func (s *SensorReadingMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*SensorReadingMessage) ServerID ¶
func (s *SensorReadingMessage) ServerID() ServerID
ServerID implements ServerMessage
func (*SensorReadingMessage) Type ¶
func (s *SensorReadingMessage) Type() MessageType
Type returns MessageTypeSensorReading.
type SensorSubscribeCmdItem ¶
type SensorSubscribeCmdItem struct {
SensorType string `json:"SensorType"`
FeatureDescriptor string `json:"FeatureDescriptor"`
SensorRange [][2]int `json:"SensorRange"`
}
SensorSubscribeCmdItem: attributes for sensor device messages.
type SensorSubscribeCmdMessage ¶
type SensorSubscribeCmdMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
SensorIndex int `json:"SensorIndex"`
SensorType string `json:"SensorType"`
}
SensorSubscribeCmdMessage: sends a request to subscribe for updates to a sensor value.
func (*SensorSubscribeCmdMessage) ClientID ¶
func (s *SensorSubscribeCmdMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*SensorSubscribeCmdMessage) LogValue ¶
func (s *SensorSubscribeCmdMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*SensorSubscribeCmdMessage) Type ¶
func (s *SensorSubscribeCmdMessage) Type() MessageType
Type returns MessageTypeSensorSubscribeCmd.
func (*SensorSubscribeCmdMessage) WithID ¶
func (s *SensorSubscribeCmdMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type SensorUnsubscribeCmdMessage ¶
type SensorUnsubscribeCmdMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
SensorIndex int `json:"SensorIndex"`
SensorType string `json:"SensorType"`
}
SensorUnsubscribeCmdMessage: sends a request to subscribe for updates to a sensor value.
func (*SensorUnsubscribeCmdMessage) ClientID ¶
func (s *SensorUnsubscribeCmdMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*SensorUnsubscribeCmdMessage) LogValue ¶
func (s *SensorUnsubscribeCmdMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*SensorUnsubscribeCmdMessage) Type ¶
func (s *SensorUnsubscribeCmdMessage) Type() MessageType
Type returns MessageTypeSensorUnsubscribeCmd.
func (*SensorUnsubscribeCmdMessage) WithID ¶
func (s *SensorUnsubscribeCmdMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type ServerID ¶
type ServerID int
ServerID: user-set id for the message. 0 denotes system message and is reserved.
type ServerInfoMessage ¶
type ServerInfoMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// MessageVersion: message template version of the server software.
MessageVersion int `json:"MessageVersion"`
// MaxPingTime: maximum time (in milliseconds) the server will wait between
// ping messages from client before shutting down.
MaxPingTime int `json:"MaxPingTime"`
// ServerName: name of the server. Can be 0-length.
ServerName string `json:"ServerName"`
}
ServerInfoMessage: server version information, in Major.Minor.Build format.
func (*ServerInfoMessage) ClientID ¶
func (s *ServerInfoMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*ServerInfoMessage) LogValue ¶
func (s *ServerInfoMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*ServerInfoMessage) Type ¶
func (s *ServerInfoMessage) Type() MessageType
Type returns MessageTypeServerInfo.
func (*ServerInfoMessage) WithID ¶
func (s *ServerInfoMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type ServerMessage ¶
type ServerMessage interface {
Message
// ServerID returns the ID field of the message.
ServerID() ServerID
// contains filtered or unexported methods
}
ServerMessage represents a message that can be sent from the server to the client. It extends Message.
The following messages are defined:
type StartScanningMessage ¶
type StartScanningMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
}
StartScanningMessage: request for the server to start scanning for new devices.
func (*StartScanningMessage) ClientID ¶
func (s *StartScanningMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*StartScanningMessage) LogValue ¶
func (s *StartScanningMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*StartScanningMessage) Type ¶
func (s *StartScanningMessage) Type() MessageType
Type returns MessageTypeStartScanning.
func (*StartScanningMessage) WithID ¶
func (s *StartScanningMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type StopAllDevicesMessage ¶
type StopAllDevicesMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
}
StopAllDevicesMessage: stops all actions currently being taken by all connected devices.
func (*StopAllDevicesMessage) ClientID ¶
func (s *StopAllDevicesMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*StopAllDevicesMessage) LogValue ¶
func (s *StopAllDevicesMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*StopAllDevicesMessage) Type ¶
func (s *StopAllDevicesMessage) Type() MessageType
Type returns MessageTypeStopAllDevices.
func (*StopAllDevicesMessage) WithID ¶
func (s *StopAllDevicesMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type StopDeviceCmdMessage ¶
type StopDeviceCmdMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
// DeviceIndex: index used for referencing the device in device messages.
DeviceIndex DeviceIndex `json:"DeviceIndex"`
}
StopDeviceCmdMessage: stops the all actions currently being taken by a device.
func (*StopDeviceCmdMessage) ClientID ¶
func (s *StopDeviceCmdMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*StopDeviceCmdMessage) LogValue ¶
func (s *StopDeviceCmdMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*StopDeviceCmdMessage) Type ¶
func (s *StopDeviceCmdMessage) Type() MessageType
Type returns MessageTypeStopDeviceCmd.
func (*StopDeviceCmdMessage) WithID ¶
func (s *StopDeviceCmdMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type StopScanningMessage ¶
type StopScanningMessage struct {
// ID: user-set id for the message. 0 denotes system message and is
// reserved.
ID ClientID `json:"Id"`
}
StopScanningMessage: request for the server to stop scanning for new devices.
func (*StopScanningMessage) ClientID ¶
func (s *StopScanningMessage) ClientID() ClientID
ClientID implements ClientMessage
func (*StopScanningMessage) LogValue ¶
func (s *StopScanningMessage) LogValue() slog.Value
LogValue implements slog.LogValuer.
func (*StopScanningMessage) Type ¶
func (s *StopScanningMessage) Type() MessageType
Type returns MessageTypeStopScanning.
func (*StopScanningMessage) WithID ¶
func (s *StopScanningMessage) WithID(id ClientID) ClientMessage
WithID implements ClientMessage.
type SystemID ¶
type SystemID int
SystemID: used for non-direct-reply messages that can only be sent from server to client, using the reserved system message Id of 0.
type Vector ¶ added in v0.0.6
type Vector struct {
// Index: linear actuator number.
Index int `json:"Index"`
// Duration: linear movement time in milliseconds.
Duration float64 `json:"Duration"`
// Position: linear movement position (floating point, 0 < x < 1), stepping
// will be device specific.
Position float64 `json:"Position"`
}