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 | |
| 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 struct BluetoothGattID { | |
| 149 BluetoothUUID uuid; | |
| 150 uint8 inst_id; | |
| 151 }; | |
| 152 | |
| 153 struct BluetoothGattServiceID { | |
| 154 BluetoothGattID id; | |
| 155 uint8 is_primary; | |
| 156 }; | |
| 157 | |
| 158 struct BluetoothGattValue { | |
| 159 BluetoothGattStatus status; | |
| 160 uint32 len; | |
| 161 uint32 type; | |
| 162 array<uint8> value; | |
| 163 }; | |
| 164 | |
| 165 // Copy from Bluetooth Assigned Numbers Document, Generic Access Profile | |
| 166 // https://www.bluetooth.com/specifications/assigned-numbers/generic-access-prof ile | |
| 167 [Extensible] | |
| 168 enum BluetoothAdvertisingDataType { | |
| 169 DATA_TYPE_FLAGS = 0x01, | |
| 170 DATA_TYPE_SERVICE_UUIDS_128_BIT_COMPLETE = 0x07, | |
| 171 DATA_TYPE_LOCAL_NAME_COMPLETE = 0x09, | |
| 172 DATA_TYPE_TX_POWER_LEVEL = 0x0A, | |
| 173 DATA_TYPE_SERVICE_DATA = 0x16, | |
| 174 DATA_TYPE_MANUFACTURER_SPECIFIC_DATA = 0xff, | |
| 175 }; | |
| 176 | |
| 177 // Copy from Bluetooth Core v4.2 Volume 3 Part C Chapter 11 | |
| 178 // and Bluetooth Core Specification Supplement v6 Part A Chapter 1 | |
| 179 // https://www.bluetooth.com/specifications/adopted-specifications | |
| 180 union BluetoothAdvertisingData { | |
| 181 uint8 flags; | |
| 182 array<BluetoothUUID> service_uuids; | |
| 183 string local_name; | |
| 184 uint8 tx_power_level; | |
| 185 BluetoothServiceData service_data; | |
| 186 array<uint8> manufacture_data; | |
|
Luis Héctor Chávez
2016/06/09 20:59:13
Shouldn't this be |manufacturer_data|?
puthik_chromium
2016/06/09 21:30:56
Done
| |
| 187 array<uint8> other_data; | |
| 188 }; | |
| 189 | |
| 190 struct BluetoothServiceData { | |
| 191 uint16 uuid_16bit; | |
| 192 array<uint8> data; | |
| 193 }; | |
| 194 | |
| 195 [Extensible] | |
| 196 enum BluetoothGattDBAttributeType { | |
| 197 BTGATT_DB_PRIMARY_SERVICE = 0, | |
| 198 BTGATT_DB_SECONDARY_SERVICE, | |
| 199 BTGATT_DB_INCLUDED_SERVICE, | |
| 200 BTGATT_DB_CHARACTERISTIC, | |
| 201 BTGATT_DB_DESCRIPTOR, | |
| 202 }; | |
| 203 | |
| 204 struct BluetoothGattDBElement { | |
| 205 uint8 id; | |
| 206 BluetoothUUID uuid; | |
| 207 BluetoothGattDBAttributeType type; | |
| 208 uint16 attribute_handle; | |
| 209 | |
| 210 /* | |
| 211 * If |type| is |BTGATT_DB_PRIMARY_SERVICE|, or | |
| 212 * |BTGATT_DB_SECONDARY_SERVICE|, this contains the start and end attribute | |
| 213 * handles. | |
| 214 */ | |
| 215 uint16 start_handle; | |
| 216 uint16 end_handle; | |
| 217 | |
| 218 /* | |
| 219 * If |type| is |BTGATT_DB_CHARACTERISTIC|, this contains the properties of | |
| 220 * the characteristic. | |
| 221 */ | |
| 222 uint8 properties; | |
| 223 }; | |
| 224 | |
| 131 interface BluetoothHost { | 225 interface BluetoothHost { |
| 132 EnableAdapter() => (BluetoothAdapterState state); | 226 EnableAdapter() => (BluetoothAdapterState state); |
| 133 DisableAdapter() => (BluetoothAdapterState state); | 227 DisableAdapter() => (BluetoothAdapterState state); |
| 134 GetAdapterProperty(BluetoothPropertyType type); | 228 GetAdapterProperty(BluetoothPropertyType type); |
| 135 SetAdapterProperty(BluetoothProperty property); | 229 SetAdapterProperty(BluetoothProperty property); |
| 136 GetRemoteDeviceProperty(BluetoothAddress remote_addr, | 230 GetRemoteDeviceProperty(BluetoothAddress remote_addr, |
| 137 BluetoothPropertyType type); | 231 BluetoothPropertyType type); |
| 138 SetRemoteDeviceProperty(BluetoothAddress remote_addr, | 232 SetRemoteDeviceProperty(BluetoothAddress remote_addr, |
| 139 BluetoothProperty property); | 233 BluetoothProperty property); |
| 140 GetRemoteServiceRecord(BluetoothAddress remote_addr, | 234 GetRemoteServiceRecord(BluetoothAddress remote_addr, |
| 141 BluetoothUUID uuid); | 235 BluetoothUUID uuid); |
| 142 GetRemoteServices(BluetoothAddress remote_addr); | 236 GetRemoteServices(BluetoothAddress remote_addr); |
| 143 StartDiscovery(); | 237 StartDiscovery(); |
| 144 CancelDiscovery(); | 238 CancelDiscovery(); |
| 145 CreateBond(BluetoothAddress addr, int32 transport); | 239 CreateBond(BluetoothAddress addr, int32 transport); |
| 146 RemoveBond(BluetoothAddress addr); | 240 RemoveBond(BluetoothAddress addr); |
| 147 CancelBond(BluetoothAddress addr); | 241 CancelBond(BluetoothAddress addr); |
| 148 | 242 |
| 149 GetConnectionState(BluetoothAddress addr) => (bool connected); | 243 GetConnectionState(BluetoothAddress addr) => (bool connected); |
| 244 | |
| 245 // Bluetooth Gatt Client functions | |
| 246 [MinVersion=1] StartLEScan(); | |
| 247 [MinVersion=1] StopLEScan(); | |
| 248 [MinVersion=1] ConnectLEDevice(BluetoothAddress remote_addr); | |
| 249 [MinVersion=1] DisconnectLEDevice(BluetoothAddress remote_addr); | |
| 250 [MinVersion=1] SearchService(BluetoothAddress remote_addr); | |
| 251 [MinVersion=1] GetGattDB(BluetoothAddress remote_addr); | |
| 252 [MinVersion=1] StartLEListen() => (BluetoothGattStatus status); | |
| 253 [MinVersion=1] StopLEListen() => (BluetoothGattStatus status); | |
| 254 [MinVersion=1] ReadGattCharacteristic(BluetoothAddress remote_addr, | |
| 255 BluetoothGattServiceID service_id, | |
| 256 BluetoothGattID char_id) | |
| 257 => (BluetoothGattValue value); | |
| 258 [MinVersion=1] WriteGattCharacteristic(BluetoothAddress remote_addr, | |
| 259 BluetoothGattServiceID service_id, | |
| 260 BluetoothGattID char_id, | |
| 261 BluetoothGattValue value) | |
| 262 => (BluetoothGattStatus status); | |
| 263 [MinVersion=1] ReadGattDescriptor(BluetoothAddress remote_addr, | |
| 264 BluetoothGattServiceID service_id, | |
| 265 BluetoothGattID char_id, | |
| 266 BluetoothGattID desc_id) | |
| 267 => (BluetoothGattValue value); | |
| 268 [MinVersion=1] WriteGattDescriptor(BluetoothAddress remote_addr, | |
| 269 BluetoothGattServiceID service_id, | |
| 270 BluetoothGattID char_id, | |
| 271 BluetoothGattID desc_id, | |
| 272 BluetoothGattValue value) | |
| 273 => (BluetoothGattStatus status); | |
| 274 [MinVersion=1] RegisterForGattNotification(BluetoothAddress remote_addr, | |
| 275 BluetoothGattServiceID service_id, | |
| 276 BluetoothGattID char_id) | |
| 277 => (BluetoothGattStatus status); | |
| 278 [MinVersion=1] DeregisterForGattNotification(BluetoothAddress remote_addr, | |
| 279 BluetoothGattServiceID service_id , | |
| 280 BluetoothGattID char_id) | |
| 281 => (BluetoothGattStatus status); | |
| 282 [MinVersion=1] ReadRemoteRssi(BluetoothAddress remote_addr) | |
| 283 => (int32 rssi); | |
| 284 | |
| 150 }; | 285 }; |
| 151 | 286 |
| 152 interface BluetoothInstance { | 287 interface BluetoothInstance { |
| 153 Init(BluetoothHost host_ptr); | 288 Init(BluetoothHost host_ptr); |
| 154 | 289 |
| 155 OnAdapterProperties(BluetoothStatus status, | 290 OnAdapterProperties(BluetoothStatus status, |
| 156 array<BluetoothProperty> properties); | 291 array<BluetoothProperty> properties); |
| 157 OnRemoteDeviceProperties(BluetoothStatus status, | 292 OnRemoteDeviceProperties(BluetoothStatus status, |
| 158 BluetoothAddress address, | 293 BluetoothAddress address, |
| 159 array<BluetoothProperty> properties); | 294 array<BluetoothProperty> properties); |
| 160 OnDeviceFound(array<BluetoothProperty> properties); | 295 OnDeviceFound(array<BluetoothProperty> properties); |
| 161 OnDiscoveryStateChanged(BluetoothDiscoveryState state); | 296 OnDiscoveryStateChanged(BluetoothDiscoveryState state); |
| 162 OnBondStateChanged(BluetoothStatus status, | 297 OnBondStateChanged(BluetoothStatus status, |
| 163 BluetoothAddress remote_addr, | 298 BluetoothAddress remote_addr, |
| 164 BluetoothBondState state); | 299 BluetoothBondState state); |
| 165 OnAclStateChanged(BluetoothStatus status, | 300 OnAclStateChanged(BluetoothStatus status, |
| 166 BluetoothAddress remote_addr, | 301 BluetoothAddress remote_addr, |
| 167 BluetoothAclState state); | 302 BluetoothAclState state); |
| 303 | |
| 304 // Bluetooth Gatt Client callbacks | |
| 305 [MinVersion=1] OnLEDeviceFound(BluetoothAddress addr, | |
| 306 int32 rssi, | |
| 307 array<BluetoothAdvertisingData> adv_data); | |
| 308 [MinVersion=1] OnLEConnectionStateChange(BluetoothAddress remote_addr, | |
| 309 bool connected); | |
| 310 [MinVersion=1] OnSearchComplete(BluetoothAddress remote_addr, | |
| 311 BluetoothGattStatus status); | |
| 312 [MinVersion=1] OnGetGattDB(BluetoothAddress remote_addr, | |
| 313 array<BluetoothGattDBElement> db); | |
| 314 [MinVersion=1] OnServicesRemoved(BluetoothAddress remote_addr, | |
| 315 uint16 start_handle, | |
| 316 uint16 end_handle); | |
| 317 [MinVersion=1] OnServicesAdded(BluetoothAddress remote_addr, | |
| 318 array<BluetoothGattDBElement> db); | |
| 168 }; | 319 }; |
| OLD | NEW |