| OLD | NEW |
| 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_classic_device_mac.h" | 5 #include "device/bluetooth/bluetooth_classic_device_mac.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/hash.h" | 10 #include "base/hash.h" |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 if ([service_class_data getTypeDescriptor] == | 138 if ([service_class_data getTypeDescriptor] == |
| 139 kBluetoothSDPDataElementTypeDataElementSequence) { | 139 kBluetoothSDPDataElementTypeDataElementSequence) { |
| 140 BluetoothUUID uuid = ExtractUuid(service_class_data); | 140 BluetoothUUID uuid = ExtractUuid(service_class_data); |
| 141 if (uuid.IsValid()) | 141 if (uuid.IsValid()) |
| 142 uuids.push_back(uuid); | 142 uuids.push_back(uuid); |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 return uuids; | 145 return uuids; |
| 146 } | 146 } |
| 147 | 147 |
| 148 int16_t BluetoothClassicDeviceMac::GetInquiryRSSI() const { | 148 int8_t BluetoothClassicDeviceMac::GetInquiryRSSI() const { |
| 149 return kUnknownPower; | 149 return kUnknownRSSI; |
| 150 } | 150 } |
| 151 | 151 |
| 152 int16_t BluetoothClassicDeviceMac::GetInquiryTxPower() const { | 152 int8_t BluetoothClassicDeviceMac::GetInquiryTxPower() const { |
| 153 NOTIMPLEMENTED(); | 153 NOTIMPLEMENTED(); |
| 154 return kUnknownPower; | 154 return kUnknownTxPower; |
| 155 } | 155 } |
| 156 | 156 |
| 157 bool BluetoothClassicDeviceMac::ExpectingPinCode() const { | 157 bool BluetoothClassicDeviceMac::ExpectingPinCode() const { |
| 158 NOTIMPLEMENTED(); | 158 NOTIMPLEMENTED(); |
| 159 return false; | 159 return false; |
| 160 } | 160 } |
| 161 | 161 |
| 162 bool BluetoothClassicDeviceMac::ExpectingPasskey() const { | 162 bool BluetoothClassicDeviceMac::ExpectingPasskey() const { |
| 163 NOTIMPLEMENTED(); | 163 NOTIMPLEMENTED(); |
| 164 return false; | 164 return false; |
| 165 } | 165 } |
| 166 | 166 |
| 167 bool BluetoothClassicDeviceMac::ExpectingConfirmation() const { | 167 bool BluetoothClassicDeviceMac::ExpectingConfirmation() const { |
| 168 NOTIMPLEMENTED(); | 168 NOTIMPLEMENTED(); |
| 169 return false; | 169 return false; |
| 170 } | 170 } |
| 171 | 171 |
| 172 void BluetoothClassicDeviceMac::GetConnectionInfo( | 172 void BluetoothClassicDeviceMac::GetConnectionInfo( |
| 173 const ConnectionInfoCallback& callback) { | 173 const ConnectionInfoCallback& callback) { |
| 174 ConnectionInfo connection_info; | 174 ConnectionInfo connection_info; |
| 175 if (![device_ isConnected]) { | 175 if (![device_ isConnected]) { |
| 176 callback.Run(connection_info); | 176 callback.Run(connection_info); |
| 177 return; | 177 return; |
| 178 } | 178 } |
| 179 | 179 |
| 180 connection_info.rssi = [device_ rawRSSI]; | 180 connection_info.rssi = [device_ rawRSSI]; |
| 181 // The API guarantees that +127 is returned in case the RSSI is not readable: | 181 // The API guarantees that +127 is returned in case the RSSI is not readable: |
| 182 // http://goo.gl/bpURYv | 182 // http://goo.gl/bpURYv |
| 183 if (connection_info.rssi == 127) | 183 if (connection_info.rssi == 127) |
| 184 connection_info.rssi = kUnknownPower; | 184 connection_info.rssi = kUnknownRSSI; |
| 185 | 185 |
| 186 connection_info.transmit_power = | 186 connection_info.transmit_power = |
| 187 GetHostTransmitPower(kReadCurrentTransmitPowerLevel); | 187 GetHostTransmitPower(kReadCurrentTransmitPowerLevel); |
| 188 connection_info.max_transmit_power = | 188 connection_info.max_transmit_power = |
| 189 GetHostTransmitPower(kReadMaximumTransmitPowerLevel); | 189 GetHostTransmitPower(kReadMaximumTransmitPowerLevel); |
| 190 | 190 |
| 191 callback.Run(connection_info); | 191 callback.Run(connection_info); |
| 192 } | 192 } |
| 193 | 193 |
| 194 void BluetoothClassicDeviceMac::Connect( | 194 void BluetoothClassicDeviceMac::Connect( |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 int BluetoothClassicDeviceMac::GetHostTransmitPower( | 259 int BluetoothClassicDeviceMac::GetHostTransmitPower( |
| 260 BluetoothHCITransmitPowerLevelType power_level_type) const { | 260 BluetoothHCITransmitPowerLevelType power_level_type) const { |
| 261 IOBluetoothHostController* controller = | 261 IOBluetoothHostController* controller = |
| 262 [IOBluetoothHostController defaultController]; | 262 [IOBluetoothHostController defaultController]; |
| 263 | 263 |
| 264 // Bail if the undocumented API is unavailable on this machine. | 264 // Bail if the undocumented API is unavailable on this machine. |
| 265 SEL selector = @selector(BluetoothHCIReadTransmitPowerLevel: | 265 SEL selector = @selector(BluetoothHCIReadTransmitPowerLevel: |
| 266 inType: | 266 inType: |
| 267 outTransmitPowerLevel:); | 267 outTransmitPowerLevel:); |
| 268 if (![controller respondsToSelector:selector]) | 268 if (![controller respondsToSelector:selector]) |
| 269 return kUnknownPower; | 269 return kUnknownTxPower; |
| 270 | 270 |
| 271 BluetoothHCITransmitPowerLevel power_level; | 271 BluetoothHCITransmitPowerLevel power_level; |
| 272 IOReturn result = | 272 IOReturn result = |
| 273 [controller BluetoothHCIReadTransmitPowerLevel:[device_ connectionHandle] | 273 [controller BluetoothHCIReadTransmitPowerLevel:[device_ connectionHandle] |
| 274 inType:power_level_type | 274 inType:power_level_type |
| 275 outTransmitPowerLevel:&power_level]; | 275 outTransmitPowerLevel:&power_level]; |
| 276 if (result != kIOReturnSuccess) | 276 if (result != kIOReturnSuccess) |
| 277 return kUnknownPower; | 277 return kUnknownTxPower; |
| 278 | 278 |
| 279 return power_level; | 279 return power_level; |
| 280 } | 280 } |
| 281 | 281 |
| 282 // static | 282 // static |
| 283 std::string BluetoothClassicDeviceMac::GetDeviceAddress( | 283 std::string BluetoothClassicDeviceMac::GetDeviceAddress( |
| 284 IOBluetoothDevice* device) { | 284 IOBluetoothDevice* device) { |
| 285 return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString])); | 285 return CanonicalizeAddress(base::SysNSStringToUTF8([device addressString])); |
| 286 } | 286 } |
| 287 | 287 |
| 288 } // namespace device | 288 } // namespace device |
| OLD | NEW |