Skip to content
Snippets Groups Projects
Commit 034077f1 authored by André Sterba's avatar André Sterba Committed by Manuel Kieweg
Browse files

Fix cli parsing of pnd and sbi

parent a3600632
No related branches found
No related tags found
9 merge requests!246Develop,!245Develop into Master,!244Master into develop2 into master,!219Draft: Testing,!214Test pipelines,!195DO NOT MERGE 2,!194DO NOT MERGE! just for testing,!147Commit-Confirm Mechanic for PND,!138Develop
......@@ -3,11 +3,12 @@ package cli
import (
"errors"
"fmt"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"io/ioutil"
"net/http"
"strings"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
)
const apiRoot = "?"
......@@ -26,6 +27,7 @@ func HTTPGet(apiEndpoint, f string, args ...string) error {
}
resp, err := http.Get(apiEndpoint + apiRoot + "q=" + f + builder.String())
if err != nil {
log.Info(fmt.Sprintf("Err: %s", err))
return err
}
builder.Reset()
......@@ -38,8 +40,8 @@ func HTTPGet(apiEndpoint, f string, args ...string) error {
}
switch f {
case "init":
pnd := string(bytes[:36])
sbi := string(bytes[36:])
pnd := string(bytes[9:45])
sbi := string(bytes[55:91])
viper.Set("CLI_PND", pnd)
viper.Set("CLI_SBI", sbi)
err := viper.WriteConfig()
......@@ -49,6 +51,7 @@ func HTTPGet(apiEndpoint, f string, args ...string) error {
default:
fmt.Println(string(bytes))
}
case http.StatusCreated:
defer resp.Body.Close()
bytes, err := ioutil.ReadAll(resp.Body)
......@@ -58,8 +61,8 @@ func HTTPGet(apiEndpoint, f string, args ...string) error {
uuid := string(bytes[19:55])
viper.Set("LAST_DEVICE_UUID", uuid)
fmt.Println(string(bytes))
case http.StatusAccepted:
case http.StatusAccepted:
default:
log.WithFields(log.Fields{
"status code": resp.StatusCode,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment