Compare commits
13 Commits
bea49c78a9
...
master
Author | SHA1 | Date | |
---|---|---|---|
4050090814 | |||
05f5b3f771 | |||
daadb9b678 | |||
1fcf748310 | |||
2c5d1442fe | |||
5a8f4301cb | |||
af3b3b40f3 | |||
3224e1ef0f | |||
359a0018c5 | |||
f560465364 | |||
abebc7d8c6 | |||
81741d20c1 | |||
d66e91f221 |
@ -8,6 +8,7 @@ Librairie Golang d'interaction avec les produits [Emlid](https://emlid.com/).
|
||||
|
||||
- [`cmd/broadcast`](./cmd/broadcast) - Affichage en flux continu des évènements transmis par un module Reach
|
||||
- [`cmd/configuration`](./cmd/configuration) - Affichage de la configuration d'un module Reach
|
||||
- [`cmd/proxy`](./cmd/proxy) - Service proxy permettant de joindre un module ReachView présent sur un autre réseau
|
||||
|
||||
## Licence
|
||||
|
||||
|
21
cmd/average_position/README.md
Normal file
21
cmd/average_position/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
# `configuration`
|
||||
|
||||
Utilitaire permettant de faire le scénario de paramétrage de la base automatique :
|
||||
|
||||
- Récupération de la configuration
|
||||
- Configuration de la base pour avoir des corrections NTRIP
|
||||
- Changement de mode de la balise (passage de `manuel` à `fix-and-hold`)
|
||||
- Collecte des positions pour obtenir la moyenne
|
||||
- Configuration de la base avec les nouvelles coordonées
|
||||
|
||||
## Utilisation
|
||||
|
||||
```shell
|
||||
go run ./cmd/average_position -host <HOST> -baseAccuracy <fix|float|single>
|
||||
```
|
||||
|
||||
Où:
|
||||
|
||||
- `<HOST>` est l'adresse IP du module Reach sur le réseau (par défaut `192.168.42.1`).
|
||||
|
||||
> **Info** Utiliser le flag `-h` pour voir les autres options disponibles.
|
240
cmd/average_position/main.go
Normal file
240
cmd/average_position/main.go
Normal file
@ -0,0 +1,240 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
reach "forge.cadoles.com/cadoles/go-emlid/reach/client"
|
||||
"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"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
host string = "192.168.42.1"
|
||||
rawLogLevel string = "ERROR"
|
||||
baseAccuracy string = "fix"
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&rawLogLevel, "log-level", rawLogLevel, "log level")
|
||||
flag.StringVar(&host, "host", host, "the reachrs module host")
|
||||
flag.StringVar(&baseAccuracy, "baseAccuracy", baseAccuracy, "precision required for average position")
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
client, err := initializeClient(ctx)
|
||||
if err != nil {
|
||||
fmt.Printf("[FATAL] %+v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer closeClient(ctx, client)
|
||||
/// setModem
|
||||
if err := updateModem(ctx, client); err != nil {
|
||||
fmt.Printf("[FATAL] %+v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
// Récupération de la configuration
|
||||
config, err := retrieveAndProcessConfig(ctx, client)
|
||||
if err != nil {
|
||||
fmt.Printf("[FATAL] %+v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Printf("Configuration actuelle de la base :\n lat=%v\n lon=%v\n height=%v\n antenna_offset=%v\n accumulation=%v\n\n NTRIPSettings: \n address:%s\n port:%d \n username: %s\n password:%s\n sendPositionToBase:%t\n",
|
||||
config.BaseMode.BaseCoordinates.Coordinates.Latitude, config.BaseMode.BaseCoordinates.Coordinates.Longitude, config.BaseMode.BaseCoordinates.Coordinates.Height, config.BaseMode.BaseCoordinates.AntennaOffset, config.BaseMode.BaseCoordinates.Accumulation, config.CorrectionInput.BaseCorrections.Settings.Ntripcli.Address, config.CorrectionInput.BaseCorrections.Settings.Ntripcli.Port, config.CorrectionInput.BaseCorrections.Settings.Ntripcli.Username, config.CorrectionInput.BaseCorrections.Settings.Ntripcli.Password, config.CorrectionInput.BaseCorrections.Settings.Ntripcli.SendPositionToBase)
|
||||
|
||||
//NTRIP Correction
|
||||
processNTRIPCorrection(ctx, client, config)
|
||||
|
||||
//Base configuration
|
||||
if err := setBaseToModeAndHold(ctx, client, config, baseAccuracy, 30); err != nil {
|
||||
fmt.Printf("[FATAL] %+v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// AveragePosition
|
||||
processAveragePosition(ctx, client)
|
||||
}
|
||||
|
||||
func initializeClient(ctx context.Context) (*reach.Client, error) {
|
||||
logLevel, err := logger.ParseLevel(rawLogLevel)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
slog.SetLogLoggerLevel(logLevel)
|
||||
|
||||
client := reach.NewClient(host)
|
||||
if err := client.Connect(ctx); err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
||||
func closeClient(ctx context.Context, client *reach.Client) {
|
||||
if err := client.Close(ctx); err != nil {
|
||||
fmt.Printf("[ERROR] Erreur lors de la fermeture: %+v", errors.WithStack(err))
|
||||
}
|
||||
}
|
||||
|
||||
func retrieveAndProcessConfig(ctx context.Context, client *reach.Client) (*model.Configuration, error) {
|
||||
configData, err := client.Configuration(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
var config model.Configuration
|
||||
if err := mapstructure.Decode(configData, &config); err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return &config, nil
|
||||
}
|
||||
|
||||
func processNTRIPCorrection(ctx context.Context, client *reach.Client, config *model.Configuration) {
|
||||
// Configuration des corrections NTRIP
|
||||
ntripMsg, err := setupNTRIPCorrections(ctx, client)
|
||||
if err != nil {
|
||||
fmt.Printf("[FATAL] %+v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
displayAvailableMountPoint(ntripMsg)
|
||||
updateNTRIPMountPoint(ctx, client, config)
|
||||
}
|
||||
|
||||
func setupNTRIPCorrections(ctx context.Context, client *reach.Client) (*protocol.TaskMessage[protocol.NTRIPPayload], error) {
|
||||
fmt.Println("\nConfiguration des corrections NTRIP...")
|
||||
|
||||
// Recherche de points de montage
|
||||
ntripMsg, err := client.GetNTRIPMountPoint(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
return ntripMsg, nil
|
||||
}
|
||||
|
||||
func displayAvailableMountPoint(response *protocol.TaskMessage[protocol.NTRIPPayload]) {
|
||||
streams := response.Payload.Str
|
||||
fmt.Printf("=== %d Streams disponibles ===\n", len(streams))
|
||||
fmt.Printf("=== Base < 50 km disponibles ===\n")
|
||||
for i, stream := range streams {
|
||||
if stream.Distance < 50 {
|
||||
fmt.Printf("%d. %-15s | %s (%s) | %.1fkm\n",
|
||||
i+1,
|
||||
stream.Mountpoint,
|
||||
stream.ID,
|
||||
stream.Country,
|
||||
stream.Distance)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func updateNTRIPMountPoint(ctx context.Context, client *reach.Client, config *model.Configuration) error {
|
||||
opts := []protocol.SetBaseCorrectionsFunc{
|
||||
protocol.WithNTRIPAddress(config.CorrectionInput.BaseCorrections.Settings.Ntripcli.Address),
|
||||
protocol.WithNTRIPPort(config.CorrectionInput.BaseCorrections.Settings.Ntripcli.Port),
|
||||
protocol.WithNTRIPUsername(config.CorrectionInput.BaseCorrections.Settings.Ntripcli.Username),
|
||||
protocol.WithNTRIPPassword(config.CorrectionInput.BaseCorrections.Settings.Ntripcli.Password),
|
||||
// todo modification du point de montage ici
|
||||
protocol.WithNTRIPMountPoint("EPI21"),
|
||||
protocol.WithSendPositionToBase(true),
|
||||
}
|
||||
|
||||
if err := client.SetBaseCorrections(ctx, opts...); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
fmt.Println("MountPoint NTRIP mis à jour")
|
||||
return nil
|
||||
}
|
||||
|
||||
func setBaseToModeAndHold(ctx context.Context, client *reach.Client, baseConfig *model.Configuration, mode string, accumulation int) error {
|
||||
fmt.Printf("Configuration de la base en mode %s-and-hold...\n", baseAccuracy)
|
||||
|
||||
opts := []protocol.SetBaseOptionFunc{
|
||||
protocol.WithBaseLatitude(baseConfig.BaseMode.BaseCoordinates.Coordinates.Latitude),
|
||||
protocol.WithBaseLongitude(baseConfig.BaseMode.BaseCoordinates.Coordinates.Longitude),
|
||||
protocol.WithBaseHeight(baseConfig.BaseMode.BaseCoordinates.Coordinates.Height),
|
||||
protocol.WithBaseAntennaOffset(baseConfig.BaseMode.BaseCoordinates.AntennaOffset),
|
||||
protocol.WithBaseMode(fmt.Sprintf("%s-and-hold", mode)),
|
||||
protocol.WithAccumulation(accumulation),
|
||||
}
|
||||
|
||||
if err := client.SetBase(ctx, opts...); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Base configurée en mode %s-and-hold\n", baseAccuracy)
|
||||
return nil
|
||||
}
|
||||
|
||||
func processAveragePosition(ctx context.Context, client *reach.Client) {
|
||||
// Collecte des données de positions
|
||||
messageTask, err := averagePosition(ctx, client)
|
||||
if err != nil {
|
||||
fmt.Printf("[FATAL] %+v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
displayAveragePositionMessage(messageTask)
|
||||
saveAveragedPosition(ctx, client, messageTask)
|
||||
|
||||
fmt.Println("Configuration terminée avec succès")
|
||||
}
|
||||
|
||||
func averagePosition(ctx context.Context, client *reach.Client) (*protocol.TaskMessage[protocol.AveragePositionPayload], error) {
|
||||
fmt.Println("Démarrage de la moyenne des position...")
|
||||
messageTask, err := client.AveragePosition(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
return messageTask, nil
|
||||
|
||||
}
|
||||
|
||||
func displayAveragePositionMessage(message *protocol.TaskMessage[protocol.AveragePositionPayload]) error {
|
||||
fmt.Printf("Position moyennée: lat=%g, lon=%g, altitude=%g\n",
|
||||
message.Payload.Coordinates.Latitude, message.Payload.Coordinates.Longitude, message.Payload.Coordinates.Height)
|
||||
return nil
|
||||
|
||||
}
|
||||
|
||||
func saveAveragedPosition(ctx context.Context, client *reach.Client, message *protocol.TaskMessage[protocol.AveragePositionPayload]) error {
|
||||
opts := []protocol.SetBaseOptionFunc{
|
||||
protocol.WithBaseLatitude(message.Payload.Coordinates.Latitude),
|
||||
protocol.WithBaseLongitude(message.Payload.Coordinates.Longitude),
|
||||
protocol.WithBaseHeight(message.Payload.Coordinates.Height),
|
||||
protocol.WithBaseAntennaOffset(message.Payload.AntennaOffset),
|
||||
protocol.WithBaseMode("manual"),
|
||||
}
|
||||
|
||||
if err := client.SetBase(ctx, opts...); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
fmt.Println("Position sauvegardée en configuration")
|
||||
return nil
|
||||
}
|
||||
|
||||
func updateModem(ctx context.Context, client *reach.Client) error {
|
||||
opts := []protocol.SetModemOptionsFunc{
|
||||
protocol.WithApn("mmsbouygtel.com"),
|
||||
}
|
||||
|
||||
if err := client.SetModem(ctx, opts...); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
fmt.Println("Modem mis à jour")
|
||||
return nil
|
||||
}
|
70
cmd/message/main.go
Normal file
70
cmd/message/main.go
Normal file
@ -0,0 +1,70 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"os"
|
||||
|
||||
reach "forge.cadoles.com/cadoles/go-emlid/reach/client"
|
||||
"forge.cadoles.com/cadoles/go-emlid/reach/client/logger"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
var (
|
||||
host string = "192.168.42.1"
|
||||
filter string = "task"
|
||||
rawLogLevel string = "ERROR"
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&rawLogLevel, "log-level", rawLogLevel, "log level")
|
||||
flag.StringVar(&host, "host", host, "the reachrs module host")
|
||||
flag.StringVar(&filter, "filter", filter, "filter the type messages by name")
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
ctx := context.Background()
|
||||
client := reach.NewClient(host)
|
||||
|
||||
logLevel, err := logger.ParseLevel(rawLogLevel)
|
||||
if err != nil {
|
||||
fmt.Printf("[FATAL] %+v", errors.WithStack(err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
slog.SetLogLoggerLevel(logLevel)
|
||||
|
||||
if err := client.Connect(ctx); err != nil {
|
||||
fmt.Printf("[FATAL] %+v", errors.WithStack(err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := client.Close(ctx); err != nil {
|
||||
fmt.Printf("[FATAL] %+v", errors.WithStack(err))
|
||||
os.Exit(1)
|
||||
}
|
||||
}()
|
||||
fmt.Println(filter)
|
||||
messages, err := reach.OnMessageType(ctx, client, filter)
|
||||
if err != nil {
|
||||
fmt.Printf("[FATAL] %+v", errors.WithStack(err))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for b := range messages {
|
||||
|
||||
data, err := json.MarshalIndent(b, "", " ")
|
||||
if err != nil {
|
||||
fmt.Printf("[ERROR] %+v", errors.WithStack(err))
|
||||
continue
|
||||
}
|
||||
|
||||
fmt.Println(string(data))
|
||||
}
|
||||
}
|
17
cmd/proxy/README.md
Normal file
17
cmd/proxy/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
# Reach Proxy
|
||||
|
||||
Ce petit utilitaire permet de créer un proxy vers un module Reach, permettant ainsi à une instance [Fieldnotes](https://forge.cadoles.com/Pyxis/fieldnotes) de découvrir et travailler avec des modules qui seraient sur un autre réseau, par exemple:
|
||||
|
||||
```
|
||||
Fieldnotes ----- [ Réseau WiFi local ] ------> PC avec proxy ----- [ VPN ] ------> Module Reach
|
||||
```
|
||||
|
||||
Le proxy s'annonce en mDNS permettant ainsi à l'application mobile de l'identifier automatiquement sur le réseau, comme si le proxy était un module Reach.
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
go run ./cmd/proxy -address <listening_address> -host <reachview_module_host>
|
||||
```
|
||||
|
||||
Plus d'informations sont disponibles sur les différents flags via la commande `go run ./cmd/proxy -h`.
|
188
cmd/proxy/main.go
Normal file
188
cmd/proxy/main.go
Normal file
@ -0,0 +1,188 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
"strconv"
|
||||
|
||||
"forge.cadoles.com/cadoles/go-emlid/reach/discovery"
|
||||
"github.com/grandcat/zeroconf"
|
||||
"github.com/pkg/errors"
|
||||
sloghttp "github.com/samber/slog-http"
|
||||
"github.com/wlynxg/anet"
|
||||
)
|
||||
|
||||
var (
|
||||
address = ":8080"
|
||||
host = "192.168.42.1"
|
||||
name = ""
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&address, "address", address, "proxy listening address")
|
||||
flag.StringVar(&host, "host", host, "reachview host adress")
|
||||
flag.StringVar(&name, "name", name, "reachview service name, default machine hostname")
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
server, err := startProxy(ctx, address, host)
|
||||
if err != nil {
|
||||
slog.Error("could not start proxy", slog.Any("error", errors.WithStack(err)))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
defer server.Close()
|
||||
|
||||
service, err := startMDNSService(ctx, address, name)
|
||||
if err != nil {
|
||||
slog.Error("could not start mdns service", slog.Any("error", errors.WithStack(err)))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
defer service.Shutdown()
|
||||
|
||||
interrupt := make(chan os.Signal, 1)
|
||||
signal.Notify(interrupt, os.Interrupt)
|
||||
|
||||
slog.Info("Ctrl+C to interrupt")
|
||||
|
||||
<-interrupt
|
||||
}
|
||||
|
||||
func startProxy(ctx context.Context, address string, host string) (*http.Server, error) {
|
||||
backendURL, err := url.Parse(fmt.Sprintf("http://%s", host))
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
proxy := httputil.NewSingleHostReverseProxy(backendURL)
|
||||
|
||||
handler := sloghttp.Recovery(proxy)
|
||||
handler = sloghttp.New(slog.Default())(handler)
|
||||
|
||||
server := &http.Server{
|
||||
Addr: address,
|
||||
Handler: handler,
|
||||
}
|
||||
|
||||
go func() {
|
||||
slog.Info("starting proxy server", slog.Any("address", server.Addr))
|
||||
|
||||
if err := server.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
slog.Error("could not listen and proxy http requests", slog.Any("error", errors.WithStack(err)))
|
||||
}
|
||||
}()
|
||||
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
if err := server.Close(); err != nil {
|
||||
slog.Error("could not close proxy server", slog.Any("error", errors.WithStack(err)))
|
||||
}
|
||||
}()
|
||||
|
||||
return server, nil
|
||||
}
|
||||
|
||||
func startMDNSService(ctx context.Context, address string, name string) (*zeroconf.Server, error) {
|
||||
if name == "" {
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
name = hostname
|
||||
}
|
||||
|
||||
ifaces, err := anet.Interfaces()
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
ips, err := GetLANIPv4Addrs()
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
info := []string{
|
||||
fmt.Sprintf("local_name=%s", name),
|
||||
"device=ReachProxy",
|
||||
"manufacturer_data=egoHIABggkMnZWSuoy0KAgAA",
|
||||
}
|
||||
|
||||
host, rawPort, err := net.SplitHostPort(address)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
var port int64
|
||||
if rawPort != "" {
|
||||
port, err = strconv.ParseInt(rawPort, 10, 32)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
}
|
||||
|
||||
if host != "" {
|
||||
ips = []string{host}
|
||||
}
|
||||
|
||||
slog.Info("announcing mdns service", slog.Any("ips", ips), slog.Any("info", info))
|
||||
|
||||
server, err := zeroconf.RegisterProxy("Reach", discovery.ReachService, "local.", int(port), name, ips, info, ifaces)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
server.Shutdown()
|
||||
}()
|
||||
|
||||
return server, nil
|
||||
}
|
||||
|
||||
var (
|
||||
_, lanA, _ = net.ParseCIDR("10.0.0.0/8")
|
||||
_, lanB, _ = net.ParseCIDR("172.16.0.0/12")
|
||||
_, lanC, _ = net.ParseCIDR("192.168.0.0/16")
|
||||
)
|
||||
|
||||
func GetLANIPv4Addrs() ([]string, error) {
|
||||
ips := make([]string, 0)
|
||||
|
||||
addrs, err := anet.InterfaceAddrs()
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
for _, address := range addrs {
|
||||
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||
ipv4 := ipnet.IP.To4()
|
||||
if ipv4 == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
isLAN := lanA.Contains(ipv4) || lanB.Contains(ipv4) || lanC.Contains(ipv4)
|
||||
if !isLAN {
|
||||
continue
|
||||
}
|
||||
|
||||
ips = append(ips, ipv4.String())
|
||||
}
|
||||
}
|
||||
|
||||
return ips, nil
|
||||
}
|
26
go.mod
26
go.mod
@ -1,23 +1,31 @@
|
||||
module forge.cadoles.com/cadoles/go-emlid
|
||||
|
||||
go 1.22.5
|
||||
go 1.23
|
||||
|
||||
require (
|
||||
forge.cadoles.com/Pyxis/golang-socketio v0.0.0-20240805155359-f54949ba3a46
|
||||
github.com/Masterminds/semver/v3 v3.2.1
|
||||
github.com/Masterminds/semver/v3 v3.3.0
|
||||
github.com/davecgh/go-spew v1.1.1
|
||||
github.com/googollee/go-socket.io v1.7.0
|
||||
github.com/gorilla/websocket v1.5.3
|
||||
github.com/grandcat/zeroconf v1.0.0
|
||||
github.com/miekg/dns v1.1.62
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/samber/slog-http v1.4.2
|
||||
github.com/wlynxg/anet v0.0.4
|
||||
golang.org/x/net v0.29.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/hashicorp/mdns v1.0.5 // indirect
|
||||
github.com/miekg/dns v1.1.41 // indirect
|
||||
github.com/wlynxg/anet v0.0.4-0.20240806025826-e684438fc7c6 // indirect
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 // indirect
|
||||
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1 // indirect
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44 // indirect
|
||||
github.com/gofrs/uuid v4.4.0+incompatible // indirect
|
||||
github.com/gomodule/redigo v1.9.2 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
go.opentelemetry.io/otel v1.30.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.30.0 // indirect
|
||||
golang.org/x/mod v0.21.0 // indirect
|
||||
golang.org/x/sync v0.8.0 // indirect
|
||||
golang.org/x/sys v0.25.0 // indirect
|
||||
golang.org/x/tools v0.25.0 // indirect
|
||||
)
|
||||
|
77
go.sum
77
go.sum
@ -1,59 +1,76 @@
|
||||
forge.cadoles.com/Pyxis/golang-socketio v0.0.0-20180919100209-bb857ced6b95 h1:o3G5+9RjczCK1xAYFaRMknk1kY9Ule6PNfiW6N6hEpg=
|
||||
forge.cadoles.com/Pyxis/golang-socketio v0.0.0-20180919100209-bb857ced6b95/go.mod h1:I6kYOFWNkFlNeQLI7ZqfTRz4NdPHZxX0Bzizmzgchs0=
|
||||
forge.cadoles.com/Pyxis/golang-socketio v0.0.0-20240805155359-f54949ba3a46 h1:vLTYHA4+pYeI9mZvCMrc29AmnNjeGEpEG1mTwtCOoDI=
|
||||
forge.cadoles.com/Pyxis/golang-socketio v0.0.0-20240805155359-f54949ba3a46/go.mod h1:bT+HWia42VRX1TzTUlEM645tPJEOtsEdzlKBiEqVchY=
|
||||
github.com/Masterminds/semver/v3 v3.2.1 h1:RN9w6+7QoMeJVGyfmbcgs28Br8cvmnucEXnY0rYXWg0=
|
||||
github.com/Masterminds/semver/v3 v3.2.1/go.mod h1:qvl/7zhW3nngYb5+80sSMF+FG2BjYrf8m9wsX0PNOMQ=
|
||||
github.com/Masterminds/semver/v3 v3.3.0 h1:B8LGeaivUe71a5qox1ICM/JLl0NqZSW5CHyL+hmvYS0=
|
||||
github.com/Masterminds/semver/v3 v3.3.0/go.mod h1:4V+yj/TJE1HU9XfppCwVMZq3I84lprf4nC11bSS5beM=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
|
||||
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gomodule/redigo v1.8.4/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
|
||||
github.com/gomodule/redigo v1.9.2 h1:HrutZBLhSIU8abiSfW8pj8mPhOyMYjZT/wcA4/L9L9s=
|
||||
github.com/gomodule/redigo v1.9.2/go.mod h1:KsU3hiK/Ay8U42qpaJk+kuNa3C+spxapWpM+ywhcgtw=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googollee/go-socket.io v1.7.0 h1:ODcQSAvVIPvKozXtUGuJDV3pLwdpBLDs1Uoq/QHIlY8=
|
||||
github.com/googollee/go-socket.io v1.7.0/go.mod h1:0vGP8/dXR9SZUMMD4+xxaGo/lohOw3YWMh2WRiWeKxg=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/grandcat/zeroconf v1.0.0 h1:uHhahLBKqwWBV6WZUDAT71044vwOTL+McW0mBJvo6kE=
|
||||
github.com/grandcat/zeroconf v1.0.0/go.mod h1:lTKmG1zh86XyCoUeIHSA4FJMBwCJiQmGfcP2PdzytEs=
|
||||
github.com/hashicorp/mdns v1.0.5 h1:1M5hW1cunYeoXOqHwEb/GBDDHAFo0Yqb/uz/beC6LbE=
|
||||
github.com/hashicorp/mdns v1.0.5/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc=
|
||||
github.com/miekg/dns v1.1.27 h1:aEH/kqUzUxGJ/UHcEKdJY+ugH6WEzsEBBSPa8zuy1aM=
|
||||
github.com/miekg/dns v1.1.27/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
|
||||
github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY=
|
||||
github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI=
|
||||
github.com/miekg/dns v1.1.62 h1:cN8OuEF1/x5Rq6Np+h1epln8OiyPWV+lROx9LxcGgIQ=
|
||||
github.com/miekg/dns v1.1.62/go.mod h1:mvDlcItzm+br7MToIKqkglaGhlFMHJ9DTNNWONWXbNQ=
|
||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/wlynxg/anet v0.0.3 h1:PvR53psxFXstc12jelG6f1Lv4MWqE0tI76/hHGjh9rg=
|
||||
github.com/wlynxg/anet v0.0.3/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
|
||||
github.com/wlynxg/anet v0.0.4-0.20240806025826-e684438fc7c6 h1:c/wkXIJvpg2oot7iFqPESTBAO9UvhWTBnW97y9aPgyU=
|
||||
github.com/wlynxg/anet v0.0.4-0.20240806025826-e684438fc7c6/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/samber/slog-http v1.4.2 h1:tOOhwE/rFpDzaSxdzttMFFaMDUM+ah7h2zppZ4UCNC0=
|
||||
github.com/samber/slog-http v1.4.2/go.mod h1:n6h4x2ZBeTgLqMKf95EuNlU6mcJF1b/RVLxo1od5+V0=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/wlynxg/anet v0.0.4 h1:0de1OFQxnNqAu+x2FAKKCVIrnfGKQbs7FQz++tB0+Uw=
|
||||
github.com/wlynxg/anet v0.0.4/go.mod h1:eay5PRQr7fIVAMbTbchTnO9gG65Hg/uYGdc7mguHxoA=
|
||||
go.opentelemetry.io/otel v1.30.0 h1:F2t8sK4qf1fAmY9ua4ohFS/K+FUuOPemHUIXHtktrts=
|
||||
go.opentelemetry.io/otel v1.30.0/go.mod h1:tFw4Br9b7fOS+uEao81PJjVMjW/5fvNCbpsDIXqP0pc=
|
||||
go.opentelemetry.io/otel/trace v1.30.0 h1:7UBkkYzeg3C7kQX8VAidWh2biiQbtAKjyIML8dQ9wmc=
|
||||
go.opentelemetry.io/otel/trace v1.30.0/go.mod h1:5EyKqTzzmyqB9bwtCCq6pDLktPK6fmGf/Dph+8VI02o=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.21.0 h1:vvrHzRwRfVKSiLrG+d4FMl/Qi4ukBCE6kZlTUkDYRT0=
|
||||
golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa h1:F+8P+gmewFQYRk6JoLQLwjBCTu3mcIURZfNkVweuRKA=
|
||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1 h1:4qWs8cYYH6PoEFy4dfhDFgoMGkwAcETd+MmPdCPMzUc=
|
||||
golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
|
||||
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
||||
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
|
||||
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe h1:6fAMxZRR6sl1Uq8U61gxU+kPTs2tR8uOySCbBP7BN/M=
|
||||
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44 h1:Bli41pIlzTzf3KEY06n+xnzK/BESIg2ze4Pgfh/aI8c=
|
||||
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191216052735-49a3e744a425/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.25.0 h1:oFU9pkj/iJgs+0DT+VMHrx+oBKs/LJMV+Uvg78sl+fE=
|
||||
golang.org/x/tools v0.25.0/go.mod h1:/vtpO8WL1N9cQC3FN5zPqb//fRXskFHbLKk4OW1Q7rg=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
717596
misc/records/broadcast_record.log
Normal file
717596
misc/records/broadcast_record.log
Normal file
File diff suppressed because it is too large
Load Diff
@ -41,6 +41,7 @@ func OnMessage[T any](ctx context.Context, client *Client, mType string) (chan T
|
||||
type Broadcast struct {
|
||||
Name string `mapstructure:"name" json:"name"`
|
||||
Payload any `mapstructure:"payload" json:"payload"`
|
||||
State string `mapstructure:"state" json:"state"`
|
||||
}
|
||||
|
||||
// OnBroadcast listens for ReachView "broadcast" messages
|
||||
@ -52,3 +53,13 @@ func OnBroadcast(ctx context.Context, client *Client) (chan Broadcast, error) {
|
||||
|
||||
return ch, nil
|
||||
}
|
||||
|
||||
// OnMessageType listens for ReachView type of messages
|
||||
func OnMessageType(ctx context.Context, client *Client, messageType string) (chan Broadcast, error) {
|
||||
ch, err := OnMessage[Broadcast](ctx, client, messageType)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return ch, nil
|
||||
}
|
||||
|
@ -152,4 +152,74 @@ func (c *Client) Reboot(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// AveragePosition implements protocol.Operations.
|
||||
func (c *Client) AveragePosition(ctx context.Context) (*protocol.TaskMessage[protocol.AveragePositionPayload], error) {
|
||||
_, ops, err := c.getProtocol(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
taskMsg, err := ops.AveragePosition(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return taskMsg, err
|
||||
}
|
||||
|
||||
// GetNTRIPMountPoint implements protocol.Operations.
|
||||
func (c *Client) GetNTRIPMountPoint(ctx context.Context) (*protocol.TaskMessage[protocol.NTRIPPayload], error) {
|
||||
_, ops, err := c.getProtocol(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
ntripMsg, err := ops.GetNTRIPMountPoint(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
return ntripMsg, nil
|
||||
}
|
||||
|
||||
// SetBaseCorrections implements protocol.Operations.
|
||||
func (c *Client) SetBaseCorrections(ctx context.Context, funcs ...protocol.SetBaseCorrectionsFunc) error {
|
||||
_, ops, err := c.getProtocol(ctx)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
if err := ops.SetBaseCorrections(ctx, funcs...); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetModem implements protocol.Operations.
|
||||
func (c *Client) SetModem(ctx context.Context, funcs ...protocol.SetModemOptionsFunc) error {
|
||||
_, ops, err := c.getProtocol(ctx)
|
||||
if err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
if err := ops.SetModem(ctx, funcs...); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetModemConfiguration implements protocol.Operations.
|
||||
func (c *Client) GetModemConfiguration(ctx context.Context) (any, error) {
|
||||
_, ops, err := c.getProtocol(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
config, err := ops.GetModemConfiguration(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
var _ protocol.Operations = &Client{}
|
||||
|
12
reach/client/protocol/average_postion.go
Normal file
12
reach/client/protocol/average_postion.go
Normal file
@ -0,0 +1,12 @@
|
||||
package protocol
|
||||
|
||||
type Coordinates struct {
|
||||
Latitude float64 `json:"latitude"`
|
||||
Longitude float64 `json:"longitude"`
|
||||
Height float64 `json:"height"`
|
||||
}
|
||||
|
||||
type AveragePositionPayload struct {
|
||||
Coordinates Coordinates `json:"coordinates"`
|
||||
AntennaOffset float64 `json:"antenna_offset"`
|
||||
}
|
41
reach/client/protocol/modem.go
Normal file
41
reach/client/protocol/modem.go
Normal file
@ -0,0 +1,41 @@
|
||||
package protocol
|
||||
|
||||
type SetModemOptions struct {
|
||||
Apn *string
|
||||
Type *string
|
||||
Username *string
|
||||
Password *string
|
||||
}
|
||||
|
||||
type SetModemOptionsFunc func(opts *SetModemOptions)
|
||||
|
||||
func NewSetModemOptions(funcs ...SetModemOptionsFunc) *SetModemOptions {
|
||||
opts := &SetModemOptions{}
|
||||
for _, fn := range funcs {
|
||||
fn(opts)
|
||||
}
|
||||
return opts
|
||||
}
|
||||
|
||||
func WithApn(value string) SetModemOptionsFunc {
|
||||
return func(opts *SetModemOptions) {
|
||||
opts.Apn = &value
|
||||
}
|
||||
}
|
||||
|
||||
func WithType(value string) SetModemOptionsFunc {
|
||||
return func(opts *SetModemOptions) {
|
||||
opts.Type = &value
|
||||
}
|
||||
}
|
||||
|
||||
func WithUsername(value string) SetModemOptionsFunc {
|
||||
return func(opts *SetModemOptions) {
|
||||
opts.Username = &value
|
||||
}
|
||||
}
|
||||
func WithPassword(value string) SetModemOptionsFunc {
|
||||
return func(opts *SetModemOptions) {
|
||||
opts.Password = &value
|
||||
}
|
||||
}
|
75
reach/client/protocol/ntrip.go
Normal file
75
reach/client/protocol/ntrip.go
Normal file
@ -0,0 +1,75 @@
|
||||
package protocol
|
||||
|
||||
type IOConfig struct {
|
||||
IOType string `json:"io_type"`
|
||||
Settings IOConfigSettings `json:"settings"`
|
||||
}
|
||||
|
||||
type IOConfigSettings struct {
|
||||
NTRIPCli NTRIPCliConfig `json:"ntripcli"`
|
||||
}
|
||||
|
||||
type NTRIPCliConfig struct {
|
||||
Address string `json:"address"`
|
||||
Port int `json:"port"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
MountPoint string `json:"mount_point"`
|
||||
SendPositionToBase bool `json:"send_position_to_base"`
|
||||
}
|
||||
|
||||
type NTRIPPayload struct {
|
||||
CAS []CasterInfo `json:"cas"`
|
||||
Net []NetworkInfo `json:"net"`
|
||||
Str []StreamInfo `json:"str"`
|
||||
}
|
||||
|
||||
type CasterInfo struct {
|
||||
Country string `json:"country"`
|
||||
Distance float64 `json:"distance"`
|
||||
FallbackHost string `json:"fallback_host"`
|
||||
FallbackPort string `json:"fallback_port"`
|
||||
Host string `json:"host"`
|
||||
ID string `json:"id"`
|
||||
Latitude string `json:"latitude"`
|
||||
Longitude string `json:"longitude"`
|
||||
NMEA string `json:"nmea"`
|
||||
Operator string `json:"operator"`
|
||||
OtherDetails *string `json:"other_details"`
|
||||
Port string `json:"port"`
|
||||
Site string `json:"site"`
|
||||
}
|
||||
|
||||
type NetworkInfo struct {
|
||||
Authentication string `json:"authentication"`
|
||||
Distance *float64 `json:"distance"`
|
||||
Fee string `json:"fee"`
|
||||
ID string `json:"id"`
|
||||
Operator string `json:"operator"`
|
||||
OtherDetails string `json:"other_details"`
|
||||
WebNet string `json:"web_net"`
|
||||
WebReg string `json:"web_reg"`
|
||||
WebStr string `json:"web_str"`
|
||||
}
|
||||
|
||||
type StreamInfo struct {
|
||||
Authentication string `json:"authentication"`
|
||||
Bitrate string `json:"bitrate"`
|
||||
Carrier string `json:"carrier"`
|
||||
ComprEncryp string `json:"compr_encryp"`
|
||||
Country string `json:"country"`
|
||||
Distance float64 `json:"distance"`
|
||||
Fee string `json:"fee"`
|
||||
Format string `json:"format"`
|
||||
FormatDetails string `json:"format_details"`
|
||||
Generator string `json:"generator"`
|
||||
ID string `json:"id"`
|
||||
Latitude string `json:"latitude"`
|
||||
Longitude string `json:"longitude"`
|
||||
Mountpoint string `json:"mountpoint"`
|
||||
NavSystem string `json:"nav_system"`
|
||||
Network string `json:"network"`
|
||||
NMEA string `json:"nmea"`
|
||||
OtherDetails string `json:"other_details"`
|
||||
Solution string `json:"solution"`
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package protocol
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type BaseInfo struct {
|
||||
Mode string
|
||||
@ -8,6 +10,12 @@ type BaseInfo struct {
|
||||
Latitude float64
|
||||
Longitude float64
|
||||
Height float64
|
||||
Accumulation int
|
||||
}
|
||||
type TaskMessage[T any] struct {
|
||||
Name string `json:"name"`
|
||||
State string `json:"state"`
|
||||
Payload T `json:"payload"`
|
||||
}
|
||||
|
||||
type Operations interface {
|
||||
@ -41,4 +49,19 @@ type Operations interface {
|
||||
|
||||
// Reboot restarts the module
|
||||
Reboot(ctx context.Context) error
|
||||
|
||||
// AveragePosition gathers data and computes the average position
|
||||
AveragePosition(ctx context.Context) (*TaskMessage[AveragePositionPayload], error)
|
||||
|
||||
//GetNTRIPMountPoint retrieves availables mount point
|
||||
GetNTRIPMountPoint(ctx context.Context) (*TaskMessage[NTRIPPayload], error)
|
||||
|
||||
//SetBaseCorrections updates the corrections obtaining station
|
||||
SetBaseCorrections(ctx context.Context, funcs ...SetBaseCorrectionsFunc) error
|
||||
|
||||
//SetModem updates mobile data config
|
||||
SetModem(ctx context.Context, funcs ...SetModemOptionsFunc) error
|
||||
|
||||
//GetModemConfiguration mobile data config
|
||||
GetModemConfiguration(ctx context.Context) (any, error)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ type SetBaseOptions struct {
|
||||
Latitude *float64
|
||||
Longitude *float64
|
||||
Height *float64
|
||||
Accumulation *int
|
||||
}
|
||||
|
||||
type SetBaseOptionFunc func(opts *SetBaseOptions)
|
||||
@ -47,3 +48,9 @@ func WithBaseHeight(value float64) SetBaseOptionFunc {
|
||||
opts.Height = &value
|
||||
}
|
||||
}
|
||||
|
||||
func WithAccumulation(value int) SetBaseOptionFunc {
|
||||
return func(opts *SetBaseOptions) {
|
||||
opts.Accumulation = &value
|
||||
}
|
||||
}
|
||||
|
56
reach/client/protocol/set_base_correction.go
Normal file
56
reach/client/protocol/set_base_correction.go
Normal file
@ -0,0 +1,56 @@
|
||||
package protocol
|
||||
|
||||
type SetBaseCorrectionsOptions struct {
|
||||
Address *string
|
||||
Port *int
|
||||
Username *string
|
||||
Password *string
|
||||
MountPoint *string
|
||||
SendPositionToBase *bool
|
||||
}
|
||||
|
||||
type SetBaseCorrectionsFunc func(opts *SetBaseCorrectionsOptions)
|
||||
|
||||
func NewSetBaseCorrectionsOptions(funcs ...SetBaseCorrectionsFunc) *SetBaseCorrectionsOptions {
|
||||
opts := &SetBaseCorrectionsOptions{}
|
||||
for _, fn := range funcs {
|
||||
fn(opts)
|
||||
}
|
||||
return opts
|
||||
}
|
||||
|
||||
func WithNTRIPAddress(value string) SetBaseCorrectionsFunc {
|
||||
return func(opts *SetBaseCorrectionsOptions) {
|
||||
opts.Address = &value
|
||||
}
|
||||
}
|
||||
|
||||
func WithNTRIPPort(value int) SetBaseCorrectionsFunc {
|
||||
return func(opts *SetBaseCorrectionsOptions) {
|
||||
opts.Port = &value
|
||||
}
|
||||
}
|
||||
|
||||
func WithNTRIPUsername(value string) SetBaseCorrectionsFunc {
|
||||
return func(opts *SetBaseCorrectionsOptions) {
|
||||
opts.Username = &value
|
||||
}
|
||||
}
|
||||
|
||||
func WithNTRIPPassword(value string) SetBaseCorrectionsFunc {
|
||||
return func(opts *SetBaseCorrectionsOptions) {
|
||||
opts.Password = &value
|
||||
}
|
||||
}
|
||||
|
||||
func WithNTRIPMountPoint(value string) SetBaseCorrectionsFunc {
|
||||
return func(opts *SetBaseCorrectionsOptions) {
|
||||
opts.MountPoint = &value
|
||||
}
|
||||
}
|
||||
|
||||
func WithSendPositionToBase(value bool) SetBaseCorrectionsFunc {
|
||||
return func(opts *SetBaseCorrectionsOptions) {
|
||||
opts.SendPositionToBase = &value
|
||||
}
|
||||
}
|
@ -237,7 +237,167 @@ var testCases = []operationTestCase{
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
return
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "SetBaseModeAveragePosition",
|
||||
Run: func(t *testing.T, ops protocol.Operations) {
|
||||
ctx := context.Background()
|
||||
|
||||
if err := ops.Connect(ctx); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := ops.Close(ctx); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
}
|
||||
}()
|
||||
latitude := -90 + rand.Float64()*180
|
||||
longitude := -180 + rand.Float64()*360
|
||||
height := rand.Float64() * 1000
|
||||
antennaOffset := toFixed(rand.Float64()*2, 3)
|
||||
|
||||
opts := []protocol.SetBaseOptionFunc{
|
||||
protocol.WithBaseLatitude(latitude),
|
||||
protocol.WithBaseLongitude(longitude),
|
||||
protocol.WithBaseHeight(height),
|
||||
protocol.WithBaseAntennaOffset(antennaOffset),
|
||||
protocol.WithBaseMode("fix-and-hold"),
|
||||
}
|
||||
|
||||
if err := ops.SetBase(ctx, opts...); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
}
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "SetBaseCorrections",
|
||||
Run: func(t *testing.T, ops protocol.Operations) {
|
||||
ctx := context.Background()
|
||||
if err := ops.Connect(ctx); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := ops.Close(ctx); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
}
|
||||
}()
|
||||
opts := []protocol.SetBaseCorrectionsFunc{
|
||||
protocol.WithNTRIPAddress("crtk.net"),
|
||||
protocol.WithNTRIPPort(2101),
|
||||
protocol.WithNTRIPUsername("centipede"),
|
||||
protocol.WithNTRIPPassword("centipede"),
|
||||
protocol.WithNTRIPMountPoint("EPI21"),
|
||||
protocol.WithSendPositionToBase(true),
|
||||
}
|
||||
|
||||
if err := ops.SetBaseCorrections(ctx, opts...); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
return
|
||||
}
|
||||
t.Logf("BaseCorrection Update")
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "SetModem",
|
||||
Run: func(t *testing.T, ops protocol.Operations) {
|
||||
ctx := context.Background()
|
||||
if err := ops.Connect(ctx); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := ops.Close(ctx); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
}
|
||||
}()
|
||||
opts := []protocol.SetModemOptionsFunc{
|
||||
protocol.WithApn("mmsbouygtel.com"),
|
||||
}
|
||||
|
||||
if err := ops.SetModem(ctx, opts...); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
return
|
||||
}
|
||||
t.Logf("Modem Update")
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "AveragePosition",
|
||||
Run: func(t *testing.T, ops protocol.Operations) {
|
||||
ctx := context.Background()
|
||||
|
||||
if err := ops.Connect(ctx); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := ops.Close(ctx); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
}
|
||||
}()
|
||||
|
||||
taskmessage, err := ops.AveragePosition(ctx)
|
||||
if err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
return
|
||||
}
|
||||
t.Logf("Task Message : %+v", taskmessage)
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "GetNTRIPMountPoint",
|
||||
Run: func(t *testing.T, ops protocol.Operations) {
|
||||
ctx := context.Background()
|
||||
|
||||
if err := ops.Connect(ctx); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := ops.Close(ctx); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
}
|
||||
}()
|
||||
taskMsg, err := ops.GetNTRIPMountPoint(ctx)
|
||||
if err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
return
|
||||
}
|
||||
t.Logf("Message : %+v", taskMsg)
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "GetModemConfiguration",
|
||||
Run: func(t *testing.T, ops protocol.Operations) {
|
||||
ctx := context.Background()
|
||||
|
||||
if err := ops.Connect(ctx); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
return
|
||||
}
|
||||
|
||||
defer func() {
|
||||
if err := ops.Close(ctx); err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
}
|
||||
}()
|
||||
config, err := ops.GetModemConfiguration(ctx)
|
||||
if err != nil {
|
||||
t.Errorf("%+v", errors.WithStack(err))
|
||||
return
|
||||
}
|
||||
t.Logf("Modem configuration : %+v", config)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package v1
|
||||
|
||||
import "forge.cadoles.com/cadoles/go-emlid/reach/client/protocol"
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
func init() {
|
||||
protocol.Register(Identifier, func(opts *protocol.ProtocolOptions) (protocol.Protocol, error) {
|
||||
return &Protocol{
|
||||
|
@ -22,12 +22,14 @@ const (
|
||||
eventSettingsResetToDefault = "settings reset to default"
|
||||
)
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
type configurationApplied struct {
|
||||
Configuration *model.Configuration `mapstructure:"configuration,omitempty"`
|
||||
Result string `mapstructure:"result"`
|
||||
Constraints *model.Constraints `mapstructure:"constraints,omitempty"`
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
func (o *Operations) ApplyConfiguration(ctx context.Context, config *model.Configuration) (string, *model.Configuration, error) {
|
||||
o.logger.Debug("applying configuration", logger.Attr("configuration", spew.Sdump(config)))
|
||||
|
||||
@ -41,6 +43,7 @@ func (o *Operations) ApplyConfiguration(ctx context.Context, config *model.Confi
|
||||
return res.Result, res.Configuration, nil
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
func (o *Operations) RequestConfiguration(ctx context.Context) (*model.Configuration, error) {
|
||||
configuration := &model.Configuration{}
|
||||
if err := o.ReqResp(ctx, eventGetConfiguration, nil, eventCurrentConfiguration, configuration); err != nil {
|
||||
@ -49,6 +52,7 @@ func (o *Operations) RequestConfiguration(ctx context.Context) (*model.Configura
|
||||
return configuration, nil
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// ReqResp emits an event with the given data and waits for a response
|
||||
func (o *Operations) ReqResp(ctx context.Context,
|
||||
requestEvent string, requestData any,
|
||||
|
@ -1,5 +1,6 @@
|
||||
package model
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
var (
|
||||
// On -
|
||||
On = String("on")
|
||||
|
8
reach/client/protocol/v1/model/message.go
Normal file
8
reach/client/protocol/v1/model/message.go
Normal file
@ -0,0 +1,8 @@
|
||||
package model
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
type TaskMessage struct {
|
||||
Name string `json:"name"`
|
||||
State string `json:"state"`
|
||||
Payload map[string]interface{} `json:"payload"`
|
||||
}
|
@ -13,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
|
||||
@ -22,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()
|
||||
@ -36,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()
|
||||
@ -80,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()
|
||||
@ -96,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()
|
||||
@ -136,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()
|
||||
@ -148,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)
|
||||
@ -162,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()
|
||||
@ -212,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)
|
||||
@ -297,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)
|
||||
@ -353,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{}
|
||||
@ -363,4 +375,29 @@ 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[protocol.AveragePositionPayload], error) {
|
||||
return nil, protocol.ErrUnimplemented
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
func (o *Operations) GetNTRIPMountPoint(ctx context.Context) (*protocol.TaskMessage[protocol.NTRIPPayload], error) {
|
||||
return nil, protocol.ErrUnimplemented
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
func (o *Operations) SetBaseCorrections(ctx context.Context, funcs ...protocol.SetBaseCorrectionsFunc) error {
|
||||
return protocol.ErrUnimplemented
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
func (o *Operations) SetModem(ctx context.Context, funcs ...protocol.SetModemOptionsFunc) error {
|
||||
return protocol.ErrUnimplemented
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
func (o *Operations) GetModemConfiguration(ctx context.Context) (any, error) {
|
||||
return nil, protocol.ErrUnimplemented
|
||||
}
|
||||
|
||||
var _ protocol.Operations = &Operations{}
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
const Identifier protocol.Identifier = "v1"
|
||||
|
||||
const compatibleVersionConstraint = "^2.24"
|
||||
@ -19,6 +20,7 @@ type Protocol struct {
|
||||
dial protocol.DialFunc
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// Available implements protocol.Protocol.
|
||||
func (p *Protocol) Available(ctx context.Context, addr string) (bool, error) {
|
||||
ops := p.Operations(addr).(*Operations)
|
||||
@ -53,11 +55,13 @@ func (p *Protocol) Available(ctx context.Context, addr string) (bool, error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// Identifier implements protocol.Protocol.
|
||||
func (p *Protocol) Identifier() protocol.Identifier {
|
||||
return Identifier
|
||||
}
|
||||
|
||||
// Deprecated : is no longer maintained for modules in V1
|
||||
// Operations implements protocol.Protocol.
|
||||
func (p *Protocol) Operations(addr string) protocol.Operations {
|
||||
return &Operations{addr: addr, logger: p.logger, dial: p.dial}
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"forge.cadoles.com/cadoles/go-emlid/reach/client/protocol"
|
||||
"forge.cadoles.com/cadoles/go-emlid/reach/client/protocol/v2/model"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
@ -126,6 +127,16 @@ func (o *Operations) PostDevice(ctx context.Context, device *model.Configuration
|
||||
return &updated, nil
|
||||
}
|
||||
|
||||
func (o *Operations) PostBaseCorrection(ctx context.Context, base *protocol.IOConfig) (*protocol.IOConfig, error) {
|
||||
var updated protocol.IOConfig
|
||||
|
||||
if err := o.PostJSON("/configuration/correction_input/base_corrections", base, &updated); err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return &updated, nil
|
||||
}
|
||||
|
||||
func (o *Operations) GetUpdater(ctx context.Context) (*model.Updater, error) {
|
||||
updater := &model.Updater{}
|
||||
if err := o.GetJSON("/updater", updater); err != nil {
|
||||
@ -152,3 +163,23 @@ func (o *Operations) GetConfiguration(ctx context.Context) (*model.Configuration
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
||||
func (o *Operations) PostModem(ctx context.Context, config *model.ModemAuthentication) (*model.ModemAuthentication, error) {
|
||||
var updated model.ModemAuthentication
|
||||
|
||||
if err := o.PostJSON("/modem/1/settings", config, &updated); err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return &updated, nil
|
||||
}
|
||||
|
||||
func (o *Operations) GetModem(ctx context.Context) (*model.ModemConfiguration, error) {
|
||||
config := &model.ModemConfiguration{}
|
||||
|
||||
if err := o.GetJSON("/modem/1/info", config); err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return config, nil
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package model
|
||||
|
||||
type Action struct {
|
||||
Name string `json:"name"`
|
||||
Name string `json:"name"`
|
||||
Paylaod map[string]any `json:"payload,omitempty"`
|
||||
}
|
||||
|
34
reach/client/protocol/v2/model/modem.go
Normal file
34
reach/client/protocol/v2/model/modem.go
Normal file
@ -0,0 +1,34 @@
|
||||
package model
|
||||
|
||||
// type : null, pap_chap, pap, chap
|
||||
// if type selected, username and password are mandatory
|
||||
type ModemAuthentication struct {
|
||||
Authentication struct {
|
||||
Apn string `json:"apn"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Username string `json:"username,omitempty"`
|
||||
Password string `json:"password,omitempty"`
|
||||
} `json:"authentication"`
|
||||
}
|
||||
|
||||
type ModemConfiguration struct {
|
||||
AccessTechnology string `json:"access_technology"`
|
||||
AllowedModes []string `json:"allowed_modes"`
|
||||
AvailableAPNs []string `json:"available_apns,omitempty"`
|
||||
CurrentAPN string `json:"current_apn"`
|
||||
CurrentMode string `json:"current_mode"`
|
||||
FailReason *string `json:"fail_reason,omitempty"`
|
||||
IMEI string `json:"imei"`
|
||||
InternetAvailable string `json:"internet_available,omitempty"`
|
||||
LockReason *string `json:"lock_reason,omitempty"`
|
||||
OperatorName string `json:"operator_name"`
|
||||
PreferredMode string `json:"preferred_mode"`
|
||||
RegistrationState string `json:"registration_state"`
|
||||
RSSI int `json:"rssi"`
|
||||
State string `json:"state"`
|
||||
Stats struct {
|
||||
Since string `json:"since"`
|
||||
UsageMB string `json:"usage_mb"`
|
||||
} `json:"stats"`
|
||||
UnlockRetries int `json:"unlock_retries"`
|
||||
}
|
@ -10,6 +10,7 @@ import (
|
||||
"forge.cadoles.com/cadoles/go-emlid/reach/client/protocol/v2/model"
|
||||
|
||||
"forge.cadoles.com/cadoles/go-emlid/reach/client/socketio"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
@ -86,6 +87,10 @@ func (o *Operations) SetBase(ctx context.Context, funcs ...protocol.SetBaseOptio
|
||||
base.Mode = *opts.Mode
|
||||
}
|
||||
|
||||
if opts.Accumulation != nil {
|
||||
base.Accumulation = *opts.Accumulation
|
||||
}
|
||||
|
||||
if opts.Height != nil {
|
||||
base.Coordinates.Height = *opts.Height
|
||||
}
|
||||
@ -128,6 +133,7 @@ func (o *Operations) GetBaseInfo(ctx context.Context) (*protocol.BaseInfo, error
|
||||
Height: config.BaseMode.BaseCoordinates.Coordinates.Height,
|
||||
Latitude: config.BaseMode.BaseCoordinates.Coordinates.Latitude,
|
||||
Longitude: config.BaseMode.BaseCoordinates.Coordinates.Longitude,
|
||||
Accumulation: config.BaseMode.BaseCoordinates.Accumulation,
|
||||
}
|
||||
|
||||
return baseInfo, nil
|
||||
@ -264,4 +270,133 @@ func (o *Operations) On(ctx context.Context, event string) (chan any, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (o *Operations) AveragePosition(ctx context.Context) (*protocol.TaskMessage[protocol.AveragePositionPayload], error) {
|
||||
var err error
|
||||
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
err = ctx.Err()
|
||||
}()
|
||||
|
||||
if err = o.client.Emit("task", &model.Action{Name: "average_base_coordinates"}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// GetNTRIPMountPoint implements protocol.Operations.
|
||||
func (o *Operations) GetNTRIPMountPoint(ctx context.Context) (*protocol.TaskMessage[protocol.NTRIPPayload], error) {
|
||||
var err error
|
||||
|
||||
config, err := o.GetConfiguration(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
err = ctx.Err()
|
||||
}()
|
||||
|
||||
payload := map[string]any{
|
||||
"address": config.CorrectionInput.BaseCorrections.Settings.Ntripcli.Address,
|
||||
"port": config.CorrectionInput.BaseCorrections.Settings.Ntripcli.Port,
|
||||
}
|
||||
|
||||
if err = o.client.Emit("task", &model.Action{Name: "get_ntrip_mountpoints", Paylaod: payload}); err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
ch, err := o.On(ctx, "task_status")
|
||||
for message := range ch {
|
||||
var taskMsg protocol.TaskMessage[protocol.NTRIPPayload]
|
||||
if err := mapstructure.Decode(message, &taskMsg); err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
if taskMsg.State == "completed" {
|
||||
return &taskMsg, nil
|
||||
}
|
||||
}
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// SetBaseCorrections implements protocol.Operations.
|
||||
func (o *Operations) SetBaseCorrections(ctx context.Context, funcs ...protocol.SetBaseCorrectionsFunc) error {
|
||||
opts := protocol.NewSetBaseCorrectionsOptions(funcs...)
|
||||
if opts.Address == nil {
|
||||
return errors.New("NTRIP address is required")
|
||||
}
|
||||
if opts.Port == nil {
|
||||
return errors.New("NTRIP port is required")
|
||||
}
|
||||
if opts.Username == nil {
|
||||
return errors.New("NTRIP username is required")
|
||||
}
|
||||
if opts.Password == nil {
|
||||
return errors.New("NTRIP password is required")
|
||||
}
|
||||
if opts.MountPoint == nil {
|
||||
return errors.New("NTRIP mount point is required")
|
||||
}
|
||||
|
||||
config := &protocol.IOConfig{
|
||||
// todo parametrage du type
|
||||
IOType: "ntripcli",
|
||||
Settings: protocol.IOConfigSettings{
|
||||
NTRIPCli: protocol.NTRIPCliConfig{
|
||||
Address: *opts.Address,
|
||||
Port: *opts.Port,
|
||||
Username: *opts.Username,
|
||||
Password: *opts.Password,
|
||||
MountPoint: *opts.MountPoint,
|
||||
SendPositionToBase: opts.SendPositionToBase != nil && *opts.SendPositionToBase,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if _, err := o.PostBaseCorrection(ctx, config); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetModem implements protocol.Operations.
|
||||
func (o *Operations) SetModem(ctx context.Context, funcs ...protocol.SetModemOptionsFunc) error {
|
||||
opts := protocol.NewSetModemOptions(funcs...)
|
||||
modem := &model.ModemAuthentication{}
|
||||
if opts.Apn != nil {
|
||||
modem.Authentication.Apn = *opts.Apn
|
||||
}
|
||||
|
||||
if opts.Type != nil {
|
||||
modem.Authentication.Type = *opts.Type
|
||||
}
|
||||
|
||||
if opts.Password != nil {
|
||||
modem.Authentication.Password = *opts.Password
|
||||
}
|
||||
|
||||
if opts.Username != nil {
|
||||
modem.Authentication.Username = *opts.Username
|
||||
}
|
||||
|
||||
if _, err := o.PostModem(ctx, modem); err != nil {
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetModem implements protocol.Operations.
|
||||
func (o *Operations) GetModemConfiguration(ctx context.Context) (any, error) {
|
||||
config, err := o.GetModem(ctx)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
return config, nil
|
||||
|
||||
}
|
||||
|
||||
var _ protocol.Operations = &Operations{}
|
||||
|
Reference in New Issue
Block a user