| 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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 virtual uint16_t GetProductID() const = 0; | 231 virtual uint16_t GetProductID() const = 0; |
| 232 | 232 |
| 233 // Returns the Device ID of the device, typically the release or version | 233 // Returns the Device ID of the device, typically the release or version |
| 234 // number in BCD format, where available. | 234 // number in BCD format, where available. |
| 235 virtual uint16_t GetDeviceID() const = 0; | 235 virtual uint16_t GetDeviceID() const = 0; |
| 236 | 236 |
| 237 // Returns the appearance of the device. | 237 // Returns the appearance of the device. |
| 238 virtual uint16_t GetAppearance() const = 0; | 238 virtual uint16_t GetAppearance() const = 0; |
| 239 | 239 |
| 240 // Returns the name of the device, which may be empty. | 240 // Returns the name of the device, which may be empty. |
| 241 // |
| 242 // On Android: If the device is connected we retrieve the name from the system |
| 243 // but if the device is not connected we use the name in the last advertising |
| 244 // packet. We do this because the function to retrieve the name takes several |
| 245 // ms on Android. |
| 241 virtual base::Optional<std::string> GetName() const = 0; | 246 virtual base::Optional<std::string> GetName() const = 0; |
| 242 | 247 |
| 243 // Returns the name of the device suitable for displaying, this may | 248 // Returns the name of the device suitable for displaying, this may |
| 244 // be a synthesized string containing the address and localized type name | 249 // be a synthesized string containing the address and localized type name |
| 245 // if the device has no obtained name. | 250 // if the device has no obtained name. |
| 246 virtual base::string16 GetNameForDisplay() const; | 251 virtual base::string16 GetNameForDisplay() const; |
| 247 | 252 |
| 248 // Returns the type of the device, limited to those we support or are | 253 // Returns the type of the device, limited to those we support or are |
| 249 // aware of, by decoding the bluetooth class information. The returned | 254 // aware of, by decoding the bluetooth class information. The returned |
| 250 // values are unique, and do not overlap, so DEVICE_KEYBOARD is not also | 255 // values are unique, and do not overlap, so DEVICE_KEYBOARD is not also |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 // Update the last time this device was seen. | 547 // Update the last time this device was seen. |
| 543 void UpdateTimestamp(); | 548 void UpdateTimestamp(); |
| 544 | 549 |
| 545 // Returns the time of the last call to UpdateTimestamp(), or base::Time() if | 550 // Returns the time of the last call to UpdateTimestamp(), or base::Time() if |
| 546 // it hasn't been called yet. | 551 // it hasn't been called yet. |
| 547 virtual base::Time GetLastUpdateTime() const; | 552 virtual base::Time GetLastUpdateTime() const; |
| 548 | 553 |
| 549 // Called by BluetoothAdapter when a new Advertisement is seen for this | 554 // Called by BluetoothAdapter when a new Advertisement is seen for this |
| 550 // device. This replaces previously seen Advertisement Data. | 555 // device. This replaces previously seen Advertisement Data. |
| 551 void UpdateAdvertisementData(int8_t rssi, | 556 void UpdateAdvertisementData(int8_t rssi, |
| 557 const std::string* advertised_name, |
| 552 UUIDList advertised_uuids, | 558 UUIDList advertised_uuids, |
| 553 ServiceDataMap service_data, | 559 ServiceDataMap service_data, |
| 554 const int8_t* tx_power); | 560 const int8_t* tx_power); |
| 555 | 561 |
| 556 // Called by BluetoothAdapter when it stops discoverying. | 562 // Called by BluetoothAdapter when it stops discoverying. |
| 557 void ClearAdvertisementData(); | 563 void ClearAdvertisementData(); |
| 558 | 564 |
| 559 // Return associated BluetoothAdapter. | 565 // Return associated BluetoothAdapter. |
| 560 BluetoothAdapter* GetAdapter() { return adapter_; } | 566 BluetoothAdapter* GetAdapter() { return adapter_; } |
| 561 | 567 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 // specific pointers via adapter_. | 648 // specific pointers via adapter_. |
| 643 BluetoothAdapter* adapter_; | 649 BluetoothAdapter* adapter_; |
| 644 | 650 |
| 645 // Callbacks for pending success and error result of CreateGattConnection. | 651 // Callbacks for pending success and error result of CreateGattConnection. |
| 646 std::vector<GattConnectionCallback> create_gatt_connection_success_callbacks_; | 652 std::vector<GattConnectionCallback> create_gatt_connection_success_callbacks_; |
| 647 std::vector<ConnectErrorCallback> create_gatt_connection_error_callbacks_; | 653 std::vector<ConnectErrorCallback> create_gatt_connection_error_callbacks_; |
| 648 | 654 |
| 649 // BluetoothGattConnection objects keeping the GATT connection alive. | 655 // BluetoothGattConnection objects keeping the GATT connection alive. |
| 650 std::set<BluetoothGattConnection*> gatt_connections_; | 656 std::set<BluetoothGattConnection*> gatt_connections_; |
| 651 | 657 |
| 658 base::Optional<std::string> advertised_name_; |
| 659 |
| 652 GattServiceMap gatt_services_; | 660 GattServiceMap gatt_services_; |
| 653 bool gatt_services_discovery_complete_; | 661 bool gatt_services_discovery_complete_; |
| 654 | 662 |
| 655 // Received Signal Strength Indicator of the advertisement received. | 663 // Received Signal Strength Indicator of the advertisement received. |
| 656 base::Optional<int8_t> inquiry_rssi_; | 664 base::Optional<int8_t> inquiry_rssi_; |
| 657 | 665 |
| 658 // Tx Power advertised by the device. | 666 // Tx Power advertised by the device. |
| 659 base::Optional<int8_t> inquiry_tx_power_; | 667 base::Optional<int8_t> inquiry_tx_power_; |
| 660 | 668 |
| 661 // Advertising Data flags of the device. | 669 // Advertising Data flags of the device. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 675 | 683 |
| 676 private: | 684 private: |
| 677 // Returns a localized string containing the device's bluetooth address and | 685 // Returns a localized string containing the device's bluetooth address and |
| 678 // a device type for display when |name_| is empty. | 686 // a device type for display when |name_| is empty. |
| 679 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 687 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
| 680 }; | 688 }; |
| 681 | 689 |
| 682 } // namespace device | 690 } // namespace device |
| 683 | 691 |
| 684 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 692 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
| OLD | NEW |