添加gpio控制/进程健康管理

This commit is contained in:
gqc
2025-12-03 14:12:38 +08:00
parent 7a9d103943
commit 9b02bd9779
6 changed files with 302 additions and 27 deletions
+15 -7
View File
@@ -24,6 +24,19 @@ var (
currentServiceID string // New: current service's server_id
)
type PublishParams struct {
Topic string `json:"topic"`
Data json.RawMessage `json:"data,omitempty"`
Content json.RawMessage `json:"content,omitempty"`
}
type InferenceHeartbeat struct {
DeviceUUID string `json:"device_uuid"`
PersonCount int `json:"person_count"`
Temperature float64 `json:"temperature,omitempty"`
Timestamp int64 `json:"timestamp"` // 上报时间戳
}
func GetWSClient() *WSClient {
wsMutex.RLock()
defer wsMutex.RUnlock()
@@ -106,13 +119,6 @@ type SubscribeParams struct {
Topic string `json:"topic"`
}
type PublishParams struct {
EventType string `json:"event_type,omitempty"`
Body json.RawMessage `json:"body,omitempty"`
Topic string `json:"topic,omitempty"`
Data json.RawMessage `json:"data,omitempty"`
}
type WSClient struct {
Conn *websocket.Conn
url string
@@ -423,6 +429,8 @@ func (c *WSClient) handlePublishMessage(message WSMessage) {
logger.Logger.Printf("Failed to parse publish message parameters: %v", err)
return
}
logger.Logger.Printf("WebSocket 收到 publish 消息 → Topic: %s | 原始数据: %s",
publishParams.Topic, string(publishParams.Data))
if publishParams.Topic != "" {
c.mutex.Lock()