package models import "time" type TaskStatus string type DeviceTaskType string const ( TaskStatusPending TaskStatus = "pending" TaskStatusRunning TaskStatus = "running" TaskStatusFinished TaskStatus = "finished" TaskStatusError TaskStatus = "error" ) const ( // 1. start/stop audiostream TaskTypeStartStream DeviceTaskType = "start_stream" TaskTypeStopStream DeviceTaskType = "stop_stream" // 2. start/stop recording TaskTypeStartRecording DeviceTaskType = "start_recording" TaskTypeStopRecording DeviceTaskType = "stop_recording" // 3. change configuration (sleep timeout, jitter, recording duration) TaskTypeUpdateConfig DeviceTaskType = "update_config" // 4. set deep sleep duration (minutes) TaskTypeSetDeepSleep DeviceTaskType = "set_deep_sleep" ) type DEviceTask struct { ID uint `gorm:"primaryKey"` DeviceGUID string `gorm:"index;not null"` Type DeviceTaskType `gorm:"type:varchar(64);not null"` // JSON payload from server to device (parameters) Payload string `gorm:"type:text;not null;default:'{}'"` Status TaskStatus `gorm:"type:varchar(16);not null;index"` // Optional error/reason from server or device ErrorMsg string `gorm:"type:text"` // Raw result JSON from device (success path) Result string `gorm:"type:text"` // State timing CreatedAt time.Time UpdatedAt time.Time StartedAt *time.Time // when device fetched/acknowledged (Running) FinishedAt *time.Time // when device posted result (Finished/Error) // Optional: small attempt/lease system if you ever need retries/timeouts // Attempts int `gorm:"not null;default:0"` }