1#!/usr/bin/env python3 2# 3# Copyright (C) 2018 The Android Open Source Project 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); you may not 6# use this file except in compliance with the License. You may obtain a copy of 7# the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14# License for the specific language governing permissions and limitations under 15# the License. 16 17from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest 18from acts.test_utils.bt.bt_constants import gatt_characteristic 19from acts.test_utils.bt.bt_constants import gatt_descriptor 20from acts.test_utils.bt.bt_constants import gatt_service_types 21from acts.test_utils.bt.bt_constants import gatt_characteristic_value_format 22from acts.test_utils.bt.bt_constants import gatt_char_desc_uuids 23from acts.test_utils.bt.gatts_lib import GattServerLib 24 25service_uuid = '0000a00a-0000-1000-8000-00805f9b34fb' 26characteristic_uuid = 'aa7edd5a-4d1d-4f0e-883a-d145616a1630' 27descriptor_uuid = gatt_char_desc_uuids['client_char_cfg'] 28 29gatt_server_read_descriptor_sample = { 30 'services': [{ 31 'uuid': 32 service_uuid, 33 'type': 34 gatt_service_types['primary'], 35 'characteristics': [{ 36 'uuid': 37 characteristic_uuid, 38 'properties': 39 gatt_characteristic['property_read'], 40 'permissions': 41 gatt_characteristic['permission_read'], 42 'instance_id': 43 0x002a, 44 'value_type': 45 gatt_characteristic_value_format['string'], 46 'value': 47 'Test Database', 48 'descriptors': [{ 49 'uuid': descriptor_uuid, 50 'permissions': gatt_descriptor['permission_read'], 51 }] 52 }] 53 }] 54} 55 56 57class GattServerExampleTest(BluetoothBaseTest): 58 def setup_class(self): 59 super().setup_class() 60 self.dut = self.android_devices[0] 61 62 @BluetoothBaseTest.bt_test_wrap 63 def test_create_gatt_server_db_example(self): 64 gatts = GattServerLib(log=self.log, dut=self.dut) 65 gatts.setup_gatts_db(database=gatt_server_read_descriptor_sample) 66 self.log.info(gatts.list_all_uuids()) 67 return True 68