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 |
(...skipping 15 matching lines...) Expand all Loading... | |
26 AUTHENTICATED_SIGNED_WRITES = 64, | 26 AUTHENTICATED_SIGNED_WRITES = 64, |
27 EXTENDED_PROPERTIES = 128, | 27 EXTENDED_PROPERTIES = 128, |
28 RELIABLE_WRITE = 256, | 28 RELIABLE_WRITE = 256, |
29 WRITABLE_AUXILIARIES = 512, | 29 WRITABLE_AUXILIARIES = 512, |
30 READ_ENCRYPTED = 1024, | 30 READ_ENCRYPTED = 1024, |
31 WRITE_ENCRYPTED = 2048, | 31 WRITE_ENCRYPTED = 2048, |
32 READ_ENCRYPTED_AUTHENTICATED = 4096, | 32 READ_ENCRYPTED_AUTHENTICATED = 4096, |
33 WRITE_ENCRYPTED_AUTHENTICATED = 8192 | 33 WRITE_ENCRYPTED_AUTHENTICATED = 8192 |
34 }; | 34 }; |
35 | 35 |
36 // Values representing read, write, and encryption permissions for a | |
37 // characteristic's value. While attribute permissions for all GATT | |
38 // definitions have been set by the Bluetooth specification, characteristic | |
39 // value permissions are left up to the higher-level profile. | |
40 // | |
41 // Attribute permissions are distinct from the characteristic properties. For | |
42 // example, a characteristic may have the property |PROPERTY_READ| to make | |
43 // clients know that it is possible to read the characteristic value and have | |
44 // the permission |PERMISSION_READ_ENCRYPTED| to require a secure connection. | |
45 // It is up to the application to properly specify the permissions and | |
46 // properties for a local characteristic. | |
47 // TODO(rkc): Currently BlueZ infers permissions for characteristics from | |
48 // the properties. Once this is fixed, we will start sending the permissions | |
49 // for characteristics to BlueZ. Till then permissions for characteristics | |
50 // are unimplemented. | |
51 enum Permission { | |
52 NONE = 0, | |
53 READ = 1, | |
54 WRITE = 2, | |
55 READ_ENCRYPTED = 4, | |
56 WRITE_ENCRYPTED = 8, | |
57 READ_ENCRYPTED_AUTHENTICATED = 16, | |
58 WRITE_ENCRYPTED_AUTHENTICATED = 32 | |
ortuno
2017/01/20 03:45:22
So sad that we have to manually write these... Are
mbrunson
2017/01/21 01:49:00
There are no open issues for this. rockot has told
ortuno
2017/01/22 22:38:00
Ah I should have been more explicit. I'm sad that
mbrunson
2017/01/24 00:25:31
I didn't find any open issues for this, so I made
| |
59 }; | |
60 | |
61 enum GattResult { | |
62 SUCCESS, | |
63 UNKNOWN, | |
64 FAILED, | |
65 IN_PROGRESS, | |
66 INVALID_LENGTH, | |
67 NOT_PERMITTED, | |
68 NOT_AUTHORIZED, | |
69 NOT_PAIRED, | |
70 NOT_SUPPORTED | |
71 }; | |
72 | |
36 // TODO(crbug.com/657632): Remove when numerical values can be optional. | 73 // TODO(crbug.com/657632): Remove when numerical values can be optional. |
37 struct RSSIWrapper { | 74 struct RSSIWrapper { |
38 int8 value; | 75 int8 value; |
39 }; | 76 }; |
40 | 77 |
41 struct DeviceInfo { | 78 struct DeviceInfo { |
42 string? name; | 79 string? name; |
43 string name_for_display; | 80 string name_for_display; |
44 string address; | 81 string address; |
45 bool is_gatt_connected; | 82 bool is_gatt_connected; |
46 RSSIWrapper? rssi; | 83 RSSIWrapper? rssi; |
47 }; | 84 }; |
48 | 85 |
49 struct ServiceInfo { | 86 struct ServiceInfo { |
50 string id; | 87 string id; |
51 UUID uuid; | 88 UUID uuid; |
52 bool is_primary; | 89 bool is_primary; |
53 }; | 90 }; |
54 | 91 |
55 struct CharacteristicInfo { | 92 struct CharacteristicInfo { |
56 string id; | 93 string id; |
57 UUID uuid; | 94 UUID uuid; |
58 uint32 properties; | 95 uint32 properties; |
96 uint32 permissions; | |
97 array<uint8> value; | |
ortuno
2017/01/20 03:45:22
I would rename this to last_known_value.
mbrunson
2017/01/21 01:49:00
Done.
| |
59 }; | 98 }; |
60 | 99 |
61 interface Device { | 100 interface Device { |
62 // Disconnects and deletes the Device. | 101 // Disconnects and deletes the Device. |
63 Disconnect(); | 102 Disconnect(); |
64 | 103 |
65 // Gets basic information about the device. Returns null, if no device is | 104 // Gets basic information about the device. Returns null, if no device is |
66 // available. | 105 // available. |
67 GetInfo() => (DeviceInfo? info); | 106 GetInfo() => (DeviceInfo? info); |
68 | 107 |
69 // Gets the GATT Services in this device's GATT Server. | 108 // Gets the GATT Services in this device's GATT Server. |
70 GetServices() => (array<ServiceInfo> services); | 109 GetServices() => (array<ServiceInfo> services); |
71 | 110 |
72 // Gets the GATT Characteristics in the GATT Service with |service_id|. | 111 // Gets the GATT Characteristics in the GATT Service with |service_id|. |
73 GetCharacteristics(string service_id) => | 112 GetCharacteristics(string service_id) => |
74 (array<CharacteristicInfo> characteristics); | 113 (array<CharacteristicInfo> characteristics); |
114 | |
115 // Reads the value for the GATT Characteristic with |characteristic_id| in | |
116 // the GATT Service with |service_id|. | |
117 ReadValueForCharacteristic(string service_id, string characteristic_id) => | |
118 (GattResult result, array<uint8> value); | |
ortuno
2017/01/20 03:45:22
shouldn't value be optional?
mbrunson
2017/01/21 01:49:00
Done.
| |
119 | |
120 // Writes the |value| to the GATT Characteristic with |characteristic_id| in | |
121 // the GATT Service with |service_id|. | |
122 WriteValueForCharacteristic(array<uint8> value, string service_id, | |
ortuno
2017/01/20 03:45:22
optional: put value at the end.
mbrunson
2017/01/21 01:49:00
Done.
| |
123 string characteristic_id) => (GattResult result); | |
75 }; | 124 }; |
OLD | NEW |