采集失败处理
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -256,6 +257,12 @@ func (c *ChirpStackListener) handleUpEvent(event *UpEvent) {
|
|||||||
for i, deviceID := range deviceIDs {
|
for i, deviceID := range deviceIDs {
|
||||||
rawSensorValue := values[i] // 这是设备上报的原始值
|
rawSensorValue := values[i] // 这是设备上报的原始值
|
||||||
|
|
||||||
|
// 检查设备上报的值是否为 NaN (Not a Number),如果是则跳过
|
||||||
|
if math.IsNaN(float64(rawSensorValue)) {
|
||||||
|
c.logger.Warnf("设备 (ID: %d) 上报了一个无效的 NaN 值,已跳过当前值的记录。", deviceID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
// 5.1 获取设备及其模板
|
// 5.1 获取设备及其模板
|
||||||
dev, err := c.deviceRepo.FindByID(deviceID)
|
dev, err := c.deviceRepo.FindByID(deviceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user