Преглед изворни кода

chore: add RSSI to location event and persist in tracks

master
Blaz Smehov пре 2 недеља
родитељ
комит
23208dc32d
4 измењених фајлова са 4 додато и 2 уклоњено
  1. +1
    -0
      cmd/location/main.go
  2. +1
    -1
      internal/pkg/model/tracks.go
  3. +1
    -0
      internal/pkg/model/types.go
  4. +1
    -1
      internal/pkg/service/beacon_service.go

+ 1
- 0
cmd/location/main.go Прегледај датотеку

@@ -129,6 +129,7 @@ func getLikelyLocations(appState *appcontext.AppState, writer *kafka.Writer) {
r.Distance = beacon.BeaconMetrics[mSize-1].Distance r.Distance = beacon.BeaconMetrics[mSize-1].Distance
r.Location = bestLocName r.Location = bestLocName
r.LastSeen = beacon.BeaconMetrics[mSize-1].Timestamp r.LastSeen = beacon.BeaconMetrics[mSize-1].Timestamp
r.RSSI = beacon.BeaconMetrics[mSize-1].RSSI


if beacon.LocationConfidence == settings.LocationConfidence && beacon.PreviousConfidentLocation != bestLocName { if beacon.LocationConfidence == settings.LocationConfidence && beacon.PreviousConfidentLocation != bestLocName {
beacon.LocationConfidence = 0 beacon.LocationConfidence = 0


+ 1
- 1
internal/pkg/model/tracks.go Прегледај датотеку

@@ -15,6 +15,6 @@ type Tracks struct {
Subject string `json:"subject"` Subject string `json:"subject"`
SubjectName string `json:"subjectName"` SubjectName string `json:"subjectName"`
Floor string `json:"floor"` Floor string `json:"floor"`
Signal int `json:"signal"`
Signal int64 `json:"signal"`
Building string `json:"building"` Building string `json:"building"`
} }

+ 1
- 0
internal/pkg/model/types.go Прегледај датотеку

@@ -43,6 +43,7 @@ type HTTPLocation struct {
ID string `json:"id"` ID string `json:"id"`
Location string `json:"location"` Location string `json:"location"`
LastSeen int64 `json:"last_seen"` LastSeen int64 `json:"last_seen"`
RSSI int64 `json:"rssi"`
} }


// Beacon holds all relevant information about a tracked beacon device. // Beacon holds all relevant information about a tracked beacon device.


+ 1
- 1
internal/pkg/service/beacon_service.go Прегледај датотеку

@@ -61,7 +61,7 @@ func LocationToBeaconService(msg model.HTTPLocation, db *gorm.DB, writer *kafka.
} }


// status, subject, subject name? // status, subject, subject name?
if err := db.Create(&model.Tracks{UUID: msg.ID, Timestamp: time.Now(), Gateway: gw.ID, GatewayMac: gw.MAC, Tracker: msg.ID, Floor: gw.Floor, Building: gw.Building, TrackerMac: tracker.MAC}).Error; err != nil {
if err := db.Create(&model.Tracks{UUID: msg.ID, Timestamp: time.Now(), Gateway: gw.ID, GatewayMac: gw.MAC, Tracker: msg.ID, Floor: gw.Floor, Building: gw.Building, TrackerMac: tracker.MAC, Signal: msg.RSSI}).Error; err != nil {
fmt.Println("Error in saving distance for beacon: ", err) fmt.Println("Error in saving distance for beacon: ", err)
return return
} }


Loading…
Откажи
Сачувај