wip deprecated V1
This commit is contained in:
@ -2,7 +2,6 @@ package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -14,6 +13,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
type Operations struct {
|
||||
addr string
|
||||
client *socketio.Client
|
||||
@ -23,6 +23,7 @@ type Operations struct {
|
||||
dial protocol.DialFunc
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// Close implements protocol.Operations.
|
||||
func (o *Operations) Close(ctx context.Context) error {
|
||||
o.mutex.Lock()
|
||||
@ -37,12 +38,14 @@ func (o *Operations) Close(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
const (
|
||||
// EventBrowserConnected is emitted after the initial connection to the
|
||||
// ReachView endpoint
|
||||
eventBrowserConnected = "browser connected"
|
||||
)
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// Connect implements protocol.Operations.
|
||||
func (o *Operations) Connect(ctx context.Context) error {
|
||||
o.mutex.Lock()
|
||||
@ -81,6 +84,7 @@ func (o *Operations) Connect(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// Emit implements protocol.Operations.
|
||||
func (o *Operations) Emit(ctx context.Context, mType string, message any) error {
|
||||
o.mutex.RLock()
|
||||
@ -97,6 +101,7 @@ func (o *Operations) Emit(ctx context.Context, mType string, message any) error
|
||||
return nil
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// On implements protocol.Operations.
|
||||
func (o *Operations) On(ctx context.Context, event string) (chan any, error) {
|
||||
o.mutex.RLock()
|
||||
@ -137,6 +142,7 @@ func (o *Operations) On(ctx context.Context, event string) (chan any, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// Alive implements protocol.Operations.
|
||||
func (o *Operations) Alive(ctx context.Context) (bool, error) {
|
||||
o.mutex.RLock()
|
||||
@ -149,6 +155,7 @@ func (o *Operations) Alive(ctx context.Context) (bool, error) {
|
||||
return o.client.Alive(), nil
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// Configuration implements protocol.Operations.
|
||||
func (o *Operations) Configuration(ctx context.Context) (any, error) {
|
||||
config, err := o.RequestConfiguration(ctx)
|
||||
@ -163,6 +170,7 @@ const (
|
||||
eventReboot = "reboot"
|
||||
)
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// Reboot implements protocol.Operations.
|
||||
func (o *Operations) Reboot(ctx context.Context) error {
|
||||
o.mutex.RLock()
|
||||
@ -213,6 +221,7 @@ const (
|
||||
configurationApplyFailed = "failed"
|
||||
)
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// SetBase implements protocol.Operations.
|
||||
func (o *Operations) SetBase(ctx context.Context, funcs ...protocol.SetBaseOptionFunc) error {
|
||||
rawConfig, err := o.Configuration(ctx)
|
||||
@ -298,6 +307,7 @@ func (o *Operations) SetBase(ctx context.Context, funcs ...protocol.SetBaseOptio
|
||||
return nil
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// GetBaseInfo implements protocol.Operations.
|
||||
func (o *Operations) GetBaseInfo(ctx context.Context) (*protocol.BaseInfo, error) {
|
||||
rawConfig, err := o.Configuration(ctx)
|
||||
@ -354,6 +364,7 @@ type reachViewVersion struct {
|
||||
Stable bool `json:"bool"`
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// Version implements protocol.Operations.
|
||||
func (o *Operations) Version(ctx context.Context) (string, bool, error) {
|
||||
res := &reachViewVersion{}
|
||||
@ -364,79 +375,24 @@ func (o *Operations) Version(ctx context.Context) (string, bool, error) {
|
||||
return strings.TrimSpace(res.Version), res.Stable, nil
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
func (o *Operations) AveragePosition(ctx context.Context) (*protocol.TaskMessage, error) {
|
||||
var err error
|
||||
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
err = ctx.Err()
|
||||
}()
|
||||
|
||||
if err = o.client.Emit("task", map[string]string{"name": "average_base_coordinates"}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
ch, err := o.On(ctx, "task_status")
|
||||
for message := range ch {
|
||||
// Convertir vers notre struct
|
||||
jsonData, err := json.Marshal(message)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
var taskMsg protocol.TaskMessage
|
||||
if err := json.Unmarshal(jsonData, &taskMsg); err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if taskMsg.State == "completed" {
|
||||
return &taskMsg, nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, err
|
||||
return nil, protocol.ErrUnimplemented
|
||||
}
|
||||
|
||||
// TODO À VOIR POUR LES VERSION 1
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
func (o *Operations) GetNTRIPMountPoint(ctx context.Context) error {
|
||||
var err error
|
||||
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
err = ctx.Err()
|
||||
}()
|
||||
payloadJSON, err := json.Marshal(map[string]interface{}{
|
||||
"address": "crtk.net",
|
||||
"port": 2101,
|
||||
})
|
||||
if err = o.client.Emit("task", map[string]string{"name": "get_ntrip_mountpoints", "payload": string(payloadJSON)}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
return protocol.ErrUnimplemented
|
||||
}
|
||||
|
||||
// todo
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
func (o *Operations) SetBaseCorrections(ctx context.Context, funcs ...protocol.SetBaseCorrectionsFunc) error {
|
||||
var err error
|
||||
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
err = ctx.Err()
|
||||
}()
|
||||
// todo
|
||||
payloadJSON, err := json.Marshal(map[string]interface{}{
|
||||
"address": "crtk.net",
|
||||
"port": 2101,
|
||||
})
|
||||
if err = o.client.Emit("task", map[string]string{"name": "get_ntrip_mountpoints", "payload": string(payloadJSON)}); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
return protocol.ErrUnimplemented
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
func (o *Operations) SetModem(ctx context.Context, funcs ...protocol.SetModemOptionsFunc) error {
|
||||
var err error
|
||||
return err
|
||||
return protocol.ErrUnimplemented
|
||||
}
|
||||
|
||||
var _ protocol.Operations = &Operations{}
|
||||
|
Reference in New Issue
Block a user