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

Side by Side Diff: device/bluetooth/bluetooth_device_mac.mm

Issue 735893002: Add GetConnectionInfo function for BluetoothDevice, replacing the existing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix compile errors on other platforms Created 5 years, 11 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
« no previous file with comments | « device/bluetooth/bluetooth_device_mac.h ('k') | device/bluetooth/bluetooth_device_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_device_mac.h" 5 #include "device/bluetooth/bluetooth_device_mac.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 } 86 }
87 87
88 uint16 BluetoothDeviceMac::GetProductID() const { 88 uint16 BluetoothDeviceMac::GetProductID() const {
89 return 0; 89 return 0;
90 } 90 }
91 91
92 uint16 BluetoothDeviceMac::GetDeviceID() const { 92 uint16 BluetoothDeviceMac::GetDeviceID() const {
93 return 0; 93 return 0;
94 } 94 }
95 95
96 int BluetoothDeviceMac::GetRSSI() const {
97 if (![device_ isConnected]) {
98 NOTIMPLEMENTED();
99 return kUnknownPower;
100 }
101
102 int rssi = [device_ rawRSSI];
103
104 // The API guarantees that +127 is returned in case the RSSI is not readable:
105 // http://goo.gl/bpURYv
106 if (rssi == 127)
107 return kUnknownPower;
108
109 return rssi;
110 }
111
112 int BluetoothDeviceMac::GetCurrentHostTransmitPower() const {
113 return GetHostTransmitPower(kReadCurrentTransmitPowerLevel);
114 }
115
116 int BluetoothDeviceMac::GetMaximumHostTransmitPower() const {
117 return GetHostTransmitPower(kReadMaximumTransmitPowerLevel);
118 }
119
120 bool BluetoothDeviceMac::IsPaired() const { 96 bool BluetoothDeviceMac::IsPaired() const {
121 return [device_ isPaired]; 97 return [device_ isPaired];
122 } 98 }
123 99
124 bool BluetoothDeviceMac::IsConnected() const { 100 bool BluetoothDeviceMac::IsConnected() const {
125 return [device_ isConnected]; 101 return [device_ isConnected];
126 } 102 }
127 103
128 bool BluetoothDeviceMac::IsConnectable() const { 104 bool BluetoothDeviceMac::IsConnectable() const {
129 return false; 105 return false;
(...skipping 27 matching lines...) Expand all
157 bool BluetoothDeviceMac::ExpectingPasskey() const { 133 bool BluetoothDeviceMac::ExpectingPasskey() const {
158 NOTIMPLEMENTED(); 134 NOTIMPLEMENTED();
159 return false; 135 return false;
160 } 136 }
161 137
162 bool BluetoothDeviceMac::ExpectingConfirmation() const { 138 bool BluetoothDeviceMac::ExpectingConfirmation() const {
163 NOTIMPLEMENTED(); 139 NOTIMPLEMENTED();
164 return false; 140 return false;
165 } 141 }
166 142
143 void BluetoothDeviceMac::GetConnectionInfo(
144 const ConnectionInfoCallback& callback) {
145 ConnectionInfo connection_info;
146 if (![device_ isConnected]) {
147 callback.Run(connection_info);
148 return;
149 }
150
151 connection_info.rssi = [device_ rawRSSI];
152 // The API guarantees that +127 is returned in case the RSSI is not readable:
153 // http://goo.gl/bpURYv
154 if (connection_info.rssi == 127)
155 connection_info.rssi = kUnknownPower;
156
157 connection_info.transmit_power =
158 GetHostTransmitPower(kReadCurrentTransmitPowerLevel);
159 connection_info.max_transmit_power =
160 GetHostTransmitPower(kReadMaximumTransmitPowerLevel);
161
162 callback.Run(connection_info);
163 }
164
167 void BluetoothDeviceMac::Connect( 165 void BluetoothDeviceMac::Connect(
168 PairingDelegate* pairing_delegate, 166 PairingDelegate* pairing_delegate,
169 const base::Closure& callback, 167 const base::Closure& callback,
170 const ConnectErrorCallback& error_callback) { 168 const ConnectErrorCallback& error_callback) {
171 NOTIMPLEMENTED(); 169 NOTIMPLEMENTED();
172 } 170 }
173 171
174 void BluetoothDeviceMac::SetPinCode(const std::string& pincode) { 172 void BluetoothDeviceMac::SetPinCode(const std::string& pincode) {
175 NOTIMPLEMENTED(); 173 NOTIMPLEMENTED();
176 } 174 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 error_callback.Run(kApiUnavailable); 214 error_callback.Run(kApiUnavailable);
217 } 215 }
218 216
219 void BluetoothDeviceMac::CreateGattConnection( 217 void BluetoothDeviceMac::CreateGattConnection(
220 const GattConnectionCallback& callback, 218 const GattConnectionCallback& callback,
221 const ConnectErrorCallback& error_callback) { 219 const ConnectErrorCallback& error_callback) {
222 // TODO(armansito): Implement. 220 // TODO(armansito): Implement.
223 error_callback.Run(ERROR_UNSUPPORTED_DEVICE); 221 error_callback.Run(ERROR_UNSUPPORTED_DEVICE);
224 } 222 }
225 223
226 void BluetoothDeviceMac::StartConnectionMonitor(
227 const base::Closure& callback,
228 const ErrorCallback& error_callback) {
229 NOTIMPLEMENTED();
230 }
231
232 NSDate* BluetoothDeviceMac::GetLastInquiryUpdate() { 224 NSDate* BluetoothDeviceMac::GetLastInquiryUpdate() {
233 return [device_ getLastInquiryUpdate]; 225 return [device_ getLastInquiryUpdate];
234 } 226 }
235 227
236 int BluetoothDeviceMac::GetHostTransmitPower( 228 int BluetoothDeviceMac::GetHostTransmitPower(
237 BluetoothHCITransmitPowerLevelType power_level_type) const { 229 BluetoothHCITransmitPowerLevelType power_level_type) const {
238 IOBluetoothHostController* controller = 230 IOBluetoothHostController* controller =
239 [IOBluetoothHostController defaultController]; 231 [IOBluetoothHostController defaultController];
240 232
241 // Bail if the undocumented API is unavailable on this machine. 233 // Bail if the undocumented API is unavailable on this machine.
(...skipping 12 matching lines...) Expand all
254 246
255 return power_level; 247 return power_level;
256 } 248 }
257 249
258 // static 250 // static
259 std::string BluetoothDeviceMac::GetDeviceAddress(IOBluetoothDevice* device) { 251 std::string BluetoothDeviceMac::GetDeviceAddress(IOBluetoothDevice* device) {
260 return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString])); 252 return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString]));
261 } 253 }
262 254
263 } // namespace device 255 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_device_mac.h ('k') | device/bluetooth/bluetooth_device_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698