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

Commit bca18e94 authored by Etienne Ruffieux's avatar Etienne Ruffieux Committed by Automerger Merge Worker
Browse files
parents 6de5ba8f 854eb8bd
Loading
Loading
Loading
Loading
+244 −6
Original line number Diff line number Diff line
@@ -20,7 +20,11 @@ from mmi2grpc._proxy import ProfileProxy

from pandora_experimental.gatt_grpc import GATT
from pandora_experimental.host_grpc import Host
from pandora_experimental.gatt_pb2 import AttStatusCode
from pandora_experimental.host_pb2 import Connection, ConnectabilityMode, AddressType
from pandora_experimental.gatt_pb2 import AttStatusCode, AttProperties, AttPermissions
from pandora_experimental.gatt_pb2 import GattService
from pandora_experimental.gatt_pb2 import GattCharacteristic
from pandora_experimental.gatt_pb2 import GattCharacteristicDescriptor
from pandora_experimental.gatt_pb2 import ReadCharacteristicResponse
from pandora_experimental.gatt_pb2 import ReadCharacteristicsFromUuidResponse

@@ -30,6 +34,17 @@ NEEDS_CACHE_CLEARED = {
    "GATT/CL/GAD/BV-06-C",
}

MMI_SERVER = {
    "GATT/SR/GAD/BV-01-C",
}

# 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"


class GATTProxy(ProfileProxy):

@@ -44,6 +59,7 @@ class GATTProxy(ProfileProxy):
        self.read_response = None
        self.write_response = None
        self.written_over_length = False
        self.last_added_service = None

    @assert_description
    def MMI_IUT_INITIATE_CONNECTION(self, test, pts_addr: bytes, **kwargs):
@@ -79,6 +95,7 @@ class GATTProxy(ProfileProxy):
        self.read_response = None
        self.write_response = None
        self.written_over_length = False
        self.last_added_service = None
        return "OK"

    @assert_description
@@ -195,7 +212,7 @@ class GATTProxy(ProfileProxy):
        # Android doesn't store services discovered by UUID.
        return "Yes"

    def MMI_CONFIRM_PRIMARY_SERVICE(self, description: str, **kwargs):
    def MMI_CONFIRM_PRIMARY_SERVICE(self, test, description: str, **kwargs):
        """
        Please confirm IUT received primary services Primary Service = 'XXXX'O
        Primary Service = 'XXXX'O  in database. Click Yes if IUT received it,
@@ -205,6 +222,7 @@ class GATTProxy(ProfileProxy):
        Test (IUT) can send Discover all primary services in database.
        """

        if test not in MMI_SERVER:
            assert self.services is not None
            all_matches = list(map(formatUuid, re.findall("'([a0-Z9]*)'O", description)))
            assert all(uuid in list(map(lambda service: service.uuid, self.services))\
@@ -870,6 +888,226 @@ class GATTProxy(ProfileProxy):
                handle=handle, value=data)
        return "OK"

    def MMI_MAKE_IUT_CONNECTABLE(self, **kwargs):
        """
        Please prepare IUT into a connectable mode.

        Description: Verify that
        the Implementation Under Test (IUT) can accept GATT connect request from
        PTS.
        """
        self.host.StartAdvertising(
            connectability_mode=ConnectabilityMode.CONNECTABILITY_CONNECTABLE,
            own_address_type=AddressType.PUBLIC,
        )
        self.gatt.RegisterService(
            service=GattService(
                uuid=BASE_READ_WRITE_SERVICE_UUID,
                characteristics=[
                    GattCharacteristic(
                        uuid=BASE_READ_CHARACTERISTIC_UUID,
                        properties=AttProperties.PROPERTY_READ,
                        permissions=AttPermissions.PERMISSION_READ,
                    ),
                    GattCharacteristic(
                        uuid=BASE_WRITE_CHARACTERISTIC_UUID,
                        properties=AttProperties.PROPERTY_WRITE,
                        permissions=AttPermissions.PERMISSION_WRITE,
                    ),
                ],
            ))

        return "OK"

    def MMI_CONFIRM_IUT_PRIMARY_SERVICE_128(self, **kwargs):
        """
        Please confirm IUT have following primary services UUID= 'XXXX'O
        Service start handle = 'XXXX'O, end handle = 'XXXX'O. Click Yes if IUT
        have it, otherwise click No.

        Description: Verify that the
        Implementation Under Test (IUT) can respond Discover all primary
        services by UUID.
        """

        return "Yes"

    def MMI_CONFIRM_CHARACTERISTICS_SERVICE(self, **kwargs):
        """
        Please confirm IUT have following characteristics in services UUID=
        'XXXX'O handle='XXXX'O handle='XXXX'O handle='XXXX'O handle='XXXX'O .
        Click Yes if IUT have it, otherwise click No.

        Description: Verify that
        the Implementation Under Test (IUT) can respond Discover all
        characteristics of a service.
        """

        return "Yes"

    def MMI_CONFIRM_SERVICE_UUID(self, **kwargs):
        """
        Please confirm the following handles for GATT Service UUID = 0xXXXX.
        Start Handle = 0xXXXX
        End Handle = 0xXXXX
        """

        return "Yes"

    def MMI_IUT_ENTER_HANDLE_INVALID(self, **kwargs):
        """
        Please input a handle(0x)(Range 0x0001-0xFFFF) that is known to be
        invalid.

        Description: Verify that the Implementation Under Test (IUT)
        can issue an Invalid Handle Response.
        """

        return "FFFF"

    def MMI_IUT_NO_SECURITY(self, **kwargs):
        """
        Please make sure IUT does not initiate security procedure.

        Description:
        PTS will delete bond information. Test case requires that no
        authentication or authorization procedure has been performed between the
        IUT and the test system.
        """

        return "OK"

    def MMI_IUT_ENTER_UUID_READ_NOT_PERMITTED(self, **kwargs):
        """
        Enter UUID(0x) response with Read Not Permitted.

        Description: Verify
        that the Implementation Under Test (IUT) can respond Read Not Permitted.
        """

        self.last_added_service = self.gatt.RegisterService(
            service=GattService(
                uuid=CUSTOM_SERVICE_UUID,
                characteristics=[
                    GattCharacteristic(
                        uuid=CUSTOM_CHARACTERISTIC_UUID,
                        properties=AttProperties.PROPERTY_READ,
                        permissions=AttPermissions.PERMISSION_NONE,
                    ),
                ],
            ))
        return CUSTOM_CHARACTERISTIC_UUID[4:8].upper()

    def MMI_IUT_ENTER_HANDLE_READ_NOT_PERMITTED(self, **kwargs):
        """
        Please input a handle(0x)(Range 0x0001-0xFFFF) that doesn't permit
        reading (i.e. Read Not Permitted)

        Description: Verify that the
        Implementation Under Test (IUT) can issue a Read Not Permitted Response.
        """

        return "{:04x}".format(self.last_added_service.service.characteristics[0].handle)

    def MMI_IUT_ENTER_UUID_ATTRIBUTE_NOT_FOUND(self, **kwargs):
        """
        Enter UUID(0x) response with Attribute Not Found.

        Description: Verify
        that the Implementation Under Test (IUT) can respond Attribute Not
        Found.
        """

        return CUSTOM_CHARACTERISTIC_UUID[4:8].upper()

    def MMI_IUT_ENTER_UUID_INSUFFICIENT_AUTHENTICATION(self, **kwargs):
        """
        Enter UUID(0x) response with Insufficient Authentication.

        Description:
        Verify that the Implementation Under Test (IUT) can respond Insufficient
        Authentication.
        """

        self.last_added_service = self.gatt.RegisterService(
            service=GattService(
                uuid=CUSTOM_SERVICE_UUID,
                characteristics=[
                    GattCharacteristic(
                        uuid=CUSTOM_CHARACTERISTIC_UUID,
                        properties=AttProperties.PROPERTY_READ,
                        permissions=AttPermissions.PERMISSION_READ_ENCRYPTED,
                    ),
                ],
            ))
        return CUSTOM_CHARACTERISTIC_UUID[4:8].upper()

    def MMI_IUT_ENTER_HANDLE_INSUFFICIENT_AUTHENTICATION(self, **kwargs):
        """
        Enter Handle(0x)(Range 0x0001-0xFFFF) response with Insufficient
        Authentication.

        Description: Verify that the Implementation Under Test
        (IUT) can respond Insufficient Authentication.
        """

        return "{:04x}".format(self.last_added_service.service.characteristics[0].handle)

    def MMI_IUT_ENTER_HANDLE_READ_NOT_PERMITTED(self, **kwargs):
        """
        Please input a handle(0x)(Range 0x0001-0xFFFF) that doesn't permit
        reading (i.e. Read Not Permitted)

        Description: Verify that the
        Implementation Under Test (IUT) can issue a Read Not Permitted Response.
        """

        self.last_added_service = self.gatt.RegisterService(
            service=GattService(
                uuid=CUSTOM_SERVICE_UUID,
                characteristics=[
                    GattCharacteristic(
                        uuid=CUSTOM_CHARACTERISTIC_UUID,
                        properties=AttProperties.PROPERTY_READ,
                        permissions=AttPermissions.PERMISSION_NONE,
                    ),
                ],
            ))
        return "{:04x}".format(self.last_added_service.service.characteristics[0].handle)

    def MMI_IUT_CONFIRM_READ_MULTIPLE_HANDLE_VALUES(self, **kwargs):
        """
        Please confirm IUT Handle pair = 'XXXX'O 'XXXX'O
        value='XXXXXXXXXXXXXXXXXXXXXXXXXXX in random selected
        adopted database. Click Yes if it matches the IUT, otherwise click No.
        Description: Verify that the Implementation Under Test (IUT) can send
        Read multiple characteristics.
        """

        return "OK"

    def MMI_IUT_ENTER_HANDLE_WRITE_NOT_PERMITTED(self, **kwargs):
        """
        Enter Handle(0x) response with Write Not Permitted.

        Description:
        Verify that the Implementation Under Test (IUT) can respond Write Not
        Permitted.
        """

        self.last_added_service = self.gatt.RegisterService(
            service=GattService(
                uuid=CUSTOM_SERVICE_UUID,
                characteristics=[
                    GattCharacteristic(
                        uuid=CUSTOM_CHARACTERISTIC_UUID,
                        properties=AttProperties.PROPERTY_WRITE,
                        permissions=AttPermissions.PERMISSION_NONE,
                    ),
                ],
            ))
        return "{:04x}".format(self.last_added_service.service.characteristics[0].handle)


common_uuid = "0000XXXX-0000-1000-8000-00805f9b34fb"

+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
        <option name="profile" value="GATT/CL/GAD" />
        <option name="profile" value="GATT/CL/GAR" />
        <option name="profile" value="GATT/CL/GAW" />
        <option name="profile" value="GATT/SR" />
        <option name="profile" value="HFP/AG/DIS" />
        <option name="profile" value="HFP/AG/HFI" />
        <option name="profile" value="HFP/AG/PSI" />
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
        <option name="profile" value="GATT/CL/GAD" />
        <option name="profile" value="GATT/CL/GAR" />
        <option name="profile" value="GATT/CL/GAW" />
        <option name="profile" value="GATT/SR" />
        <option name="profile" value="HFP/AG/DIS" />
        <option name="profile" value="HFP/AG/HFI" />
        <option name="profile" value="HFP/AG/PSI" />
+60 −0
Original line number Diff line number Diff line
@@ -144,6 +144,42 @@
    "GATT/CL/GAW/BV-05-C",
    "GATT/CL/GAW/BV-08-C",
    "GATT/CL/GAW/BV-09-C",
    "GATT/SR/GAC/BV-01-C",
    "GATT/SR/GAD/BV-01-C",
    "GATT/SR/GAD/BV-02-C",
    "GATT/SR/GAD/BV-03-C",
    "GATT/SR/GAD/BV-04-C",
    "GATT/SR/GAD/BV-05-C",
    "GATT/SR/GAD/BV-06-C",
    "GATT/SR/GAD/BV-07-C",
    "GATT/SR/GAD/BV-08-C",
    "GATT/SR/GAR/BI-01-C",
    "GATT/SR/GAR/BI-02-C",
    "GATT/SR/GAR/BI-04-C",
    "GATT/SR/GAR/BI-06-C",
    "GATT/SR/GAR/BI-07-C",
    "GATT/SR/GAR/BI-08-C",
    "GATT/SR/GAR/BI-10-C",
    "GATT/SR/GAR/BI-12-C",
    "GATT/SR/GAR/BI-13-C",
    "GATT/SR/GAR/BI-14-C",
    "GATT/SR/GAR/BI-16-C",
    "GATT/SR/GAR/BI-18-C",
    "GATT/SR/GAR/BI-19-C",
    "GATT/SR/GAR/BI-21-C",
    "GATT/SR/GAR/BV-01-C",
    "GATT/SR/GAR/BV-03-C",
    "GATT/SR/GAR/BV-04-C",
    "GATT/SR/GAR/BV-05-C",
    "GATT/SR/GAR/BV-06-C",
    "GATT/SR/GAW/BI-02-C",
    "GATT/SR/GAW/BI-03-C",
    "GATT/SR/GAW/BI-05-C",
    "GATT/SR/GAW/BI-07-C",
    "GATT/SR/GAW/BI-08-C",
    "GATT/SR/GAW/BI-12-C",
    "GATT/SR/UNS/BI-01-C",
    "GATT/SR/UNS/BI-02-C",
    "HFP/AG/PSI/BV-03-C",
    "HID/HOS/DAT/BV-01-C",
    "HID/HOS/HCE/BV-01-I",
@@ -376,6 +412,30 @@
    "GATT/CL/GAW/BI-32-C",
    "GATT/CL/GAW/BV-01-C",
    "GATT/CL/GAW/BV-06-C",
    "GATT/SR/GAI/BV-01-C",
    "GATT/SR/GAN/BV-01-C",
    "GATT/SR/GAR/BI-05-C",
    "GATT/SR/GAR/BI-11-C",
    "GATT/SR/GAR/BI-17-C",
    "GATT/SR/GAR/BI-22-C",
    "GATT/SR/GAR/BV-07-C",
    "GATT/SR/GAR/BV-08-C",
    "GATT/SR/GAS/BV-01-C",
    "GATT/SR/GAT/BV-01-C",
    "GATT/SR/GAW/BI-06-C",
    "GATT/SR/GAW/BI-09-C",
    "GATT/SR/GAW/BI-13-C",
    "GATT/SR/GAW/BI-32-C",
    "GATT/SR/GAW/BI-33-C",
    "GATT/SR/GAW/BV-01-C",
    "GATT/SR/GAW/BV-03-C",
    "GATT/SR/GAW/BV-05-C",
    "GATT/SR/GAW/BV-06-C",
    "GATT/SR/GAW/BV-07-C",
    "GATT/SR/GAW/BV-08-C",
    "GATT/SR/GAW/BV-09-C",
    "GATT/SR/GAW/BV-10-C",
    "GATT/SR/GAW/BV-11-C",
    "HFP/AG/DIS/BV-01-I",
    "HFP/AG/HFI/BI-03-I",
    "HFP/AG/HFI/BV-02-I",
+14 −12
Original line number Diff line number Diff line
@@ -52,6 +52,19 @@ enum AttStatusCode {
  APPLICATION_ERROR = 0x80;
}

enum AttProperties {
  PROPERTY_NONE = 0x00;
  PROPERTY_READ = 0x02;
  PROPERTY_WRITE = 0x08;
}

enum AttPermissions {
  PERMISSION_NONE = 0x00;
  PERMISSION_READ = 0x01;
  PERMISSION_WRITE = 0x10;
  PERMISSION_READ_ENCRYPTED = 0x02;
}

// A message representing a GATT service.
message GattService {
  uint32 handle = 1;
@@ -176,19 +189,8 @@ message ReadCharacteristicDescriptorResponse {
  AttStatusCode status = 2;
}

message GattServiceParams {
  string uuid = 1;
  repeated GattCharacteristicParams characteristics = 2;
}

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

message RegisterServiceRequest {
  GattServiceParams service = 1;
  GattService service = 1;
}

message RegisterServiceResponse {
Loading