| Index: device/bluetooth/bluetooth_device_mac.mm
|
| diff --git a/device/bluetooth/bluetooth_device_mac.mm b/device/bluetooth/bluetooth_device_mac.mm
|
| index 24c2b45664655a671b79ede15c794208dd7f2c08..aaeffb8fa6327ec785a14b9b8dee1b994659f066 100644
|
| --- a/device/bluetooth/bluetooth_device_mac.mm
|
| +++ b/device/bluetooth/bluetooth_device_mac.mm
|
| @@ -4,11 +4,6 @@
|
|
|
| #include "device/bluetooth/bluetooth_device_mac.h"
|
|
|
| -#include <IOBluetooth/Bluetooth.h>
|
| -#import <IOBluetooth/objc/IOBluetoothDevice.h>
|
| -#import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h>
|
| -#import <IOBluetooth/objc/IOBluetoothSDPUUID.h>
|
| -
|
| #include <string>
|
|
|
| #include "base/basictypes.h"
|
| @@ -28,13 +23,23 @@
|
|
|
| @interface IOBluetoothDevice (LionSDKDeclarations)
|
| - (NSString*)addressString;
|
| -- (NSString*)name;
|
| - (unsigned int)classOfDevice;
|
| +- (BluetoothConnectionHandle)connectionHandle;
|
| +- (BluetoothHCIRSSIValue)rawRSSI;
|
| - (NSArray*)services;
|
| @end
|
|
|
| #endif // MAC_OS_X_VERSION_10_7
|
|
|
| +// Undocumented API for accessing the Bluetooth transmit power level.
|
| +// Similar to the API defined here [ http://goo.gl/20Q5vE ].
|
| +@interface IOBluetoothHostController (UndocumentedAPI)
|
| +- (IOReturn)
|
| + BluetoothHCIReadTransmitPowerLevel:(BluetoothConnectionHandle)connection
|
| + inType:(BluetoothHCITransmitPowerLevelType)type
|
| + outTransmitPowerLevel:(BluetoothHCITransmitPowerLevel*)level;
|
| +@end
|
| +
|
| namespace device {
|
|
|
| BluetoothDeviceMac::BluetoothDeviceMac(IOBluetoothDevice* device)
|
| @@ -84,6 +89,30 @@ uint16 BluetoothDeviceMac::GetDeviceID() const {
|
| return 0;
|
| }
|
|
|
| +int BluetoothDeviceMac::GetRSSI() const {
|
| + if (![device_ isConnected]) {
|
| + NOTIMPLEMENTED();
|
| + return kUnknownPower;
|
| + }
|
| +
|
| + int rssi = [device_ rawRSSI];
|
| +
|
| + // The API guarantees that +127 is returned in case the RSSI is not readable:
|
| + // http://goo.gl/bpURYv
|
| + if (rssi == 127)
|
| + return kUnknownPower;
|
| +
|
| + return rssi;
|
| +}
|
| +
|
| +int BluetoothDeviceMac::GetCurrentHostTransmitPower() const {
|
| + return GetHostTransmitPower(kReadCurrentTransmitPowerLevel);
|
| +}
|
| +
|
| +int BluetoothDeviceMac::GetMaximumHostTransmitPower() const {
|
| + return GetHostTransmitPower(kReadMaximumTransmitPowerLevel);
|
| +}
|
| +
|
| bool BluetoothDeviceMac::IsPaired() const {
|
| return [device_ isPaired];
|
| }
|
| @@ -183,4 +212,26 @@ void BluetoothDeviceMac::ClearOutOfBandPairingData(
|
| NOTIMPLEMENTED();
|
| }
|
|
|
| +int BluetoothDeviceMac::GetHostTransmitPower(
|
| + BluetoothHCITransmitPowerLevelType power_level_type) const {
|
| + IOBluetoothHostController* controller =
|
| + [IOBluetoothHostController defaultController];
|
| +
|
| + // Bail if the undocumented API is unavailable on this machine.
|
| + SEL selector = @selector(
|
| + BluetoothHCIReadTransmitPowerLevel:inType:outTransmitPowerLevel:);
|
| + if (![controller respondsToSelector:selector])
|
| + return kUnknownPower;
|
| +
|
| + BluetoothHCITransmitPowerLevel power_level;
|
| + IOReturn result =
|
| + [controller BluetoothHCIReadTransmitPowerLevel:[device_ connectionHandle]
|
| + inType:power_level_type
|
| + outTransmitPowerLevel:&power_level];
|
| + if (result != kIOReturnSuccess)
|
| + return kUnknownPower;
|
| +
|
| + return power_level;
|
| +}
|
| +
|
| } // namespace device
|
|
|