Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
4a56fea33b
|
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"encoding/json"
|
||||
@ -30,6 +31,7 @@ type locativeEvent struct {
|
||||
Latitude string `json:"latitude"`
|
||||
Longitude string `json:"longitude"`
|
||||
Person string `json:"person"`
|
||||
Timestamp string `json:"timestamp"`
|
||||
}
|
||||
|
||||
|
||||
@ -46,6 +48,7 @@ func main() {
|
||||
person, err := dbh.GetPersonById(event.Device)
|
||||
event.Person = person
|
||||
event.Location = event.Id
|
||||
event.Timestamp = time.Now().Format("2006-01-02 15:04:05 MST")
|
||||
event.Id = ""
|
||||
if err != nil {
|
||||
log.Printf("Person unknown: %v", err)
|
||||
|
@ -45,7 +45,7 @@ func (self *MqttHandle) Publish(topicPost string, message string) error {
|
||||
}
|
||||
|
||||
topic := fmt.Sprintf("%s/%s", self.pubTopic, topicPost)
|
||||
token := self.client.Publish(topic, 0, false, message)
|
||||
token := self.client.Publish(topic, 0, true, message)
|
||||
token.Wait()
|
||||
if token.Error() != nil {
|
||||
return fmt.Errorf("MQTT publish failed: %v", token.Error())
|
||||
|
Reference in New Issue
Block a user