Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: chrome/browser/chromeos/bluetooth/bluetooth_utils.cc

Issue 10007008: Add support for creating bluetooth RFCOMM sockets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase diff to exclude extensions code Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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 #include "chrome/browser/chromeos/bluetooth/bluetooth_utils.h"
6
7 #include <vector>
8
9 #include <bluetooth/bluetooth.h>
10
11 #include "base/logging.h"
12 #include "base/string_number_conversions.h"
13
14 namespace chromeos {
15 namespace bluetooth_utils {
16
17 bool str2ba(const std::string& in_address, bdaddr_t* out_address) {
18 if (!out_address)
19 return false;
20
21 memset(out_address, 0, sizeof(*out_address));
22
23 if (in_address.size() != 17)
24 return false;
25
26 std::string numbers_only;
27 for (int i = 0; i < 6; ++i) {
28 numbers_only += in_address.substr(i * 3, 2);
29 }
30
31 std::vector<uint8> address_bytes;
32 if (base::HexStringToBytes(numbers_only, &address_bytes)) {
33 if (address_bytes.size() == 6) {
34 for (int i = 0; i < 6; ++i) {
35 out_address->b[i] = address_bytes[i];
36 }
37 return true;
38 }
39 }
40
41 return false;
42 }
43
44 } // namespace bluetooth_utils
45 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/bluetooth/bluetooth_utils.h ('k') | chrome/browser/chromeos/bluetooth/bluetooth_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698