Skip to content

Commit

Permalink
Add support for RPC connection to FOTA
Browse files Browse the repository at this point in the history
Change-Id: I81af96070dc3112f81efac36ce900590bbb071f5
  • Loading branch information
amistewicz committed Jun 22, 2018
1 parent 3cb3d7d commit 96ff831
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions sw/nanopi/cmd/fota/fota.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/json"
"flag"
"log"
"net/rpc"
"os"

"git.tizen.org/tools/muxpi/sw/nanopi/fota"
Expand All @@ -31,6 +32,8 @@ var (
mapping string
md5sums string
quiet bool

remote string
)

func setFlags() {
Expand All @@ -39,6 +42,8 @@ func setFlags() {
flag.StringVar(&mapping, "map", "", "path to JSON formatted mapping")
flag.StringVar(&md5sums, "md5", "", "URL to MD5SUMS file")
flag.BoolVar(&quiet, "q", false, "suppress logging")

flag.StringVar(&remote, "remote", "", "path to remote service socket")
}

func checkErr(ctx string, err error) {
Expand Down Expand Up @@ -72,8 +77,15 @@ func main() {
decoder := json.NewDecoder(f)
checkErr("failed to decode the mapping: ", decoder.Decode(&partMapping))

dev, err := stm.GetDefaultSTM()
checkErr("failed to connect to STM: ", err)
var dev stm.InterfaceCloser
if remote != "" {
cl, err := rpc.Dial("unix", remote)
checkErr("failed to connect to RPC service: ", err)
dev = stm.NewInterfaceClient(cl)
} else {
dev, err = stm.GetDefaultSTM()
checkErr("failed to connect to STM: ", err)
}
defer dev.Close()

flasher := fota.NewFOTA(dev, flag.Args(), md5sums, sdcard, partMapping)
Expand Down

0 comments on commit 96ff831

Please sign in to comment.