fix: protocol v1

This commit is contained in:
2024-08-02 12:57:07 +02:00
parent 8f89ed7e77
commit b976bde363
23 changed files with 392 additions and 85 deletions

View File

@ -3,5 +3,9 @@ package v2
import "forge.cadoles.com/cadoles/go-emlid/reach/client/protocol"
func init() {
protocol.Register(&Protocol{})
protocol.Register(Identifier, func(opts *protocol.ProtocolOptions) (protocol.Protocol, error) {
return &Protocol{
logger: opts.Logger,
}, nil
})
}

View File

@ -18,7 +18,7 @@ type Configuration struct {
Lora struct {
AirRate float64 `json:"air_rate,omitempty"`
Frequency int `json:"frequency,omitempty"`
OutputPower int `json:"output_power,omitempty"`
OutputPower float64 `json:"output_power,omitempty"`
} `json:"lora,omitempty"`
Ntripcaster struct {
MountPoint string `json:"mount_point,omitempty"`

View File

@ -4,6 +4,7 @@ import (
"context"
"sync"
"forge.cadoles.com/cadoles/go-emlid/reach/client/logger"
"forge.cadoles.com/cadoles/go-emlid/reach/client/protocol"
"forge.cadoles.com/cadoles/go-emlid/reach/client/protocol/v2/model"
@ -15,6 +16,7 @@ type Operations struct {
addr string
client *socketio.Client
mutex sync.RWMutex
logger logger.Logger
}
// Reboot implements protocol.Operations.

View File

@ -10,7 +10,9 @@ import (
)
func TestProtocolV2Operations(t *testing.T) {
proto := &Protocol{}
proto := &Protocol{
logger: testsuite.NewLogger(t),
}
factory := func(addr string) (protocol.Operations, error) {
ctx := context.Background()

View File

@ -3,6 +3,7 @@ package v2
import (
"context"
"forge.cadoles.com/cadoles/go-emlid/reach/client/logger"
"forge.cadoles.com/cadoles/go-emlid/reach/client/protocol"
"github.com/Masterminds/semver/v3"
"github.com/pkg/errors"
@ -13,6 +14,7 @@ const Identifier protocol.Identifier = "v2"
const compatibleVersionConstraint = ">= 32"
type Protocol struct {
logger logger.Logger
}
// Available implements protocol.Protocol.
@ -35,7 +37,7 @@ func (p *Protocol) Available(ctx context.Context, addr string) (bool, error) {
}
if !versionConstraint.Check(version) {
return false, errors.Errorf("reachview version '%s' does not match constraint '%s'", info.Reachview.Version, compatibleVersionConstraint)
return false, nil
}
return true, nil
@ -48,7 +50,7 @@ func (p *Protocol) Identifier() protocol.Identifier {
// Operations implements protocol.Protocol.
func (p *Protocol) Operations(addr string) protocol.Operations {
return &Operations{addr: addr}
return &Operations{addr: addr, logger: p.logger}
}
var _ protocol.Protocol = &Protocol{}