| 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/dbus/fake_bluetooth_gatt_characteristic_client.h" | 5 #include "device/bluetooth/dbus/fake_bluetooth_gatt_characteristic_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/rand_util.h" | 9 #include "base/rand_util.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 value.flags = 0x0; | 526 value.flags = 0x0; |
| 527 value.flags |= (0x03 << 1); | 527 value.flags |= (0x03 << 1); |
| 528 value.flags |= (0x01 << 3); | 528 value.flags |= (0x01 << 3); |
| 529 value.flags |= (0x01 << 4); | 529 value.flags |= (0x01 << 4); |
| 530 | 530 |
| 531 // Pick a value between 117 bpm and 153 bpm for heart rate. | 531 // Pick a value between 117 bpm and 153 bpm for heart rate. |
| 532 value.bpm = static_cast<uint8_t>(base::RandInt(117, 153)); | 532 value.bpm = static_cast<uint8_t>(base::RandInt(117, 153)); |
| 533 | 533 |
| 534 // Total calories burned in kJoules since the last reset. Increment this by 1 | 534 // Total calories burned in kJoules since the last reset. Increment this by 1 |
| 535 // every time. It's fine if it overflows: it becomes 0 when the user resets | 535 // every time. It's fine if it overflows: it becomes 0 when the user resets |
| 536 // the heart rate monitor (or pretend that he had a lot of cheeseburgers). | 536 // the heart rate monitor (or pretend that they had a lot of cheeseburgers). |
| 537 value.energy_expanded = calories_burned_++; | 537 value.energy_expanded = calories_burned_++; |
| 538 | 538 |
| 539 // Include one RR-Interval value, in seconds. | 539 // Include one RR-Interval value, in seconds. |
| 540 value.rr_interval = 60 / value.bpm; | 540 value.rr_interval = 60 / value.bpm; |
| 541 | 541 |
| 542 // Return the bytes in an array. | 542 // Return the bytes in an array. |
| 543 uint8_t* bytes = reinterpret_cast<uint8_t*>(&value); | 543 uint8_t* bytes = reinterpret_cast<uint8_t*>(&value); |
| 544 std::vector<uint8_t> return_value; | 544 std::vector<uint8_t> return_value; |
| 545 return_value.assign(bytes, bytes + sizeof(value)); | 545 return_value.assign(bytes, bytes + sizeof(value)); |
| 546 return return_value; | 546 return return_value; |
| 547 } | 547 } |
| 548 | 548 |
| 549 bool FakeBluetoothGattCharacteristicClient::IsHeartRateVisible() const { | 549 bool FakeBluetoothGattCharacteristicClient::IsHeartRateVisible() const { |
| 550 DCHECK(heart_rate_visible_ != heart_rate_measurement_path_.empty()); | 550 DCHECK(heart_rate_visible_ != heart_rate_measurement_path_.empty()); |
| 551 DCHECK(heart_rate_visible_ != body_sensor_location_path_.empty()); | 551 DCHECK(heart_rate_visible_ != body_sensor_location_path_.empty()); |
| 552 DCHECK(heart_rate_visible_ != heart_rate_control_point_path_.empty()); | 552 DCHECK(heart_rate_visible_ != heart_rate_control_point_path_.empty()); |
| 553 DCHECK(heart_rate_visible_ == !!heart_rate_measurement_properties_.get()); | 553 DCHECK(heart_rate_visible_ == !!heart_rate_measurement_properties_.get()); |
| 554 DCHECK(heart_rate_visible_ == !!body_sensor_location_properties_.get()); | 554 DCHECK(heart_rate_visible_ == !!body_sensor_location_properties_.get()); |
| 555 DCHECK(heart_rate_visible_ == !!heart_rate_control_point_properties_.get()); | 555 DCHECK(heart_rate_visible_ == !!heart_rate_control_point_properties_.get()); |
| 556 return heart_rate_visible_; | 556 return heart_rate_visible_; |
| 557 } | 557 } |
| 558 | 558 |
| 559 } // namespace bluez | 559 } // namespace bluez |
| OLD | NEW |