mirror of https://bitbucket.org/ausocean/av.git
revid + psi: getting metadata from replies now
This commit is contained in:
parent
35d86b559d
commit
b78904ac72
|
@ -148,8 +148,22 @@ func (s *httpSender) send() error {
|
||||||
if send {
|
if send {
|
||||||
reply, _, err = s.client.Send(netsender.RequestRecv, pins)
|
reply, _, err = s.client.Send(netsender.RequestRecv, pins)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = extractMeta(reply, s)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func extractMeta(r string, s *httpSender) error {
|
||||||
|
dec, err := netsender.NewJsonDecoder(r)
|
||||||
|
if err != nil {
|
||||||
|
s.log(smartlogger.Warning, pkg+"Could not decode JSON to get metadata")
|
||||||
|
}
|
||||||
// Extract time from reply
|
// Extract time from reply
|
||||||
t, err := netsender.ExtractJsonInt(reply, "ts")
|
t, err := dec.Int("ts")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log(smartlogger.Warning, pkg+"No timestamp in reply")
|
s.log(smartlogger.Warning, pkg+"No timestamp in reply")
|
||||||
} else {
|
} else {
|
||||||
|
@ -157,14 +171,14 @@ func (s *httpSender) send() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extract gps from reply
|
// Extract gps from reply
|
||||||
g, err := netsender.ExtractJsonString(reply, "ll")
|
g, err := dec.String("ll")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.log(smartlogger.Warning, pkg+"No gps in reply")
|
s.log(smartlogger.Warning, pkg+"No gps in reply")
|
||||||
} else {
|
} else {
|
||||||
mts.GpsMeta(g)
|
mts.GpsMeta(g)
|
||||||
}
|
}
|
||||||
|
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *httpSender) release() {
|
func (s *httpSender) release() {
|
||||||
|
|
|
@ -121,6 +121,7 @@ func addCrc(out []byte) []byte {
|
||||||
out = updateCrc(out)
|
out = updateCrc(out)
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func updateCrc(out []byte) []byte {
|
func updateCrc(out []byte) []byte {
|
||||||
crc32 := crc32_Update(0xffffffff, crc32_MakeTable(bits.Reverse32(crc32.IEEE)), out[1:len(out)-4])
|
crc32 := crc32_Update(0xffffffff, crc32_MakeTable(bits.Reverse32(crc32.IEEE)), out[1:len(out)-4])
|
||||||
out[len(out)-4] = byte(crc32 >> 24)
|
out[len(out)-4] = byte(crc32 >> 24)
|
||||||
|
|
Loading…
Reference in New Issue