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

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

Issue 256413003: chrome.bluetoothLowEnergy: Implement getService and getServices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased Created 6 years, 7 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_service_chromeos.h" 5 #include "device/bluetooth/bluetooth_remote_gatt_service_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_service_client.h" 9 #include "chromeos/dbus/bluetooth_gatt_service_client.h"
10 #include "chromeos/dbus/dbus_thread_manager.h" 10 #include "chromeos/dbus/dbus_thread_manager.h"
11 #include "device/bluetooth/bluetooth_device_chromeos.h"
11 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" 12 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h"
12 13
13 namespace chromeos { 14 namespace chromeos {
14 15
15 namespace { 16 namespace {
16 17
17 // Stream operator for logging vector<uint8>. 18 // Stream operator for logging vector<uint8>.
18 std::ostream& operator<<(std::ostream& out, const std::vector<uint8> bytes) { 19 std::ostream& operator<<(std::ostream& out, const std::vector<uint8> bytes) {
19 out << "["; 20 out << "[";
20 for (std::vector<uint8>::const_iterator iter = bytes.begin(); 21 for (std::vector<uint8>::const_iterator iter = bytes.begin();
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 } 96 }
96 97
97 bool BluetoothRemoteGattServiceChromeOS::IsPrimary() const { 98 bool BluetoothRemoteGattServiceChromeOS::IsPrimary() const {
98 BluetoothGattServiceClient::Properties* properties = 99 BluetoothGattServiceClient::Properties* properties =
99 DBusThreadManager::Get()->GetBluetoothGattServiceClient()-> 100 DBusThreadManager::Get()->GetBluetoothGattServiceClient()->
100 GetProperties(object_path_); 101 GetProperties(object_path_);
101 DCHECK(properties); 102 DCHECK(properties);
102 return properties->primary.value(); 103 return properties->primary.value();
103 } 104 }
104 105
106 device::BluetoothDevice* BluetoothRemoteGattServiceChromeOS::GetDevice() const {
107 return device_;
108 }
109
105 std::vector<device::BluetoothGattCharacteristic*> 110 std::vector<device::BluetoothGattCharacteristic*>
106 BluetoothRemoteGattServiceChromeOS::GetCharacteristics() const { 111 BluetoothRemoteGattServiceChromeOS::GetCharacteristics() const {
107 std::vector<device::BluetoothGattCharacteristic*> characteristics; 112 std::vector<device::BluetoothGattCharacteristic*> characteristics;
108 for (CharacteristicMap::const_iterator iter = characteristics_.begin(); 113 for (CharacteristicMap::const_iterator iter = characteristics_.begin();
109 iter != characteristics_.end(); ++iter) { 114 iter != characteristics_.end(); ++iter) {
110 characteristics.push_back(iter->second); 115 characteristics.push_back(iter->second);
111 } 116 }
112 return characteristics; 117 return characteristics;
113 } 118 }
114 119
115 std::vector<device::BluetoothGattService*> 120 std::vector<device::BluetoothGattService*>
116 BluetoothRemoteGattServiceChromeOS::GetIncludedServices() const { 121 BluetoothRemoteGattServiceChromeOS::GetIncludedServices() const {
117 // TODO(armansito): Return the actual included services here. 122 // TODO(armansito): Return the actual included services here.
118 return std::vector<device::BluetoothGattService*>(); 123 return std::vector<device::BluetoothGattService*>();
119 } 124 }
120 125
121 device::BluetoothGattCharacteristic* 126 device::BluetoothGattCharacteristic*
122 BluetoothRemoteGattServiceChromeOS::GetCharacteristic( 127 BluetoothRemoteGattServiceChromeOS::GetCharacteristic(
123 const std::string& identifier) { 128 const std::string& identifier) const {
124 CharacteristicMap::const_iterator iter = 129 CharacteristicMap::const_iterator iter =
125 characteristics_.find(dbus::ObjectPath(identifier)); 130 characteristics_.find(dbus::ObjectPath(identifier));
126 if (iter == characteristics_.end()) 131 if (iter == characteristics_.end())
127 return NULL; 132 return NULL;
128 return iter->second; 133 return iter->second;
129 } 134 }
130 135
131 bool BluetoothRemoteGattServiceChromeOS::AddCharacteristic( 136 bool BluetoothRemoteGattServiceChromeOS::AddCharacteristic(
132 device::BluetoothGattCharacteristic* characteristic) { 137 device::BluetoothGattCharacteristic* characteristic) {
133 VLOG(1) << "Characteristics cannot be added to a remote GATT service."; 138 VLOG(1) << "Characteristics cannot be added to a remote GATT service.";
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 return; 242 return;
238 243
239 VLOG(1) << "GATT characteristic value has changed: " << object_path.value() 244 VLOG(1) << "GATT characteristic value has changed: " << object_path.value()
240 << ": " << properties->value.value(); 245 << ": " << properties->value.value();
241 FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_, 246 FOR_EACH_OBSERVER(device::BluetoothGattService::Observer, observers_,
242 GattCharacteristicValueChanged(this, iter->second, 247 GattCharacteristicValueChanged(this, iter->second,
243 properties->value.value())); 248 properties->value.value()));
244 } 249 }
245 250
246 } // namespace chromeos 251 } // namespace chromeos
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_remote_gatt_service_chromeos.h ('k') | device/bluetooth/test/mock_bluetooth_device.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698