The pkg/brightsign package provides a clean, well-structured Go API for interacting with BrightSign players via their Diagnostic Web Server (DWS) API.
package main
import (
"fmt"
"log"
"time"
"bscli/pkg/brightsign"
)
func main() {
// Create client
client := brightsign.NewClient(brightsign.Config{
Host: "192.168.1.100",
Username: "admin",
Password: "mypassword",
Debug: false,
Insecure: false, // Set to true for self-signed certificates
Timeout: 30 * time.Second,
})
// Get device information
info, err := client.Info.GetInfo()
if err != nil {
log.Fatal(err)
}
fmt.Printf("Model: %s\n", info.Model)
fmt.Printf("Serial: %s\n", info.Serial)
fmt.Printf("Firmware: %s\n", info.FWVersion)
// Upload a file
err = client.Storage.UploadFile("local.mp4", "/storage/sd/video.mp4")
if err != nil {
log.Fatal(err)
}
// List files
files, err := client.Storage.ListFiles("/storage/sd/", nil)
if err != nil {
log.Fatal(err)
}
for _, file := range files {
fmt.Printf("%s: %d bytes\n", file.Name, file.Size)
}
// Run ping diagnostic
result, err := client.Diagnostics.Ping("8.8.8.8")
if err != nil {
log.Fatal(err)
}
if result.Success {
fmt.Printf("Ping successful: %d/%d packets, %.2fms avg\n",
result.PacketsRecv, result.PacketsSent, result.AvgTime)
}
// Take a snapshot
filename, err := client.Control.TakeSnapshot(nil)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Snapshot saved: %s\n", filename)
}The library is organized into services that correspond to DWS API categories:
- Info: Device information, health, time, video modes
- Control: Player control, snapshots, DWS configuration
- Storage: File operations, storage management
- Diagnostics: Network diagnostics, SSH/telnet configuration
- Display: Display control for Moka displays
- Registry: Player registry management
- Logs: Log retrieval and logging configuration
- Video: Video output management, EDID, CEC
client := brightsign.NewClient(brightsign.Config{
Host: "192.168.1.100", // Player IP address or hostname
Username: "admin", // Username (usually "admin")
Password: "mypassword", // Player password
Debug: false, // Enable debug HTTP logging
Timeout: 30 * time.Second, // HTTP timeout
Insecure: false, // Skip TLS certificate verification for local certificates
})The library automatically handles digest authentication. You only need to provide the username and password in the configuration.
Enable debug mode to see HTTP requests and responses:
client := brightsign.NewClient(brightsign.Config{
Debug: true,
// ... other config
})For players using locally signed certificates (common in newer firmware), enable insecure mode:
client := brightsign.NewClient(brightsign.Config{
Host: "192.168.1.100",
Username: "admin",
Password: "mypassword",
Insecure: true, // Use HTTPS with insecure TLS (skip certificate verification)
// ... other config
})Note: When Insecure: true is set, the client automatically uses HTTPS instead of HTTP and skips TLS certificate verification. This is necessary for BrightSign players that use self-signed certificates.
All methods return an error as the second value. Always check for errors:
info, err := client.Info.GetInfo()
if err != nil {
log.Fatalf("Failed to get device info: %v", err)
}// Get device information
info, err := client.Info.GetInfo()
// Get player health
health, err := client.Info.GetHealth()
// Get time information
timeInfo, err := client.Info.GetTime()
// Set time
err = client.Info.SetTime(time.Now())
// Get video mode
videoMode, err := client.Info.GetVideoMode()
// List available APIs
apis, err := client.Info.GetAPIs()// Reboot the player
err := client.Control.Reboot()
// Take a snapshot
filename, err := client.Control.TakeSnapshot(nil)
// Get DWS password status
status, err := client.Control.GetDWSPasswordStatus()
// Enable local DWS
err = client.Control.EnableLocalDWS(true)// List files
files, err := client.Storage.ListFiles("/storage/sd/", nil)
// Upload a file
err = client.Storage.UploadFile("local.mp4", "/storage/sd/video.mp4")
// Download a file
err = client.Storage.DownloadFile("/storage/sd/video.mp4", "local.mp4")
// Delete a file
err = client.Storage.DeleteFile("/storage/sd/video.mp4")
// Create directory
err = client.Storage.CreateDirectory("/storage/sd/videos/")
// Rename file
err = client.Storage.RenameFile("/storage/sd/old.mp4", "new.mp4")// Ping test
result, err := client.Diagnostics.Ping("8.8.8.8")
// DNS lookup
result, err := client.Diagnostics.DNSLookup("google.com", false)
// Traceroute
result, err := client.Diagnostics.Traceroute("8.8.8.8")
// Get network interfaces
interfaces, err := client.Diagnostics.GetInterfaces()
// Network diagnostics
diagnostics, err := client.Diagnostics.GetDiagnostics()// Get registry value
value, err := client.Registry.GetValue("networking", "hostname")
// Set registry value
err = client.Registry.SetValue("networking", "hostname", "myplayer")
// Delete registry value
err = client.Registry.DeleteValue("networking", "hostname")
// Search registry
results, err := client.Registry.Search("hostname")
// Get full registry dump
registry, err := client.Registry.GetRegistry()// Get display settings
settings, err := client.Display.GetSettings()
// Set brightness
err = client.Display.SetBrightness(80)
// Set contrast
err = client.Display.SetContrast(50)
// Set volume
err = client.Display.SetVolume(75)
// Power on/off
err = client.Display.SetPower(true)// Get logs
logs, err := client.Logs.GetLogs(nil)
// Get supervisor logging level
level, err := client.Logs.GetSupervisorLogging()
// Set supervisor logging level
err = client.Logs.SetSupervisorLogging("debug")// Get video output info
output, err := client.Video.GetOutputInfo("hdmi", "0")
// Get EDID information
edid, err := client.Video.GetEDID("hdmi", "0")
// Send CEC command
err = client.Video.SendCEC("hdmi", "0", "power_on")This implementation covers all Local DWS API endpoints as documented in the BrightSign API documentation:
GET /info/- Basic player informationGET /health/- Player health statusGET /time/- Current time configurationPUT /time/- Set timeGET /video-mode/- Current video modeGET /- List all available APIs
PUT /control/reboot/- Reboot playerGET /control/dws-password/- DWS password statusPUT /control/dws-password/- Set/reset DWS passwordGET /control/local-dws/- Local DWS statusPUT /control/local-dws/- Enable/disable local DWSPOST /snapshot/- Take screenshotGET /download-firmware/- Download firmware
GET /files/:path/- List files/directoriesPOST /files/:path/- Rename filesPUT /files/:path/- Upload files/create directoriesDELETE /files/:path/- Delete files/directoriesDELETE /storage/:device/- Format storage
GET /diagnostics/- Run network diagnosticsGET /diagnostics/dns-lookup/:address/- DNS lookupGET /diagnostics/ping/:ipAddress/- Ping testGET /diagnostics/trace-route/:address/- TracerouteGET /diagnostics/network-neighborhood/- Network neighborhoodGET /diagnostics/network-configuration/:interface/- Network configPUT /diagnostics/network-configuration/:interface/- Set network configGET /diagnostics/interfaces/- List interfaces- Packet capture operations
- SSH/Telnet configuration
GET /display-control/- All display settings- Brightness, contrast, volume controls
- Power management
- Firmware updates
- Display information
GET /registry/- Full registry dumpGET /registry/:section/:key/- Get registry valuePUT /registry/:section/:key/- Set registry valueDELETE /registry/:section/:key/- Delete registry valueDELETE /registry/:section/- Delete registry section- Recovery URL management
- Registry flush
GET /logs/- Get player logsGET /system/supervisor/logging/- Supervisor logging levelPUT /system/supervisor/logging/- Set logging level
GET /video/:connector/output/:device/- Video output infoGET /video/:connector/output/:device/edid/- EDID information- Power save management
- Video mode operations
POST /sendCecX/- CEC commands
- Go 1.21 or higher
- BrightSign player with DWS enabled
- Network connectivity to the player
- The library provides full access to the DWS API
- Be careful with destructive operations like formatting storage or rebooting
- Always test operations on non-production players first
- Consider implementing your own safety checks for critical operations