Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 283 // we consider a call is ongoing if none of the callbacks passed to Connect() | 283 // we consider a call is ongoing if none of the callbacks passed to Connect() |
| 284 // were called after the corresponding call to Connect(). | 284 // were called after the corresponding call to Connect(). |
| 285 virtual bool IsConnecting() const = 0; | 285 virtual bool IsConnecting() const = 0; |
| 286 | 286 |
| 287 // Indicates whether the device can be trusted, based on device properties, | 287 // Indicates whether the device can be trusted, based on device properties, |
| 288 // such as vendor and product id. | 288 // such as vendor and product id. |
| 289 bool IsTrustable() const; | 289 bool IsTrustable() const; |
| 290 | 290 |
| 291 // Returns the set of UUIDs that this device supports. For classic Bluetooth | 291 // Returns the set of UUIDs that this device supports. For classic Bluetooth |
| 292 // devices this data is collected from both the EIR data and SDP tables, | 292 // devices this data is collected from both the EIR data and SDP tables, |
| 293 // for Low Energy devices this data is collected from AD and GATT primary | 293 // For non-connected Low Energy Devices this returns the latest advertised |
|
scheib
2016/08/05 18:49:31
optional:
* Use some bullets.
* There are a few ca
ortuno
2016/08/05 23:00:17
Done.
| |
| 294 // services, for dual mode devices this may be collected from both./ | 294 // UUIDs. For Low Energy connected devices for which services have been |
| 295 virtual UUIDList GetUUIDs() const = 0; | 295 // discovered we return the UUIDs of the device's services. If the services |
| 296 // have not been discovered yet we return an empty list. | |
| 297 // For dual mode devices this may be collected from both. | |
| 298 // | |
| 299 // Note: On ChromeOS and Linux, Bluez persists all services meaning if | |
| 300 // a device stops advertising a service this function will still return | |
| 301 // its UUID. | |
| 302 virtual UUIDList GetUUIDs() const; | |
| 296 | 303 |
| 297 // The received signal strength, in dBm. This field is avaliable and valid | 304 // The received signal strength, in dBm. This field is avaliable and valid |
| 298 // only during discovery. If not during discovery, or RSSI wasn't reported, | 305 // only during discovery. If not during discovery, or RSSI wasn't reported, |
| 299 // this method will return |kUnknownPower|. | 306 // this method will return |kUnknownPower|. |
| 300 virtual int16_t GetInquiryRSSI() const = 0; | 307 virtual int16_t GetInquiryRSSI() const = 0; |
| 301 | 308 |
| 302 // The transmitted power level. This field is avaliable only for LE devices | 309 // The transmitted power level. This field is avaliable only for LE devices |
| 303 // that include this field in AD. It is avaliable and valid only during | 310 // that include this field in AD. It is avaliable and valid only during |
| 304 // discovery. If not during discovery, or TxPower wasn't reported, this | 311 // discovery. If not during discovery, or TxPower wasn't reported, this |
| 305 // method will return |kUnknownPower|. | 312 // method will return |kUnknownPower|. |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 485 | 492 |
| 486 // Update the last time this device was seen. | 493 // Update the last time this device was seen. |
| 487 void UpdateTimestamp(); | 494 void UpdateTimestamp(); |
| 488 | 495 |
| 489 // Return associated BluetoothAdapter. | 496 // Return associated BluetoothAdapter. |
| 490 BluetoothAdapter* GetAdapter() { return adapter_; } | 497 BluetoothAdapter* GetAdapter() { return adapter_; } |
| 491 | 498 |
| 492 protected: | 499 protected: |
| 493 // BluetoothGattConnection is a friend to call Add/RemoveGattConnection. | 500 // BluetoothGattConnection is a friend to call Add/RemoveGattConnection. |
| 494 friend BluetoothGattConnection; | 501 friend BluetoothGattConnection; |
| 502 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, GetUUIDs); | |
| 495 FRIEND_TEST_ALL_PREFIXES( | 503 FRIEND_TEST_ALL_PREFIXES( |
| 496 BluetoothTest, | 504 BluetoothTest, |
| 497 BluetoothGattConnection_DisconnectGatt_SimulateConnect); | 505 BluetoothGattConnection_DisconnectGatt_SimulateConnect); |
| 498 FRIEND_TEST_ALL_PREFIXES( | 506 FRIEND_TEST_ALL_PREFIXES( |
| 499 BluetoothTest, | 507 BluetoothTest, |
| 500 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect); | 508 BluetoothGattConnection_DisconnectGatt_SimulateDisconnect); |
| 501 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, | 509 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, |
| 502 BluetoothGattConnection_ErrorAfterConnection); | 510 BluetoothGattConnection_ErrorAfterConnection); |
| 503 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, | 511 FRIEND_TEST_ALL_PREFIXES(BluetoothTest, |
| 504 BluetoothGattConnection_DisconnectGatt_Cleanup); | 512 BluetoothGattConnection_DisconnectGatt_Cleanup); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 558 std::set<BluetoothGattConnection*> gatt_connections_; | 566 std::set<BluetoothGattConnection*> gatt_connections_; |
| 559 | 567 |
| 560 // Mapping from the platform-specific GATT service identifiers to | 568 // Mapping from the platform-specific GATT service identifiers to |
| 561 // BluetoothRemoteGattService objects. | 569 // BluetoothRemoteGattService objects. |
| 562 typedef base::ScopedPtrHashMap<std::string, | 570 typedef base::ScopedPtrHashMap<std::string, |
| 563 std::unique_ptr<BluetoothRemoteGattService>> | 571 std::unique_ptr<BluetoothRemoteGattService>> |
| 564 GattServiceMap; | 572 GattServiceMap; |
| 565 GattServiceMap gatt_services_; | 573 GattServiceMap gatt_services_; |
| 566 bool gatt_services_discovery_complete_; | 574 bool gatt_services_discovery_complete_; |
| 567 | 575 |
| 576 std::unordered_set<BluetoothUUID, BluetoothUUIDHash> advertised_uuids_; | |
|
scheib
2016/08/05 18:49:31
optional... we already have the code to gather all
ortuno
2016/08/08 22:56:39
Done. Forgot to mark this done the first time.
| |
| 577 | |
| 568 // Mapping from service UUID represented as a std::string of a bluetooth | 578 // Mapping from service UUID represented as a std::string of a bluetooth |
| 569 // service to | 579 // service to |
| 570 // the specific data. The data is stored as BinaryValue. | 580 // the specific data. The data is stored as BinaryValue. |
| 571 std::unique_ptr<base::DictionaryValue> services_data_; | 581 std::unique_ptr<base::DictionaryValue> services_data_; |
| 572 | 582 |
| 573 // Timestamp for when an advertisement was last seen. | 583 // Timestamp for when an advertisement was last seen. |
| 574 base::Time last_update_time_; | 584 base::Time last_update_time_; |
| 575 | 585 |
| 576 private: | 586 private: |
| 577 // Returns a localized string containing the device's bluetooth address and | 587 // Returns a localized string containing the device's bluetooth address and |
| 578 // a device type for display when |name_| is empty. | 588 // a device type for display when |name_| is empty. |
| 579 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 589 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
| 580 }; | 590 }; |
| 581 | 591 |
| 582 } // namespace device | 592 } // namespace device |
| 583 | 593 |
| 584 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 594 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |