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

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.cc

Issue 307453007: device/bluetooth: Implement GATT characteristic properties on Chrome OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 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
« no previous file with comments | « device/bluetooth/bluetooth_gatt_chromeos_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" 5 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h" 9 #include "chromeos/dbus/bluetooth_gatt_characteristic_client.h"
10 #include "chromeos/dbus/dbus_thread_manager.h" 10 #include "chromeos/dbus/dbus_thread_manager.h"
11 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h" 11 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h"
12 #include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h" 12 #include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h"
13 #include "third_party/cros_system_api/dbus/service_constants.h"
13 14
14 namespace chromeos { 15 namespace chromeos {
15 16
16 namespace { 17 namespace {
17 18
18 // Stream operator for logging vector<uint8>. 19 // Stream operator for logging vector<uint8>.
19 std::ostream& operator<<(std::ostream& out, const std::vector<uint8> bytes) { 20 std::ostream& operator<<(std::ostream& out, const std::vector<uint8> bytes) {
20 out << "["; 21 out << "[";
21 for (std::vector<uint8>::const_iterator iter = bytes.begin(); 22 for (std::vector<uint8>::const_iterator iter = bytes.begin();
22 iter != bytes.end(); ++iter) { 23 iter != bytes.end(); ++iter) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return properties->value.value(); 87 return properties->value.value();
87 } 88 }
88 89
89 device::BluetoothGattService* 90 device::BluetoothGattService*
90 BluetoothRemoteGattCharacteristicChromeOS::GetService() const { 91 BluetoothRemoteGattCharacteristicChromeOS::GetService() const {
91 return service_; 92 return service_;
92 } 93 }
93 94
94 device::BluetoothGattCharacteristic::Properties 95 device::BluetoothGattCharacteristic::Properties
95 BluetoothRemoteGattCharacteristicChromeOS::GetProperties() const { 96 BluetoothRemoteGattCharacteristicChromeOS::GetProperties() const {
96 // TODO(armansito): Once BlueZ implements properties properly, return those 97 BluetoothGattCharacteristicClient::Properties* properties =
97 // values here. 98 DBusThreadManager::Get()->GetBluetoothGattCharacteristicClient()->
98 return kPropertyNone; 99 GetProperties(object_path_);
100 DCHECK(properties);
101
102 Properties props = kPropertyNone;
103 const std::vector<std::string>& flags = properties->flags.value();
104 for (std::vector<std::string>::const_iterator iter = flags.begin();
105 iter != flags.end();
106 ++iter) {
107 if (*iter == bluetooth_gatt_characteristic::kFlagBroadcast)
108 props |= kPropertyBroadcast;
109 if (*iter == bluetooth_gatt_characteristic::kFlagRead)
110 props |= kPropertyRead;
111 if (*iter == bluetooth_gatt_characteristic::kFlagWriteWithoutResponse)
112 props |= kPropertyWriteWithoutResponse;
113 if (*iter == bluetooth_gatt_characteristic::kFlagWrite)
114 props |= kPropertyWrite;
115 if (*iter == bluetooth_gatt_characteristic::kFlagNotify)
116 props |= kPropertyNotify;
117 if (*iter == bluetooth_gatt_characteristic::kFlagIndicate)
118 props |= kPropertyIndicate;
119 if (*iter == bluetooth_gatt_characteristic::kFlagAuthenticatedSignedWrites)
120 props |= kPropertyAuthenticatedSignedWrites;
121 if (*iter == bluetooth_gatt_characteristic::kFlagExtendedProperties)
122 props |= kPropertyExtendedProperties;
123 if (*iter == bluetooth_gatt_characteristic::kFlagReliableWrite)
124 props |= kPropertyReliableWrite;
125 if (*iter == bluetooth_gatt_characteristic::kFlagWritableAuxiliaries)
126 props |= kPropertyWritableAuxiliaries;
127 }
128
129 return props;
99 } 130 }
100 131
101 device::BluetoothGattCharacteristic::Permissions 132 device::BluetoothGattCharacteristic::Permissions
102 BluetoothRemoteGattCharacteristicChromeOS::GetPermissions() const { 133 BluetoothRemoteGattCharacteristicChromeOS::GetPermissions() const {
103 // TODO(armansito): Once BlueZ defines the permissions, return the correct 134 // TODO(armansito): Once BlueZ defines the permissions, return the correct
104 // values here. 135 // values here.
105 return kPermissionNone; 136 return kPermissionNone;
106 } 137 }
107 138
108 std::vector<device::BluetoothGattDescriptor*> 139 std::vector<device::BluetoothGattDescriptor*>
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 VLOG(1) << "Failed to write the value of remote characteristic."; 313 VLOG(1) << "Failed to write the value of remote characteristic.";
283 error_callback.Run(); 314 error_callback.Run();
284 return; 315 return;
285 } 316 }
286 317
287 VLOG(1) << "Wrote value of remote characteristic."; 318 VLOG(1) << "Wrote value of remote characteristic.";
288 callback.Run(); 319 callback.Run();
289 } 320 }
290 321
291 } // namespace chromeos 322 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_gatt_chromeos_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698