Add full protobuf schema and generated code
This commit is contained in:
@@ -2,10 +2,16 @@ syntax = "proto3";
|
||||
|
||||
package keyboard.cdc;
|
||||
|
||||
// The AA55 CDC frame still lives outside protobuf:
|
||||
// [head1][head2][len][type][data][checksum]
|
||||
// `data` is the serialized protobuf payload for the matching `type`.
|
||||
// Keep the outer `type` field for fast dispatch and debugging.
|
||||
// Full protocol schema.
|
||||
//
|
||||
// CDC uses:
|
||||
// [AA][55][Len][Type][Payload][Checksum]
|
||||
//
|
||||
// GATT uses:
|
||||
// protobuf(CdcPacketBody)
|
||||
//
|
||||
// In this schema, the outer CDC frame is also modeled explicitly so we keep
|
||||
// one complete protocol definition.
|
||||
|
||||
enum CdcPacketType {
|
||||
CDC_PACKET_TYPE_UNKNOWN = 0;
|
||||
@@ -33,11 +39,34 @@ enum ErrorCode {
|
||||
ERROR_CODE_NOT_READY = 4;
|
||||
}
|
||||
|
||||
message HelloReqPayload {
|
||||
message CdcFrame {
|
||||
uint32 head1 = 1;
|
||||
uint32 head2 = 2;
|
||||
uint32 payload_length = 3;
|
||||
CdcPacketType type = 4;
|
||||
bytes payload = 5;
|
||||
uint32 checksum = 6;
|
||||
}
|
||||
|
||||
message CdcPacketBody {
|
||||
oneof body {
|
||||
HelloReq hello_req = 1;
|
||||
HelloRsp hello_rsp = 2;
|
||||
Bitmap bitmap = 3;
|
||||
FunctionKeyEvent function_key_event = 4;
|
||||
LedState led_state = 5;
|
||||
TimeSync time_sync = 6;
|
||||
ThemeRgb theme_rgb = 7;
|
||||
Ack ack = 8;
|
||||
Error error = 9;
|
||||
}
|
||||
}
|
||||
|
||||
message HelloReq {
|
||||
uint32 protocol_version = 1;
|
||||
}
|
||||
|
||||
message HelloRspPayload {
|
||||
message HelloRsp {
|
||||
uint32 protocol_version = 1;
|
||||
uint32 vendor_id = 2;
|
||||
uint32 product_id = 3;
|
||||
@@ -46,20 +75,20 @@ message HelloRspPayload {
|
||||
uint32 capability_flags = 6;
|
||||
}
|
||||
|
||||
message BitmapPayload {
|
||||
message Bitmap {
|
||||
bytes usage_bitmap = 1;
|
||||
}
|
||||
|
||||
message FunctionKeyEventPayload {
|
||||
message FunctionKeyEvent {
|
||||
uint32 usage = 1;
|
||||
KeyAction action = 2;
|
||||
}
|
||||
|
||||
message LedStatePayload {
|
||||
message LedState {
|
||||
uint32 led_mask = 1;
|
||||
}
|
||||
|
||||
message TimeSyncPayload {
|
||||
message TimeSync {
|
||||
uint32 version = 1;
|
||||
uint32 flags = 2;
|
||||
sint32 timezone_min = 3;
|
||||
@@ -67,17 +96,17 @@ message TimeSyncPayload {
|
||||
fixed32 accuracy_ms = 5;
|
||||
}
|
||||
|
||||
message ThemeRgbPayload {
|
||||
message ThemeRgb {
|
||||
uint32 red = 1;
|
||||
uint32 green = 2;
|
||||
uint32 blue = 3;
|
||||
}
|
||||
|
||||
message AckPayload {
|
||||
message Ack {
|
||||
uint32 acked_type = 1;
|
||||
}
|
||||
|
||||
message ErrorPayload {
|
||||
message Error {
|
||||
uint32 error_type = 1;
|
||||
ErrorCode error_code = 2;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user