mirror of
https://github.com/brianshea2/meshmap.net.git
synced 2025-03-05 21:00:01 -08:00
Compare commits
3 commits
ca2b7b3dd1
...
caf9e2a2dd
Author | SHA1 | Date | |
---|---|---|---|
|
caf9e2a2dd | ||
|
b9cdcc3abc | ||
|
547e76a6e2 |
|
@ -107,15 +107,34 @@ func handleMessage(from uint32, topic string, portNum generated.PortNum, payload
|
|||
temperature := envMetrics.GetTemperature()
|
||||
relativeHumidity := envMetrics.GetRelativeHumidity()
|
||||
barometricPressure := envMetrics.GetBarometricPressure()
|
||||
lux := envMetrics.GetLux()
|
||||
windDirection := envMetrics.GetWindDirection()
|
||||
windSpeed := envMetrics.GetWindSpeed()
|
||||
windGust := envMetrics.GetWindGust()
|
||||
radiation := envMetrics.GetRadiation()
|
||||
rainfall1 := envMetrics.GetRainfall_1H()
|
||||
rainfall24 := envMetrics.GetRainfall_24H()
|
||||
log.Printf(
|
||||
"[msg] %v (%v) %s: EnvironmentMetrics{temperature: %vC; humidity: %v%%; pressure: %vhPA}",
|
||||
from, topic, portNum, temperature, relativeHumidity, barometricPressure,
|
||||
"[msg] %v (%v) %s: EnvironmentMetrics{temp: %v; hum: %v; pres: %v; lux: %v; wind: %v @ %v G %v; rad: %v; rain: %v %v}",
|
||||
from, topic, portNum, temperature, relativeHumidity, barometricPressure, lux,
|
||||
windDirection, windSpeed, windGust, radiation, rainfall1, rainfall24,
|
||||
)
|
||||
NodesMutex.Lock()
|
||||
if Nodes[from] == nil {
|
||||
Nodes[from] = meshtastic.NewNode(topic)
|
||||
}
|
||||
Nodes[from].UpdateEnvironmentMetrics(temperature, relativeHumidity, barometricPressure)
|
||||
Nodes[from].UpdateEnvironmentMetrics(
|
||||
temperature,
|
||||
relativeHumidity,
|
||||
barometricPressure,
|
||||
lux,
|
||||
windDirection,
|
||||
windSpeed,
|
||||
windGust,
|
||||
radiation,
|
||||
rainfall1,
|
||||
rainfall24,
|
||||
)
|
||||
NodesMutex.Unlock()
|
||||
}
|
||||
case generated.PortNum_NEIGHBORINFO_APP:
|
||||
|
|
|
@ -54,6 +54,13 @@ type Node struct {
|
|||
Temperature float32 `json:"temperature,omitempty"`
|
||||
RelativeHumidity float32 `json:"relativeHumidity,omitempty"`
|
||||
BarometricPressure float32 `json:"barometricPressure,omitempty"`
|
||||
Lux float32 `json:"lux,omitempty"`
|
||||
WindDirection uint32 `json:"windDirection,omitempty"`
|
||||
WindSpeed float32 `json:"windSpeed,omitempty"`
|
||||
WindGust float32 `json:"windGust,omitempty"`
|
||||
Radiation float32 `json:"radiation,omitempty"`
|
||||
Rainfall1 float32 `json:"rainfall1,omitempty"`
|
||||
Rainfall24 float32 `json:"rainfall24,omitempty"`
|
||||
LastEnvironmentMetrics int64 `json:"lastEnvironmentMetrics,omitempty"`
|
||||
// NeighborInfo
|
||||
Neighbors map[uint32]*NeighborInfo `json:"neighbors,omitempty"`
|
||||
|
@ -80,6 +87,13 @@ func (node *Node) ClearEnvironmentMetrics() {
|
|||
node.Temperature = 0
|
||||
node.RelativeHumidity = 0
|
||||
node.BarometricPressure = 0
|
||||
node.Lux = 0
|
||||
node.WindDirection = 0
|
||||
node.WindSpeed = 0
|
||||
node.WindGust = 0
|
||||
node.Radiation = 0
|
||||
node.Rainfall1 = 0
|
||||
node.Rainfall24 = 0
|
||||
node.LastEnvironmentMetrics = 0
|
||||
}
|
||||
|
||||
|
@ -163,10 +177,17 @@ func (node *Node) UpdateDeviceMetrics(batteryLevel uint32, voltage, chUtil, airU
|
|||
node.LastDeviceMetrics = time.Now().Unix()
|
||||
}
|
||||
|
||||
func (node *Node) UpdateEnvironmentMetrics(temperature, relativeHumidity, barometricPressure float32) {
|
||||
func (node *Node) UpdateEnvironmentMetrics(temperature, relativeHumidity, barometricPressure, lux float32, windDirection uint32, windSpeed, windGust, radiation, rainfall1, rainfall24 float32) {
|
||||
node.Temperature = cleanFloat(temperature)
|
||||
node.RelativeHumidity = cleanFloat(relativeHumidity)
|
||||
node.BarometricPressure = cleanFloat(barometricPressure)
|
||||
node.Lux = cleanFloat(lux)
|
||||
node.WindDirection = windDirection
|
||||
node.WindSpeed = cleanFloat(windSpeed)
|
||||
node.WindGust = cleanFloat(windGust)
|
||||
node.Radiation = cleanFloat(radiation)
|
||||
node.Rainfall1 = cleanFloat(rainfall1)
|
||||
node.Rainfall24 = cleanFloat(rainfall24)
|
||||
node.LastEnvironmentMetrics = time.Now().Unix()
|
||||
}
|
||||
|
||||
|
|
|
@ -216,7 +216,8 @@
|
|||
fwVersion, region, modemPreset, hasDefaultCh, onlineLocalNodes,
|
||||
latitude, longitude, altitude, precision,
|
||||
batteryLevel, voltage, chUtil, airUtilTx, uptime,
|
||||
temperature, relativeHumidity, barometricPressure,
|
||||
temperature, relativeHumidity, barometricPressure, lux,
|
||||
windDirection, windSpeed, windGust, radiation, rainfall1, rainfall24,
|
||||
neighbors, seenBy
|
||||
} = node
|
||||
const id = `!${Number(nodeNum).toString(16)}`
|
||||
|
@ -250,9 +251,23 @@
|
|||
`${(temperature * 1.8 + 32).toFixed(1)}℉</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>` : ''}
|
||||
${lux ? `<tr><th>Lux</th><td>${Math.round(lux)} lx</td></tr>` : ''}
|
||||
${windDirection || windSpeed ? `<tr><th>Wind</th><td>` +
|
||||
(windDirection ? `${windDirection}°` : '') +
|
||||
(windDirection && windSpeed ? ' @ ' : '') +
|
||||
(windSpeed ? `${(windSpeed * 3.6).toFixed(1)}` : '') +
|
||||
(windSpeed && windGust ? ` G ${(windGust * 3.6).toFixed(1)}` : '') +
|
||||
(windSpeed ? ' km/h' : '') +
|
||||
`</td></tr>` : ''}
|
||||
${radiation ? `<tr><th>Radiation</th><td>${radiation.toFixed(2)} µR/h</td></tr>` : ''}
|
||||
${rainfall1 || rainfall24 ? `<tr><th>Rainfall</th><td>` +
|
||||
(rainfall1 ? `${rainfall1.toFixed(2)} mm/h` : '') +
|
||||
(rainfall1 && rainfall24 ? ', ' : '') +
|
||||
(rainfall24 ? `${rainfall24.toFixed(2)} mm/24h` : '') +
|
||||
`</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>±" +
|
||||
`${precisionMargins[precision-1].toLocaleString()} m (orange circle)</td></tr>` : ''}
|
||||
${precision && precisionMargins[precision-1] ? `<tr><th>Location precision</th><td>` +
|
||||
`±${precisionMargins[precision-1].toLocaleString()} m (orange circle)</td></tr>` : ''}
|
||||
</tbody></table>
|
||||
<table><thead>
|
||||
<tr><th>Last seen</th><th>via</th><th>root topic</th><th>channel</th></tr>
|
||||
|
|
Loading…
Reference in a new issue