|
|
|
@@ -24,7 +24,7 @@ func main() { |
|
|
|
BeaconMetricSize: 30, |
|
|
|
HASendInterval: 5, |
|
|
|
HASendChangesOnly: false, |
|
|
|
RSSIEnforceThreshold: true, |
|
|
|
RSSIEnforceThreshold: false, |
|
|
|
RSSIMinThreshold: 100, |
|
|
|
}, |
|
|
|
}, |
|
|
|
@@ -32,6 +32,9 @@ func main() { |
|
|
|
LatestList: model.LatestBeaconsList{ |
|
|
|
LatestList: make(map[string]model.Beacon), |
|
|
|
}, |
|
|
|
Beacons: model.BeaconsList{ |
|
|
|
Beacons: make(map[string]model.Beacon), |
|
|
|
}, |
|
|
|
} |
|
|
|
|
|
|
|
cfg := config.Load() |
|
|
|
@@ -83,13 +86,10 @@ func getLikelyLocations(ctx *model.AppContext, writer *kafka.Writer) { |
|
|
|
ctx.Beacons.Lock.Unlock() |
|
|
|
|
|
|
|
for _, beacon := range beacons { |
|
|
|
fmt.Printf("beacon: %+v", beacon) |
|
|
|
|
|
|
|
// Shrinking the model because other properties have nothing to do with the location |
|
|
|
r := model.HTTPLocation{ |
|
|
|
Method: "Standard", |
|
|
|
Distance: 999, |
|
|
|
Name: beacon.Name, |
|
|
|
ID: beacon.ID, |
|
|
|
Location: "", |
|
|
|
LastSeen: 999, |
|
|
|
@@ -188,30 +188,28 @@ func assignBeaconToList(adv model.BeaconAdvertisement, ctx *model.AppContext) { |
|
|
|
now := time.Now().Unix() |
|
|
|
|
|
|
|
if !ok { |
|
|
|
// handle removing from the list somewhere else, probably at the point where this is being used which is nowhere in the original code |
|
|
|
ctx.LatestList.Lock.Lock() |
|
|
|
ctx.LatestList.LatestList[id] = model.Beacon{ID: id, BeaconType: adv.BeaconType, LastSeen: now, IncomingJSON: adv, BeaconLocation: adv.Hostname, Distance: getBeaconDistance(adv)} |
|
|
|
ctx.LatestList.Lock.Unlock() |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
fmt.Println("Beacon exists: ", id) |
|
|
|
|
|
|
|
fmt.Println("RSSI: ", adv.RSSI) |
|
|
|
if ctx.Settings.Settings.RSSIEnforceThreshold && (int64(adv.RSSI) < ctx.Settings.Settings.RSSIMinThreshold) { |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
ctx.Beacons.Lock.Lock() |
|
|
|
beacon := ctx.Beacons.Beacons[id] |
|
|
|
beacon, ok := ctx.Beacons.Beacons[id] |
|
|
|
if !ok { |
|
|
|
beacon = model.Beacon{ |
|
|
|
ID: id, |
|
|
|
} |
|
|
|
} |
|
|
|
ctx.Beacons.Lock.Unlock() |
|
|
|
|
|
|
|
beacon.IncomingJSON = adv |
|
|
|
beacon.LastSeen = now |
|
|
|
beacon.BeaconType = adv.BeaconType |
|
|
|
beacon.HSButtonCounter = adv.HSButtonCounter |
|
|
|
beacon.HSBattery = adv.HSBatteryLevel |
|
|
|
beacon.HSRandomNonce = adv.HSRandomNonce |
|
|
|
beacon.HSButtonMode = adv.HSButtonMode |
|
|
|
|
|
|
|
if beacon.BeaconMetrics == nil { |
|
|
|
beacon.BeaconMetrics = make([]model.BeaconMetric, 0, ctx.Settings.Settings.BeaconMetricSize) |
|
|
|
|