mirror of
https://github.com/brianshea2/meshmap.net.git
synced 2024-11-13 17:14:23 -08:00
collect altitude from position and map report messages
This commit is contained in:
parent
da626616b2
commit
3e5f76a5ca
|
@ -44,8 +44,9 @@ func handleMessage(from uint32, topic string, portNum generated.PortNum, payload
|
||||||
}
|
}
|
||||||
latitude := position.GetLatitudeI()
|
latitude := position.GetLatitudeI()
|
||||||
longitude := position.GetLongitudeI()
|
longitude := position.GetLongitudeI()
|
||||||
|
altitude := position.GetAltitude()
|
||||||
precision := position.GetPrecisionBits()
|
precision := position.GetPrecisionBits()
|
||||||
log.Printf("[msg] %v (%v) %s: (%v, %v) %v/32", from, topic, portNum, latitude, longitude, precision)
|
log.Printf("[msg] %v (%v) %s: (%v, %v, %v) %v/32", from, topic, portNum, latitude, longitude, altitude, precision)
|
||||||
if latitude == 0 && longitude == 0 {
|
if latitude == 0 && longitude == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -53,7 +54,7 @@ func handleMessage(from uint32, topic string, portNum generated.PortNum, payload
|
||||||
if Nodes[from] == nil {
|
if Nodes[from] == nil {
|
||||||
Nodes[from] = meshtastic.NewNode(topic)
|
Nodes[from] = meshtastic.NewNode(topic)
|
||||||
}
|
}
|
||||||
Nodes[from].UpdatePosition(latitude, longitude, precision)
|
Nodes[from].UpdatePosition(latitude, longitude, altitude, precision)
|
||||||
Nodes[from].UpdateSeenBy(topic)
|
Nodes[from].UpdateSeenBy(topic)
|
||||||
NodesMutex.Unlock()
|
NodesMutex.Unlock()
|
||||||
case generated.PortNum_NODEINFO_APP:
|
case generated.PortNum_NODEINFO_APP:
|
||||||
|
@ -147,12 +148,13 @@ func handleMessage(from uint32, topic string, portNum generated.PortNum, payload
|
||||||
onlineLocalNodes := mapReport.GetNumOnlineLocalNodes()
|
onlineLocalNodes := mapReport.GetNumOnlineLocalNodes()
|
||||||
latitude := mapReport.GetLatitudeI()
|
latitude := mapReport.GetLatitudeI()
|
||||||
longitude := mapReport.GetLongitudeI()
|
longitude := mapReport.GetLongitudeI()
|
||||||
|
altitude := mapReport.GetAltitude()
|
||||||
precision := mapReport.GetPositionPrecision()
|
precision := mapReport.GetPositionPrecision()
|
||||||
log.Printf(
|
log.Printf(
|
||||||
"[msg] %v (%v) %s: {\"%v\" \"%v\" %v %v %v %v %v %v %v} (%v, %v) %v/32",
|
"[msg] %v (%v) %s: {\"%v\" \"%v\" %v %v %v %v %v %v %v} (%v, %v, %v) %v/32",
|
||||||
from, topic, portNum,
|
from, topic, portNum,
|
||||||
longName, shortName, hwModel, role, fwVersion, region, modemPreset, hasDefaultCh, onlineLocalNodes,
|
longName, shortName, hwModel, role, fwVersion, region, modemPreset, hasDefaultCh, onlineLocalNodes,
|
||||||
latitude, longitude, precision,
|
latitude, longitude, altitude, precision,
|
||||||
)
|
)
|
||||||
if len(longName) == 0 {
|
if len(longName) == 0 {
|
||||||
return
|
return
|
||||||
|
@ -166,7 +168,7 @@ func handleMessage(from uint32, topic string, portNum generated.PortNum, payload
|
||||||
}
|
}
|
||||||
Nodes[from].UpdateUser(longName, shortName, hwModel, role)
|
Nodes[from].UpdateUser(longName, shortName, hwModel, role)
|
||||||
Nodes[from].UpdateMapReport(fwVersion, region, modemPreset, hasDefaultCh, onlineLocalNodes)
|
Nodes[from].UpdateMapReport(fwVersion, region, modemPreset, hasDefaultCh, onlineLocalNodes)
|
||||||
Nodes[from].UpdatePosition(latitude, longitude, precision)
|
Nodes[from].UpdatePosition(latitude, longitude, altitude, precision)
|
||||||
Nodes[from].UpdateSeenBy(topic)
|
Nodes[from].UpdateSeenBy(topic)
|
||||||
NodesMutex.Unlock()
|
NodesMutex.Unlock()
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -33,6 +33,7 @@ type Node struct {
|
||||||
// Position
|
// Position
|
||||||
Latitude int32 `json:"latitude"`
|
Latitude int32 `json:"latitude"`
|
||||||
Longitude int32 `json:"longitude"`
|
Longitude int32 `json:"longitude"`
|
||||||
|
Altitude int32 `json:"altitude,omitempty"`
|
||||||
Precision uint32 `json:"precision,omitempty"`
|
Precision uint32 `json:"precision,omitempty"`
|
||||||
// DeviceMetrics
|
// DeviceMetrics
|
||||||
BatteryLevel uint32 `json:"batteryLevel,omitempty"`
|
BatteryLevel uint32 `json:"batteryLevel,omitempty"`
|
||||||
|
@ -157,9 +158,10 @@ func (node *Node) UpdateNeighborInfo(neighborNum uint32, snr float32) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (node *Node) UpdatePosition(latitude, longitude int32, precision uint32) {
|
func (node *Node) UpdatePosition(latitude, longitude, altitude int32, precision uint32) {
|
||||||
node.Latitude = latitude
|
node.Latitude = latitude
|
||||||
node.Longitude = longitude
|
node.Longitude = longitude
|
||||||
|
node.Altitude = altitude
|
||||||
node.Precision = precision
|
node.Precision = precision
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue