| OLD | NEW |
| 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_low_energy_win.h" | 5 #include "device/bluetooth/bluetooth_low_energy_win.h" |
| 6 | 6 |
| 7 #include <cfg.h> | 7 #include <cfg.h> |
| 8 #define INITGUID // For DEVPKEY_Xxxx guid/pid pairs | 8 #define INITGUID // For DEVPKEY_Xxxx guid/pid pairs |
| 9 #include <devpkey.h> | 9 #include <devpkey.h> |
| 10 | 10 |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 error)) { | 315 error)) { |
| 316 return false; | 316 return false; |
| 317 } | 317 } |
| 318 | 318 |
| 319 if (value->property_type() != DEVPROP_TYPE_UINT32) { | 319 if (value->property_type() != DEVPROP_TYPE_UINT32) { |
| 320 *error = kDeviceInfoError; | 320 *error = kDeviceInfoError; |
| 321 return false; | 321 return false; |
| 322 } | 322 } |
| 323 | 323 |
| 324 device_info->connected = !(value->AsUint32() & DN_DEVICE_DISCONNECTED); | 324 device_info->connected = !(value->AsUint32() & DN_DEVICE_DISCONNECTED); |
| 325 // Windows 8 exposes BLE devices only if they are visible and paired. This | |
| 326 // might change in the future if Windows offers a public API for discovering | |
| 327 // and pairing BLE devices. | |
| 328 device_info->visible = true; | |
| 329 device_info->authenticated = true; | |
| 330 return true; | 325 return true; |
| 331 } | 326 } |
| 332 | 327 |
| 333 bool CollectBluetoothLowEnergyDeviceInfo( | 328 bool CollectBluetoothLowEnergyDeviceInfo( |
| 334 const ScopedDeviceInfoSetHandle& device_info_handle, | 329 const ScopedDeviceInfoSetHandle& device_info_handle, |
| 335 PSP_DEVICE_INTERFACE_DATA device_interface_data, | 330 PSP_DEVICE_INTERFACE_DATA device_interface_data, |
| 336 scoped_ptr<device::win::BluetoothLowEnergyDeviceInfo>* device_info, | 331 scoped_ptr<device::win::BluetoothLowEnergyDeviceInfo>* device_info, |
| 337 std::string* error) { | 332 std::string* error) { |
| 338 // Retrieve required # of bytes for interface details | 333 // Retrieve required # of bytes for interface details |
| 339 ULONG required_length = 0; | 334 ULONG required_length = 0; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 value_size_(value_size) { | 512 value_size_(value_size) { |
| 518 } | 513 } |
| 519 | 514 |
| 520 uint32_t DevicePropertyValue::AsUint32() const { | 515 uint32_t DevicePropertyValue::AsUint32() const { |
| 521 CHECK_EQ(property_type_, static_cast<DEVPROPTYPE>(DEVPROP_TYPE_UINT32)); | 516 CHECK_EQ(property_type_, static_cast<DEVPROPTYPE>(DEVPROP_TYPE_UINT32)); |
| 522 CHECK_EQ(value_size_, sizeof(uint32_t)); | 517 CHECK_EQ(value_size_, sizeof(uint32_t)); |
| 523 return *reinterpret_cast<uint32_t*>(value_.get()); | 518 return *reinterpret_cast<uint32_t*>(value_.get()); |
| 524 } | 519 } |
| 525 | 520 |
| 526 BluetoothLowEnergyDeviceInfo::BluetoothLowEnergyDeviceInfo() | 521 BluetoothLowEnergyDeviceInfo::BluetoothLowEnergyDeviceInfo() |
| 527 : visible(false), authenticated(false), connected(false) { | 522 : connected(false) { |
| 528 address.ullLong = BLUETOOTH_NULL_ADDRESS; | 523 address.ullLong = BLUETOOTH_NULL_ADDRESS; |
| 529 } | 524 } |
| 530 | 525 |
| 531 BluetoothLowEnergyDeviceInfo::~BluetoothLowEnergyDeviceInfo() { | 526 BluetoothLowEnergyDeviceInfo::~BluetoothLowEnergyDeviceInfo() { |
| 532 } | 527 } |
| 533 | 528 |
| 534 bool IsBluetoothLowEnergySupported() { | 529 bool IsBluetoothLowEnergySupported() { |
| 535 return base::win::GetVersion() >= base::win::VERSION_WIN8; | 530 return base::win::GetVersion() >= base::win::VERSION_WIN8; |
| 536 } | 531 } |
| 537 | 532 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 567 | 562 |
| 568 bool ExtractBluetoothAddressFromDeviceInstanceIdForTesting( | 563 bool ExtractBluetoothAddressFromDeviceInstanceIdForTesting( |
| 569 const std::string& instance_id, | 564 const std::string& instance_id, |
| 570 BLUETOOTH_ADDRESS* btha, | 565 BLUETOOTH_ADDRESS* btha, |
| 571 std::string* error) { | 566 std::string* error) { |
| 572 return ExtractBluetoothAddressFromDeviceInstanceId(instance_id, btha, error); | 567 return ExtractBluetoothAddressFromDeviceInstanceId(instance_id, btha, error); |
| 573 } | 568 } |
| 574 | 569 |
| 575 } // namespace win | 570 } // namespace win |
| 576 } // namespace device | 571 } // namespace device |
| OLD | NEW |