Documentation
¶
Index ¶
- Constants
- func NewAPIError(statusCode int, body []byte) error
- type APIError
- type App
- type Audio
- type AudioUpdate
- type AuthError
- type Bluetooth
- type BluetoothUpdate
- type Client
- func (c *Client) Delete(ctx context.Context, path string) error
- func (c *Client) Get(ctx context.Context, path string, out any) error
- func (c *Client) GetStreamStatus(ctx context.Context) (*StreamStatus, error)
- func (c *Client) IP() string
- func (c *Client) Post(ctx context.Context, path string, body, out any) error
- func (c *Client) Put(ctx context.Context, path string, body, out any) error
- func (c *Client) StartStream(ctx context.Context) (*StreamStartResponse, error)
- func (c *Client) StopStream(ctx context.Context) error
- type CloudIcon
- type Device
- type Display
- type DisplayUpdate
- type Frame
- type GoalData
- type IconsResponse
- type Notification
- type NotificationModel
- type NotificationRequest
- type RetryTransport
- type Screensaver
- type Sound
- type StreamSession
- type StreamStartResponse
- type StreamStatus
- type WiFi
- type Widget
Constants ¶
const ( LMSPPort = 7575 LMSPVersion = 0x0100 EncodingRAW = 0 EncodingPNG = 1 EncodingJPEG = 2 EncodingGIF = 3 )
LMSP protocol constants.
Variables ¶
This section is empty.
Functions ¶
func NewAPIError ¶
NewAPIError parses a JSON error response body and returns the appropriate typed error.
Types ¶
type APIError ¶
APIError represents a LaMetric API error response. LaMetric returns: {"errors":[{"message":"..."}]}
type App ¶
type App struct {
Package string `json:"package"`
Vendor string `json:"vendor,omitempty"`
Version string `json:"version,omitempty"`
Widgets map[string]Widget `json:"widgets,omitempty"`
}
App represents an installed app/widget.
type AudioUpdate ¶
type AudioUpdate struct {
Volume *int `json:"volume,omitempty"`
}
AudioUpdate is the payload for updating audio settings.
type AuthError ¶
type AuthError struct {
APIError
}
AuthError represents a 401 authentication error.
type Bluetooth ¶
type Bluetooth struct {
Available bool `json:"available"`
Active bool `json:"active"`
Name string `json:"name"`
MAC string `json:"mac,omitempty"`
Pairable bool `json:"pairable"`
Discoverable bool `json:"discoverable"`
}
Bluetooth represents bluetooth settings.
type BluetoothUpdate ¶
type BluetoothUpdate struct {
Active *bool `json:"active,omitempty"`
Name *string `json:"name,omitempty"`
Pairable *bool `json:"pairable,omitempty"`
Discoverable *bool `json:"discoverable,omitempty"`
}
BluetoothUpdate is the payload for updating bluetooth settings.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the LaMetric local API client.
func NewClient ¶
NewClient creates a Client for a LaMetric device at the given IP. It auto-detects the protocol: HTTPS:4343 first, fallback HTTP:8080.
func (*Client) GetStreamStatus ¶
func (c *Client) GetStreamStatus(ctx context.Context) (*StreamStatus, error)
GetStreamStatus returns current streaming status via GET /api/v2/device/stream.
func (*Client) StartStream ¶
func (c *Client) StartStream(ctx context.Context) (*StreamStartResponse, error)
StartStream initiates a streaming session via PUT /api/v2/device/stream/start.
type CloudIcon ¶
type CloudIcon struct {
ID int `json:"id"`
Title string `json:"title"`
Code string `json:"code"`
Type string `json:"type"` // "picture" or "movie"
}
CloudIcon represents an icon from the LaMetric cloud icon library.
func GetPopularIcons ¶
GetPopularIcons returns popular icons from the LaMetric cloud library.
type Device ¶
type Device struct {
ID string `json:"id"`
UUID string `json:"uuid"`
Name string `json:"name"`
SerialNumber string `json:"serial_number"`
OSVersion string `json:"os_version"`
Mode string `json:"mode"`
Model string `json:"model"`
Audio Audio `json:"audio"`
Bluetooth Bluetooth `json:"bluetooth"`
Display Display `json:"display"`
WiFi WiFi `json:"wifi"`
}
Device represents a LaMetric device info response.
type Display ¶
type Display struct {
Brightness int `json:"brightness"`
BrightnessMode string `json:"brightness_mode"` // auto|manual
Width int `json:"width"`
Height int `json:"height"`
Type string `json:"type"`
Screensaver *Screensaver `json:"screensaver,omitempty"`
}
Display represents display settings.
type DisplayUpdate ¶
type DisplayUpdate struct {
Brightness *int `json:"brightness,omitempty"`
BrightnessMode *string `json:"brightness_mode,omitempty"`
}
DisplayUpdate is the payload for updating display settings.
type Frame ¶
type Frame struct {
Icon string `json:"icon,omitempty"`
Text string `json:"text,omitempty"`
GoalData *GoalData `json:"goalData,omitempty"`
ChartData []int `json:"chartData,omitempty"`
}
Frame represents a single notification frame.
type GoalData ¶
type GoalData struct {
Start int `json:"start"`
Current int `json:"current"`
End int `json:"end"`
Unit string `json:"unit,omitempty"`
}
GoalData represents goal progress data.
type IconsResponse ¶
type IconsResponse struct {
Meta struct {
TotalIconCount int `json:"total_icon_count"`
Page int `json:"page"`
PageSize int `json:"page_size"`
PageCount int `json:"page_count"`
} `json:"meta"`
Data []CloudIcon `json:"data"`
}
IconsResponse is the API response for the icons endpoint.
type Notification ¶
type Notification struct {
ID string `json:"id"`
Type string `json:"type,omitempty"`
Priority string `json:"priority,omitempty"`
Created string `json:"created,omitempty"`
}
Notification represents a created/queued notification.
type NotificationModel ¶
type NotificationModel struct {
Frames []Frame `json:"frames"`
Sound *Sound `json:"sound,omitempty"`
Cycles int `json:"cycles,omitempty"`
}
NotificationModel holds the frames, sound, and cycle config.
type NotificationRequest ¶
type NotificationRequest struct {
Priority string `json:"priority,omitempty"` // info|warning|critical
IconType string `json:"icon_type,omitempty"` // none|info|alert
Lifetime int `json:"lifetime,omitempty"` // ms
Model NotificationModel `json:"model"`
}
NotificationRequest is the payload sent to create a notification.
type RetryTransport ¶
type RetryTransport struct {
Base http.RoundTripper
MaxRetries int
}
RetryTransport wraps an http.RoundTripper with retry logic and exponential backoff.
func NewRetryTransport ¶
func NewRetryTransport(base http.RoundTripper) *RetryTransport
NewRetryTransport creates a RetryTransport with default 3 retries.
type Screensaver ¶
Screensaver represents screensaver configuration.
type Sound ¶
type Sound struct {
Category string `json:"category,omitempty"` // notifications|alarms
ID string `json:"id,omitempty"`
Repeat int `json:"repeat,omitempty"`
}
Sound represents a notification sound.
type StreamSession ¶
type StreamSession struct {
SessionID string // UUID from start response
DeviceIP string
Width int // 37 for TIME, 8 for SKY
Height int // always 8
// contains filtered or unexported fields
}
StreamSession represents an active LMSP streaming session.
func NewStreamSession ¶
func NewStreamSession(deviceIP, sessionID string, width, height int) (*StreamSession, error)
NewStreamSession creates a StreamSession and opens the UDP connection.
func (*StreamSession) Close ¶
func (s *StreamSession) Close() error
Close closes the UDP connection.
type StreamStartResponse ¶
type StreamStartResponse struct {
SessionID string `json:"session_id"`
}
StreamStartResponse is returned by the streaming start endpoint.
type StreamStatus ¶
type StreamStatus struct {
Active bool `json:"active"`
SessionID string `json:"session_id,omitempty"`
}
StreamStatus is returned by the streaming status endpoint.