float64全部改float32
This commit is contained in:
@@ -298,7 +298,7 @@ func (c *ChirpStackListener) handleUpEvent(ctx context.Context, event *UpEvent)
|
||||
valueDescriptor := valueDescriptors[0]
|
||||
|
||||
// 5.3 应用乘数和偏移量计算最终值
|
||||
parsedValue := float64(rawSensorValue)*valueDescriptor.Multiplier + valueDescriptor.Offset
|
||||
parsedValue := rawSensorValue*valueDescriptor.Multiplier + valueDescriptor.Offset
|
||||
|
||||
// 5.4 根据传感器类型构建具体的数据结构
|
||||
var dataToRecord interface{}
|
||||
@@ -312,7 +312,7 @@ func (c *ChirpStackListener) handleUpEvent(ctx context.Context, event *UpEvent)
|
||||
default:
|
||||
// TODO 未知传感器的数据需要记录吗
|
||||
logger.Warnf("未知的传感器类型 '%s',将使用通用格式记录", valueDescriptor.Type)
|
||||
dataToRecord = map[string]float64{"value": parsedValue}
|
||||
dataToRecord = map[string]float32{"value": parsedValue}
|
||||
}
|
||||
|
||||
// 5.5 记录传感器数据
|
||||
|
||||
@@ -24,9 +24,9 @@ type DeviceInfo struct {
|
||||
|
||||
// Location 包含了地理位置信息。
|
||||
type Location struct {
|
||||
Latitude float64 `json:"latitude"` // 纬度
|
||||
Longitude float64 `json:"longitude"` // 经度
|
||||
Altitude float64 `json:"altitude"` // 海拔
|
||||
Latitude float32 `json:"latitude"` // 纬度
|
||||
Longitude float32 `json:"longitude"` // 经度
|
||||
Altitude float32 `json:"altitude"` // 海拔
|
||||
}
|
||||
|
||||
// --- 可复用的子结构体 ---
|
||||
@@ -61,7 +61,7 @@ type UplinkRxInfo struct {
|
||||
UplinkID uint32 `json:"uplink_id"` // 上行ID
|
||||
Time time.Time `json:"time"` // 接收时间
|
||||
Rssi int `json:"rssi"` // 接收信号强度指示
|
||||
Snr float64 `json:"snr"` // 信噪比
|
||||
Snr float32 `json:"snr"` // 信噪比
|
||||
Channel int `json:"channel"` // 接收通道
|
||||
Location *Location `json:"location"` // 网关位置
|
||||
Context string `json:"context"` // 上下文信息
|
||||
@@ -96,9 +96,9 @@ type DownlinkTxInfo struct {
|
||||
|
||||
// ResolvedLocation 包含了地理位置解析结果。
|
||||
type ResolvedLocation struct {
|
||||
Latitude float64 `json:"latitude"` // 纬度
|
||||
Longitude float64 `json:"longitude"` // 经度
|
||||
Altitude float64 `json:"altitude"` // 海拔
|
||||
Latitude float32 `json:"latitude"` // 纬度
|
||||
Longitude float32 `json:"longitude"` // 经度
|
||||
Altitude float32 `json:"altitude"` // 海拔
|
||||
Source string `json:"source"` // 位置来源
|
||||
Accuracy int `json:"accuracy"` // 精度
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user