增加ping指令并获取带版本号的响应
This commit is contained in:
@@ -556,6 +556,89 @@ func (x *LogUploadRequest) GetEntries() []*LogEntry {
|
||||
return nil
|
||||
}
|
||||
|
||||
// 平台向设备发送的Ping指令,用于检查存活性。
|
||||
type Ping struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Ping) Reset() {
|
||||
*x = Ping{}
|
||||
mi := &file_device_proto_msgTypes[9]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Ping) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Ping) ProtoMessage() {}
|
||||
|
||||
func (x *Ping) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_device_proto_msgTypes[9]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Ping.ProtoReflect.Descriptor instead.
|
||||
func (*Ping) Descriptor() ([]byte, []int) {
|
||||
return file_device_proto_rawDescGZIP(), []int{9}
|
||||
}
|
||||
|
||||
// 设备对Ping的响应,或设备主动上报的心跳。
|
||||
// 它包含了设备的关键状态信息。
|
||||
type Pong struct {
|
||||
state protoimpl.MessageState `protogen:"open.v1"`
|
||||
FirmwareVersion string `protobuf:"bytes,1,opt,name=firmware_version,json=firmwareVersion,proto3" json:"firmware_version,omitempty"` // 当前固件版本
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
}
|
||||
|
||||
func (x *Pong) Reset() {
|
||||
*x = Pong{}
|
||||
mi := &file_device_proto_msgTypes[10]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
|
||||
func (x *Pong) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*Pong) ProtoMessage() {}
|
||||
|
||||
func (x *Pong) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_device_proto_msgTypes[10]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use Pong.ProtoReflect.Descriptor instead.
|
||||
func (*Pong) Descriptor() ([]byte, []int) {
|
||||
return file_device_proto_rawDescGZIP(), []int{10}
|
||||
}
|
||||
|
||||
func (x *Pong) GetFirmwareVersion() string {
|
||||
if x != nil {
|
||||
return x.FirmwareVersion
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Instruction 封装了所有与设备间的通信。
|
||||
// 使用 oneof 来确保每个消息只有一个负载类型,这在嵌入式系统中是高效且类型安全的。
|
||||
type Instruction struct {
|
||||
@@ -566,9 +649,11 @@ type Instruction struct {
|
||||
// *Instruction_BatchCollectCommand
|
||||
// *Instruction_OtaUpgradeCommand
|
||||
// *Instruction_ControlLogUploadCommand
|
||||
// *Instruction_Ping
|
||||
// *Instruction_CollectResult
|
||||
// *Instruction_OtaUpgradeStatus
|
||||
// *Instruction_LogUploadRequest
|
||||
// *Instruction_Pong
|
||||
Payload isInstruction_Payload `protobuf_oneof:"payload"`
|
||||
unknownFields protoimpl.UnknownFields
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -576,7 +661,7 @@ type Instruction struct {
|
||||
|
||||
func (x *Instruction) Reset() {
|
||||
*x = Instruction{}
|
||||
mi := &file_device_proto_msgTypes[9]
|
||||
mi := &file_device_proto_msgTypes[11]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
@@ -588,7 +673,7 @@ func (x *Instruction) String() string {
|
||||
func (*Instruction) ProtoMessage() {}
|
||||
|
||||
func (x *Instruction) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_device_proto_msgTypes[9]
|
||||
mi := &file_device_proto_msgTypes[11]
|
||||
if x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
@@ -601,7 +686,7 @@ func (x *Instruction) ProtoReflect() protoreflect.Message {
|
||||
|
||||
// Deprecated: Use Instruction.ProtoReflect.Descriptor instead.
|
||||
func (*Instruction) Descriptor() ([]byte, []int) {
|
||||
return file_device_proto_rawDescGZIP(), []int{9}
|
||||
return file_device_proto_rawDescGZIP(), []int{11}
|
||||
}
|
||||
|
||||
func (x *Instruction) GetPayload() isInstruction_Payload {
|
||||
@@ -647,6 +732,15 @@ func (x *Instruction) GetControlLogUploadCommand() *ControlLogUploadCommand {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Instruction) GetPing() *Ping {
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*Instruction_Ping); ok {
|
||||
return x.Ping
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Instruction) GetCollectResult() *CollectResult {
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*Instruction_CollectResult); ok {
|
||||
@@ -674,6 +768,15 @@ func (x *Instruction) GetLogUploadRequest() *LogUploadRequest {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *Instruction) GetPong() *Pong {
|
||||
if x != nil {
|
||||
if x, ok := x.Payload.(*Instruction_Pong); ok {
|
||||
return x.Pong
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type isInstruction_Payload interface {
|
||||
isInstruction_Payload()
|
||||
}
|
||||
@@ -695,6 +798,10 @@ type Instruction_ControlLogUploadCommand struct {
|
||||
ControlLogUploadCommand *ControlLogUploadCommand `protobuf:"bytes,4,opt,name=control_log_upload_command,json=controlLogUploadCommand,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Instruction_Ping struct {
|
||||
Ping *Ping `protobuf:"bytes,6,opt,name=ping,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Instruction_CollectResult struct {
|
||||
// --- 上行数据 (设备 -> 平台) ---
|
||||
CollectResult *CollectResult `protobuf:"bytes,101,opt,name=collect_result,json=collectResult,proto3,oneof"`
|
||||
@@ -708,6 +815,10 @@ type Instruction_LogUploadRequest struct {
|
||||
LogUploadRequest *LogUploadRequest `protobuf:"bytes,103,opt,name=log_upload_request,json=logUploadRequest,proto3,oneof"`
|
||||
}
|
||||
|
||||
type Instruction_Pong struct {
|
||||
Pong *Pong `protobuf:"bytes,104,opt,name=pong,proto3,oneof"`
|
||||
}
|
||||
|
||||
func (*Instruction_Raw_485Command) isInstruction_Payload() {}
|
||||
|
||||
func (*Instruction_BatchCollectCommand) isInstruction_Payload() {}
|
||||
@@ -716,12 +827,16 @@ func (*Instruction_OtaUpgradeCommand) isInstruction_Payload() {}
|
||||
|
||||
func (*Instruction_ControlLogUploadCommand) isInstruction_Payload() {}
|
||||
|
||||
func (*Instruction_Ping) isInstruction_Payload() {}
|
||||
|
||||
func (*Instruction_CollectResult) isInstruction_Payload() {}
|
||||
|
||||
func (*Instruction_OtaUpgradeStatus) isInstruction_Payload() {}
|
||||
|
||||
func (*Instruction_LogUploadRequest) isInstruction_Payload() {}
|
||||
|
||||
func (*Instruction_Pong) isInstruction_Payload() {}
|
||||
|
||||
var File_device_proto protoreflect.FileDescriptor
|
||||
|
||||
const file_device_proto_rawDesc = "" +
|
||||
@@ -755,15 +870,20 @@ const file_device_proto_rawDesc = "" +
|
||||
"\x06enable\x18\x01 \x01(\bR\x06enable\x12)\n" +
|
||||
"\x10duration_seconds\x18\x02 \x01(\rR\x0fdurationSeconds\">\n" +
|
||||
"\x10LogUploadRequest\x12*\n" +
|
||||
"\aentries\x18\x01 \x03(\v2\x10.device.LogEntryR\aentries\"\xad\x04\n" +
|
||||
"\aentries\x18\x01 \x03(\v2\x10.device.LogEntryR\aentries\"\x06\n" +
|
||||
"\x04Ping\"1\n" +
|
||||
"\x04Pong\x12)\n" +
|
||||
"\x10firmware_version\x18\x01 \x01(\tR\x0ffirmwareVersion\"\xf5\x04\n" +
|
||||
"\vInstruction\x12?\n" +
|
||||
"\x0fraw_485_command\x18\x01 \x01(\v2\x15.device.Raw485CommandH\x00R\rraw485Command\x12Q\n" +
|
||||
"\x15batch_collect_command\x18\x02 \x01(\v2\x1b.device.BatchCollectCommandH\x00R\x13batchCollectCommand\x12K\n" +
|
||||
"\x13ota_upgrade_command\x18\x03 \x01(\v2\x19.device.OtaUpgradeCommandH\x00R\x11otaUpgradeCommand\x12^\n" +
|
||||
"\x1acontrol_log_upload_command\x18\x04 \x01(\v2\x1f.device.ControlLogUploadCommandH\x00R\x17controlLogUploadCommand\x12>\n" +
|
||||
"\x1acontrol_log_upload_command\x18\x04 \x01(\v2\x1f.device.ControlLogUploadCommandH\x00R\x17controlLogUploadCommand\x12\"\n" +
|
||||
"\x04ping\x18\x06 \x01(\v2\f.device.PingH\x00R\x04ping\x12>\n" +
|
||||
"\x0ecollect_result\x18e \x01(\v2\x15.device.CollectResultH\x00R\rcollectResult\x12H\n" +
|
||||
"\x12ota_upgrade_status\x18f \x01(\v2\x18.device.OtaUpgradeStatusH\x00R\x10otaUpgradeStatus\x12H\n" +
|
||||
"\x12log_upload_request\x18g \x01(\v2\x18.device.LogUploadRequestH\x00R\x10logUploadRequestB\t\n" +
|
||||
"\x12log_upload_request\x18g \x01(\v2\x18.device.LogUploadRequestH\x00R\x10logUploadRequest\x12\"\n" +
|
||||
"\x04pong\x18h \x01(\v2\f.device.PongH\x00R\x04pongB\t\n" +
|
||||
"\apayload*O\n" +
|
||||
"\bLogLevel\x12\x19\n" +
|
||||
"\x15LOG_LEVEL_UNSPECIFIED\x10\x00\x12\t\n" +
|
||||
@@ -785,7 +905,7 @@ func file_device_proto_rawDescGZIP() []byte {
|
||||
}
|
||||
|
||||
var file_device_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
|
||||
var file_device_proto_msgTypes = make([]protoimpl.MessageInfo, 10)
|
||||
var file_device_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
|
||||
var file_device_proto_goTypes = []any{
|
||||
(LogLevel)(0), // 0: device.LogLevel
|
||||
(*LogEntry)(nil), // 1: device.LogEntry
|
||||
@@ -797,7 +917,9 @@ var file_device_proto_goTypes = []any{
|
||||
(*OtaUpgradeStatus)(nil), // 7: device.OtaUpgradeStatus
|
||||
(*ControlLogUploadCommand)(nil), // 8: device.ControlLogUploadCommand
|
||||
(*LogUploadRequest)(nil), // 9: device.LogUploadRequest
|
||||
(*Instruction)(nil), // 10: device.Instruction
|
||||
(*Ping)(nil), // 10: device.Ping
|
||||
(*Pong)(nil), // 11: device.Pong
|
||||
(*Instruction)(nil), // 12: device.Instruction
|
||||
}
|
||||
var file_device_proto_depIdxs = []int32{
|
||||
0, // 0: device.LogEntry.level:type_name -> device.LogLevel
|
||||
@@ -808,14 +930,16 @@ var file_device_proto_depIdxs = []int32{
|
||||
3, // 5: device.Instruction.batch_collect_command:type_name -> device.BatchCollectCommand
|
||||
6, // 6: device.Instruction.ota_upgrade_command:type_name -> device.OtaUpgradeCommand
|
||||
8, // 7: device.Instruction.control_log_upload_command:type_name -> device.ControlLogUploadCommand
|
||||
5, // 8: device.Instruction.collect_result:type_name -> device.CollectResult
|
||||
7, // 9: device.Instruction.ota_upgrade_status:type_name -> device.OtaUpgradeStatus
|
||||
9, // 10: device.Instruction.log_upload_request:type_name -> device.LogUploadRequest
|
||||
11, // [11:11] is the sub-list for method output_type
|
||||
11, // [11:11] is the sub-list for method input_type
|
||||
11, // [11:11] is the sub-list for extension type_name
|
||||
11, // [11:11] is the sub-list for extension extendee
|
||||
0, // [0:11] is the sub-list for field type_name
|
||||
10, // 8: device.Instruction.ping:type_name -> device.Ping
|
||||
5, // 9: device.Instruction.collect_result:type_name -> device.CollectResult
|
||||
7, // 10: device.Instruction.ota_upgrade_status:type_name -> device.OtaUpgradeStatus
|
||||
9, // 11: device.Instruction.log_upload_request:type_name -> device.LogUploadRequest
|
||||
11, // 12: device.Instruction.pong:type_name -> device.Pong
|
||||
13, // [13:13] is the sub-list for method output_type
|
||||
13, // [13:13] is the sub-list for method input_type
|
||||
13, // [13:13] is the sub-list for extension type_name
|
||||
13, // [13:13] is the sub-list for extension extendee
|
||||
0, // [0:13] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_device_proto_init() }
|
||||
@@ -823,14 +947,16 @@ func file_device_proto_init() {
|
||||
if File_device_proto != nil {
|
||||
return
|
||||
}
|
||||
file_device_proto_msgTypes[9].OneofWrappers = []any{
|
||||
file_device_proto_msgTypes[11].OneofWrappers = []any{
|
||||
(*Instruction_Raw_485Command)(nil),
|
||||
(*Instruction_BatchCollectCommand)(nil),
|
||||
(*Instruction_OtaUpgradeCommand)(nil),
|
||||
(*Instruction_ControlLogUploadCommand)(nil),
|
||||
(*Instruction_Ping)(nil),
|
||||
(*Instruction_CollectResult)(nil),
|
||||
(*Instruction_OtaUpgradeStatus)(nil),
|
||||
(*Instruction_LogUploadRequest)(nil),
|
||||
(*Instruction_Pong)(nil),
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
@@ -838,7 +964,7 @@ func file_device_proto_init() {
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: unsafe.Slice(unsafe.StringData(file_device_proto_rawDesc), len(file_device_proto_rawDesc)),
|
||||
NumEnums: 1,
|
||||
NumMessages: 10,
|
||||
NumMessages: 12,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user