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

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: 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
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"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 return properties->value.value(); 86 return properties->value.value();
87 } 87 }
88 88
89 device::BluetoothGattService* 89 device::BluetoothGattService*
90 BluetoothRemoteGattCharacteristicChromeOS::GetService() const { 90 BluetoothRemoteGattCharacteristicChromeOS::GetService() const {
91 return service_; 91 return service_;
92 } 92 }
93 93
94 device::BluetoothGattCharacteristic::Properties 94 device::BluetoothGattCharacteristic::Properties
95 BluetoothRemoteGattCharacteristicChromeOS::GetProperties() const { 95 BluetoothRemoteGattCharacteristicChromeOS::GetProperties() const {
96 // TODO(armansito): Once BlueZ implements properties properly, return those 96 BluetoothGattCharacteristicClient::Properties* properties =
97 // values here. 97 DBusThreadManager::Get()->GetBluetoothGattCharacteristicClient()->
98 return kPropertyNone; 98 GetProperties(object_path_);
99 DCHECK(properties);
100
101 Properties props = kPropertyNone;
102 const std::vector<std::string>& flags = properties->flags.value();
103 for (std::vector<std::string>::const_iterator iter = flags.begin();
104 iter != flags.end();
105 ++iter) {
106 if (*iter == BluetoothGattCharacteristicClient::kFlagBroadcast)
107 props |= kPropertyBroadcast;
108 if (*iter == BluetoothGattCharacteristicClient::kFlagRead)
109 props |= kPropertyRead;
110 if (*iter == BluetoothGattCharacteristicClient::kFlagWriteWithoutResponse)
111 props |= kPropertyWriteWithoutResponse;
112 if (*iter == BluetoothGattCharacteristicClient::kFlagWrite)
113 props |= kPropertyWrite;
114 if (*iter == BluetoothGattCharacteristicClient::kFlagNotify)
115 props |= kPropertyNotify;
116 if (*iter == BluetoothGattCharacteristicClient::kFlagIndicate)
117 props |= kPropertyIndicate;
118 if (*iter ==
119 BluetoothGattCharacteristicClient::kFlagAuthenticatedSignedWrites)
120 props |= kPropertyAuthenticatedSignedWrites;
121 if (*iter == BluetoothGattCharacteristicClient::kFlagExtendedProperties)
122 props |= kPropertyExtendedProperties;
123 if (*iter == BluetoothGattCharacteristicClient::kFlagReliableWrite)
124 props |= kPropertyReliableWrite;
125 if (*iter == BluetoothGattCharacteristicClient::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

Powered by Google App Engine
This is Rietveld 408576698