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