more robust ID change handling, also time out on web interface

pull/827/merge^2
Adrian Batzill 2022-03-26 10:21:49 +00:00
rodzic ddd2bb3b1e
commit 4a841d6184
3 zmienionych plików z 13 dodań i 3 usunięć

Wyświetl plik

@ -1270,6 +1270,8 @@ type status struct {
OGN_noise_db float32
OGN_gain_db float32
OGN_tx_enabled bool // If ogn-rx-eu uses a local tx module for transmission
OGNPrevRandomAddr string // when OGN is in random stealth mode, it's ID changes randomly - keep the previous one so we can filter properly
}
var globalSettings settings

Wyświetl plik

@ -1689,7 +1689,8 @@ func processNMEALine(l string) (sentenceUsed bool) {
// OGN Tracker can change its address arbitrarily. However, if it does,
// ownship detection would fail for the old target. Therefore we remove the old one from the traffic list
if oldAddr != globalSettings.OGNAddr && globalSettings.OGNAddrType == 0 {
oldAddrInt, _ := strconv.ParseUint(globalSettings.OGNAddr, 16, 32)
globalStatus.OGNPrevRandomAddr = oldAddr
oldAddrInt, _ := strconv.ParseUint(oldAddr, 16, 32)
removeTarget(uint32(oldAddrInt))
// potentially other address type before
removeTarget(uint32((1 << 24) | oldAddrInt))

Wyświetl plik

@ -197,7 +197,13 @@ func cleanupOldEntries() {
func removeTarget(id uint32) {
trafficMutex.Lock()
defer trafficMutex.Unlock()
delete(traffic, id)
if val, ok := traffic[id]; ok {
// Make sure the web interface times it out..
val.Age = 60
val.Position_valid = false
registerTrafficUpdate(val)
delete(traffic, id)
}
}
// Checks if the given TrafficInfo is our ownship. As the user can specify multiple ownship
@ -209,7 +215,8 @@ func isOwnshipTrafficInfo(ti TrafficInfo) (isOwnshipInfo bool, shouldIgnore bool
if (globalStatus.GPS_detected_type & 0x0f) == GPS_TYPE_OGNTRACKER {
ognTrackerCodeInt, _ := strconv.ParseUint(globalSettings.OGNAddr, 16, 32)
if uint32(ognTrackerCodeInt) == ti.Icao_addr {
prevTrackerCodeInt, _ := strconv.ParseUint(globalStatus.OGNPrevRandomAddr, 16, 32)
if uint32(ognTrackerCodeInt) == ti.Icao_addr || uint32(prevTrackerCodeInt) == ti.Icao_addr {
isOwnshipInfo = !isGPSValid() // only use OGN tracker as ownship position if we are not equipped with a GPS..
shouldIgnore = true
return