NetReceiver vars updating again. sendTo() now takes a *netsender.Sender.

This commit is contained in:
Alan Noble 2018-06-15 17:29:59 +09:30
parent 5ba5327f33
commit 82f58ec996
1 changed files with 6 additions and 14 deletions
cmd/revid-cli

View File

@ -250,8 +250,6 @@ func main() {
l.Log(progName, "Error", err.Error()) // TODO(kortschak): Make this "Fatal" when that exists.
os.Exit(1)
}
vs = ns.GetVarSum()
} else {
// alternatively, instantiate our own logger
config.Logger = smartlogger.New(loggerVerbosity, smartlogger.File, "/var/log/netsender/")
@ -263,8 +261,8 @@ func main() {
// loop in NetSender mode
for *useNetsender {
if err := sendTo(ns); err != nil {
config.Logger.Log(progName, "Error", err.Error())
if err := sendTo(&ns); err != nil {
config.Logger.Log(progName, "Warning", err.Error())
time.Sleep(netSendRetryTime)
continue
}
@ -273,7 +271,7 @@ func main() {
// vars changed
vars, err := ns.Vars()
if err != nil {
config.Logger.Log(progName, "Error", err.Error())
config.Logger.Log(progName, "Warning", err.Error())
time.Sleep(netSendRetryTime)
continue
}
@ -301,15 +299,9 @@ func main() {
stopRevid()
}
// sendTo handles NetReceiver configuration and sends requested data to the cloud.
func sendTo(ns netsender.Sender) error {
if !ns.IsConfigured() {
err := ns.Config()
if err != nil {
return err
}
}
// sendTo implements our main NetSender client and handles NetReceiver configuration
// (as distinct from httpSender which just sends video data).
func sendTo(ns *netsender.Sender) error {
// populate input values, if any
inputs := netsender.MakePins(ns.GetConfigParam("ip"))
for i, pin := range inputs {