From ee3113ed80873b5f8476f4d8c9ce97310b25e161 Mon Sep 17 00:00:00 2001 From: William Petit Date: Wed, 19 Sep 2018 17:45:38 +0200 Subject: [PATCH] Add package documentation and usage example of UpdaterClient --- reach/example_test.go | 30 ++++++++++++++++++++++++++++++ reach/reach.go | 4 ++++ 2 files changed, 34 insertions(+) create mode 100644 reach/example_test.go create mode 100644 reach/reach.go diff --git a/reach/example_test.go b/reach/example_test.go new file mode 100644 index 0000000..eebcb4e --- /dev/null +++ b/reach/example_test.go @@ -0,0 +1,30 @@ +package reach + +import "log" + +// ReachRS modules provides an Updater application when reset in factory mode. +// This package provides an API to communicate with this application. +func Example_updaterClientUsage() { + // Create a new Updater client instance + updater := NewUpdaterClient( + 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) + } + + networks, err := updater.SavedWifiNetworks() + 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() +} diff --git a/reach/reach.go b/reach/reach.go new file mode 100644 index 0000000..6a8aa41 --- /dev/null +++ b/reach/reach.go @@ -0,0 +1,4 @@ +// Package reach is a package to configure EMLID ReachRS modules in Go. +// +// It aims to provide a simple interface to common ReachRS modules management operations. +package reach