1#!/usr/bin/env python3
2#
3# Copyright (C) 2016 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.bt_constants import gatt_characteristic
18from acts.test_utils.bt.bt_constants import gatt_descriptor
19from acts.test_utils.bt.bt_constants import gatt_service_types
20from acts.test_utils.bt.bt_constants import gatt_char_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
23
24STRING_512BYTES = '''
2511111222223333344444555556666677777888889999900000
2611111222223333344444555556666677777888889999900000
2711111222223333344444555556666677777888889999900000
2811111222223333344444555556666677777888889999900000
2911111222223333344444555556666677777888889999900000
3011111222223333344444555556666677777888889999900000
3111111222223333344444555556666677777888889999900000
3211111222223333344444555556666677777888889999900000
3311111222223333344444555556666677777888889999900000
3411111222223333344444555556666677777888889999900000
35111112222233
36'''
37STRING_50BYTES = '''
3811111222223333344444555556666677777888889999900000
39'''
40STRING_25BYTES = '''
411111122222333334444455555
42'''
43
44INVALID_SMALL_DATABASE = {
45    'services': [{
46        'uuid': '00001800-0000-1000-8000-00805f9b34fb',
47        'type': gatt_service_types['primary'],
48        'characteristics': [{
49            'uuid': gatt_char_types['device_name'],
50            'properties': gatt_characteristic['property_read'],
51            'permissions': gatt_characteristic['permission_read'],
52            'instance_id': 0x0003,
53            'value_type': gatt_characteristic_value_format['string'],
54            'value': 'Test Database'
55        }, {
56            'uuid': gatt_char_types['appearance'],
57            'properties': gatt_characteristic['property_read'],
58            'permissions': gatt_characteristic['permission_read'],
59            'instance_id': 0x0005,
60            'value_type': gatt_characteristic_value_format['sint32'],
61            'offset': 0,
62            'value': 17
63        }, {
64            'uuid': gatt_char_types['peripheral_pref_conn'],
65            'properties': gatt_characteristic['property_read'],
66            'permissions': gatt_characteristic['permission_read'],
67            'instance_id': 0x0007
68        }]
69    }, {
70        'uuid': '00001801-0000-1000-8000-00805f9b34fb',
71        'type': gatt_service_types['primary'],
72        'characteristics': [{
73            'uuid': gatt_char_types['service_changed'],
74            'properties': gatt_characteristic['property_indicate'],
75            'permissions': gatt_characteristic['permission_read'] |
76            gatt_characteristic['permission_write'],
77            'instance_id': 0x0012,
78            'value_type': gatt_characteristic_value_format['byte'],
79            'value': [0x0000],
80            'descriptors': [{
81                'uuid': gatt_char_desc_uuids['client_char_cfg'],
82                'permissions': gatt_descriptor['permission_read'] |
83                gatt_descriptor['permission_write'],
84            }]
85        }, {
86            'uuid': '0000b004-0000-1000-8000-00805f9b34fb',
87            'properties': gatt_characteristic['property_read'],
88            'permissions': gatt_characteristic['permission_read'],
89            'instance_id': 0x0015,
90            'value_type': gatt_characteristic_value_format['byte'],
91            'value': [0x04]
92        }]
93    }]
94}
95
96# Corresponds to the PTS defined LARGE_DB_1
97LARGE_DB_1 = {
98    'services': [
99        {
100            'uuid': '0000a00b-0000-1000-8000-00805f9b34fb',
101            'type': gatt_service_types['primary'],
102            'handles': 7,
103            'characteristics': [{
104                'uuid': '0000b008-0000-1000-8000-00805f9b34fb',
105                'properties': gatt_characteristic['property_read'] |
106                gatt_characteristic['property_write'] |
107                gatt_characteristic['property_extended_props'],
108                'permissions': gatt_characteristic['permission_read'] |
109                gatt_characteristic['permission_write'],
110                'value_type': gatt_characteristic_value_format['byte'],
111                'value': [0x08],
112                'descriptors': [{
113                    'uuid': '0000b015-0000-1000-8000-00805f9b34fb',
114                    'permissions': gatt_descriptor['permission_read'] |
115                    gatt_descriptor['permission_write'],
116                }, {
117                    'uuid': '0000b016-0000-1000-8000-00805f9b34fb',
118                    'permissions': gatt_descriptor['permission_read'] |
119                    gatt_descriptor['permission_write'],
120                }, {
121                    'uuid': '0000b017-0000-1000-8000-00805f9b34fb',
122                    'permissions':
123                    gatt_characteristic['permission_read_encrypted_mitm'],
124                }]
125            }]
126        },
127        {
128            'uuid': '0000a00d-0000-1000-8000-00805f9b34fb',
129            'type': gatt_service_types['secondary'],
130            'handles': 6,
131            'characteristics': [{
132                'uuid': '0000b00c-0000-1000-8000-00805f9b34fb',
133                'properties': gatt_characteristic['property_extended_props'],
134                'permissions': gatt_characteristic['permission_read'],
135                'value_type': gatt_characteristic_value_format['byte'],
136                'value': [0x0C],
137            }, {
138                'uuid': '0000b00b-0000-0000-0123-456789abcdef',
139                'properties': gatt_characteristic['property_extended_props'],
140                'permissions': gatt_characteristic['permission_read'],
141                'value_type': gatt_characteristic_value_format['byte'],
142                'value': [0x0B],
143            }]
144        },
145        {
146            'uuid': '0000a00a-0000-1000-8000-00805f9b34fb',
147            'type': gatt_service_types['primary'],
148            'handles': 10,
149            'characteristics': [{
150                'uuid': '0000b001-0000-1000-8000-00805f9b34fb',
151                'properties': gatt_characteristic['property_read'] |
152                gatt_characteristic['property_write'],
153                'permissions': gatt_characteristic['permission_read'] |
154                gatt_characteristic['permission_write'],
155                'value_type': gatt_characteristic_value_format['byte'],
156                'value': [0x01],
157            }, {
158                'uuid': '0000b002-0000-0000-0123-456789abcdef',
159                'properties': gatt_characteristic['property_extended_props'],
160                'permissions': gatt_characteristic['permission_read'],
161                'value_type': gatt_characteristic_value_format['string'],
162                'value': STRING_512BYTES,
163            }, {
164                'uuid': '0000b004-0000-0000-0123-456789abcdef',
165                'properties': gatt_characteristic['property_read'],
166                'permissions': gatt_characteristic['permission_read'],
167                'value_type': gatt_characteristic_value_format['string'],
168                'value': STRING_512BYTES,
169            }, {
170                'uuid': '0000b002-0000-0000-0123-456789abcdef',
171                'properties': gatt_characteristic['property_write'],
172                'permissions': gatt_characteristic['permission_write'],
173                'value_type': gatt_characteristic_value_format['string'],
174                'value': '11111222223333344444555556666677777888889999900000',
175            }, {
176                'uuid': '0000b003-0000-0000-0123-456789abcdef',
177                'properties': gatt_characteristic['property_write'],
178                'permissions': gatt_characteristic['permission_write'],
179                'value_type': gatt_characteristic_value_format['byte'],
180                'value': [0x03],
181            }]
182        },
183        {
184            'uuid': '0000a00b-0000-1000-8000-00805f9b34fb',
185            'type': gatt_service_types['primary'],
186            'handles': 3,
187            'characteristics': [{
188                'uuid': '0000b007-0000-1000-8000-00805f9b34fb',
189                'properties': gatt_characteristic['property_write'],
190                'permissions': gatt_characteristic['permission_write'],
191                'value_type': gatt_characteristic_value_format['byte'],
192                'value': [0x07],
193            }]
194        },
195        {
196            'uuid': '0000a00b-0000-1000-8000-00805f9b34fb',
197            'type': gatt_service_types['primary'],
198            'handles': 3,
199            'characteristics': [{
200                'uuid': '0000b006-0000-1000-8000-00805f9b34fb',
201                'properties': gatt_characteristic['property_read'] |
202                gatt_characteristic['property_write'] |
203                gatt_characteristic['property_write_no_response'] |
204                gatt_characteristic['property_notify'] |
205                gatt_characteristic['property_indicate'],
206                'permissions': gatt_characteristic['permission_write'] |
207                gatt_characteristic['permission_read'],
208                'value_type': gatt_characteristic_value_format['byte'],
209                'value': [0x06],
210            }]
211        },
212        {
213            'uuid': '0000a00b-0000-1000-8000-00805f9b34fb',
214            'type': gatt_service_types['primary'],
215            'handles': 12,
216            'characteristics': [
217                {
218                    'uuid': '0000b004-0000-1000-8000-00805f9b34fb',
219                    'properties': gatt_characteristic['property_read'] |
220                    gatt_characteristic['property_write'],
221                    'permissions': gatt_characteristic['permission_write'] |
222                    gatt_characteristic['permission_read'],
223                    'value_type': gatt_characteristic_value_format['byte'],
224                    'value': [0x04],
225                },
226                {
227                    'uuid': '0000b004-0000-1000-8000-00805f9b34fb',
228                    'properties': gatt_characteristic['property_read'] |
229                    gatt_characteristic['property_write'],
230                    'permissions': gatt_characteristic['permission_write'] |
231                    gatt_characteristic['permission_read'],
232                    'value_type': gatt_characteristic_value_format['byte'],
233                    'value': [0x04],
234                    'descriptors': [{
235                        'uuid': gatt_char_desc_uuids['server_char_cfg'],
236                        'permissions': gatt_descriptor['permission_read'] |
237                        gatt_descriptor['permission_write'],
238                        'value': gatt_descriptor['disable_notification_value']
239                    }]
240                },
241                {
242                    'uuid': '0000b004-0000-1000-8000-00805f9b34fb',
243                    'properties': 0x0,
244                    'permissions': 0x0,
245                    'value_type': gatt_characteristic_value_format['byte'],
246                    'value': [0x04],
247                    'descriptors': [{
248                        'uuid': '0000b012-0000-1000-8000-00805f9b34fb',
249                        'permissions': gatt_descriptor['permission_read'] |
250                        gatt_descriptor['permission_write'],
251                        'value': [
252                            0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
253                            0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
254                            0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44,
255                            0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22,
256                            0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
257                            0x11, 0x22, 0x33
258                        ]
259                    }]
260                },
261                {
262                    'uuid': '0000b004-0000-1000-8000-00805f9b34fb',
263                    'properties': gatt_characteristic['property_read'],
264                    'permissions': gatt_characteristic['permission_read'],
265                    'value_type': gatt_characteristic_value_format['byte'],
266                    'value': [0x04],
267                    'descriptors': [{
268                        'uuid': '0000b012-0000-1000-8000-00805f9b34fb',
269                        'permissions': gatt_descriptor['permission_read'],
270                        'value': [
271                            0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88,
272                            0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
273                            0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44,
274                            0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0x11, 0x22,
275                            0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
276                            0x11, 0x22, 0x33
277                        ]
278                    }]
279                },
280            ]
281        },
282        {
283            'uuid': '0000a00b-0000-1000-8000-00805f9b34fb',
284            'type': gatt_service_types['primary'],
285            'handles': 7,
286            'characteristics': [{
287                'uuid': '0000b005-0000-1000-8000-00805f9b34fb',
288                'properties': gatt_characteristic['property_write'] |
289                gatt_characteristic['property_extended_props'],
290                'permissions': gatt_characteristic['permission_write'] |
291                gatt_characteristic['permission_read'],
292                'value_type': gatt_characteristic_value_format['byte'],
293                'value': [0x05],
294                'descriptors': [{
295                    'uuid': gatt_char_desc_uuids['char_ext_props'],
296                    'permissions': gatt_descriptor['permission_read'],
297                    'value': [0x03, 0x00]
298                }, {
299                    'uuid': gatt_char_desc_uuids['char_user_desc'],
300                    'permissions': gatt_descriptor['permission_read'] |
301                    gatt_descriptor['permission_write'],
302                    'value': [
303                        0x65, 0x66, 0x67, 0x68, 0x69, 0x70, 0x71, 0x72, 0x73,
304                        0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x80, 0x81, 0x82,
305                        0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x90
306                    ]
307                }, {
308                    'uuid': gatt_char_desc_uuids['char_fmt_uuid'],
309                    'permissions':
310                    gatt_descriptor['permission_read_encrypted_mitm'],
311                    'value': [0x00, 0x01, 0x30, 0x01, 0x11, 0x31]
312                }, {
313                    'uuid': '0000d5d4-0000-0000-0123-456789abcdef',
314                    'permissions': gatt_descriptor['permission_read'],
315                    'value': [0x44]
316                }]
317            }]
318        },
319        {
320            'uuid': '0000a00c-0000-0000-0123-456789abcdef',
321            'type': gatt_service_types['primary'],
322            'handles': 7,
323            'characteristics': [{
324                'uuid': '0000b009-0000-0000-0123-456789abcdef',
325                'enforce_initial_attribute_length': True,
326                'properties': gatt_characteristic['property_write'] |
327                gatt_characteristic['property_extended_props'] |
328                gatt_characteristic['property_read'],
329                'permissions': gatt_characteristic['permission_write'] |
330                gatt_characteristic['permission_read'],
331                'value_type': gatt_characteristic_value_format['byte'],
332                'value': [0x09],
333                'descriptors': [{
334                    'uuid': gatt_char_desc_uuids['char_ext_props'],
335                    'permissions': gatt_descriptor['permission_read'],
336                    'value': gatt_descriptor['enable_notification_value']
337                }, {
338                    'uuid': '0000d9d2-0000-0000-0123-456789abcdef',
339                    'permissions': gatt_descriptor['permission_read'] |
340                    gatt_descriptor['permission_write'],
341                    'value': [0x22]
342                }, {
343                    'uuid': '0000d9d3-0000-0000-0123-456789abcdef',
344                    'permissions': gatt_descriptor['permission_write'],
345                    'value': [0x33]
346                }]
347            }]
348        },
349        {
350            'uuid': '0000a00f-0000-1000-8000-00805f9b34fb',
351            'type': gatt_service_types['primary'],
352            'handles': 18,
353            'characteristics': [
354                {
355                    'uuid': '0000b00e-0000-1000-8000-00805f9b34fb',
356                    'properties': gatt_characteristic['property_read'],
357                    'permissions': gatt_characteristic['permission_read'],
358                    'value_type': gatt_characteristic_value_format['string'],
359                    'value': "Length is ",
360                    'descriptors': [{
361                        'uuid': gatt_char_desc_uuids['char_fmt_uuid'],
362                        'permissions': gatt_descriptor['permission_read'],
363                        'value': [0x19, 0x00, 0x00, 0x30, 0x01, 0x00, 0x00]
364                    }]
365                },
366                {
367                    'uuid': '0000b00f-0000-1000-8000-00805f9b34fb',
368                    'enforce_initial_attribute_length': True,
369                    'properties': gatt_characteristic['property_read'] |
370                    gatt_characteristic['property_write'],
371                    'permissions': gatt_characteristic['permission_read'] |
372                    gatt_characteristic['permission_write'],
373                    'value_type': gatt_characteristic_value_format['byte'],
374                    'value': [0x65],
375                    'descriptors': [{
376                        'uuid': gatt_char_desc_uuids['char_fmt_uuid'],
377                        'permissions': gatt_descriptor['permission_read'],
378                        'value': [0x04, 0x00, 0x01, 0x27, 0x01, 0x01, 0x00]
379                    }]
380                },
381                {
382                    'uuid': '0000b006-0000-1000-8000-00805f9b34fb',
383                    'properties': gatt_characteristic['property_read'] |
384                    gatt_characteristic['property_write'],
385                    'permissions': gatt_characteristic['permission_read'] |
386                    gatt_characteristic['permission_write'],
387                    'value_type': gatt_characteristic_value_format['byte'],
388                    'value': [0x34, 0x12],
389                    'descriptors': [{
390                        'uuid': gatt_char_desc_uuids['char_fmt_uuid'],
391                        'permissions': gatt_descriptor['permission_read'],
392                        'value': [0x06, 0x00, 0x10, 0x27, 0x01, 0x02, 0x00]
393                    }]
394                },
395                {
396                    'uuid': '0000b007-0000-1000-8000-00805f9b34fb',
397                    'enforce_initial_attribute_length': True,
398                    'properties': gatt_characteristic['property_read'] |
399                    gatt_characteristic['property_write'],
400                    'permissions': gatt_characteristic['permission_read'] |
401                    gatt_characteristic['permission_write'],
402                    'value_type': gatt_characteristic_value_format['byte'],
403                    'value': [0x04, 0x03, 0x02, 0x01],
404                    'descriptors': [{
405                        'uuid': gatt_char_desc_uuids['char_fmt_uuid'],
406                        'permissions': gatt_descriptor['permission_read'],
407                        'value': [0x08, 0x00, 0x17, 0x27, 0x01, 0x03, 0x00]
408                    }]
409                },
410                {
411                    'uuid': '0000b010-0000-1000-8000-00805f9b34fb',
412                    'properties': gatt_characteristic['property_read'],
413                    'permissions': gatt_characteristic['permission_read'],
414                    'value_type': gatt_characteristic_value_format['byte'],
415                    'value': [0x65, 0x34, 0x12, 0x04, 0x03, 0x02, 0x01],
416                    'descriptors': [{
417                        'uuid': gatt_char_desc_uuids['char_agreg_fmt'],
418                        'permissions': gatt_descriptor['permission_read'],
419                        'value': [0xa6, 0x00, 0xa9, 0x00, 0xac, 0x00]
420                    }]
421                },
422                {
423                    'uuid': '0000b011-0000-1000-8000-00805f9b34fb',
424                    'properties': gatt_characteristic['write_type_signed']
425                    |  #for some reason 0x40 is not working...
426                    gatt_characteristic['property_read'],
427                    'permissions': gatt_characteristic['permission_read'] |
428                    gatt_characteristic['permission_write'],
429                    'value_type': gatt_characteristic_value_format['byte'],
430                    'value': [0x12]
431                }
432            ]
433        },
434        {
435            'uuid': '0000a00c-0000-1000-8000-00805f9b34fb',
436            'type': gatt_service_types['primary'],
437            'handles': 30,
438            'characteristics': [{
439                'uuid': '0000b00a-0000-1000-8000-00805f9b34fb',
440                'properties': gatt_characteristic['property_read'],
441                'permissions': gatt_characteristic['permission_read'],
442                'value_type': gatt_characteristic_value_format['byte'],
443                'value': [0x0a],
444            }, {
445                'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
446                'properties': gatt_characteristic['property_read'] |
447                gatt_characteristic['property_write'],
448                'permissions': gatt_characteristic['permission_read'] |
449                gatt_characteristic['permission_write'],
450                'value_type': gatt_characteristic_value_format['string'],
451                'value': "111112222233333444445",
452                'descriptors': [{
453                    'uuid': '0000b012-0000-1000-8000-00805f9b34fb',
454                    'permissions': gatt_descriptor['permission_read'] |
455                    gatt_descriptor['permission_write'],
456                    'value': [
457                        0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
458                        0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x11
459                    ]
460                }]
461            }, {
462                'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
463                'properties': gatt_characteristic['property_read'] |
464                gatt_characteristic['property_write'],
465                'permissions': gatt_characteristic['permission_read'] |
466                gatt_characteristic['permission_write'],
467                'value_type': gatt_characteristic_value_format['string'],
468                'value': "2222233333444445555566",
469                'descriptors': [{
470                    'uuid': '0000b013-0000-1000-8000-00805f9b34fb',
471                    'permissions': gatt_descriptor['permission_read'] |
472                    gatt_descriptor['permission_write'],
473                    'value': [
474                        0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
475                        0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x11, 0x22
476                    ]
477                }]
478            }, {
479                'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
480                'properties': gatt_characteristic['property_read'] |
481                gatt_characteristic['property_write'],
482                'permissions': gatt_characteristic['permission_read'] |
483                gatt_characteristic['permission_write'],
484                'value_type': gatt_characteristic_value_format['string'],
485                'value': "33333444445555566666777",
486                'descriptors': [{
487                    'uuid': '0000b014-0000-1000-8000-00805f9b34fb',
488                    'permissions': gatt_descriptor['permission_read'] |
489                    gatt_descriptor['permission_write'],
490                    'value': [
491                        0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
492                        0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x11, 0x22, 0x33
493                    ]
494                }]
495            }, {
496                'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
497                'properties': gatt_characteristic['property_read'] |
498                gatt_characteristic['property_write'],
499                'permissions': gatt_characteristic['permission_read'] |
500                gatt_characteristic['permission_write'],
501                'value_type': gatt_characteristic_value_format['byte'],
502                'value': [
503                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
504                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
505                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
506                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
507                    0x11, 0x22, 0x33
508                ],
509                'descriptors': [{
510                    'uuid': '0000b012-0000-1000-8000-00805f9b34fb',
511                    'permissions': gatt_descriptor['permission_read'] |
512                    gatt_descriptor['permission_write'],
513                    'value': [
514                        0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
515                        0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56,
516                        0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34,
517                        0x56, 0x78, 0x90, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
518                        0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33
519                    ]
520                }]
521            }, {
522                'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
523                'properties': gatt_characteristic['property_read'] |
524                gatt_characteristic['property_write'],
525                'permissions': gatt_characteristic['permission_read'] |
526                gatt_characteristic['permission_write'],
527                'value_type': gatt_characteristic_value_format['byte'],
528                'value': [
529                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
530                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
531                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
532                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
533                    0x11, 0x22, 0x33, 0x44
534                ],
535                'descriptors': [{
536                    'uuid': '0000b013-0000-1000-8000-00805f9b34fb',
537                    'permissions': gatt_descriptor['permission_read'] |
538                    gatt_descriptor['permission_write'],
539                    'value': [
540                        0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
541                        0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56,
542                        0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34,
543                        0x56, 0x78, 0x90, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
544                        0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44
545                    ]
546                }]
547            }, {
548                'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
549                'properties': gatt_characteristic['property_read'] |
550                gatt_characteristic['property_write'],
551                'permissions': gatt_characteristic['permission_read'] |
552                gatt_characteristic['permission_write'],
553                'value_type': gatt_characteristic_value_format['byte'],
554                'value': [
555                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
556                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
557                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
558                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
559                    0x11, 0x22, 0x33, 0x44, 0x55
560                ],
561                'descriptors': [{
562                    'uuid': '0000b014-0000-1000-8000-00805f9b34fb',
563                    'permissions': gatt_descriptor['permission_read'] |
564                    gatt_descriptor['permission_write'],
565                    'value': [
566                        0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
567                        0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56,
568                        0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34,
569                        0x56, 0x78, 0x90, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
570                        0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55
571                    ]
572                }]
573            }, {
574                'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
575                'properties': gatt_characteristic['property_read'] |
576                gatt_characteristic['property_write'],
577                'permissions': gatt_characteristic['permission_read'] |
578                gatt_characteristic['permission_write'],
579                'value_type': gatt_characteristic_value_format['string'],
580                'value': "1111122222333334444455555666667777788888999",
581                'descriptors': [{
582                    'uuid': '0000b012-0000-1000-8000-00805f9b34fb',
583                    'permissions': gatt_descriptor['permission_read'] |
584                    gatt_descriptor['permission_write'],
585                    'value': [
586                        0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
587                        0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56,
588                        0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34,
589                        0x56, 0x78, 0x90, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
590                        0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33
591                    ]
592                }]
593            }, {
594                'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
595                'properties': gatt_characteristic['property_read'] |
596                gatt_characteristic['property_write'],
597                'permissions': gatt_characteristic['permission_read'] |
598                gatt_characteristic['permission_write'],
599                'value_type': gatt_characteristic_value_format['string'],
600                'value': "22222333334444455555666667777788888999990000",
601                'descriptors': [{
602                    'uuid': '0000b013-0000-1000-8000-00805f9b34fb',
603                    'permissions': gatt_descriptor['permission_read'] |
604                    gatt_descriptor['permission_write'],
605                    'value': [
606                        0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
607                        0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56,
608                        0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34,
609                        0x56, 0x78, 0x90, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
610                        0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44
611                    ]
612                }]
613            }, {
614                'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
615                'properties': gatt_characteristic['property_read'] |
616                gatt_characteristic['property_write'],
617                'permissions': gatt_characteristic['permission_read'] |
618                gatt_characteristic['permission_write'],
619                'value_type': gatt_characteristic_value_format['string'],
620                'value': "333334444455555666667777788888999990000011111",
621                'descriptors': [{
622                    'uuid': '0000b014-0000-1000-8000-00805f9b34fb',
623                    'permissions': gatt_descriptor['permission_read'] |
624                    gatt_descriptor['permission_write'],
625                    'value': [
626                        0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
627                        0x00, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56,
628                        0x78, 0x90, 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34,
629                        0x56, 0x78, 0x90, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
630                        0x77, 0x88, 0x99, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55
631                    ]
632                }]
633            }]
634        },
635    ]
636}
637
638# Corresponds to the PTS defined LARGE_DB_2
639LARGE_DB_2 = {
640    'services': [
641        {
642            'uuid': '0000a00c-0000-0000-0123-456789abdcef',
643            'type': gatt_service_types['primary'],
644            'characteristics': [{
645                'uuid': '0000b00a-0000-1000-8000-00805f9b34fb',
646                'instance_id': 0x0003,
647                'properties': gatt_characteristic['property_read'],
648                'permissions': gatt_characteristic['permission_read'],
649                'value_type': gatt_characteristic_value_format['byte'],
650                'value': [0x04],
651            }, {
652                'uuid': '0000b0002-0000-1000-8000-00805f9b34fb',
653                'instance_id': 0x0005,
654                'properties': 0x0a,
655                'permissions': gatt_characteristic['permission_read'] |
656                gatt_characteristic['permission_write'],
657                'value_type': gatt_characteristic_value_format['string'],
658                'value': '111112222233333444445',
659            }, {
660                'uuid': '0000b0002-0000-1000-8000-00805f9b34fb',
661                'instance_id': 0x0007,
662                'properties': 0x0a,
663                'permissions': gatt_characteristic['permission_read'] |
664                gatt_characteristic['permission_write'],
665                'value_type': gatt_characteristic_value_format['string'],
666                'value': '2222233333444445555566',
667            }, {
668                'uuid': '0000b0002-0000-1000-8000-00805f9b34fb',
669                'instance_id': 0x0009,
670                'properties': 0x0a,
671                'permissions': gatt_characteristic['permission_read'] |
672                gatt_characteristic['permission_write'],
673                'value_type': gatt_characteristic_value_format['string'],
674                'value': '33333444445555566666777',
675            }, {
676                'uuid': '0000b0002-0000-1000-8000-00805f9b34fb',
677                'instance_id': 0x000b,
678                'properties': 0x0a0,
679                'permissions': gatt_characteristic['permission_read'] |
680                gatt_characteristic['permission_write'],
681                'value_type': gatt_characteristic_value_format['string'],
682                'value': '1111122222333334444455555666667777788888999',
683            }, {
684                'uuid': '0000b0002-0000-1000-8000-00805f9b34fb',
685                'instance_id': 0x000d,
686                'properties': 0x0a,
687                'permissions': gatt_characteristic['permission_read'] |
688                gatt_characteristic['permission_write'],
689                'value_type': gatt_characteristic_value_format['string'],
690                'value': '22222333334444455555666667777788888999990000',
691            }, {
692                'uuid': '0000b0002-0000-1000-8000-00805f9b34fb',
693                'instance_id': 0x000f,
694                'properties': 0x0a,
695                'permissions': gatt_characteristic['permission_read'] |
696                gatt_characteristic['permission_write'],
697                'value_type': gatt_characteristic_value_format['string'],
698                'value': '333334444455555666667777788888999990000011111',
699            }]
700        },
701        {
702            'uuid': '0000a00c-0000-0000-0123-456789abcdef',
703            'handles': 5,
704            'type': gatt_service_types['primary'],
705            'characteristics': [{
706                'uuid': '0000b009-0000-0000-0123-456789abcdef',
707                'instance_id': 0x0023,
708                'properties': 0x8a,
709                'permissions': gatt_characteristic['permission_read'] |
710                gatt_characteristic['permission_write'],
711                'value_type': gatt_characteristic_value_format['byte'],
712                'value': [0x09],
713                'descriptors': [{
714                    'uuid': '0000d9d2-0000-0000-0123-456789abcdef',
715                    'permissions': gatt_descriptor['permission_read'] |
716                    gatt_descriptor['permission_write'],
717                    'value': [0x22]
718                }, {
719                    'uuid': '0000d9d3-0000-0000-0123-456789abcdef',
720                    'permissions': gatt_descriptor['permission_write'],
721                    'value': [0x33]
722                }, {
723                    'uuid': gatt_char_desc_uuids['char_ext_props'],
724                    'permissions': gatt_descriptor['permission_write'],
725                    'value': gatt_descriptor['enable_notification_value']
726                }]
727            }]
728        },
729        {
730            'uuid': '0000a00b-0000-1000-8000-00805f9b34fb',
731            'type': gatt_service_types['primary'],
732            'characteristics': [{
733                'uuid': '0000b007-0000-1000-8000-00805f9b34fb',
734                'instance_id': 0x0012,
735                'properties': 0x0a,
736                'permissions': gatt_characteristic['permission_read'] |
737                gatt_characteristic['permission_write'],
738                'value_type': gatt_characteristic_value_format['byte'],
739                'value': [0x04],
740            }]
741        },
742    ]
743}
744
745DB_TEST = {
746    'services': [{
747        'uuid': '0000a00b-0000-1000-8000-00805f9b34fb',
748        'type': gatt_service_types['primary'],
749        'characteristics': [{
750            'uuid': '0000b004-0000-1000-8000-00805f9b34fb',
751            'properties': 0x02 | 0x08,
752            'permissions': 0x10 | 0x01,
753            'value_type': gatt_characteristic_value_format['byte'],
754            'value': [0x01],
755            'enforce_initial_attribute_length': True,
756            'descriptors': [{
757                'uuid': '0000b004-0000-1000-8000-00805f9b34fb',
758                'permissions': gatt_descriptor['permission_read'] |
759                gatt_descriptor['permission_write'],
760                'value': [0x01] * 30
761            }]
762        }, ]
763    }]
764}
765
766PTS_TEST2 = {
767    'services': [{
768        'uuid': '0000a00b-0000-1000-8000-00805f9b34fb',
769        'type': gatt_service_types['primary'],
770        'characteristics': [
771            {
772                'uuid': '000018ba-0000-1000-8000-00805f9b34fb',
773                'properties': 0x02,
774                'permissions': 0x10 | 0x01,
775                'value_type': gatt_characteristic_value_format['string'],
776                'value': STRING_512BYTES,
777            },
778            {
779                'uuid': '000060aa-0000-0000-0123-456789abcdef',
780                'properties': 0x02,
781                'permissions': 0x10 | 0x01,
782                'value_type': gatt_characteristic_value_format['string'],
783                'value': STRING_512BYTES,
784            },
785            {
786                'uuid': '00000af2-0000-1000-8000-00805f9b34fb',
787                'properties': 0x20,
788                'permissions': 0x10 | 0x01,
789                'value_type': gatt_characteristic_value_format['string'],
790                'value': STRING_512BYTES,
791            },
792            {
793                'uuid': '000000af2-0000-1000-8000-00805f9b34fb',
794                'properties': 0x08,
795                'permissions': 0x10 | 0x01,
796                'value_type': gatt_characteristic_value_format['string'],
797                'value': STRING_512BYTES,
798            },
799            {
800                'uuid': '000004d5e-0000-1000-8000-00805f9b34fb',
801                'properties': 0x08,
802                'permissions': 0x10 | 0x01,
803                'value_type': gatt_characteristic_value_format['string'],
804                'value': STRING_512BYTES,
805            },
806            {
807                'uuid': '000001b44-0000-1000-8000-00805f9b34fb',
808                'properties': 0x08,
809                'permissions': 0x10 | 0x01,
810                'value_type': gatt_characteristic_value_format['string'],
811                'value': STRING_512BYTES,
812            },
813            {
814                'uuid': '000006b98-0000-1000-8000-00805f9b34fb',
815                'properties': 0x02 | 0x08 | 0x10 | 0x04,
816                'permissions': 0x10 | 0x01,
817                'value_type': gatt_characteristic_value_format['string'],
818                'value': STRING_512BYTES,
819            },
820            {
821                'uuid': '00000247f-0000-1000-8000-00805f9b34fb',
822                'properties': 0x02 | 0x08,
823                'permissions': 0x10 | 0x01,
824                'value_type': gatt_characteristic_value_format['string'],
825                'value': STRING_512BYTES,
826            },
827            {
828                'uuid': '00000247f-0000-1000-8000-00805f9b34fb',
829                'properties': 0x02 | 0x08,
830                'permissions': 0x10 | 0x01,
831                'value_type': gatt_characteristic_value_format['string'],
832                'value': STRING_512BYTES,
833            },
834            {
835                'uuid': '00000247f-0000-1000-8000-00805f9b34fb',
836                'properties': 0x00,
837                'permissions': 0x00,
838                'value_type': gatt_characteristic_value_format['string'],
839                'value': STRING_512BYTES,
840            },
841            {
842                'uuid': '00000247f-0000-1000-8000-00805f9b34fb',
843                'properties': 0x02,
844                'permissions': 0x10,
845                'value_type': gatt_characteristic_value_format['string'],
846                'value': STRING_512BYTES,
847            },
848            {
849                'uuid': '000000d62-0000-1000-8000-00805f9b34fb',
850                'properties': 0x02 | 0x08 | 0x80,
851                'permissions': 0x10 | 0x01,
852                'value_type': gatt_characteristic_value_format['string'],
853                'value': STRING_512BYTES,
854            },
855            {
856                'uuid': '000002e85-0000-1000-8000-00805f9b34fb',
857                'properties': 0x02 | 0x08,
858                'permissions': 0x10 | 0x01,
859                'value_type': gatt_characteristic_value_format['string'],
860                'value': STRING_512BYTES,
861            },
862            {
863                'uuid': '000004a64-0000-0000-0123-456789abcdef',
864                'properties': 0x02 | 0x08 | 0x80,
865                'permissions': 0x10 | 0x01,
866                'value_type': gatt_characteristic_value_format['string'],
867                'value': STRING_512BYTES,
868            },
869            {
870                'uuid': '000005b4a-0000-1000-8000-00805f9b34fb',
871                'properties': 0x02,
872                'permissions': 0x10,
873                'value_type': gatt_characteristic_value_format['string'],
874                'value': STRING_512BYTES,
875            },
876            {
877                'uuid': '000001c81-0000-1000-8000-00805f9b34fb',
878                'properties': 0x02,
879                'permissions': 0x10,
880                'value_type': gatt_characteristic_value_format['string'],
881                'value': STRING_512BYTES,
882            },
883            {
884                'uuid': '000006b98-0000-1000-8000-00805f9b34fb',
885                'properties': 0x02 | 0x08,
886                'permissions': 0x10 | 0x01,
887                'value_type': gatt_characteristic_value_format['string'],
888                'value': STRING_512BYTES,
889            },
890            {
891                'uuid': '000001b44-0000-1000-8000-00805f9b34fb',
892                'properties': 0x02 | 0x08,
893                'permissions': 0x10 | 0x01,
894                'value_type': gatt_characteristic_value_format['string'],
895                'value': STRING_512BYTES,
896            },
897            {
898                'uuid': '000000c55-0000-1000-8000-00805f9b34fb',
899                'properties': 0x02,
900                'permissions': 0x10,
901                'value_type': gatt_characteristic_value_format['string'],
902                'value': STRING_512BYTES,
903            },
904            {
905                'uuid': '0000014dd-0000-1000-8000-00805f9b34fb',
906                'properties': 0x02,
907                'permissions': 0x10,
908                'value_type': gatt_characteristic_value_format['string'],
909                'value': STRING_512BYTES,
910            },
911            {
912                'uuid': '000000c55-0000-1000-8000-00805f9b34fb',
913                'properties': 0x02,
914                'permissions': 0x10,
915                'value_type': gatt_characteristic_value_format['string'],
916                'value': STRING_512BYTES,
917            },
918            {
919                'uuid': '000000c55-0000-1000-8000-00805f9b34fb',
920                'properties': 0x02,
921                'permissions': 0x10,
922                'value_type': gatt_characteristic_value_format['string'],
923                'value': STRING_512BYTES,
924            },
925            {
926                'uuid': '000000c55-0000-1000-8000-00805f9b34fb',
927                'properties': 0x02,
928                'permissions': 0x10,
929                'value_type': gatt_characteristic_value_format['string'],
930                'value': STRING_512BYTES,
931            },
932            {
933                'uuid': '000000c55-0000-1000-8000-00805f9b34fb',
934                'properties': 0x02,
935                'permissions': 0x10,
936                'value_type': gatt_characteristic_value_format['string'],
937                'value': STRING_512BYTES,
938            },
939            {
940                'uuid': '00000008f-0000-1000-8000-00805f9b34fb',
941                'properties': 0x02,
942                'permissions': 0x10,
943                'value_type': gatt_characteristic_value_format['string'],
944                'value': STRING_512BYTES,
945            },
946            {
947                'uuid': '000000af2-0000-1000-8000-00805f9b34fb',
948                'properties': 0x02 | 0x08,
949                'permissions': 0x10 | 0x01,
950                'value_type': gatt_characteristic_value_format['byte'],
951                'value': [
952                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
953                    0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32
954                ],
955            },
956            {
957                'uuid': '000000af2-0000-1000-8000-00805f9b34fb',
958                'properties': 0x02 | 0x08,
959                'permissions': 0x10 | 0x01,
960                'value_type': gatt_characteristic_value_format['byte'],
961                'value': [
962                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
963                    0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32
964                ],
965            },
966            {
967                'uuid': '000000af2-0000-1000-8000-00805f9b34fb',
968                'properties': 0x02 | 0x08,
969                'permissions': 0x10 | 0x01,
970                'value_type': gatt_characteristic_value_format['byte'],
971                'value': [
972                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
973                    0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32
974                ],
975            },
976            {
977                'uuid': '000000af2-0000-1000-8000-00805f9b34fb',
978                'properties': 0x02 | 0x08,
979                'permissions': 0x10 | 0x01,
980                'value_type': gatt_characteristic_value_format['byte'],
981                'value': [
982                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
983                    0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32
984                ],
985            },
986            {
987                'uuid': '000000af2-0000-1000-8000-00805f9b34fb',
988                'properties': 0x02 | 0x08,
989                'permissions': 0x10 | 0x01,
990                'value_type': gatt_characteristic_value_format['byte'],
991                'value': [
992                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
993                    0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32
994                ],
995            },
996            {
997                'uuid': '000000af2-0000-1000-8000-00805f9b34fb',
998                'properties': 0x02 | 0x08,
999                'permissions': 0x10 | 0x01,
1000                'value_type': gatt_characteristic_value_format['byte'],
1001                'value': [
1002                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
1003                    0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32
1004                ],
1005            },
1006            {
1007                'uuid': '000000af2-0000-1000-8000-00805f9b34fb',
1008                'properties': 0x02 | 0x08,
1009                'permissions': 0x10 | 0x01,
1010                'value_type': gatt_characteristic_value_format['byte'],
1011                'value': [
1012                    0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00,
1013                    0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x32
1014                ],
1015            },
1016            {
1017                'uuid': '000002aad-0000-1000-8000-00805f9b34fb',
1018                'properties': 0x02 | 0x08,
1019                'permissions': 0x10 | 0x01,
1020                'value_type': gatt_characteristic_value_format['string'],
1021                'value': STRING_512BYTES,
1022            },
1023            {
1024                'uuid': '000002ab0-0000-1000-8000-00805f9b34fb',
1025                'properties': 0x02 | 0x08,
1026                'permissions': 0x10 | 0x01,
1027                'value_type': gatt_characteristic_value_format['string'],
1028                'value': STRING_512BYTES,
1029            },
1030            {
1031                'uuid': '000002ab3-0000-1000-8000-00805f9b34fb',
1032                'properties': 0x02 | 0x08,
1033                'permissions': 0x10 | 0x01,
1034                'value_type': gatt_characteristic_value_format['string'],
1035                'value': STRING_512BYTES,
1036            },
1037        ]
1038    }]
1039}
1040
1041PTS_TEST = {
1042    'services': [{
1043        'uuid': '0000a00b-0000-1000-8000-00805f9b34fb',
1044        'type': gatt_service_types['primary'],
1045        'characteristics': [
1046            {
1047                'uuid': '000018ba-0000-1000-8000-00805f9b34fb',
1048                'properties': 0x02 | 0x08,
1049                'permissions': 0x10 | 0x01,
1050                'value_type': gatt_characteristic_value_format['string'],
1051                'value': STRING_25BYTES,
1052            },
1053            {
1054                'uuid': '000060aa-0000-1000-8000-00805f9b34fb',
1055                'properties': 0x02 | 0x08,
1056                'permissions': 0x10 | 0x01,
1057                'value_type': gatt_characteristic_value_format['string'],
1058                'value': STRING_25BYTES,
1059            },
1060        ]
1061    }]
1062}
1063
1064# Corresponds to the PTS defined LARGE_DB_3
1065LARGE_DB_3 = {
1066    'services': [
1067        {
1068            'uuid': '0000a00b-0000-1000-8000-00805f9b34fb',
1069            'type': gatt_service_types['primary'],
1070            'characteristics': [
1071                {
1072                    'uuid': '0000b004-0000-1000-8000-00805f9b34fb',
1073                    'instance_id': 0x0003,
1074                    'properties': 0x0a,
1075                    'permissions': gatt_characteristic['permission_read'] |
1076                    gatt_characteristic['permission_write'],
1077                    'value_type': gatt_characteristic_value_format['byte'],
1078                    'value': [0x04],
1079                },
1080                {
1081                    'uuid': '0000b004-0000-1000-8000-00805f9b34fb',
1082                    'instance_id': 0x0013,
1083                    'properties': 0x10,
1084                    'permissions': 0x17,
1085                    'value_type': gatt_characteristic_value_format['byte'],
1086                    'value': [0x04],
1087                    'descriptors': [
1088                        {
1089                            'uuid': gatt_char_desc_uuids['char_ext_props'],
1090                            'permissions': gatt_descriptor['permission_read'] |
1091                            gatt_descriptor['permission_write'],
1092                            'value': [0x09]
1093                        },
1094                        {
1095                            'uuid': gatt_char_desc_uuids['char_user_desc'],
1096                            'permissions': gatt_descriptor['permission_read'] |
1097                            gatt_descriptor['permission_write'],
1098                            'value': [0x22]
1099                        },
1100                        {
1101                            'uuid': gatt_char_desc_uuids['client_char_cfg'],
1102                            'permissions': gatt_descriptor['permission_read'] |
1103                            gatt_descriptor['permission_write'],
1104                            'value': [0x01, 0x00]
1105                        },
1106                        {
1107                            'uuid': gatt_char_desc_uuids['server_char_cfg'],
1108                            'permissions': gatt_descriptor['permission_read'] |
1109                            gatt_descriptor['permission_write'],
1110                            'value': [0x22]
1111                        },
1112                        {
1113                            'uuid': gatt_char_desc_uuids['char_fmt_uuid'],
1114                            'permissions': gatt_descriptor['permission_read'] |
1115                            gatt_descriptor['permission_write'],
1116                            'value': [0x22]
1117                        },
1118                        {
1119                            'uuid': gatt_char_desc_uuids['char_agreg_fmt'],
1120                            'permissions': gatt_descriptor['permission_read'] |
1121                            gatt_descriptor['permission_write'],
1122                            'value': [0x22]
1123                        },
1124                        {
1125                            'uuid': gatt_char_desc_uuids['char_valid_range'],
1126                            'permissions': gatt_descriptor['permission_read'] |
1127                            gatt_descriptor['permission_write'],
1128                            'value': [0x22]
1129                        },
1130                        {
1131                            'uuid':
1132                            gatt_char_desc_uuids['external_report_reference'],
1133                            'permissions': gatt_descriptor['permission_read'] |
1134                            gatt_descriptor['permission_write'],
1135                            'value': [0x22]
1136                        },
1137                        {
1138                            'uuid': gatt_char_desc_uuids['report_reference'],
1139                            'permissions': gatt_descriptor['permission_read'] |
1140                            gatt_descriptor['permission_write'],
1141                            'value': [0x22]
1142                        },
1143                    ]
1144                },
1145                {
1146                    'uuid': gatt_char_types['service_changed'],
1147                    'instance_id': 0x0023,
1148                    'properties': gatt_characteristic['property_read'],
1149                    'permissions': gatt_characteristic['permission_read'] |
1150                    gatt_characteristic['permission_write'],
1151                    'value_type': gatt_characteristic_value_format['string'],
1152                    'value': '333334444455555666667777788888999990000011111',
1153                },
1154                {
1155                    'uuid': gatt_char_types['appearance'],
1156                    'properties': gatt_characteristic['property_read'],
1157                    'permissions': gatt_characteristic['permission_read'] |
1158                    gatt_characteristic['permission_write'],
1159                    'value_type': gatt_characteristic_value_format['string'],
1160                    'value': '333334444455555666667777788888999990000011111',
1161                },
1162                {
1163                    'uuid': gatt_char_types['peripheral_priv_flag'],
1164                    'properties': gatt_characteristic['property_read'],
1165                    'permissions': gatt_characteristic['permission_read'] |
1166                    gatt_characteristic['permission_write'],
1167                    'value_type': gatt_characteristic_value_format['string'],
1168                    'value': '333334444455555666667777788888999990000011111',
1169                },
1170                {
1171                    'uuid': gatt_char_types['reconnection_address'],
1172                    'properties': gatt_characteristic['property_read'],
1173                    'permissions': gatt_characteristic['permission_read'] |
1174                    gatt_characteristic['permission_write'],
1175                    'value_type': gatt_characteristic_value_format['string'],
1176                    'value': '333334444455555666667777788888999990000011111',
1177                },
1178                {
1179                    'uuid': gatt_char_types['system_id'],
1180                    'properties': gatt_characteristic['property_read'],
1181                    'permissions': gatt_characteristic['permission_read'] |
1182                    gatt_characteristic['permission_write'],
1183                    'value_type': gatt_characteristic_value_format['string'],
1184                    'value': '333334444455555666667777788888999990000011111',
1185                },
1186                {
1187                    'uuid': gatt_char_types['model_number_string'],
1188                    'properties': gatt_characteristic['property_read'],
1189                    'permissions': gatt_characteristic['permission_read'] |
1190                    gatt_characteristic['permission_write'],
1191                    'value_type': gatt_characteristic_value_format['string'],
1192                    'value': '333334444455555666667777788888999990000011111',
1193                },
1194                {
1195                    'uuid': gatt_char_types['serial_number_string'],
1196                    'properties': gatt_characteristic['property_read'],
1197                    'permissions': gatt_characteristic['permission_read'] |
1198                    gatt_characteristic['permission_write'],
1199                    'value_type': gatt_characteristic_value_format['string'],
1200                    'value': '333334444455555666667777788888999990000011111',
1201                },
1202                {
1203                    'uuid': gatt_char_types['firmware_revision_string'],
1204                    'properties': gatt_characteristic['property_read'],
1205                    'permissions': gatt_characteristic['permission_read'] |
1206                    gatt_characteristic['permission_write'],
1207                    'value_type': gatt_characteristic_value_format['string'],
1208                    'value': '333334444455555666667777788888999990000011111',
1209                },
1210                {
1211                    'uuid': gatt_char_types['hardware_revision_string'],
1212                    'properties': gatt_characteristic['property_read'],
1213                    'permissions': gatt_characteristic['permission_read'] |
1214                    gatt_characteristic['permission_write'],
1215                    'value_type': gatt_characteristic_value_format['string'],
1216                    'value': '333334444455555666667777788888999990000011111',
1217                },
1218                {
1219                    'uuid': gatt_char_types['software_revision_string'],
1220                    'properties': gatt_characteristic['property_read'],
1221                    'permissions': gatt_characteristic['permission_read'] |
1222                    gatt_characteristic['permission_write'],
1223                    'value_type': gatt_characteristic_value_format['string'],
1224                    'value': '333334444455555666667777788888999990000011111',
1225                },
1226                {
1227                    'uuid': gatt_char_types['manufacturer_name_string'],
1228                    'properties': gatt_characteristic['property_read'],
1229                    'permissions': gatt_characteristic['permission_read'] |
1230                    gatt_characteristic['permission_write'],
1231                    'value_type': gatt_characteristic_value_format['string'],
1232                    'value': '333334444455555666667777788888999990000011111',
1233                },
1234                {
1235                    'uuid': gatt_char_types['pnp_id'],
1236                    'properties': gatt_characteristic['property_read'],
1237                    'permissions': gatt_characteristic['permission_read'] |
1238                    gatt_characteristic['permission_write'],
1239                    'value_type': gatt_characteristic_value_format['string'],
1240                    'value': '333334444455555666667777788888999990000011111',
1241                },
1242            ]
1243        },
1244        {
1245            'uuid': '0000a00d-0000-1000-8000-00805f9b34fb',
1246            'type': gatt_service_types['secondary'],
1247            'handles': 5,
1248            'characteristics': [{
1249                'uuid': '0000b00c-0000-1000-8000-00805f9b34fb',
1250                'instance_id': 0x0023,
1251                'properties': gatt_characteristic['property_read'],
1252                'permissions': gatt_characteristic['permission_read'],
1253                'value_type': gatt_characteristic_value_format['byte'],
1254                'value': [0x0c],
1255            }, {
1256                'uuid': '0000b00b-0000-0000-0123-456789abcdef',
1257                'instance_id': 0x0025,
1258                'properties': gatt_characteristic['property_read'],
1259                'permissions': gatt_characteristic['permission_read'],
1260                'value_type': gatt_characteristic_value_format['byte'],
1261                'value': [0x0b],
1262            }]
1263        },
1264        {
1265            'uuid': '0000a00b-0000-1000-8000-00805f9b34fb',
1266            'type': gatt_service_types['primary'],
1267            'characteristics': [{
1268                'uuid': '0000b008-0000-1000-8000-00805f9b34fb',
1269                'instance_id': 0x0032,
1270                'properties': gatt_characteristic['property_read'],
1271                'permissions': gatt_characteristic['permission_read'],
1272                'value_type': gatt_characteristic_value_format['byte'],
1273                'value': [0x08],
1274            }]
1275        },
1276        {
1277            'uuid': '0000a00b-0000-1000-8000-00805f9b34fb',
1278            'type': gatt_service_types['primary'],
1279            'characteristics': [{
1280                'uuid': '0000b007-0000-1000-8000-00805f9b34fb',
1281                'instance_id': 0x0042,
1282                'properties': gatt_characteristic['property_write'],
1283                'permissions': gatt_characteristic['permission_write'],
1284                'value_type': gatt_characteristic_value_format['byte'],
1285                'value': [0x07],
1286            }]
1287        },
1288        {
1289            'uuid': '0000a00b-0000-1000-8000-00805f9b34fb',
1290            'type': gatt_service_types['primary'],
1291            'characteristics': [{
1292                'uuid': '0000b006-0000-1000-8000-00805f9b34fb',
1293                'instance_id': 0x0052,
1294                'properties': 0x3e,
1295                'permissions': gatt_characteristic['permission_write_encrypted_mitm'] |
1296                gatt_characteristic['permission_read_encrypted_mitm'],
1297                'value_type': gatt_characteristic_value_format['byte'],
1298                'value': [0x06],
1299            }]
1300        },
1301        {
1302            'uuid': '0000a00a-0000-1000-8000-00805f9b34fb',
1303            'type': gatt_service_types['primary'],
1304            'handles': 10,
1305            'characteristics': [{
1306                'uuid': '0000b001-0000-1000-8000-00805f9b34fb',
1307                'instance_id': 0x0074,
1308                'properties': gatt_characteristic['property_read'],
1309                'permissions': gatt_characteristic['permission_read'],
1310                'value_type': gatt_characteristic_value_format['byte'],
1311                'value': [0x01],
1312            }, {
1313                'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
1314                'enforce_initial_attribute_length': True,
1315                'instance_id': 0x0076,
1316                'properties': 0x0a,
1317                'permissions': gatt_characteristic['permission_read'] |
1318                gatt_characteristic['permission_write'],
1319                'value_type': gatt_characteristic_value_format['string'],
1320                'value': '11111222223333344444555556666677777888889999900000',
1321            }, {
1322                'uuid': '0000b003-0000-1000-8000-00805f9b34fb',
1323                'instance_id': 0x0078,
1324                'properties': gatt_characteristic['property_write'],
1325                'permissions': gatt_characteristic['permission_write'],
1326                'value_type': gatt_characteristic_value_format['byte'],
1327                'value': [0x03],
1328            }]
1329        },
1330        {
1331            'uuid': '0000a00c-0000-0000-0123-456789abcdef',
1332            'type': gatt_service_types['primary'],
1333            'handles': 10,
1334            'characteristics': [{
1335                'uuid': '0000b009-0000-0000-0123-456789abcdef',
1336                'instance_id': 0x0082,
1337                'properties': 0x8a,
1338                'permissions': gatt_characteristic['permission_read'] |
1339                gatt_characteristic['permission_write'],
1340                'value_type': gatt_characteristic_value_format['byte'],
1341                'value': [0x09],
1342                'descriptors': [
1343                    {
1344                        'uuid': '0000b009-0000-0000-0123-456789abcdef',
1345                        'permissions': gatt_descriptor['permission_read'] |
1346                        gatt_descriptor['permission_write'],
1347                        'value': [0x09]
1348                    },
1349                    {
1350                        'uuid': '0000d9d2-0000-0000-0123-456789abcdef',
1351                        'permissions': gatt_descriptor['permission_read'] |
1352                        gatt_descriptor['permission_write'],
1353                        'value': [0x22]
1354                    },
1355                    {
1356                        'uuid': gatt_char_desc_uuids['char_ext_props'],
1357                        'permissions': gatt_descriptor['permission_read'],
1358                        'value': [0x01, 0x00]
1359                    },
1360                    {
1361                        'uuid': '0000d9d3-0000-0000-0123-456789abcdef',
1362                        'permissions': gatt_descriptor['permission_write'],
1363                        'value': [0x22]
1364                    },
1365                ]
1366            }]
1367        },
1368        {
1369            'uuid': '0000a00b-0000-0000-0123-456789abcdef',
1370            'type': gatt_service_types['primary'],
1371            'characteristics': [{
1372                'uuid': '0000b009-0000-0000-0123-456789abcdef',
1373                'instance_id': 0x0092,
1374                'properties': 0x8a,
1375                'permissions': gatt_characteristic['permission_read'] |
1376                gatt_characteristic['permission_write'],
1377                'value_type': gatt_characteristic_value_format['byte'],
1378                'value': [0x05],
1379                'descriptors': [
1380                    {
1381                        'uuid': gatt_char_desc_uuids['char_user_desc'],
1382                        'permissions': gatt_descriptor['permission_read'] |
1383                        gatt_descriptor['permission_write'],
1384                        'value': [0] * 26
1385                    },
1386                    {
1387                        'uuid': gatt_char_desc_uuids['char_ext_props'],
1388                        'permissions': gatt_descriptor['permission_read'],
1389                        'value': [0x03, 0x00]
1390                    },
1391                    {
1392                        'uuid': '0000d5d4-0000-0000-0123-456789abcdef',
1393                        'permissions': gatt_descriptor['permission_read'],
1394                        'value': [0x44]
1395                    },
1396                    {
1397                        'uuid': gatt_char_desc_uuids['char_fmt_uuid'],
1398                        'permissions': gatt_descriptor['permission_read'],
1399                        'value': [0x04, 0x00, 0x01, 0x30, 0x01, 0x11, 0x31]
1400                    },
1401                ]
1402            }]
1403        },
1404        {
1405            'uuid': '0000a00c-0000-0000-0123-456789abcdef',
1406            'type': gatt_service_types['primary'],
1407            'characteristics': [
1408                {
1409                    'uuid': '0000b00a-0000-1000-8000-00805f9b34fb',
1410                    'instance_id': 0x00a2,
1411                    'properties': gatt_characteristic['property_read'],
1412                    'permissions': gatt_characteristic['permission_read'],
1413                    'value_type': gatt_characteristic_value_format['byte'],
1414                    'value': [0x0a],
1415                },
1416                {
1417                    'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
1418                    'instance_id': 0x00a4,
1419                    'enforce_initial_attribute_length': True,
1420                    'properties': 0x0a,
1421                    'permissions': gatt_characteristic['permission_read'] |
1422                    gatt_characteristic['permission_write'],
1423                    'value_type': gatt_characteristic_value_format['string'],
1424                    'value': '111112222233333444445',
1425                },
1426                {
1427                    'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
1428                    'instance_id': 0x00a6,
1429                    'enforce_initial_attribute_length': True,
1430                    'properties': 0x0a,
1431                    'permissions': gatt_characteristic['permission_read'] |
1432                    gatt_characteristic['permission_write'],
1433                    'value_type': gatt_characteristic_value_format['string'],
1434                    'value': '2222233333444445555566',
1435                },
1436                {
1437                    'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
1438                    'instance_id': 0x00a8,
1439                    'enforce_initial_attribute_length': True,
1440                    'properties': 0x0a,
1441                    'permissions': gatt_characteristic['permission_read'] |
1442                    gatt_characteristic['permission_write'],
1443                    'value_type': gatt_characteristic_value_format['string'],
1444                    'value': '33333444445555566666777',
1445                },
1446                {
1447                    'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
1448                    'instance_id': 0x00aa,
1449                    'enforce_initial_attribute_length': True,
1450                    'properties': 0x0a,
1451                    'permissions': gatt_characteristic['permission_read'] |
1452                    gatt_characteristic['permission_write'],
1453                    'value_type': gatt_characteristic_value_format['string'],
1454                    'value': '1111122222333334444455555666667777788888999',
1455                },
1456                {
1457                    'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
1458                    'instance_id': 0x00ac,
1459                    'enforce_initial_attribute_length': True,
1460                    'properties': 0x0a,
1461                    'permissions': gatt_characteristic['permission_read'] |
1462                    gatt_characteristic['permission_write'],
1463                    'value_type': gatt_characteristic_value_format['string'],
1464                    'value': '22222333334444455555666667777788888999990000',
1465                },
1466                {
1467                    'uuid': '0000b002-0000-1000-8000-00805f9b34fb',
1468                    'instance_id': 0x00ae,
1469                    'enforce_initial_attribute_length': True,
1470                    'properties': 0x0a,
1471                    'permissions': gatt_characteristic['permission_read'] |
1472                    gatt_characteristic['permission_write'],
1473                    'value_type': gatt_characteristic_value_format['string'],
1474                    'value': '333334444455555666667777788888999990000011111',
1475                },
1476            ]
1477        },
1478        {
1479            'uuid': '0000a00e-0000-1000-8000-00805f9b34fb',
1480            'type': gatt_service_types['primary'],
1481            'characteristics': [{
1482                'uuid': '0000b00d-0000-1000-8000-00805f9b34fb',
1483                'instance_id': 0xffff,
1484                'properties': gatt_characteristic['property_read'],
1485                'permissions': gatt_characteristic['permission_read'],
1486                'value_type': gatt_characteristic_value_format['byte'],
1487                'value': [0x0d],
1488            }]
1489        },
1490    ]
1491}
1492
1493TEST_DB_1 = {
1494    'services': [{
1495        'uuid': '0000180d-0000-1000-8000-00805f9b34fb',
1496        'type': gatt_service_types['primary'],
1497        'handles': 4,
1498        'characteristics': [{
1499            'uuid': '00002a29-0000-1000-8000-00805f9b34fb',
1500            'properties': gatt_characteristic['property_read'] |
1501            gatt_characteristic['property_write'],
1502            'permissions': gatt_characteristic['permission_read'] |
1503            gatt_characteristic['permission_write'],
1504            'value_type': gatt_characteristic_value_format['string'],
1505            'value': 'test',
1506            'instance_id': 0x002a,
1507            'descriptors': [{
1508                'uuid': gatt_char_desc_uuids['char_user_desc'],
1509                'permissions': gatt_descriptor['permission_read'],
1510                'value': [0x01]
1511            }]
1512        }]
1513    }]
1514}
1515
1516TEST_DB_2 = {
1517    'services': [{
1518        'uuid': '0000180d-0000-1000-8000-00805f9b34fb',
1519        'type': gatt_service_types['primary'],
1520        'handles': 4,
1521        'characteristics': [{
1522            'uuid': '00002a29-0000-1000-8000-00805f9b34fb',
1523            'properties': gatt_characteristic['property_read'],
1524            'permissions':
1525            gatt_characteristic['permission_read_encrypted_mitm'],
1526            'value_type': gatt_characteristic_value_format['string'],
1527            'value': 'test',
1528            'instance_id': 0x002a,
1529        }, {
1530            'uuid': '00002a30-0000-1000-8000-00805f9b34fb',
1531            'properties': gatt_characteristic['property_read'],
1532            'permissions':
1533            gatt_characteristic['permission_read_encrypted_mitm'],
1534            'value_type': gatt_characteristic_value_format['string'],
1535            'value': 'test',
1536            'instance_id': 0x002b,
1537        }]
1538    }]
1539}
1540
1541TEST_DB_3 = {
1542    'services': [{
1543        'uuid': '0000180d-0000-1000-8000-00805f9b34fb',
1544        'type': gatt_service_types['primary'],
1545        'handles': 4,
1546        'characteristics': [{
1547            'uuid': '00002a29-0000-1000-8000-00805f9b34fb',
1548            'properties': gatt_characteristic['property_read'] |
1549            gatt_characteristic['property_write'],
1550            'permissions': gatt_characteristic['permission_read'] |
1551            gatt_characteristic['permission_write'],
1552            'value_type': gatt_characteristic_value_format['string'],
1553            'value': 'test',
1554            'instance_id': 0x002a,
1555            'descriptors': [{
1556                'uuid': gatt_char_desc_uuids['char_user_desc'],
1557                'permissions': gatt_descriptor['permission_read'],
1558                'value': [0x01]
1559            }, {
1560                'uuid': '00002a20-0000-1000-8000-00805f9b34fb',
1561                'permissions': gatt_descriptor['permission_read'] |
1562                gatt_descriptor['permission_write'],
1563                'instance_id': 0x002c,
1564                'value': [0x01]
1565            }]
1566        }, {
1567            'uuid': '00002a30-0000-1000-8000-00805f9b34fb',
1568            'properties': gatt_characteristic['property_read'] |
1569            gatt_characteristic['property_write'],
1570            'permissions': gatt_characteristic['permission_read'] |
1571            gatt_characteristic['permission_write'],
1572            'value_type': gatt_characteristic_value_format['string'],
1573            'value': 'test',
1574            'instance_id': 0x002b,
1575        }]
1576    }]
1577}
1578
1579TEST_DB_4 = {
1580    'services': [{
1581        'uuid': '0000180d-0000-1000-8000-00805f9b34fb',
1582        'type': gatt_service_types['primary'],
1583        'handles': 4,
1584        'characteristics': [{
1585            'uuid': '00002a29-0000-1000-8000-00805f9b34fb',
1586            'properties': gatt_characteristic['property_write_no_response'],
1587            'permissions': gatt_characteristic['permission_read'],
1588            'value_type': gatt_characteristic_value_format['string'],
1589            'value': "test",
1590            'instance_id': 0x002a,
1591            'descriptors': [{
1592                'uuid': gatt_char_desc_uuids['char_user_desc'],
1593                'permissions':
1594                gatt_descriptor['permission_read_encrypted_mitm'],
1595                'value': [0] * 512
1596            }]
1597        }]
1598    }]
1599}
1600
1601TEST_DB_5 = {
1602    'services': [{
1603        'uuid': '0000180d-0000-1000-8000-00805f9b34fb',
1604        'type': gatt_service_types['primary'],
1605        'characteristics': [{
1606            'uuid': 'b2c83efa-34ca-11e6-ac61-9e71128cae77',
1607            'properties': gatt_characteristic['property_write'] |
1608            gatt_characteristic['property_read'] |
1609            gatt_characteristic['property_notify'],
1610            'permissions': gatt_characteristic['permission_read'] |
1611            gatt_characteristic['permission_write'],
1612            'value_type': gatt_characteristic_value_format['byte'],
1613            'value': [0x1],
1614            'instance_id': 0x002c,
1615            'descriptors': [{
1616                'uuid': '00002902-0000-1000-8000-00805f9b34fb',
1617                'permissions': gatt_descriptor['permission_read'] |
1618                gatt_descriptor['permission_write'],
1619            }]
1620        }]
1621    }]
1622}
1623
1624TEST_DB_6 = {
1625    'services': [{
1626        'uuid': '0000180d-0000-1000-8000-00805f9b34fb',
1627        'type': gatt_service_types['primary'],
1628        'handles': 4,
1629        'characteristics': [{
1630            'uuid': '00002a29-0000-1000-8000-00805f9b34fb',
1631            'properties': gatt_characteristic['property_read'] | gatt_characteristic['property_notify'],
1632            'permissions': gatt_characteristic['permission_read_encrypted_mitm'],
1633            'value_type': gatt_characteristic_value_format['string'],
1634            'value': 'test',
1635            'instance_id': 0x002a,
1636            'descriptors': [{
1637                'uuid': '00002a19-0000-1000-8000-00805f9b34fb',
1638                'permissions': gatt_descriptor['permission_read'],
1639                'value': [0x01] * 30
1640            }]
1641        }]
1642    }]
1643}
1644
1645SIMPLE_READ_DESCRIPTOR = {
1646    'services': [{
1647        'uuid': '0000a00a-0000-1000-8000-00805f9b34fb',
1648        'type': gatt_service_types['primary'],
1649        'characteristics': [{
1650            'uuid': 'aa7edd5a-4d1d-4f0e-883a-d145616a1630',
1651            'properties': gatt_characteristic['property_read'],
1652            'permissions': gatt_characteristic['permission_read'],
1653            'instance_id': 0x002a,
1654            'value_type': gatt_characteristic_value_format['string'],
1655            'value': 'Test Database',
1656            'descriptors': [{
1657                'uuid': gatt_char_desc_uuids['client_char_cfg'],
1658                'permissions': gatt_descriptor['permission_read'],
1659            }]
1660        }]
1661    }]
1662}
1663
1664CHARACTERISTIC_PROPERTY_WRITE_NO_RESPONSE = {
1665    'services': [{
1666        'uuid': '0000a00a-0000-1000-8000-00805f9b34fb',
1667        'type': gatt_service_types['primary'],
1668        'characteristics': [{
1669            'uuid': 'aa7edd5a-4d1d-4f0e-883a-d145616a1630',
1670            'properties': gatt_characteristic['property_write_no_response'],
1671            'permissions': gatt_characteristic['permission_write'] |
1672            gatt_characteristic['permission_read'],
1673            'instance_id': 0x0042,
1674            'value_type': gatt_characteristic_value_format['string'],
1675            'value': 'Test Database'
1676        }, {
1677            'uuid': 'aa7edd6a-4d1d-4f0e-883a-d145616a1630',
1678            'properties': gatt_characteristic['property_write_no_response'],
1679            'permissions': gatt_characteristic['permission_write'] |
1680            gatt_characteristic['permission_read'],
1681            'instance_id': 0x004d,
1682            'value_type': gatt_characteristic_value_format['string'],
1683            'value': 'Test Database'
1684        }]
1685    }]
1686}
1687
1688GATT_SERVER_DB_MAPPING = {
1689    'LARGE_DB_1': LARGE_DB_1,
1690    'LARGE_DB_3': LARGE_DB_3,
1691    'INVALID_SMALL_DATABASE': INVALID_SMALL_DATABASE,
1692    'SIMPLE_READ_DESCRIPTOR': SIMPLE_READ_DESCRIPTOR,
1693    'CHARACTERISTIC_PROPERTY_WRITE_NO_RESPONSE':
1694    CHARACTERISTIC_PROPERTY_WRITE_NO_RESPONSE,
1695    'TEST_DB_1': TEST_DB_1,
1696    'TEST_DB_2': TEST_DB_2,
1697    'TEST_DB_3': TEST_DB_3,
1698    'TEST_DB_4': TEST_DB_4,
1699    'TEST_DB_5': TEST_DB_5,
1700    'LARGE_DB_3_PLUS': LARGE_DB_3,
1701    'DB_TEST': DB_TEST,
1702    'PTS_TEST': PTS_TEST,
1703    'PTS_TEST2': PTS_TEST2,
1704    'TEST_DB_6': TEST_DB_6,
1705}
1706