feat: mqtt receive.

This commit is contained in:
2026-04-28 15:29:16 +08:00
parent 51871c352a
commit 2464617599
9 changed files with 2820 additions and 2 deletions
+57
View File
@@ -0,0 +1,57 @@
package models
import "gorm.io/gorm"
type MqttHeartRateRecord struct {
gorm.Model
Identifier string `gorm:"uniqueIndex;size:255" json:"identifier"`
Topic string `gorm:"size:255;index" json:"topic"`
RegionID uint32 `gorm:"index" json:"regionId"`
GatewayMAC string `gorm:"size:32;index" json:"gatewayMac"`
BandID uint32 `gorm:"index" json:"bandId"`
BeltAddr string `gorm:"size:64;index" json:"beltAddr"`
PacketNum uint32 `gorm:"index" json:"packetNum"`
HeartRate int `gorm:"type:int" json:"heartRate"`
HrConfidence int `gorm:"type:int" json:"hrConfidence"`
IsActive bool `json:"isActive"`
IsOnSkin bool `json:"isOnSkin"`
Battery uint32 `json:"battery"`
SignalRSSINeg float64 `gorm:"type:double precision" json:"signalRssiNeg"`
SNR float64 `gorm:"type:double precision" json:"snr"`
HubBusID uint32 `json:"hubBusId"`
HubSubDevID uint32 `json:"hubSubDevId"`
ReceivedAt int64 `gorm:"type:bigint;index" json:"receivedAt"`
}
type MqttStepCountRecord struct {
gorm.Model
Identifier string `gorm:"uniqueIndex;size:255" json:"identifier"`
Topic string `gorm:"size:255;index" json:"topic"`
RegionID uint32 `gorm:"index" json:"regionId"`
GatewayMAC string `gorm:"size:32;index" json:"gatewayMac"`
BandID uint32 `gorm:"index" json:"bandId"`
BeltAddr string `gorm:"size:64;index" json:"beltAddr"`
PacketNum uint32 `gorm:"index" json:"packetNum"`
StepCount uint32 `json:"stepCount"`
SignalRSSINeg float64 `gorm:"type:double precision" json:"signalRssiNeg"`
SNR float64 `gorm:"type:double precision" json:"snr"`
HubBusID uint32 `json:"hubBusId"`
HubSubDevID uint32 `json:"hubSubDevId"`
ReceivedAt int64 `gorm:"type:bigint;index" json:"receivedAt"`
}
type MqttGatewayStatusRecord struct {
gorm.Model
Identifier string `gorm:"uniqueIndex;size:255" json:"identifier"`
Topic string `gorm:"size:255;index" json:"topic"`
RegionID uint32 `gorm:"index" json:"regionId"`
GatewayMAC string `gorm:"size:32;index" json:"gatewayMac"`
BootCount uint32 `json:"bootCount"`
UptimeMs uint32 `json:"uptimeMs"`
DurationMsSinceLastPacket uint32 `json:"durationMsSinceLastPacket"`
RxCount uint32 `json:"rxCount"`
BatteryVoltageMV uint32 `json:"batteryVoltageMv"`
BatterySOCPercentage uint32 `json:"batterySocPercentage"`
ChargingRatePercentage int32 `json:"chargingRatePercentage"`
ReceivedAt int64 `gorm:"type:bigint;index" json:"receivedAt"`
}