This repository has been archived on 2024-08-02. You can view files and clone it, but cannot push or open issues or pull requests.
orion/emlid/updater/example_test.go

40 lines
863 B
Go

package updater
import (
"context"
"log"
"time"
"forge.cadoles.com/Pyxis/orion/emlid"
)
func Example_usage() {
// Create a new Updater client instance
updater := NewClient(
emlid.WithEndpoint("192.168.42.1", 80), // Define the module endpoint
)
// Connect to the ReachRS Updater endpoint
if err := updater.Connect(); err != nil {
log.Fatal(err)
}
// We create a context for the API call with a 10 second delay
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
// Retrieve the Wifi networks
networks, err := updater.WifiNetworks(ctx)
if err != nil {
log.Fatal(err)
}
// Do something with network
for _, n := range networks {
log.Printf("Save WiFi network: SSID: '%s', Security: '%s'", n.SSID, n.Security)
}
// Dont forget to close the connection when you are done
defer updater.Close()
}