Compare commits

..

No commits in common. "f33853a4ddf969595826d9f47a93e63875dc0930" and "95cae1c6d06ef85d60818846adebd5cdb728ba62" have entirely different histories.

3 changed files with 5 additions and 46 deletions

View file

@ -101,20 +101,6 @@ func handleMessage(from uint32, topic string, portNum generated.PortNum, payload
}
Nodes[from].UpdateDeviceMetrics(batteryLevel, voltage, chUtil, airUtilTx, uptime)
NodesMutex.Unlock()
} else if envMetrics := telemetry.GetEnvironmentMetrics(); envMetrics != nil {
temperature := envMetrics.GetTemperature()
relativeHumidity := envMetrics.GetRelativeHumidity()
barometricPressure := envMetrics.GetBarometricPressure()
log.Printf(
"[msg] %v (%v) %s: EnvironmentMetrics{temperature: %vC; humidity: %v%%; pressure: %vhPA}",
from, topic, portNum, temperature, relativeHumidity, barometricPressure,
)
NodesMutex.Lock()
if Nodes[from] == nil {
Nodes[from] = meshtastic.NewNode(topic)
}
Nodes[from].UpdateEnvironmentMetrics(temperature, relativeHumidity, barometricPressure)
NodesMutex.Unlock()
}
case generated.PortNum_NEIGHBORINFO_APP:
var neighborInfo generated.NeighborInfo

View file

@ -42,11 +42,6 @@ type Node struct {
AirUtilTx float32 `json:"airUtilTx,omitempty"`
Uptime uint32 `json:"uptime,omitempty"`
LastDeviceMetrics int64 `json:"lastDeviceMetrics,omitempty"`
// EnvironmentMetrics
Temperature float32 `json:"temperature,omitempty"`
RelativeHumidity float32 `json:"relativeHumidity,omitempty"`
BarometricPressure float32 `json:"barometricPressure,omitempty"`
LastEnvironmentMetrics int64 `json:"lastEnvironmentMetrics,omitempty"`
// NeighborInfo
Neighbors map[uint32]*NeighborInfo `json:"neighbors,omitempty"`
// key=mqtt topic, value=first seen/last position update
@ -68,13 +63,6 @@ func (node *Node) ClearDeviceMetrics() {
node.LastDeviceMetrics = 0
}
func (node *Node) ClearEnvironmentMetrics() {
node.Temperature = 0
node.RelativeHumidity = 0
node.BarometricPressure = 0
node.LastEnvironmentMetrics = 0
}
func (node *Node) ClearMapReportData() {
node.FwVersion = ""
node.Region = ""
@ -97,7 +85,7 @@ func (node *Node) IsValid() bool {
return true
}
func (node *Node) Prune(seenByTtl, neighborTtl, metricsTtl, mapReportTtl int64) {
func (node *Node) Prune(seenByTtl, neighborTtl, deviceMetricsTtl, mapReportTtl int64) {
now := time.Now().Unix()
// SeenBy
for topic, lastSeen := range node.SeenBy {
@ -133,13 +121,9 @@ func (node *Node) Prune(seenByTtl, neighborTtl, metricsTtl, mapReportTtl int64)
delete(node.Neighbors, toDelete)
}
// DeviceMetrics
if node.LastDeviceMetrics > 0 && node.LastDeviceMetrics+metricsTtl < now {
if node.LastDeviceMetrics > 0 && node.LastDeviceMetrics+deviceMetricsTtl < now {
node.ClearDeviceMetrics()
}
// EnvironmentMetrics
if node.LastEnvironmentMetrics > 0 && node.LastEnvironmentMetrics+metricsTtl < now {
node.ClearEnvironmentMetrics()
}
// MapReport
if node.LastMapReport > 0 && node.LastMapReport+mapReportTtl < now {
node.ClearMapReportData()
@ -155,13 +139,6 @@ func (node *Node) UpdateDeviceMetrics(batteryLevel uint32, voltage, chUtil, airU
node.LastDeviceMetrics = time.Now().Unix()
}
func (node *Node) UpdateEnvironmentMetrics(temperature, relativeHumidity, barometricPressure float32) {
node.Temperature = temperature
node.RelativeHumidity = relativeHumidity
node.BarometricPressure = barometricPressure
node.LastEnvironmentMetrics = time.Now().Unix()
}
func (node *Node) UpdateMapReport(fwVersion, region, modemPreset string, hasDefaultCh bool, onlineLocalNodes uint32) {
node.FwVersion = fwVersion
node.Region = region
@ -201,9 +178,9 @@ func (node *Node) UpdateUser(longName, shortName, hwModel, role string) {
type NodeDB map[uint32]*Node
func (db NodeDB) Prune(seenByTtl, neighborTtl, metricsTtl, mapReportTtl int64) {
func (db NodeDB) Prune(seenByTtl, neighborTtl, deviceMetricsTtl, mapReportTtl int64) {
for nodeNum, node := range db {
node.Prune(seenByTtl, neighborTtl, metricsTtl, mapReportTtl)
node.Prune(seenByTtl, neighborTtl, deviceMetricsTtl, mapReportTtl)
if len(node.SeenBy) == 0 {
delete(db, nodeNum)
}

View file

@ -211,7 +211,6 @@
fwVersion, region, modemPreset, hasDefaultCh, onlineLocalNodes,
latitude, longitude, altitude, precision,
batteryLevel, voltage, chUtil, airUtilTx, uptime,
temperature, relativeHumidity, barometricPressure,
neighbors, seenBy
} = node
const id = `!${Number(nodeNum).toString(16)}`
@ -235,14 +234,11 @@
${region ? `<tr><th>Region</th><td>${html(region)}</td></tr>` : ''}
${modemPreset ? `<tr><th>Modem preset</th><td>${html(modemPreset)}</td></tr>` : ''}
${hasDefaultCh ? `<tr><th>Has default channel</th><td>True</td></tr>` : ''}
${onlineLocalNodes ? `<tr><th>Online local nodes</th><td>${onlineLocalNodes}</td></tr>` : ''}
${batteryLevel ? `<tr><th>Power</th><td>${batteryLevel > 100 ? 'Plugged in' : `${batteryLevel}%`}${voltage ? ` (${voltage.toFixed(2)}V)` : ''}</td></tr>` : ''}
${chUtil ? `<tr><th>ChUtil</th><td>${chUtil.toFixed(2)}%</td></tr>` : ''}
${airUtilTx ? `<tr><th>AirUtilTX</th><td>${airUtilTx.toFixed(2)}%</td></tr>` : ''}
${uptime ? `<tr><th>Uptime</th><td>${duration(uptime)}</td></tr>` : ''}
${temperature ? `<tr><th>Temperature</th><td>${temperature.toFixed(1)}&#8451; / ${(temperature * 1.8 + 32).toFixed(1)}&#8457;</td></tr>` : ''}
${relativeHumidity ? `<tr><th>Relative Humidity</th><td>${Math.round(relativeHumidity)}%</td></tr>` : ''}
${barometricPressure ? `<tr><th>Barometric Pressure</th><td>${Math.round(barometricPressure)} hPa</td></tr>` : ''}
${onlineLocalNodes ? `<tr><th>Online local nodes</th><td>${onlineLocalNodes}</td></tr>` : ''}
${altitude ? `<tr><th>Altitude</th><td>${altitude.toLocaleString()} m above MSL</td></tr>` : ''}
${precision && precisionMargins[precision-1] ?
`<tr><th>Location precision</th><td>&#177; ${precisionMargins[precision-1].toLocaleString()} m (orange circle)</td></tr>` : ''