Chromium Code Reviews| 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 arc.mojom; | 5 module arc.mojom; |
| 6 | 6 |
| 7 [Extensible] | 7 [Extensible] |
| 8 enum BluetoothAdapterState { | 8 enum BluetoothAdapterState { |
| 9 OFF = 0, | 9 OFF = 0, |
| 10 ON | 10 ON |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 BluetoothServiceRecord service_record; | 121 BluetoothServiceRecord service_record; |
| 122 BluetoothScanMode adapter_scan_mode; | 122 BluetoothScanMode adapter_scan_mode; |
| 123 array<BluetoothAddress> bonded_devices; | 123 array<BluetoothAddress> bonded_devices; |
| 124 uint32 discovery_timeout; | 124 uint32 discovery_timeout; |
| 125 string remote_friendly_name; | 125 string remote_friendly_name; |
| 126 int32 remote_rssi; | 126 int32 remote_rssi; |
| 127 BluetoothRemoteVersion remote_version; | 127 BluetoothRemoteVersion remote_version; |
| 128 BluetoothLocalLEFeatures local_le_features; | 128 BluetoothLocalLEFeatures local_le_features; |
| 129 }; | 129 }; |
| 130 | 130 |
| 131 // Bluetooth GATT types | |
| 132 // Copy from Android API | |
|
palmer
2016/06/13 19:07:18
So how do we ensure that we correctly track the ch
puthik_chromium
2016/06/13 20:50:27
Android API will backward compatible.
| |
| 133 // https://developer.android.com/reference/android/bluetooth/BluetoothGatt.html | |
| 134 [Extensible] | |
| 135 enum BluetoothGattStatus { | |
| 136 GATT_SUCCESS = 0, | |
| 137 GATT_READ_NOT_PERMITTED = 0x2, | |
| 138 GATT_WRITE_NOT_PERMITTED = 0x3, | |
| 139 GATT_INSUFFICIENT_AUTHENTICATION = 0x5, | |
| 140 GATT_REQUEST_NOT_SUPPORTED = 0x6, | |
| 141 GATT_INVALID_OFFSET = 0x7, | |
| 142 GATT_INVALID_ATTRIBUTE_LENGTH = 0xd, | |
| 143 GATT_INSUFFICIENT_ENCRYPTION = 0xf, | |
| 144 GATT_CONNECTION_CONGESTED = 0x8f, | |
| 145 GATT_FAILURE = 0x101, | |
| 146 }; | |
| 147 | |
| 148 // Copy from Android API | |
| 149 // https://source.android.com/devices/halref/structbtgatt__gatt__id__t.html | |
| 150 struct BluetoothGattID { | |
| 151 BluetoothUUID uuid; | |
| 152 uint8 inst_id; | |
| 153 }; | |
| 154 | |
| 155 // Copy from Android API | |
| 156 // is_primary is not a boolean because Android define it as uint8_t. | |
|
palmer
2016/06/13 19:07:18
Typo: "defines"
puthik_chromium
2016/06/13 20:50:26
Done.
| |
| 157 // https://source.android.com/devices/halref/structbtgatt__srvc__id__t.html | |
| 158 struct BluetoothGattServiceID { | |
| 159 BluetoothGattID id; | |
| 160 uint8 is_primary; | |
| 161 }; | |
| 162 | |
| 163 struct BluetoothGattValue { | |
| 164 BluetoothGattStatus status; | |
| 165 uint32 len; | |
|
palmer
2016/06/13 19:07:18
Use the full word here: |length|.
Is it really po
puthik_chromium
2016/06/13 20:50:27
Removed. See below.
| |
| 166 array<uint8> value; | |
| 167 }; | |
| 168 | |
| 169 // Copy from Bluetooth Assigned Numbers Document, Generic Access Profile | |
| 170 // https://www.bluetooth.com/specifications/assigned-numbers/generic-access-prof ile | |
| 171 [Extensible] | |
| 172 enum BluetoothAdvertisingDataType { | |
| 173 DATA_TYPE_FLAGS = 0x01, | |
| 174 DATA_TYPE_SERVICE_UUIDS_128_BIT_COMPLETE = 0x07, | |
| 175 DATA_TYPE_LOCAL_NAME_COMPLETE = 0x09, | |
| 176 DATA_TYPE_TX_POWER_LEVEL = 0x0A, | |
| 177 DATA_TYPE_SERVICE_DATA = 0x16, | |
| 178 DATA_TYPE_MANUFACTURER_SPECIFIC_DATA = 0xff, | |
| 179 }; | |
| 180 | |
| 181 // Copy from Bluetooth Core v4.2 Volume 3 Part C Chapter 11 | |
| 182 // and Bluetooth Core Specification Supplement v6 Part A Chapter 1 | |
| 183 // https://www.bluetooth.com/specifications/adopted-specifications | |
| 184 union BluetoothAdvertisingData { | |
| 185 uint8 flags; | |
| 186 array<BluetoothUUID> service_uuids; | |
| 187 string local_name; | |
| 188 uint8 tx_power_level; | |
| 189 BluetoothServiceData service_data; | |
| 190 array<uint8> manufacturer_data; | |
|
palmer
2016/06/13 19:07:18
Why does |BluetoothGattValue| have a |length| fiel
puthik_chromium
2016/06/13 20:50:26
I don't actually need the |length| field in Blueto
| |
| 191 array<uint8> other_data; | |
| 192 }; | |
| 193 | |
| 194 struct BluetoothServiceData { | |
| 195 uint16 uuid_16bit; | |
|
palmer
2016/06/13 19:07:19
16 bits doesn't really seem like a universally-uni
puthik_chromium
2016/06/13 20:50:26
The BT spec and Android side want 16 bits data for
| |
| 196 array<uint8> data; | |
| 197 }; | |
| 198 | |
| 199 [Extensible] | |
| 200 enum BluetoothGattDBAttributeType { | |
| 201 BTGATT_DB_PRIMARY_SERVICE = 0, | |
| 202 BTGATT_DB_SECONDARY_SERVICE, | |
| 203 BTGATT_DB_INCLUDED_SERVICE, | |
| 204 BTGATT_DB_CHARACTERISTIC, | |
| 205 BTGATT_DB_DESCRIPTOR, | |
| 206 }; | |
| 207 | |
| 208 struct BluetoothGattDBElement { | |
| 209 uint8 id; | |
|
palmer
2016/06/13 19:07:18
Nit: Indented too far.
puthik_chromium
2016/06/13 20:50:27
Done.
| |
| 210 BluetoothUUID uuid; | |
| 211 BluetoothGattDBAttributeType type; | |
| 212 uint16 attribute_handle; | |
| 213 | |
| 214 /* | |
| 215 * If |type| is |BTGATT_DB_PRIMARY_SERVICE|, or | |
| 216 * |BTGATT_DB_SECONDARY_SERVICE|, this contains the start and end attribute | |
| 217 * handles. | |
| 218 */ | |
| 219 uint16 start_handle; | |
| 220 uint16 end_handle; | |
| 221 | |
| 222 /* | |
| 223 * If |type| is |BTGATT_DB_CHARACTERISTIC|, this contains the properties of | |
| 224 * the characteristic. | |
| 225 */ | |
| 226 uint8 properties; | |
| 227 }; | |
| 228 | |
| 131 interface BluetoothHost { | 229 interface BluetoothHost { |
| 132 EnableAdapter() => (BluetoothAdapterState state); | 230 EnableAdapter() => (BluetoothAdapterState state); |
| 133 DisableAdapter() => (BluetoothAdapterState state); | 231 DisableAdapter() => (BluetoothAdapterState state); |
| 134 GetAdapterProperty(BluetoothPropertyType type); | 232 GetAdapterProperty(BluetoothPropertyType type); |
| 135 SetAdapterProperty(BluetoothProperty property); | 233 SetAdapterProperty(BluetoothProperty property); |
| 136 GetRemoteDeviceProperty(BluetoothAddress remote_addr, | 234 GetRemoteDeviceProperty(BluetoothAddress remote_addr, |
| 137 BluetoothPropertyType type); | 235 BluetoothPropertyType type); |
| 138 SetRemoteDeviceProperty(BluetoothAddress remote_addr, | 236 SetRemoteDeviceProperty(BluetoothAddress remote_addr, |
| 139 BluetoothProperty property); | 237 BluetoothProperty property); |
| 140 GetRemoteServiceRecord(BluetoothAddress remote_addr, | 238 GetRemoteServiceRecord(BluetoothAddress remote_addr, |
| 141 BluetoothUUID uuid); | 239 BluetoothUUID uuid); |
| 142 GetRemoteServices(BluetoothAddress remote_addr); | 240 GetRemoteServices(BluetoothAddress remote_addr); |
| 143 StartDiscovery(); | 241 StartDiscovery(); |
| 144 CancelDiscovery(); | 242 CancelDiscovery(); |
| 145 CreateBond(BluetoothAddress addr, int32 transport); | 243 CreateBond(BluetoothAddress addr, int32 transport); |
| 146 RemoveBond(BluetoothAddress addr); | 244 RemoveBond(BluetoothAddress addr); |
| 147 CancelBond(BluetoothAddress addr); | 245 CancelBond(BluetoothAddress addr); |
| 148 | 246 |
| 149 GetConnectionState(BluetoothAddress addr) => (bool connected); | 247 GetConnectionState(BluetoothAddress addr) => (bool connected); |
| 248 | |
| 249 // Bluetooth Gatt Client functions | |
| 250 [MinVersion=1] StartLEScan(); | |
| 251 [MinVersion=1] StopLEScan(); | |
| 252 [MinVersion=1] ConnectLEDevice(BluetoothAddress remote_addr); | |
| 253 [MinVersion=1] DisconnectLEDevice(BluetoothAddress remote_addr); | |
| 254 [MinVersion=1] SearchService(BluetoothAddress remote_addr); | |
| 255 [MinVersion=1] GetGattDB(BluetoothAddress remote_addr); | |
| 256 [MinVersion=1] StartLEListen() => (BluetoothGattStatus status); | |
| 257 [MinVersion=1] StopLEListen() => (BluetoothGattStatus status); | |
| 258 [MinVersion=1] ReadGattCharacteristic(BluetoothAddress remote_addr, | |
| 259 BluetoothGattServiceID service_id, | |
| 260 BluetoothGattID char_id) | |
| 261 => (BluetoothGattValue value); | |
| 262 [MinVersion=1] WriteGattCharacteristic(BluetoothAddress remote_addr, | |
| 263 BluetoothGattServiceID service_id, | |
| 264 BluetoothGattID char_id, | |
| 265 BluetoothGattValue value) | |
| 266 => (BluetoothGattStatus status); | |
| 267 [MinVersion=1] ReadGattDescriptor(BluetoothAddress remote_addr, | |
| 268 BluetoothGattServiceID service_id, | |
| 269 BluetoothGattID char_id, | |
| 270 BluetoothGattID desc_id) | |
| 271 => (BluetoothGattValue value); | |
| 272 [MinVersion=1] WriteGattDescriptor(BluetoothAddress remote_addr, | |
| 273 BluetoothGattServiceID service_id, | |
| 274 BluetoothGattID char_id, | |
| 275 BluetoothGattID desc_id, | |
| 276 BluetoothGattValue value) | |
| 277 => (BluetoothGattStatus status); | |
| 278 [MinVersion=1] RegisterForGattNotification(BluetoothAddress remote_addr, | |
| 279 BluetoothGattServiceID service_id, | |
| 280 BluetoothGattID char_id) | |
| 281 => (BluetoothGattStatus status); | |
| 282 [MinVersion=1] DeregisterForGattNotification(BluetoothAddress remote_addr, | |
| 283 BluetoothGattServiceID service_id , | |
| 284 BluetoothGattID char_id) | |
| 285 => (BluetoothGattStatus status); | |
| 286 [MinVersion=1] ReadRemoteRssi(BluetoothAddress remote_addr) | |
| 287 => (int32 rssi); | |
| 288 | |
| 150 }; | 289 }; |
| 151 | 290 |
| 152 interface BluetoothInstance { | 291 interface BluetoothInstance { |
| 153 Init(BluetoothHost host_ptr); | 292 Init(BluetoothHost host_ptr); |
| 154 | 293 |
| 155 OnAdapterProperties(BluetoothStatus status, | 294 OnAdapterProperties(BluetoothStatus status, |
| 156 array<BluetoothProperty> properties); | 295 array<BluetoothProperty> properties); |
| 157 OnRemoteDeviceProperties(BluetoothStatus status, | 296 OnRemoteDeviceProperties(BluetoothStatus status, |
| 158 BluetoothAddress address, | 297 BluetoothAddress address, |
| 159 array<BluetoothProperty> properties); | 298 array<BluetoothProperty> properties); |
| 160 OnDeviceFound(array<BluetoothProperty> properties); | 299 OnDeviceFound(array<BluetoothProperty> properties); |
| 161 OnDiscoveryStateChanged(BluetoothDiscoveryState state); | 300 OnDiscoveryStateChanged(BluetoothDiscoveryState state); |
| 162 OnBondStateChanged(BluetoothStatus status, | 301 OnBondStateChanged(BluetoothStatus status, |
| 163 BluetoothAddress remote_addr, | 302 BluetoothAddress remote_addr, |
| 164 BluetoothBondState state); | 303 BluetoothBondState state); |
| 165 OnAclStateChanged(BluetoothStatus status, | 304 OnAclStateChanged(BluetoothStatus status, |
| 166 BluetoothAddress remote_addr, | 305 BluetoothAddress remote_addr, |
| 167 BluetoothAclState state); | 306 BluetoothAclState state); |
| 307 | |
| 308 // Bluetooth Gatt Client callbacks | |
| 309 [MinVersion=1] OnLEDeviceFound(BluetoothAddress addr, | |
| 310 int32 rssi, | |
| 311 array<BluetoothAdvertisingData> adv_data); | |
| 312 [MinVersion=1] OnLEConnectionStateChange(BluetoothAddress remote_addr, | |
| 313 bool connected); | |
| 314 [MinVersion=1] OnSearchComplete(BluetoothAddress remote_addr, | |
| 315 BluetoothGattStatus status); | |
| 316 [MinVersion=1] OnGetGattDB(BluetoothAddress remote_addr, | |
| 317 array<BluetoothGattDBElement> db); | |
|
dcheng
2016/06/13 20:19:27
Out of curiosity, why aren't we taking advantage o
puthik_chromium
2016/06/13 20:50:27
On these functions, Chrome can call Android callba
| |
| 318 [MinVersion=1] OnServicesRemoved(BluetoothAddress remote_addr, | |
| 319 uint16 start_handle, | |
| 320 uint16 end_handle); | |
| 321 [MinVersion=1] OnServicesAdded(BluetoothAddress remote_addr, | |
| 322 array<BluetoothGattDBElement> db); | |
| 168 }; | 323 }; |
| OLD | NEW |