diff --git a/revid/senders.go b/revid/senders.go index 97276793..64eb7967 100644 --- a/revid/senders.go +++ b/revid/senders.go @@ -148,8 +148,22 @@ func (s *httpSender) send() error { if send { 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 - t, err := netsender.ExtractJsonInt(reply, "ts") + t, err := dec.Int("ts") if err != nil { s.log(smartlogger.Warning, pkg+"No timestamp in reply") } else { @@ -157,14 +171,14 @@ func (s *httpSender) send() error { } // Extract gps from reply - g, err := netsender.ExtractJsonString(reply, "ll") + g, err := dec.String("ll") if err != nil { s.log(smartlogger.Warning, pkg+"No gps in reply") } else { mts.GpsMeta(g) } - return err + return nil } func (s *httpSender) release() { diff --git a/stream/mts/psi/op.go b/stream/mts/psi/op.go index 7c38af2a..e8d2f04e 100644 --- a/stream/mts/psi/op.go +++ b/stream/mts/psi/op.go @@ -121,6 +121,7 @@ func addCrc(out []byte) []byte { out = updateCrc(out) return out } + func updateCrc(out []byte) []byte { crc32 := crc32_Update(0xffffffff, crc32_MakeTable(bits.Reverse32(crc32.IEEE)), out[1:len(out)-4]) out[len(out)-4] = byte(crc32 >> 24)