From bdae5c0fdf262ea9d22e7db9a70c1e235041fdec Mon Sep 17 00:00:00 2001 From: anlicheng <244108715@qq.com> Date: Mon, 21 Apr 2025 15:57:15 +0800 Subject: [PATCH] proto --- efkamove | 14 +++++++++ message.proto => message_pb.proto | 52 ++++++++++--------------------- 2 files changed, 31 insertions(+), 35 deletions(-) create mode 100755 efkamove rename message.proto => message_pb.proto (70%) diff --git a/efkamove b/efkamove new file mode 100755 index 0000000..bf04f7a --- /dev/null +++ b/efkamove @@ -0,0 +1,14 @@ +#! /bin/sh + +/usr/local/code/tmp/gpb/bin/protoc-erl -I . -rename msg_name:snake_case -strbin message_pb.proto + +#sed -i '' 's/sdlv_4_info/sdl_v4_info/g' sdlan_pb.hrl +#sed -i '' 's/sdlv_6_info/sdl_v6_info/g' sdlan_pb.hrl + +sed -i '' 's/include(\"gpb.hrl\")/include_lib(\"gpb\/include\/gpb.hrl\")/g' message_pb.erl + +#sed -i '' 's/sdlv_4_info/sdl_v4_info/g' sdlan_pb.erl +#sed -i '' 's/sdlv_6_info/sdl_v6_info/g' sdlan_pb.erl + +mv message_pb.hrl ./apps/efka/include +mv message_pb.erl ./apps/efka/src diff --git a/message.proto b/message_pb.proto similarity index 70% rename from message.proto rename to message_pb.proto index 947c874..8f53fb6 100644 --- a/message.proto +++ b/message_pb.proto @@ -1,7 +1,5 @@ syntax = "proto3"; -import "google/protobuf/any.proto"; - // auth验证请求和应答 message AuthRequest { @@ -27,25 +25,14 @@ message SessionReply { bool a = 1; } -// 定义单个数据项目 -message Field { - uint32 device_uuid = 1; - string key = 2; - google.protobuf.Any value = 3; - int32 unit = 4; - string type = 5; - int32 timestamp = 6; - string name = 7; - string label = 8; -} - // 数据传输 message Data { string device_uuid = 1; string service_name = 2; int32 at = 3; map tags = 4; - repeated Field fields = 5; + // 为了数据的灵活性,存储类型无关的二进制流 + repeated bytes fields = 5; } //#{<<"adcode">> => 0,<<"boot_time">> => 18256077,<<"city">> => <<>>, @@ -77,22 +64,17 @@ message Ping { repeated int32 disk = 11; repeated int32 memory = 12; // 接口信息的定义: 每个接口的信息, 采用json格式传输,没有办法提前定义 - repeated string interfaces = 13; + repeated bytes interfaces = 13; } // Inform消息 - -message Inform { - message Service { - string name = 1; - string props = 2; - string version = 3; - string version_copy = 4; - uint32 status = 5; - } - - uint32 at = 1; - repeated Service services = 2; +message ServiceInform { + string name = 1; + string props = 2; + string version = 3; + string version_copy = 4; + uint32 status = 5; + uint32 at = 6; } message FeedbackStep { @@ -111,19 +93,19 @@ message FeedbackResult { message Event { uint32 event_type = 1; - map params = 2; + bytes params = 2; } message AIEvent { uint32 event_type = 1; - map params = 2; + bytes params = 2; } // 指令 message Directive { - string device_uuid = 1; - string version = 2; - uint32 directive_type = 3; - uint32 timeout = 4; - map directive = 5; + string device_uuid = 1; + string version = 2; + uint32 directive_type = 3; + uint32 timeout = 4; + bytes directive = 5; } \ No newline at end of file