Skip to content

Commit

Permalink
l2cap: update APIs (breaking changes)
Browse files Browse the repository at this point in the history
  • Loading branch information
uael committed Oct 24, 2023
1 parent 90eeecd commit 9fe5914
Showing 1 changed file with 44 additions and 37 deletions.
81 changes: 44 additions & 37 deletions pandora/l2cap.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,16 @@ option java_outer_classname = "L2CAPProto";
service L2CAP {
// Establish an L2CAP channel on an ACL connection.
rpc Connect(ConnectRequest) returns (ConnectResponse);
// Await and accept incoming L2CAP channels on an existing ACL connection.
// Returns a stream of channel, this accept and yield channels until the stream
// is closed. Every incoming L2CAP channel connection request not handled by this
// Await and accept an incoming L2CAP channel on an existing ACL connection.
// Every incoming L2CAP channel connection request not handled by this
// method should be rejected.
rpc OnConnection(OnConnectionRequest) returns (stream OnConnectionResponse);
rpc WaitConnection(WaitConnectionRequest) returns (WaitConnectionResponse);
// Disconnect an established L2CAP channel.
rpc Disconnect(DisconnectRequest) returns (DisconnectResponse);
// Await an established L2CAP channel's termination.
rpc WaitDisconnection(WaitDisconnectionRequest) returns (WaitDisconnectionResponse);
// Fetch data received from an active L2CAP channel.
// Packets are yielded until the stream is closed, packets are droped otherwise.
// Packets are yielded until the stream is closed, packets are dropped otherwise.
rpc Receive(ReceiveRequest) returns (stream ReceiveResponse);
// Send data over an L2CAP channel to a connected device.
rpc Send(SendRequest) returns (SendResponse);
Expand All @@ -60,6 +59,23 @@ message Channel {
google.protobuf.Any cookie = 1;
}

// Fixed channel, represented by a `Connection` and a Fixed Channel Identifier (CID).
message FixedChannel {
// Specifies the underlying ACL connection, either BR/EDR (Basic Rate/Enhanced Data Rate) or BLE.
Connection connection = 1;
// Fixed Channel Identifier (CID). Represents the unique identifier for the fixed channel.
// Available CIDs are:
// - 0x0001: L2CAP Signaling Channel
// - 0x0002: Connectionless Channel
// - 0x0003: AMP Manager Protocol
// - 0x0004: Attribute Protocol (ATT) for BLE
// - 0x0005: L2CAP Signaling Channel for BLE
// - 0x0006: Security Manager Protocol for BLE
// - 0x0007: Security Manager Protocol for BR/EDR
// - CIDs in the range of 0x0007 to 0x003F are reserved for standardization purposes.
uint32 cid = 2;
}

// Request for establishing an L2CAP connection-oriented channel,
// where data is transmitted with acknowledgment.
message ConnectionOrientedChannelRequest {
Expand All @@ -82,35 +98,18 @@ message CreditBasedChannelRequest {
uint32 initial_credit = 4;
}

// Request for establishing a fixed L2CAP channel, often pre-defined for specific purposes.
message FixedChannelRequest {
// Fixed Channel Identifier (CID). Represents the unique identifier for the fixed channel.
// Available CIDs are:
// - 0x0001: L2CAP Signaling Channel
// - 0x0002: Connectionless Channel
// - 0x0003: AMP Manager Protocol
// - 0x0004: Attribute Protocol (ATT) for BLE
// - 0x0005: L2CAP Signaling Channel for BLE
// - 0x0006: Security Manager Protocol for BLE
// - 0x0007: Security Manager Protocol for BR/EDR
// - CIDs in the range of 0x0007 to 0x003F are reserved for standardization purposes.
uint32 cid = 1;
}

// Request of the `Connect` method.
message ConnectRequest {
// Specifies the underlying ACL connection, either BR/EDR (Basic Rate/Enhanced Data Rate) or BLE.
Connection connection = 1;
// Defines the type and specifics of the channel to establish.
oneof type {
// Request a fixed channel.
FixedChannelRequest fixed = 2;
// Request a connection-oriented channel.
ConnectionOrientedChannelRequest basic = 3;
ConnectionOrientedChannelRequest basic = 2;
// Request a BLE credit-based channel.
CreditBasedChannelRequest le_credit_based = 4;
CreditBasedChannelRequest le_credit_based = 3;
// Request an enhanced credit-based channel.
CreditBasedChannelRequest enhanced_credit_based = 5;
CreditBasedChannelRequest enhanced_credit_based = 4;
}
}

Expand All @@ -124,25 +123,23 @@ message ConnectResponse {
}
}

// Request of the `OnConnection` method.
message OnConnectionRequest {
// Request of the `WaitConnection` method.
message WaitConnectionRequest {
// Specifies the underlying ACL connection, either BR/EDR or BLE.
Connection connection = 1;
// Defines the type and specifics of the channel to wait and accept.
oneof type {
// Accept fixed channels.
FixedChannelRequest fixed = 2;
// Accept connection-oriented channels.
ConnectionOrientedChannelRequest basic = 3;
ConnectionOrientedChannelRequest basic = 2;
// Accept BLE credit-based channels.
CreditBasedChannelRequest le_credit_based = 4;
CreditBasedChannelRequest le_credit_based = 3;
// Accept enhanced credit-based channels.
CreditBasedChannelRequest enhanced_credit_based = 5;
CreditBasedChannelRequest enhanced_credit_based = 4;
}
}

// Response of the `OnConnection` method.
message OnConnectionResponse {
// Response of the `WaitConnection` method.
message WaitConnectionResponse {
oneof result {
CommandRejectReason error = 1;
Channel channel = 2;
Expand Down Expand Up @@ -180,7 +177,12 @@ message WaitDisconnectionResponse {
// Request of the `Receive` method.
message ReceiveRequest {
// Specifies the channel to fetch data from.
Channel channel = 1;
oneof source {
// Fetch data from a dynamic channel.
Channel channel = 1;
// Fetch data from a fixed channel.
FixedChannel fixed_channel = 2;
}
}

// Response of the `Receive` method.
Expand All @@ -192,9 +194,14 @@ message ReceiveResponse {
// Request of the `Send` method.
message SendRequest {
// Specifies the channel to send data over.
Channel channel = 1;
oneof sink {
// Send data over a dynamic channel.
Channel channel = 1;
// Send data over a fixed channel.
FixedChannel fixed_channel = 2;
}
// Data to be sent over the specified channel.
bytes data = 2;
bytes data = 3;
}

// Response of the `Send` method.
Expand Down

0 comments on commit 9fe5914

Please sign in to comment.