/*
 * Copyright (C) 2025 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

syntax = "proto2";

package perfetto.protos;

// Describes the packet type and direction. CMD and EVT are unidirectional, so
// no need to differentiate the direction.
enum BluetoothTracePacketType {
  HCI_CMD = 1;
  HCI_EVT = 2;
  HCI_ACL_RX = 3;
  HCI_ACL_TX = 4;
  HCI_SCO_RX = 5;
  HCI_SCO_TX = 6;
  HCI_ISO_RX = 7;
  HCI_ISO_TX = 8;
}

// Trace event for bluetooth
message BluetoothTraceEvent {
  // Packet type and direction
  optional BluetoothTracePacketType packet_type = 1;

  // Total count of the packets collected during the collection interval
  optional uint32 count = 2;

  // Total cumulative length of the packets collected during the collection
  // interval
  optional uint32 length = 3;

  // The collection interval in nanoseconds. This is the duration between the
  // first and last packets collected.
  optional uint32 duration = 4;

  // In case of CMD type, further breakdown of the type of command
  optional uint32 op_code = 5;

  // In the case of EVT type, further breakdown of the type of event
  optional uint32 event_code = 6;

  // When applicable for EVT type, further breakdown of event type into specific
  // subevent
  optional uint32 subevent_code = 7;

  // Associated handle for the bluetooth packet
  optional uint32 connection_handle = 8;
}
