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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/bluetooth/bluetooth_utils.cc
diff --git a/chrome/browser/chromeos/bluetooth/bluetooth_utils.cc b/chrome/browser/chromeos/bluetooth/bluetooth_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..8ee0ab9f5359d330dd77857f277345ae398922dc
--- /dev/null
+++ b/chrome/browser/chromeos/bluetooth/bluetooth_utils.cc
@@ -0,0 +1,45 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/bluetooth/bluetooth_utils.h"
+
+#include <vector>
+
+#include <bluetooth/bluetooth.h>
+
+#include "base/logging.h"
+#include "base/string_number_conversions.h"
+
+namespace chromeos {
+namespace bluetooth_utils {
+
+bool str2ba(const std::string& in_address, bdaddr_t* out_address) {
+ if (!out_address)
+ return false;
+
+ memset(out_address, 0, sizeof(*out_address));
+
+ if (in_address.size() != 17)
+ return false;
+
+ std::string numbers_only;
+ for (int i = 0; i < 6; ++i) {
+ numbers_only += in_address.substr(i * 3, 2);
+ }
+
+ std::vector<uint8> address_bytes;
+ if (base::HexStringToBytes(numbers_only, &address_bytes)) {
+ if (address_bytes.size() == 6) {
+ for (int i = 0; i < 6; ++i) {
+ out_address->b[i] = address_bytes[i];
+ }
+ return true;
+ }
+ }
+
+ return false;
+}
+
+} // namespace bluetooth_utils
+} // namespace chromeos
« 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