This commit is contained in:
2026-01-09 11:56:40 +01:00
parent 1ee0afa088
commit 4ab192418e
30 changed files with 3455 additions and 16 deletions

View File

@@ -6,13 +6,14 @@ import (
"net"
"strings"
"time"
. "git.rouggy.com/rouggy/ShackMaster/internal/devices"
)
type Client struct {
host string
port int
idNumber int
conn net.Conn
host string
port int
conn net.Conn
}
type Status struct {
@@ -31,11 +32,10 @@ type Status struct {
Connected bool `json:"connected"`
}
func New(host string, port int, idNumber int) *Client {
func New(host string, port int) *Client {
return &Client{
host: host,
port: port,
idNumber: idNumber,
host: host,
port: port,
}
}
@@ -62,8 +62,11 @@ func (c *Client) sendCommand(cmd string) (string, error) {
}
}
// Format command with ID
fullCmd := fmt.Sprintf("C%d|%s\n", c.idNumber, cmd)
// Get next command ID from global counter
cmdID := GetGlobalCommandID().GetNextID()
// Format command with ID: C<id>|<command>
fullCmd := fmt.Sprintf("C%d|%s\n", cmdID, cmd)
// Send command
_, err := c.conn.Write([]byte(fullCmd))