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 CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_UTILS_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_UTILS_H_ |
6 #define CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_UTILS_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_UTILS_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
| 10 #if defined(OS_CHROMEOS) |
10 #include <bluetooth/bluetooth.h> | 11 #include <bluetooth/bluetooth.h> |
| 12 #endif |
11 | 13 |
12 namespace chromeos { | 14 namespace device { |
13 namespace bluetooth_utils { | 15 namespace bluetooth_utils { |
14 | 16 |
| 17 #if defined(OS_CHROMEOS) |
15 // Converts a bluetooth address in the format "B0:D0:9C:0F:3A:2D" into a | 18 // Converts a bluetooth address in the format "B0:D0:9C:0F:3A:2D" into a |
16 // bdaddr_t struct. Returns true on success, false on failure. The contents | 19 // bdaddr_t struct. Returns true on success, false on failure. The contents |
17 // of |out_address| are zeroed on failure. | 20 // of |out_address| are zeroed on failure. |
18 // Note that the order is reversed upon conversion. For example, | 21 // Note that the order is reversed upon conversion. For example, |
19 // "B0:D0:9C:0F:3A:2D" -> {"0x2d", "0x3a", "0x0f", "0x9c", "0xd0", "0xb0"} | 22 // "B0:D0:9C:0F:3A:2D" -> {"0x2d", "0x3a", "0x0f", "0x9c", "0xd0", "0xb0"} |
20 bool str2ba(const std::string& in_address, bdaddr_t* out_address); | 23 bool str2ba(const std::string& in_address, bdaddr_t* out_address); |
| 24 #endif |
21 | 25 |
22 // Takes a 4, 8 or 36 character UUID, validates it and returns it in 36 | 26 // Takes a 4, 8 or 36 character UUID, validates it and returns it in 36 |
23 // character format with all hex digits lower case. If |uuid| is invalid, the | 27 // character format with all hex digits lower case. If |uuid| is invalid, the |
24 // empty string is returned. | 28 // empty string is returned. |
25 // | 29 // |
26 // Valid inputs are: | 30 // Valid inputs are: |
27 // XXXX | 31 // XXXX |
28 // 0xXXXX | 32 // 0xXXXX |
29 // XXXXXXXX | 33 // XXXXXXXX |
30 // 0xXXXXXXXX | 34 // 0xXXXXXXXX |
31 // XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX | 35 // XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX |
32 std::string CanonicalUuid(std::string uuid); | 36 std::string CanonicalUuid(std::string uuid); |
33 | 37 |
34 } // namespace bluetooth_utils | 38 } // namespace bluetooth_utils |
35 } // namespace chromeos | 39 } // namespace device |
36 | 40 |
37 #endif // CHROME_BROWSER_CHROMEOS_BLUETOOTH_BLUETOOTH_UTILS_H_ | 41 #endif // DEVICE_BLUETOOTH_BLUETOOTH_UTILS_H_ |
38 | 42 |
OLD | NEW |