Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d3574de authored by Henri Chataing's avatar Henri Chataing Committed by Automerger Merge Worker
Browse files

Merge changes from topic "bt-cts" am: c2608f62

parents b2d6c6fc c2608f62
Loading
Loading
Loading
Loading
+31 −6
Original line number Diff line number Diff line
@@ -39,11 +39,15 @@ from pandora_experimental.gatt_pb2 import (
    PERMISSION_READ,
    PERMISSION_WRITE,
    PERMISSION_READ_ENCRYPTED,
    PERMISSION_READ_ENCRYPTED_MITM,
    PERMISSION_WRITE_ENCRYPTED,
    PERMISSION_WRITE_ENCRYPTED_MITM,
    ENABLE_NOTIFICATION_VALUE,
    ENABLE_INDICATION_VALUE,
)
from pandora_experimental.gatt_pb2 import GattServiceParams
from pandora_experimental.gatt_pb2 import GattCharacteristicParams
from pandora_experimental.gatt_pb2 import GattDescriptorParams
from pandora_experimental.gatt_pb2 import ReadCharacteristicResponse
from pandora_experimental.gatt_pb2 import ReadCharacteristicsFromUuidResponse

@@ -58,11 +62,15 @@ MMI_SERVER = {
}

# These UUIDs are used as reference for GATT server tests
BASE_READ_WRITE_SERVICE_UUID = "0000fffa-0000-1000-8000-00805f9b34fb"
BASE_READ_CHARACTERISTIC_UUID = "0000fffb-0000-1000-8000-00805f9b34fb"
BASE_WRITE_CHARACTERISTIC_UUID = "0000fffc-0000-1000-8000-00805f9b34fb"
CUSTOM_SERVICE_UUID = "0000fffd-0000-1000-8000-00805f9b34fb"
CUSTOM_CHARACTERISTIC_UUID = "0000fffe-0000-1000-8000-00805f9b34fb"
BASE_READ_WRITE_SERVICE_UUID = "0000fffe-0000-1000-8000-00805f9b34fb"
BASE_READ_CHARACTERISTIC_UUID = "0000ffd-0000-1000-8000-00805f9b34fb"
BASE_WRITE_CHARACTERISTIC_UUID = "0000fffa-0000-1000-8000-00805f9b34fb"
BASE_READ_WRITE_ENCRYPTED_CHARACTERISTIC_UUID = "0000fff9-0000-1000-8000-00805f9b34fb"
BASE_READ_WRITE_ENCRYPTED_MITM_CHARACTERISTIC_UUID = "0000fff8-0000-1000-8000-00805f9b34fb"
BASE_READ_DESCRIPTOR_UUID = "0000fff7-0000-1000-8000-00805f9b34fb"
BASE_WRITE_DESCRIPTOR_UUID = "0000fff6-0000-1000-8000-00805f9b34fb"
CUSTOM_SERVICE_UUID = "0000fff5-0000-1000-8000-00805f9b34fb"
CUSTOM_CHARACTERISTIC_UUID = "0000fff4-0000-1000-8000-00805f9b34fb"


class GATTProxy(ProfileProxy):
@@ -987,12 +995,29 @@ class GATTProxy(ProfileProxy):
                    uuid=BASE_READ_CHARACTERISTIC_UUID,
                    properties=PROPERTY_READ,
                    permissions=PERMISSION_READ,
                    descriptors=[
                        GattDescriptorParams(
                            uuid=BASE_READ_DESCRIPTOR_UUID,
                            properties=PROPERTY_READ,
                            permissions=PERMISSION_READ,
                        ),
                    ],
                ),
                GattCharacteristicParams(
                    uuid=BASE_WRITE_CHARACTERISTIC_UUID,
                    properties=PROPERTY_WRITE,
                    permissions=PERMISSION_WRITE,
                ),
                GattCharacteristicParams(
                    uuid=BASE_READ_WRITE_ENCRYPTED_CHARACTERISTIC_UUID,
                    properties=PROPERTY_READ | PROPERTY_WRITE,
                    permissions=PERMISSION_READ_ENCRYPTED | PERMISSION_WRITE_ENCRYPTED,
                ),
                GattCharacteristicParams(
                    uuid=BASE_READ_WRITE_ENCRYPTED_MITM_CHARACTERISTIC_UUID,
                    properties=PROPERTY_READ | PROPERTY_WRITE,
                    permissions=PERMISSION_READ_ENCRYPTED_MITM | PERMISSION_WRITE_ENCRYPTED_MITM,
                ),
            ],
        ))

+12 −8
Original line number Diff line number Diff line
@@ -241,14 +241,18 @@ class Gatt(private val context: Context) : GATTImplBase(), Closeable {
      Log.i(TAG, "registerService")
      val service =
        BluetoothGattService(UUID.fromString(request.service.uuid), SERVICE_TYPE_PRIMARY)
      for (characteristic in request.service.characteristicsList) {
        service.addCharacteristic(
          BluetoothGattCharacteristic(
            UUID.fromString(characteristic.uuid),
            characteristic.properties,
            characteristic.permissions
          )
        )
      for (characteristic_params in request.service.characteristicsList) {
        val characteristic = BluetoothGattCharacteristic(
          UUID.fromString(characteristic_params.uuid),
          characteristic_params.properties,
          characteristic_params.permissions)
        for (descriptor_params in characteristic_params.descriptorsList) {
          characteristic.addDescriptor(BluetoothGattDescriptor(
            UUID.fromString(descriptor_params.uuid),
            descriptor_params.properties,
            descriptor_params.permissions))
        }
        service.addCharacteristic(characteristic)
      }

      val fullService = coroutineScope {
+11 −1
Original line number Diff line number Diff line
@@ -67,8 +67,11 @@ enum AttProperties {
enum AttPermissions {
  PERMISSION_NONE = 0x00;
  PERMISSION_READ = 0x01;
  PERMISSION_WRITE = 0x10;
  PERMISSION_READ_ENCRYPTED = 0x02;
  PERMISSION_READ_ENCRYPTED_MITM = 0x04;
  PERMISSION_WRITE = 0x10;
  PERMISSION_WRITE_ENCRYPTED = 0x20;
  PERMISSION_WRITE_ENCRYPTED_MITM = 0x40;
}

enum EnableValue {
@@ -233,6 +236,13 @@ message GattCharacteristicParams {
  uint32 properties = 1;
  uint32 permissions = 2;
  string uuid = 3;
  repeated GattDescriptorParams descriptors = 4;
}

message GattDescriptorParams {
  uint32 properties = 1;
  uint32 permissions = 2;
  string uuid = 3;
}

message RegisterServiceRequest {
+4 −1
Original line number Diff line number Diff line
@@ -68,6 +68,9 @@ struct ControllerProperties {
  // Local Supported Commands (Vol 4, Part E § 7.4.2).
  std::array<uint8_t, 64> supported_commands;

  // Vendor Supported Commands.
  bool supports_le_get_vendor_capabilities_command{true};

  // Local Supported Features (Vol 4, Part E § 7.4.3) and
  // Local Extended Features (Vol 4, Part E § 7.4.3).
  std::array<uint64_t, 3> lmp_features;
@@ -114,7 +117,7 @@ struct ControllerProperties {
  // LE Number of Supported Advertising Sets (Vol 4, Part E § 7.8.58)
  // Note: the controller can change the number of advertising sets
  // at any time. This behaviour is not emulated here.
  uint8_t le_num_supported_advertising_sets{8};
  uint8_t le_num_supported_advertising_sets{16};

  // LE Periodic Advertiser List Size (Vol 4, Part E § 7.8.73).
  uint8_t le_periodic_advertiser_list_size{8};
+9 −3
Original line number Diff line number Diff line
@@ -2332,16 +2332,22 @@ void DualModeController::LeGetVendorCapabilities(CommandView command) {
  auto command_view = bluetooth::hci::LeGetVendorCapabilitiesView::Create(
      bluetooth::hci::VendorCommandView::Create(command));
  ASSERT(command_view.IsValid());
  vector<uint8_t> caps = properties_.le_vendor_capabilities;
  if (caps.empty()) {

  if (!properties_.supports_le_get_vendor_capabilities_command) {
    SendCommandCompleteUnknownOpCodeEvent(OpCode::LE_GET_VENDOR_CAPABILITIES);
    return;
  }

  // Ensure a minimal size for vendor capabilities.
  vector<uint8_t> vendor_capabilities = properties_.le_vendor_capabilities;
  if (vendor_capabilities.size() < 8) {
    vendor_capabilities.resize(8);
  }

  std::unique_ptr<bluetooth::packet::RawBuilder> raw_builder_ptr =
      std::make_unique<bluetooth::packet::RawBuilder>();
  raw_builder_ptr->AddOctets1(static_cast<uint8_t>(ErrorCode::SUCCESS));
  raw_builder_ptr->AddOctets(properties_.le_vendor_capabilities);
  raw_builder_ptr->AddOctets(vendor_capabilities);

  send_event_(bluetooth::hci::CommandCompleteBuilder::Create(
      kNumCommandPackets, OpCode::LE_GET_VENDOR_CAPABILITIES,