Compare commits

...

2 commits

Author SHA1 Message Date
root 755b8403a3 update README to remove restriction around region-based root topics 2024-12-01 16:56:42 +00:00
root 0393e6663a treat NaN floats as zero 2024-12-01 16:54:15 +00:00
2 changed files with 15 additions and 10 deletions

View file

@ -30,12 +30,9 @@ Meshtastic has [made a change to their MQTT server](https://meshtastic.org/blog/
The most accurate resolution that conforms to this specification is 364 meters/1194 feet.
Additionally, only the default [LoRa region](https://meshtastic.org/docs/configuration/radio/lora/#region)-based root topics (and all subtopics) are now monitored.
#### To enable MQTT reporting
- Enable the MQTT module, using all default settings, possibly with a custom root topic
- View nodes around your area on the map to find MQTT topics being used
- Only the official [LoRa region](https://meshtastic.org/docs/configuration/radio/lora/#region)-based root topics (and all subtopics) are monitored
- Configure your node to connect to wifi or otherwise connect to the internet
- Enable MQTT uplink on your primary channel
- It is not necessary, and not recommended unless you know what you're doing, to enable MQTT downlink

View file

@ -12,6 +12,14 @@ const (
NeighborLimit = 100
)
func cleanFloat(f float32) float32 {
if f != f {
// IEEE 754 says that only NaNs satisfy f != f
return 0
}
return f
}
type NeighborInfo struct {
Snr float32 `json:"snr,omitempty"`
Updated int64 `json:"updated"`
@ -148,17 +156,17 @@ func (node *Node) Prune(seenByTtl, neighborTtl, metricsTtl, mapReportTtl int64)
func (node *Node) UpdateDeviceMetrics(batteryLevel uint32, voltage, chUtil, airUtilTx float32, uptime uint32) {
node.BatteryLevel = batteryLevel
node.Voltage = voltage
node.ChUtil = chUtil
node.AirUtilTx = airUtilTx
node.Voltage = cleanFloat(voltage)
node.ChUtil = cleanFloat(chUtil)
node.AirUtilTx = cleanFloat(airUtilTx)
node.Uptime = uptime
node.LastDeviceMetrics = time.Now().Unix()
}
func (node *Node) UpdateEnvironmentMetrics(temperature, relativeHumidity, barometricPressure float32) {
node.Temperature = temperature
node.RelativeHumidity = relativeHumidity
node.BarometricPressure = barometricPressure
node.Temperature = cleanFloat(temperature)
node.RelativeHumidity = cleanFloat(relativeHumidity)
node.BarometricPressure = cleanFloat(barometricPressure)
node.LastEnvironmentMetrics = time.Now().Unix()
}
@ -176,7 +184,7 @@ func (node *Node) UpdateNeighborInfo(neighborNum uint32, snr float32) {
node.Neighbors = make(map[uint32]*NeighborInfo)
}
node.Neighbors[neighborNum] = &NeighborInfo{
Snr: snr,
Snr: cleanFloat(snr),
Updated: time.Now().Unix(),
}
}