Skip to content

Commit

Permalink
Change timestamp format from string to number to match gateway firmwa…
Browse files Browse the repository at this point in the history
…re 1.14.1 behavior
  • Loading branch information
Scrin committed Sep 16, 2023
1 parent 2c1c1f6 commit 9dbee9a
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions sender/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package sender
import (
"encoding/json"
"fmt"
"io"
"net/http"
"strings"
"sync"
Expand All @@ -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"`
}

Expand Down Expand Up @@ -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()
}
}()
}
Expand All @@ -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()
Expand Down

0 comments on commit 9dbee9a

Please sign in to comment.