Skip to content

Commit

Permalink
add support for lock mode and retrieving the KEYSPD level
Browse files Browse the repository at this point in the history
  • Loading branch information
ftl committed Jun 15, 2023
1 parent 3de4466 commit 9960be1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
18 changes: 18 additions & 0 deletions adapter/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ type inboundConnection struct {
trace bool
noDigimodes bool
version string
modeLocked bool
}

func (c *inboundConnection) run() {
Expand Down Expand Up @@ -214,6 +215,9 @@ func (c *inboundConnection) handleRequest(req protocol.Request) (protocol.Respon
if len(req.Args) < 2 {
return protocol.NoResponse, fmt.Errorf("set_mode: no arguments")
}
if c.modeLocked {
return protocol.OKResponse(req.Key()), nil
}
mode := c.overrideDigimode(hamlibToTCIMode[hamlib.Mode(req.Args[0])])
// passband, err := strconv.Atoi(req.Args[1]) // TODO also take the passband into account
err := c.tciClient.SetMode(c.trxData.trx, mode)
Expand Down Expand Up @@ -311,6 +315,20 @@ func (c *inboundConnection) handleRequest(req protocol.Request) (protocol.Respon
return protocol.NoResponse, fmt.Errorf("set_level: cannot send TCI command: %w", err)
}
return protocol.OKResponse(req.Key()), nil
case "get_level_keyspd":
wpm, err := c.tciClient.CWMacrosSpeed()
if err != nil {
return protocol.NoResponse, fmt.Errorf("get_level: cannot send TCI command: %w", err)
}
return protocol.GetLevelKeyspdResponse(wpm), nil
case "set_lock_mode":
if len(req.Args) < 1 {
return protocol.NoResponse, fmt.Errorf("set_lock_mode: no arguments")
}
c.modeLocked = (req.Args[0] == "1")
return protocol.OKResponse(req.Key()), nil
case "get_lock_mode":
return protocol.GetPTTResponse(c.modeLocked), nil
default:
log.Printf("unsupported request: %v", req.LongFormat())
return notImplementedResponse(req.Key()), nil
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ go 1.19
// replace github.com/ftl/rigproxy => ../rigproxy

require (
github.com/ftl/rigproxy v0.2.0
github.com/ftl/rigproxy v0.2.3
github.com/ftl/tci v0.3.1
github.com/spf13/cobra v1.6.1
golang.org/x/sys v0.5.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46t
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/ftl/hamradio v0.2.6 h1:AEgTLhoqYCZDg7pCZMeRFZYJPSoXTp4TEK65lBEcP2o=
github.com/ftl/hamradio v0.2.6/go.mod h1:FOZkf8liaM/H8F8Vyp36EN9iVzikKpaOJ5AqrW77cEo=
github.com/ftl/rigproxy v0.2.0 h1:CHdoFJM2wWx9IkM6jQEBMAbL7WeQiriR6AC0RNncuK0=
github.com/ftl/rigproxy v0.2.0/go.mod h1:3X0MLMrmbrglHCw0EUWVtYah15LY+Xgfh8NbynYzpVg=
github.com/ftl/rigproxy v0.2.3 h1:xXC5BweI8SZCrnt+UFLrR5F0tpXPdPUwCBH5RKys3GM=
github.com/ftl/rigproxy v0.2.3/go.mod h1:PrBUiqLwu/6zL44+uOz4lgmOfnis4FIvJDhxDNXoi60=
github.com/ftl/tci v0.3.1 h1:Njtb38PzkVYbW9zlr4Babl6+frQBsCLWNEZDvxxUTzQ=
github.com/ftl/tci v0.3.1/go.mod h1:3B8x8FI/kBbUwbWnz725tTiiiNfJpIL9cQ67TnjW3aU=
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
Expand Down

0 comments on commit 9960be1

Please sign in to comment.