saas-smartAi通信协议标准库
gongshangguo
2022-03-02 cb8a046f1d84198b6bbddb1481667b905ea522bf
aiotProto/aiot/aiot_business.proto
@@ -4,30 +4,74 @@
import "aiot_common.proto";
// 请求类型
enum RequestType{
    Async = 0;
    sync = 1;
    // 同步请求 默认
    sync = 0;
    // 异步请求
    Async = 1;
}
// 请求的body体
message BusinessReq {
message NodeReq {
    // 请求的topic url
    string topic = 1;
    // token
    string authorization = 2;
    // 请求指向的ip
    string ip = 3;
    // 请求的端口 保留字段
    string port = 4;
    RequestType type = 5;
    // 请求的同步/异步类型
    RequestType syncType = 5;
    // 请求业务参数
    bytes req = 6;
}
// 集群请求参数
message ClusterReq{
    // 集群ID
    string ClusterId = 1;
    // token
    string authorization = 2;
    // 请求的同步/异步类型
    RequestType syncType = 3;
    // 请求业务参数
    bytes req = 4;
}
// 设备列表请求参数
message NodesReq{
    // 设备列表ID
    repeated string NodeIds = 1;
    // token
    string authorization = 2;
    // 请求的同步/异步类型
    RequestType syncType = 3;
    // 请求业务参数
    bytes req = 4;
}
// 响应的body体
message BusinessReply {
    // 返回的错误码
    int32 code = 1;
    // 错误信息
    string msg = 2;
    // 是否success
    bool success = 3;
    // 返回结果
    bytes data = 4;
}
// 服务
service AiotService {
    rpc GetBusiness(BusinessReq) returns (BusinessReply){}
    // 发送指向单个设备的请求
    rpc SendToNode(NodeReq) returns (BusinessReply){}
    // 直接发送tcp请求
    rpc SendAiotReq(Protocol) returns (Protocol){}
    // 发送群组请求
    rpc SendToCluster(ClusterReq) returns (BusinessReply){}
    // 向多个设备同时发起相同参数请求
    rpc SendToNodes(NodesReq) returns (BusinessReply) {}
}