OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 module bluetooth.mojom; | 5 module bluetooth.mojom; |
6 | 6 |
7 import "device/bluetooth/public/interfaces/uuid.mojom"; | 7 import "device/bluetooth/public/interfaces/uuid.mojom"; |
8 | 8 |
9 // Values representing the possible properties of a characteristic, which | 9 // Values representing the possible properties of a characteristic, which |
10 // define how the characteristic can be used. Each of these properties serve | 10 // define how the characteristic can be used. Each of these properties serve |
11 // a role as defined in the Bluetooth Specification. | 11 // a role as defined in the Bluetooth Specification. |
12 // |EXTENDED_PROPERTIES| is a special property that, if present, | 12 // |EXTENDED_PROPERTIES| is a special property that, if present, |
13 // indicates that there is a characteristic descriptor (namely the | 13 // indicates that there is a characteristic descriptor (namely the |
14 // "Characteristic Extended Properties Descriptor" with UUID 0x2900) that | 14 // "Characteristic Extended Properties Descriptor" with UUID 0x2900) that |
15 // contains additional properties pertaining to the characteristic. | 15 // contains additional properties pertaining to the characteristic. |
16 // The properties |RELIABLE_WRITE| and |WRITABLE_AUXILIARIES| are retrieved from | 16 // The properties |RELIABLE_WRITE| and |WRITABLE_AUXILIARIES| are retrieved from |
17 // that characteristic. | 17 // that characteristic. |
| 18 // TODO(crbug.com/684168): Remove assignment of values when this is automated. |
18 enum Property { | 19 enum Property { |
19 NONE = 0, | 20 NONE = 0, |
20 BROADCAST = 1, | 21 BROADCAST = 1, |
21 READ = 2, | 22 READ = 2, |
22 WRITE_WITHOUT_RESPONSE = 4, | 23 WRITE_WITHOUT_RESPONSE = 4, |
23 WRITE = 8, | 24 WRITE = 8, |
24 NOTIFY = 16, | 25 NOTIFY = 16, |
25 INDICATE = 32, | 26 INDICATE = 32, |
26 AUTHENTICATED_SIGNED_WRITES = 64, | 27 AUTHENTICATED_SIGNED_WRITES = 64, |
27 EXTENDED_PROPERTIES = 128, | 28 EXTENDED_PROPERTIES = 128, |
28 RELIABLE_WRITE = 256, | 29 RELIABLE_WRITE = 256, |
29 WRITABLE_AUXILIARIES = 512, | 30 WRITABLE_AUXILIARIES = 512, |
30 READ_ENCRYPTED = 1024, | 31 READ_ENCRYPTED = 1024, |
31 WRITE_ENCRYPTED = 2048, | 32 WRITE_ENCRYPTED = 2048, |
32 READ_ENCRYPTED_AUTHENTICATED = 4096, | 33 READ_ENCRYPTED_AUTHENTICATED = 4096, |
33 WRITE_ENCRYPTED_AUTHENTICATED = 8192 | 34 WRITE_ENCRYPTED_AUTHENTICATED = 8192 |
34 }; | 35 }; |
35 | 36 |
| 37 // Values representing read, write, and encryption permissions for a |
| 38 // characteristic's value. While attribute permissions for all GATT |
| 39 // definitions have been set by the Bluetooth specification, characteristic |
| 40 // value permissions are left up to the higher-level profile. |
| 41 // |
| 42 // Attribute permissions are distinct from the characteristic properties. For |
| 43 // example, a characteristic may have the property |PROPERTY_READ| to make |
| 44 // clients know that it is possible to read the characteristic value and have |
| 45 // the permission |PERMISSION_READ_ENCRYPTED| to require a secure connection. |
| 46 // It is up to the application to properly specify the permissions and |
| 47 // properties for a local characteristic. |
| 48 // TODO(rkc): Currently BlueZ infers permissions for characteristics from |
| 49 // the properties. Once this is fixed, we will start sending the permissions |
| 50 // for characteristics to BlueZ. Till then permissions for characteristics |
| 51 // are unimplemented. |
| 52 // TODO(crbug.com/684168): Remove assignment of values when this is automated. |
| 53 enum Permission { |
| 54 NONE = 0, |
| 55 READ = 1, |
| 56 WRITE = 2, |
| 57 READ_ENCRYPTED = 4, |
| 58 WRITE_ENCRYPTED = 8, |
| 59 READ_ENCRYPTED_AUTHENTICATED = 16, |
| 60 WRITE_ENCRYPTED_AUTHENTICATED = 32 |
| 61 }; |
| 62 |
| 63 enum GattResult { |
| 64 SUCCESS, |
| 65 UNKNOWN, |
| 66 FAILED, |
| 67 IN_PROGRESS, |
| 68 INVALID_LENGTH, |
| 69 NOT_PERMITTED, |
| 70 NOT_AUTHORIZED, |
| 71 NOT_PAIRED, |
| 72 NOT_SUPPORTED, |
| 73 SERVICE_NOT_FOUND, |
| 74 CHARACTERISTIC_NOT_FOUND |
| 75 }; |
| 76 |
36 // TODO(crbug.com/657632): Remove when numerical values can be optional. | 77 // TODO(crbug.com/657632): Remove when numerical values can be optional. |
37 struct RSSIWrapper { | 78 struct RSSIWrapper { |
38 int8 value; | 79 int8 value; |
39 }; | 80 }; |
40 | 81 |
41 struct DeviceInfo { | 82 struct DeviceInfo { |
42 string? name; | 83 string? name; |
43 string name_for_display; | 84 string name_for_display; |
44 string address; | 85 string address; |
45 bool is_gatt_connected; | 86 bool is_gatt_connected; |
46 RSSIWrapper? rssi; | 87 RSSIWrapper? rssi; |
47 }; | 88 }; |
48 | 89 |
49 struct ServiceInfo { | 90 struct ServiceInfo { |
50 string id; | 91 string id; |
51 UUID uuid; | 92 UUID uuid; |
52 bool is_primary; | 93 bool is_primary; |
53 }; | 94 }; |
54 | 95 |
55 struct CharacteristicInfo { | 96 struct CharacteristicInfo { |
56 string id; | 97 string id; |
57 UUID uuid; | 98 UUID uuid; |
58 uint32 properties; | 99 uint32 properties; |
| 100 uint32 permissions; |
| 101 array<uint8> last_known_value; |
59 }; | 102 }; |
60 | 103 |
61 interface Device { | 104 interface Device { |
62 // Disconnects and deletes the Device. | 105 // Disconnects and deletes the Device. |
63 Disconnect(); | 106 Disconnect(); |
64 | 107 |
65 // Gets basic information about the device. Returns null, if no device is | 108 // Gets basic information about the device. Returns null, if no device is |
66 // available. | 109 // available. |
67 GetInfo() => (DeviceInfo? info); | 110 GetInfo() => (DeviceInfo? info); |
68 | 111 |
69 // Gets the GATT Services in this device's GATT Server. | 112 // Gets the GATT Services in this device's GATT Server. |
70 GetServices() => (array<ServiceInfo> services); | 113 GetServices() => (array<ServiceInfo> services); |
71 | 114 |
72 // Gets the GATT Characteristics in the GATT Service with |service_id|. | 115 // Gets the GATT Characteristics in the GATT Service with |service_id|. |
73 GetCharacteristics(string service_id) => | 116 GetCharacteristics(string service_id) => |
74 (array<CharacteristicInfo> characteristics); | 117 (array<CharacteristicInfo> characteristics); |
| 118 |
| 119 // Reads the value for the GATT Characteristic with |characteristic_id| in |
| 120 // the GATT Service with |service_id|. |
| 121 ReadValueForCharacteristic(string service_id, string characteristic_id) => |
| 122 (GattResult result, array<uint8>? value); |
| 123 |
| 124 // Writes the |value| to the GATT Characteristic with |characteristic_id| in |
| 125 // the GATT Service with |service_id|. |
| 126 WriteValueForCharacteristic(string service_id, string characteristic_id, |
| 127 array<uint8> value) => (GattResult result); |
75 }; | 128 }; |
OLD | NEW |