Home | History | Annotate | Download | only in examples
      1 # /usr/bin/env python3.4
      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 
     17 from acts.test_utils.bt.BluetoothBaseTest import BluetoothBaseTest
     18 from acts.test_utils.bt.bt_constants import gatt_characteristic
     19 from acts.test_utils.bt.bt_constants import gatt_descriptor
     20 from acts.test_utils.bt.bt_constants import gatt_service_types
     21 from acts.test_utils.bt.bt_constants import gatt_characteristic_value_format
     22 from acts.test_utils.bt.bt_constants import gatt_char_desc_uuids
     23 from acts.test_utils.bt.gatts_lib import GattServerLib
     24 
     25 service_uuid = '0000a00a-0000-1000-8000-00805f9b34fb'
     26 characteristic_uuid = 'aa7edd5a-4d1d-4f0e-883a-d145616a1630'
     27 descriptor_uuid = gatt_char_desc_uuids['client_char_cfg']
     28 
     29 gatt_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 
     57 class GattServerExampleTest(BluetoothBaseTest):
     58     def __init__(self, controllers):
     59         BluetoothBaseTest.__init__(self, controllers)
     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