Skip to content

Instantly share code, notes, and snippets.

@ahappyforest
Last active January 1, 2016 08:39
Show Gist options
  • Select an option

  • Save ahappyforest/8120153 to your computer and use it in GitHub Desktop.

Select an option

Save ahappyforest/8120153 to your computer and use it in GitHub Desktop.
这是蘑菇项目的硬件层与数据层的消息协议, 采用protobuf定义
message MessageHeader0x01
{
required int32 message_id = 1;
optional int32 session = 2;
optional HeaderPayLoad data = 3;
message HeaderPayLoad
{
required int32 birth_type = 1;
required int32 fd = 2;
}
}
enum SENSOR_TYPE {
TEMP = 1;
LIGHT = 2;
HUMI = 3;
CO2 = 4;
};
enum MESSAGE_ID {
// System Config 1-1000
READ_TIME = 1;
READ_TIME_RESPONSE = 2;
UPDATE_TIME = 3;
UPDATE_TIME_RESPONSE = 4;
READ_CONF = 5;
READ_CONF_RESPONSE = 6;
UPDATE_CONF = 7;
UPDATE_CONF_RESPONSE = 8;
REBOOT = 9;
REBOOT_RESPONSE = 10;
// control 1001 - 2000
READ_CONTROLLER_STATE = 1001;
READ_CONTROLLER_STATE_RESPONSE = 1002;
UPDATE_CONTROLLER_STATE = 1003;
UPDATE_CONTROLLER_STATE_RESPONSE = 1004;
// capture 2001 - 3000
READ_SENSOR_DATA = 2001;
READ_SENSOR_DATA_RESPONSE = 2002;
SENSOR_DATA_PUSH = 2003;
// extension 3001-4000
}
message Room {
required int32 room_id = 1;
}
message Sensor {
required int32 id = 1;
required SENSOR_TYPE type = 2;
required int32 value = 3;
}
message SynTime {
required string timestamp = 1; //时间格式为:"2014-01-08 22:15:42"
}
enum RESPONSE {
OK = 1;
}
message ResponseCode {
required RESPONSE code = 1;
optional string log = 2;
}
message Config {
required string key = 1;
optional int32 val = 2;
}
message ConfigList {
repeated Config config = 1;
}
message Controller {
required int32 controller_id = 1;
enum STATE {
OPEN = 1;
CLOSE = 2;
ERROR = 3;
}
optional STATE state = 2;
}
message SensorData {
required Room room = 1;
repeated Sensor sensor = 2;
required SynTime time = 3;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment