定义otatask模型
This commit is contained in:
@@ -376,7 +376,7 @@ func (x *Pong) GetFirmwareVersion() string {
|
||||
type PrepareUpdateReq struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
Version string `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` // 新固件版本号
|
||||
TaskId string `protobuf:"bytes,2,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` // 升级任务唯一ID
|
||||
TaskId uint32 `protobuf:"varint,2,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` // 升级任务唯一ID
|
||||
ManifestMd5 string `protobuf:"bytes,3,opt,name=manifest_md5,json=manifestMd5,proto3" json:"manifest_md5,omitempty"` // 清单文件的 MD5 校验和,用于设备初步校验清单文件完整性
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -419,11 +419,11 @@ func (x *PrepareUpdateReq) GetVersion() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *PrepareUpdateReq) GetTaskId() string {
|
||||
func (x *PrepareUpdateReq) GetTaskId() uint32 {
|
||||
if x != nil {
|
||||
return x.TaskId
|
||||
}
|
||||
return ""
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *PrepareUpdateReq) GetManifestMd5() string {
|
||||
@@ -436,8 +436,8 @@ func (x *PrepareUpdateReq) GetManifestMd5() string {
|
||||
// RequestFile: 设备向平台请求特定文件 (包括清单文件和固件文件) (上行)
|
||||
type RequestFile struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
TaskId string `protobuf:"bytes,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` // 升级任务ID
|
||||
Filepath string `protobuf:"bytes,2,opt,name=filepath,proto3" json:"filepath,omitempty"` // 请求的文件路径 (例如 "/manifest.json" 或 "/main.py")
|
||||
TaskId uint32 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` // 升级任务ID
|
||||
Filepath string `protobuf:"bytes,2,opt,name=filepath,proto3" json:"filepath,omitempty"` // 请求的文件路径 (例如 "/manifest.json" 或 "/main.py")
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -472,11 +472,11 @@ func (*RequestFile) Descriptor() ([]byte, []int) {
|
||||
return file_device_proto_rawDescGZIP(), []int{7}
|
||||
}
|
||||
|
||||
func (x *RequestFile) GetTaskId() string {
|
||||
func (x *RequestFile) GetTaskId() uint32 {
|
||||
if x != nil {
|
||||
return x.TaskId
|
||||
}
|
||||
return ""
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *RequestFile) GetFilepath() string {
|
||||
@@ -490,9 +490,9 @@ func (x *RequestFile) GetFilepath() string {
|
||||
// LoRa 传输层会自动处理分片和重组,因此应用层可以直接发送完整的单个文件内容
|
||||
type FileResponse struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
TaskId string `protobuf:"bytes,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` // 升级任务ID
|
||||
Filepath string `protobuf:"bytes,2,opt,name=filepath,proto3" json:"filepath,omitempty"` // 设备上的目标路径 (例如 "/manifest.json" 或 "/main.py")
|
||||
Content []byte `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` // 文件的完整内容
|
||||
TaskId uint32 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` // 升级任务ID
|
||||
Filepath string `protobuf:"bytes,2,opt,name=filepath,proto3" json:"filepath,omitempty"` // 设备上的目标路径 (例如 "/manifest.json" 或 "/main.py")
|
||||
Content []byte `protobuf:"bytes,3,opt,name=content,proto3" json:"content,omitempty"` // 文件的完整内容
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
@@ -527,11 +527,11 @@ func (*FileResponse) Descriptor() ([]byte, []int) {
|
||||
return file_device_proto_rawDescGZIP(), []int{8}
|
||||
}
|
||||
|
||||
func (x *FileResponse) GetTaskId() string {
|
||||
func (x *FileResponse) GetTaskId() uint32 {
|
||||
if x != nil {
|
||||
return x.TaskId
|
||||
}
|
||||
return ""
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *FileResponse) GetFilepath() string {
|
||||
@@ -551,7 +551,7 @@ func (x *FileResponse) GetContent() []byte {
|
||||
// UpdateStatusReport: 设备向平台报告升级状态 (上行)
|
||||
type UpdateStatusReport struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
TaskId string `protobuf:"bytes,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` // 升级任务ID
|
||||
TaskId uint32 `protobuf:"varint,1,opt,name=task_id,json=taskId,proto3" json:"task_id,omitempty"` // 升级任务ID
|
||||
CurrentVersion string `protobuf:"bytes,2,opt,name=current_version,json=currentVersion,proto3" json:"current_version,omitempty"` // 操作完成后的当前版本
|
||||
Status UpdateStatusReport_Status `protobuf:"varint,3,opt,name=status,proto3,enum=device.UpdateStatusReport_Status" json:"status,omitempty"` // 升级的最终状态
|
||||
ErrorMessage string `protobuf:"bytes,4,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` // 人类可读的详细错误信息
|
||||
@@ -590,11 +590,11 @@ func (*UpdateStatusReport) Descriptor() ([]byte, []int) {
|
||||
return file_device_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
func (x *UpdateStatusReport) GetTaskId() string {
|
||||
func (x *UpdateStatusReport) GetTaskId() uint32 {
|
||||
if x != nil {
|
||||
return x.TaskId
|
||||
}
|
||||
return ""
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *UpdateStatusReport) GetCurrentVersion() string {
|
||||
@@ -845,17 +845,17 @@ const file_device_proto_rawDesc = "" +
|
||||
"\x10firmware_version\x18\x01 \x01(\tR\x0ffirmwareVersion\"h\n" +
|
||||
"\x10PrepareUpdateReq\x12\x18\n" +
|
||||
"\aversion\x18\x01 \x01(\tR\aversion\x12\x17\n" +
|
||||
"\atask_id\x18\x02 \x01(\tR\x06taskId\x12!\n" +
|
||||
"\atask_id\x18\x02 \x01(\rR\x06taskId\x12!\n" +
|
||||
"\fmanifest_md5\x18\x03 \x01(\tR\vmanifestMd5\"B\n" +
|
||||
"\vRequestFile\x12\x17\n" +
|
||||
"\atask_id\x18\x01 \x01(\tR\x06taskId\x12\x1a\n" +
|
||||
"\atask_id\x18\x01 \x01(\rR\x06taskId\x12\x1a\n" +
|
||||
"\bfilepath\x18\x02 \x01(\tR\bfilepath\"]\n" +
|
||||
"\fFileResponse\x12\x17\n" +
|
||||
"\atask_id\x18\x01 \x01(\tR\x06taskId\x12\x1a\n" +
|
||||
"\atask_id\x18\x01 \x01(\rR\x06taskId\x12\x1a\n" +
|
||||
"\bfilepath\x18\x02 \x01(\tR\bfilepath\x12\x18\n" +
|
||||
"\acontent\x18\x03 \x01(\fR\acontent\"\x9a\x03\n" +
|
||||
"\x12UpdateStatusReport\x12\x17\n" +
|
||||
"\atask_id\x18\x01 \x01(\tR\x06taskId\x12'\n" +
|
||||
"\atask_id\x18\x01 \x01(\rR\x06taskId\x12'\n" +
|
||||
"\x0fcurrent_version\x18\x02 \x01(\tR\x0ecurrentVersion\x129\n" +
|
||||
"\x06status\x18\x03 \x01(\x0e2!.device.UpdateStatusReport.StatusR\x06status\x12#\n" +
|
||||
"\rerror_message\x18\x04 \x01(\tR\ferrorMessage\x12\x1f\n" +
|
||||
|
||||
@@ -46,27 +46,27 @@ message Pong {
|
||||
// PrepareUpdateReq: 平台发送给设备,通知设备准备开始 OTA 升级 (下行)
|
||||
message PrepareUpdateReq {
|
||||
string version = 1; // 新固件版本号
|
||||
string task_id = 2; // 升级任务唯一ID
|
||||
uint32 task_id = 2; // 升级任务唯一ID
|
||||
string manifest_md5 = 3; // 清单文件的 MD5 校验和,用于设备初步校验清单文件完整性
|
||||
}
|
||||
|
||||
// RequestFile: 设备向平台请求特定文件 (包括清单文件和固件文件) (上行)
|
||||
message RequestFile {
|
||||
string task_id = 1; // 升级任务ID
|
||||
uint32 task_id = 1; // 升级任务ID
|
||||
string filepath = 2; // 请求的文件路径 (例如 "/manifest.json" 或 "/main.py")
|
||||
}
|
||||
|
||||
// FileResponse: 平台响应设备请求,发送单个文件的完整内容 (下行)
|
||||
// LoRa 传输层会自动处理分片和重组,因此应用层可以直接发送完整的单个文件内容
|
||||
message FileResponse {
|
||||
string task_id = 1; // 升级任务ID
|
||||
uint32 task_id = 1; // 升级任务ID
|
||||
string filepath = 2; // 设备上的目标路径 (例如 "/manifest.json" 或 "/main.py")
|
||||
bytes content = 3; // 文件的完整内容
|
||||
}
|
||||
|
||||
// UpdateStatusReport: 设备向平台报告升级状态 (上行)
|
||||
message UpdateStatusReport {
|
||||
string task_id = 1; // 升级任务ID
|
||||
uint32 task_id = 1; // 升级任务ID
|
||||
string current_version = 2; // 操作完成后的当前版本
|
||||
enum Status {
|
||||
STATUS_UNSPECIFIED = 0; // 未指定,protobuf3 要求枚举从0开始
|
||||
|
||||
Reference in New Issue
Block a user