syntax = "proto3";
|
|
package aiot;
|
|
// 协议格式:
|
// | int32 | | enum int32 | | int32 | | []byte | | enum int32 | | enum int32 | | []byte | | []byte |
|
// ----------- -------------- -------------- --------------------------------------------------- ---------------- ---------------- ------------------------ --------------
|
// length receiver senderId deviceProto msgType reqType msgIdProto data
|
// 数据包长度 接受者身份 发送者ID 设备信息 消息类型 请求类型 消息ID 消息体
|
// 4byte
|
// {| string | | string | | string |} {| string | | string |}
|
// ---------------- ------------------ --------------- ------------ -----------
|
// clusterId masterDeviceId DeviceIds msgId PreMsgId
|
// 集群ID 集群Master设备ID 消息指向的设备ID 消息ID 原始消息ID
|
// 消息接收者
|
enum RECEIVER {
|
// 发送给saas
|
TO_SAAS = 0;
|
// 发送给集群master
|
TO_MASTER = 1;
|
// 发送给集群全部成员
|
TO_CLUSTER = 2;
|
// 发送给集群某一个节点
|
TO_NODE = 3;
|
// 发送给集群中部分节点
|
TO_NODE_LIST = 4;
|
}
|
|
// 消息类型
|
enum MSG_TYPE {
|
// 心跳
|
HEART_BEAT = 0;
|
// 注册
|
REGISTER = 1;
|
// 数据上报
|
DATA_REPORT = 2;
|
// 设备控制
|
CONTROL = 3;
|
// 业务消息
|
BUSINESS = 9;
|
}
|
|
// 请求类型
|
enum REQ_TYPE {
|
// 收到请求
|
REQUEST = 0;
|
// 收到应答
|
RESPONSE = 1;
|
}
|
|
// 设备信息组成
|
message DeviceProto {
|
// 集群ID
|
string clusterId = 1;
|
// 主节点ID
|
string masterDeviceId = 2;
|
// 消息接收者
|
repeated string deviceIds = 3;
|
}
|
|
// 消息ID
|
message MsgIdProto {
|
string msgId = 1;
|
string preMsgId = 2;
|
}
|
|
// 消息体
|
message BusinessProto {
|
string topic = 1;
|
bytes request = 2;
|
string authorization = 3;
|
}
|
|
// 消息体组成
|
message Protocol {
|
RECEIVER receiver = 1;
|
string senderId = 2;
|
DeviceProto deviceProto = 3;
|
MSG_TYPE msgType = 4;
|
REQ_TYPE reqType = 5;
|
MsgIdProto msgProto = 6;
|
bytes data = 7;
|
}
|
|
// 心跳包
|
message HeartBeatProto {}
|
|
// 注册节点ID
|
message DeviceNode {
|
string deviceId = 1;
|
}
|
|
// 设备注册包
|
message DeviceRegister {
|
// 设备ID
|
string deviceId = 1;
|
//设备名称
|
string serverName = 2;
|
// 集群ID
|
string clusterId = 3;
|
// 集群名称
|
string clusterName = 4;
|
// 漂移IP
|
string virtualIp = 5;
|
// 集群节点列表
|
repeated DeviceNode deviceList = 6;
|
}
|
|
// 数据上报
|
message DataReport {
|
string dataKey = 1;
|
bytes data = 2;
|
}
|