Demo entry 6799637

tbox_net.proto

   

Submitted by anonymous on May 21, 2019 at 09:10
Language: Protocol Buffer. Code size: 4.9 kB.

syntax = "proto3";

package tbox.net;

/* ----------Part-1 : Server/Client消息定义---------- */
/* 请求类型枚举 */
enum RequestType {
    UNKNOWN_REQUEST_TYPE          = 0;
    MAKE_I_CALL                   = 1;  // 拨打 I-CALL
    ANSWER_CALL                   = 2;  // 接电话
    HANG_UP                       = 3;  // 挂电话
    GET_I_E_CALL_STATUS           = 4;  // 获取I/E-CALL 状态
    MAKE_E_CALL                   = 5;  // 拨打E-CALL
    GET_TELECOM_OPERATOR          = 6;  // 获取运营商
    GET_NETWORK_STANDARD          = 7;  // 获取网络制式
    GET_SIGNAL_STRENGTH           = 8;  // 获取信号强度
    CELLULAR_NETWORK_CONTROL      = 9;  // 打开关闭数据通信
    SET_NETWORK_STANDARD          = 10; // 设置网络制式
    GET_CELLULAR_NETWORK_STATUS   = 11; // 获取数据通信开关状态
    GET_CELLULAR_NETWORK_STANDARD = 12; // 获取网络通信数据制式
    GET_TBOX_ID                   = 13; // 获取TBOX ID
    GET_GPS_INFO                  = 14; // 获取GPS信息
    GET_USER_ID                   = 15; // 获取UserID
    SET_ECALL_NUM                 = 16; // 设置ECall号码
    GPS_PUBLISH_CONTROL           = 17; // GPS主动发布开关
    GET_TBOX_TIME                 = 18; // 获取TBOX时间
    GET_PHONE_SOC                 = 19; // 获取手机剩余电量
}

/* I/E-CALL 状态枚举 */
enum IECallStatus {
    UNKNOWN_I_E_CALL_STATUS  = 0;
    I_CALL_INCOMING          = 1; // I-CALL 来电中
    I_CALL_DIGLING           = 2; // I-CALL 拨号中
    I_CALL_TALKING           = 3; // I-CALL 通话中
    E_CALL_INCOMING          = 4; // E-CALL 来电中
    E_CALL_DIGLING           = 5; // E-CALL 拨号中
    E_CALL_TALKING           = 6; // E-CALL 通话中
    ALL_CALL_IDLE            = 7; // 空闲
}

/* 运营商枚举 */
enum TelecomOperator {
    UNKNOWN_TELECOM_OPERATOR     = 0;
    CHINA_UNICOM                 = 1;  // 中国联通
    CHINA_MOBILE                 = 2;  // 中国移动
    CHINA_TELECOM                = 3;  // 中国电信
    TELECOM_OPERATOR_SIM_ERROR   = 4;  // SIM卡故障
}

/* 网络制式枚举 */
enum NetworkStandard {
    UNKNOWN_NETWORK_STANDARD  = 0;
    NS_2G                     = 1;
    NS_3G                     = 2;
    NS_4G                     = 3;
    NS_AUTO                   = 4;
    NS_SIM_ERROR              = 5;
}

/* 请求消息定义 */
message Request {
    RequestType                 request_type              = 1; // 请求类型

    uint32                      request_sn                = 2; // 一直递增的请求序号,需要响应消息跟这个数值一样
    bool                        cellular_network_on_off   = 3; // true:on false:off 默认只关闭APN2-3,APN1保持常开
    NetworkStandard             network_standard          = 4; // 网络制式设置
    string                      ecall_num                 = 5; // ECALL号码  不能有空格,国家区号(4位)+号码,例如"008601080287000"
    bool                        gps_publish_on_off        = 6; // GPS发布开关
}

/* 响应消息定义 */
message Response {
    message ResponseStatus {
        enum StatusCode {
            UNKNOWN_RESPONSE_STATUS  = 0;
            OK                       = 1;
            NOT_SUPPORTED            = 2;
            INVALID_REQUEST          = 3;
            ERROR                    = 4;
        }

        RequestType  request_type  = 1;  // 本次响应对应的请求类型
        uint32       request_sn    = 2;  // 对应请求消息里的请求序号
        StatusCode   status_code   = 3;  // 请求执行状态
        string       error_message = 4;  // 错误消息
    }

    ResponseStatus              response_status           = 1; // 响应状态字段

    IECallStatus                call_status               = 2; // request_type = GET_I_E_CALL_STATUS
    TelecomOperator             telecom_operator          = 3; // request_type = GET_TELECOM_OPERATOR
    NetworkStandard             network_standard          = 4;
    uint32                      signal_strength           = 5; // 0-100 %
    bool                        cellular_network_on_off   = 6; // 数据通信开关状态
    NetworkStandard             cellular_network_standard = 7; // 网络通信数据制式
    string                      tbox_id                   = 8;  // 23位 字母+数字组合 “PN003442019041012345678”
    string                      gps_info                  = 9;
    string                      user_id                   = 10;
    string                      tbox_time                 = 11; // 格式"%Y-%m-%d %H:%M:%S",默认北京时间 UTC+8,例如:2019-04-09 13:20:30
    uint32                      phone_soc                 = 12; // 0-100%
}

/* ----------Part-2 :Publish/Subscribe消息定义---------- */
//topic:"user_id"
message UserID {
    string user_id = 1;
}

// topic:"tbox_gps" 当GPS数据
message TBoxGPS {
    string gps_info = 1;
}

// topic:"tbox_time_sync" 当TBOX时间更新时主动发送
message TBoxTimeSync {
    string time = 1; // 格式"%Y-%m-%d %H:%M:%S",默认北京时间 UTC+8 例如:2019-04-09 13:20:30
}

// topic:"phone_soc" 手机剩余电量(state of charge)
message PhoneSOC {
    uint32 soc = 1; // 0-100%
}

/* ----------Part-X : 以下内容弃用---------- */
/* 消息发布事件,车展用,正式版弃用 */
//enum PublishEvent {
//   UNKNOW_PUBLISH_EVENT   = 0;
//    USER_ID                = 1;
//}

/* 状态发布消息定义,车展用,正式版弃用 */
//message PublishMsg {
//    PublishEvent       event      = 1;  // 本次发布的事件类型
//    string             user_id    = 2;
//}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).