diff --git a/presence/proto/BUILD b/presence/proto/BUILD new file mode 100644 index 00000000..8fa31990 --- /dev/null +++ b/presence/proto/BUILD @@ -0,0 +1,11 @@ +load("@rules_cc//cc:defs.bzl", "cc_proto_library") + +proto_library( + name = "presence_frame_proto", + srcs = ["presence_frame.proto"], +) + +cc_proto_library( + name = "presence_frame_cc_proto", + deps = [":presence_frame_proto"], +) diff --git a/presence/proto/presence_frame.proto b/presence/proto/presence_frame.proto new file mode 100644 index 00000000..ee6c2db9 --- /dev/null +++ b/presence/proto/presence_frame.proto @@ -0,0 +1,158 @@ +syntax = "proto2"; + +package nearby.presence; + +// import "storage/datapol/annotations/proto/semantic_annotations.proto"; + +option java_package = "com.google.android.gms.nearby.presence"; +option java_outer_classname = "PresenceFrameProtocol"; + +/** + * Nearby Presence’s wire frame format + */ +message PresenceFrame { + /** The version of the frame. */ + enum Version { + UNKNOWN_VERSION = 0; + VERSION_1 = 1; + } + + /** The version 1 frame for Nearby Presence. */ + optional V1Frame v1_frame = 1; +} + +/** + * Nearby Presence’s v1 wire frame format + */ +message V1Frame { + oneof Message { + // Control messages for connection status update. + ControlFrame control_frame = 1; + + // This frame will be shared by public and provisioned identities + DeviceIdentityFrame device_identity_frame = 2; + + // First message from discovery device to broadcaster. + ConnectionInitFrame connection_init_frame = 3; + + // Sent by broadcaster to notify discoverer its UWB capability. + UwbControleeCapabilities uwb_controlee_capabilities_frame = 4; + + // Sent by discoverer to notify broadcaster the UWB ranging parameters. + UwbConnectionInfo uwb_connection_info = 5; + } +} + +/** + * A frame contains the local device’s information, shared by public and + * provisioned identities. + */ +message DeviceIdentityFrame { + optional string device_name = 1; + + // Without this field, the device will not be connectable. + optional bytes bluetooth_mac_address = 2; // deprecated + + optional string device_image_url = 3; + + optional string model_id = 4; + + repeated int32 action = 5 [packed = true]; // deprecated + + optional string device_model_name = 6; + + optional int32 device_type = 7; +} + +/** + * A frame sent from discovery device to broadcast device when connection + * initialized, or when UWB needs to be restarted, or when dedup hint rotates. + */ +message ConnectionInitFrame { + // Discovery-side action list + repeated int32 actions = 1 [packed = true]; + + // Discovery-side identity type + optional int32 identity_type = 2; + + // Should the broadcaster (re)-start UWB OOB process or not. + optional bool uwb_enable = 3; + + // Used for device de-duplicate. Same device ID means the same physical + // device. When dedup hint rotates, this will be updated and send again. + optional int64 device_unique_id = 4; +} + +/** + * A frame that describes the controlee's UWB capabilities. + */ +message UwbControleeCapabilities { + optional bytes controlee_address = 1; + + repeated int32 supported_config_ids = 2 [packed = true]; + + repeated int32 supported_channels = 3 [packed = true]; + + optional int32 min_ranging_interval_ms = 4; + + optional bytes sub_session_id = 5 /* type = ST_SESSION_ID */; + + optional bytes sub_session_key = 6 + /* type = ST_SECURITY_MATERIAL */; + + optional bool ranging_disabled = 7; + + // Used for device de-duplicate. Same device ID means the same physical + // device. + optional int64 device_unique_id = 8; + + optional bool is_distance_supported = 9 [default = true]; + optional bool is_azimuth_supported = 10 [default = true]; + optional bool is_elevation_supported = 11 [default = false]; + optional float min_slot_duration_ms = 12 [default = 2.0]; + repeated int32 supported_ntf_configs = 13 [packed = true]; +} + +/** + * A frame that describes the connection info of the UWB ranging session. + */ +message UwbConnectionInfo { + optional bytes controller_address = 1; + + optional int32 channel = 2; + + optional int32 preamble_index = 3; + + optional int32 config_id = 4; + + optional int32 ranging_interval_ms = 5; + + optional int32 session_id = 6 /* type = ST_SESSION_ID */; + + optional bytes vendor_id = 7; + + optional bytes static_sts_iv = 8; + + optional bytes session_key = 9 + /* type = ST_SECURITY_MATERIAL */; + + optional bool ranging_disabled = 10; +} + +/** + * Control frames that used for connection status update. + */ +message ControlFrame { + /** The defined Control type of the frame. */ + enum ControlType { + UNKNOWN_TYPE = 0; + + // Keeps the connection alive. + KEEP_ALIVE = 1; + + // Notifies the peer that the connection will be closed immediately. + DISCONNECT = 2; + } + + optional ControlType type = 1; +}