Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 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 |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef DEVICE_BLUETOOTH_BLUETOOTH_SERVICE_RECORD_H_ |
| 6 | #define DEVICE_BLUETOOTH_BLUETOOTH_SERVICE_RECORD_H_ |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include "base/basictypes.h" |
| 11 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 12 | namespace device { |
| 13 | |
| 14 | // BluetoothServiceRecord represents an SDP service record. |
| 15 | // |
| 16 | // This implementation is currently incomplete: it only supports those fields |
| 17 | // that have been necessary so far. |
| 18 | class BluetoothServiceRecord { |
| 19 | public: |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 20 | virtual ~BluetoothServiceRecord(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 21 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 22 | // The human-readable name of this service. |
| 23 | const std::string& name() const { return name_; } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 24 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 25 | // The address of the BluetoothDevice providing this service. |
| 26 | const std::string& address() const { return address_; } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 27 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 28 | // The UUID of the service. This field may be empty if no UUID was |
| 29 | // specified in the service record. |
| 30 | const std::string& uuid() const { return uuid_; } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 31 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 32 | // Indicates if this service supports HID. |
| 33 | bool SupportsHid() const { return supports_hid_; } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 34 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 35 | // For HID services, returns the HIDReconnectInitiate attribute. For non-HID |
| 36 | // or unknown services defaults to true. |
| 37 | bool hid_reconnect_initiate() const { return hid_reconnect_initiate_; } |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 38 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 39 | // For HID services, returns the HIDNormallyConnectable attribute. For non-HID |
| 40 | // or unknown services defaults to true. |
| 41 | bool hid_normally_connectable() const { return hid_normally_connectable_; } |
| 42 | |
| 43 | // Indicates if this service supports RFCOMM communication. |
| 44 | bool SupportsRfcomm() const { return supports_rfcomm_; } |
| 45 | |
| 46 | // The RFCOMM channel to use, if this service supports RFCOMM communication. |
| 47 | // The return value is undefined if SupportsRfcomm() returns false. |
| 48 | uint8 rfcomm_channel() const { return rfcomm_channel_; } |
| 49 | |
| 50 | protected: |
| 51 | BluetoothServiceRecord(); |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 52 | |
| 53 | std::string address_; |
| 54 | std::string name_; |
| 55 | std::string uuid_; |
| 56 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 57 | bool supports_hid_; |
| 58 | bool hid_reconnect_initiate_; |
| 59 | bool hid_normally_connectable_; |
| 60 | |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 61 | bool supports_rfcomm_; |
| 62 | uint8 rfcomm_channel_; |
| 63 | |
Torne (Richard Coles) | 2a99a7e | 2013-03-28 15:31:22 +0000 | [diff] [blame] | 64 | private: |
Torne (Richard Coles) | 5821806 | 2012-11-14 11:43:16 +0000 | [diff] [blame] | 65 | DISALLOW_COPY_AND_ASSIGN(BluetoothServiceRecord); |
| 66 | }; |
| 67 | |
| 68 | } // namespace device |
| 69 | |
| 70 | #endif // DEVICE_BLUETOOTH_BLUETOOTH_SERVICE_RECORD_H_ |