From 9dbee9a7ecc3901ad9952d75ce1bfe572bf5fc42 Mon Sep 17 00:00:00 2001 From: Scrin Date: Sat, 16 Sep 2023 11:22:22 +0300 Subject: [PATCH] Change timestamp format from string to number to match gateway firmware 1.14.1 behavior --- sender/http.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sender/http.go b/sender/http.go index 3a13e46..8ad36ff 100644 --- a/sender/http.go +++ b/sender/http.go @@ -3,6 +3,7 @@ package sender import ( "encoding/json" "fmt" + "io" "net/http" "strings" "sync" @@ -27,7 +28,7 @@ type httpMessageData struct { type httpMessageTag struct { Rssi int `json:"rssi"` - Timestamp string `json:"timestamp"` + Timestamp int64 `json:"timestamp"` Data string `json:"data"` } @@ -70,10 +71,12 @@ func SetupHTTP(conf config.HTTP, gwMac string) { req.SetBasicAuth(conf.Username, conf.Password) } - _, err = httpClient.Do(req) + resp, err := httpClient.Do(req) if err != nil { log.WithError(err).Error("Failed POST data") } + io.ReadAll(resp.Body) + resp.Body.Close() } }() } @@ -84,7 +87,7 @@ func SendHTTP(conf config.HTTP, adv ble.Advertisement) { flags := []byte{0x00} // the actual advertisement flags don't seem to be available, so just use zero tag := httpMessageTag{ Rssi: adv.RSSI(), - Timestamp: fmt.Sprint(time.Now().Unix()), + Timestamp: time.Now().Unix(), Data: fmt.Sprintf("0201%X%XFF%X", flags, len(data)+1, data), } lock.Lock()