Index: device/bluetooth/bluetooth_adapter_mac.mm |
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm |
index f33d79290ca0a91ad6b37d341e59a4ad65b41997..8ca85cfb4736dbcbca0ed234cb636ba510f973f9 100644 |
--- a/device/bluetooth/bluetooth_adapter_mac.mm |
+++ b/device/bluetooth/bluetooth_adapter_mac.mm |
@@ -36,6 +36,25 @@ namespace { |
// The frequency with which to poll the adapter for updates. |
const int kPollIntervalMs = 500; |
+std::string GetCentralManagerStateString(CBCentralManagerState state) { |
ortuno
2017/03/14 00:34:33
I feel bad for adding these strings to the binary
jlebel
2017/03/15 01:08:40
This should not be a big source of problems, so we
|
+ switch (state) { |
+ case CBCentralManagerStateUnknown: |
+ return "CBCentralManagerStateUnknown"; |
+ case CBCentralManagerStateResetting: |
+ return "CBCentralManagerStateResetting"; |
+ case CBCentralManagerStateUnsupported: |
+ return "CBCentralManagerStateUnsupported"; |
+ case CBCentralManagerStateUnauthorized: |
+ return "CBCentralManagerStateUnauthorized"; |
+ case CBCentralManagerStatePoweredOff: |
+ return "CBCentralManagerStatePoweredOff"; |
+ case CBCentralManagerStatePoweredOn: |
+ return "CBCentralManagerStatePoweredOn"; |
+ } |
+ DCHECK(false); |
+ return std::string("Unknown central manager state ") + std::to_string(state); |
+} |
+ |
} // namespace |
namespace device { |
@@ -519,14 +538,16 @@ void BluetoothAdapterMac::LowEnergyDeviceUpdated( |
// otherwise update the existing device. |
const bool is_new_device = device_mac == nullptr; |
if (is_new_device) { |
- VLOG(1) << "LowEnergyDeviceUpdated new device"; |
// A new device has been found. |
device_mac = new BluetoothLowEnergyDeviceMac(this, peripheral); |
+ VLOG(1) << device_mac->ToString() << ": New Device."; |
} else if (DoesCollideWithKnownDevice(peripheral, device_mac)) { |
return; |
} |
DCHECK(device_mac); |
+ VLOG(1) << device_mac->ToString() << ": Device updated with " |
ortuno
2017/03/14 00:34:33
Make this a VLOG(3). We are going to get tens of t
jlebel
2017/03/15 01:08:40
Done.
|
+ << base::SysNSStringToUTF8([advertisement_data description]); |
// Get Advertised UUIDs |
BluetoothDevice::UUIDList advertised_uuids; |
@@ -576,7 +597,10 @@ void BluetoothAdapterMac::LowEnergyDeviceUpdated( |
} |
// TODO(krstnmnlsn): Implement. crbug.com/511025 |
-void BluetoothAdapterMac::LowEnergyCentralManagerUpdatedState() {} |
+void BluetoothAdapterMac::LowEnergyCentralManagerUpdatedState() { |
+ VLOG(1) << "Central manager state updated " |
+ << GetCentralManagerStateString([low_energy_central_manager_ state]); |
+} |
void BluetoothAdapterMac::AddPairedDevices() { |
// Add any new paired devices. |
@@ -605,6 +629,7 @@ BluetoothAdapterMac::RetrieveGattConnectedDevicesWithService( |
base::SysUTF8ToNSString(uuid->canonical_value().c_str()); |
cbUUIDs = @[ [CBUUID UUIDWithString:uuidString] ]; |
} |
+ VLOG(1) << "RetrieveGattConnectedDevicesWithService " << uuid->value(); |
ortuno
2017/03/14 00:34:33
uuid could be null so let's do the logging inside
jlebel
2017/03/15 01:08:40
Done.
|
NSArray* peripherals = [low_energy_central_manager_ |
retrieveConnectedPeripheralsWithServices:cbUUIDs]; |
std::vector<BluetoothDevice*> connected_devices; |
@@ -626,6 +651,7 @@ BluetoothAdapterMac::RetrieveGattConnectedDevicesWithService( |
} |
} |
connected_devices.push_back(device_mac); |
+ VLOG(1) << " " << device_mac->ToString(); |
ortuno
2017/03/14 00:34:33
Please follow the same pattern for all logs:
VLOG
jlebel
2017/03/15 01:08:40
Done.
|
} |
return connected_devices; |
} |
@@ -661,12 +687,13 @@ void BluetoothAdapterMac::DidFailToConnectPeripheral(CBPeripheral* peripheral, |
[low_energy_central_manager_ cancelPeripheralConnection:peripheral]; |
return; |
} |
- VLOG(1) << "Failed to connect to peripheral"; |
+ VLOG(1) << device_mac->ToString() << ": Failed to connect to peripheral."; |
BluetoothDevice::ConnectErrorCode error_code = |
BluetoothDevice::ConnectErrorCode::ERROR_UNKNOWN; |
if (error) { |
error_code = BluetoothDeviceMac::GetConnectErrorCodeFromNSError(error); |
- VLOG(1) << "Bluetooth error, domain: " << error.domain.UTF8String |
+ VLOG(1) << device_mac->ToString() |
+ << ": Bluetooth error, domain: " << error.domain.UTF8String |
<< ", error code: " << error.code |
<< ", converted into: " << error_code; |
} |
@@ -681,9 +708,10 @@ void BluetoothAdapterMac::DidDisconnectPeripheral(CBPeripheral* peripheral, |
[low_energy_central_manager_ cancelPeripheralConnection:peripheral]; |
return; |
} |
- VLOG(1) << "Disconnected from peripheral."; |
+ VLOG(1) << device_mac->ToString() << ": Disconnected from peripheral."; |
if (error) { |
- VLOG(1) << "Bluetooth error, domain: " << error.domain.UTF8String |
+ VLOG(1) << device_mac->ToString() |
+ << ": Bluetooth error, domain: " << error.domain.UTF8String |
<< ", error code: " << error.code; |
} |
device_mac->DidDisconnectPeripheral(error); |