我正在尝试为 FitBit 创建一个应用程序,而不使用允许我获取加速度计数据和心率的配套应用程序。
FitBit的心率传感器指南给出了如下代码,但并没有具体说明导入的模块是什么,只是说是“心率模块”:
// Import the HeartRate module
import { HeartRateSensor } from "heart-rate";
// Create a new instance of the HeartRateSensor object
var hrm = new HeartRateSensor();
hrm.onreading = function() {
// Peek the current sensor values
console.log("Current heart rate: " + hrm.heartRate);
// Stop monitoring the sensor
hrm.stop();
}
// Begin monitoring the sensor
hrm.start();
FitBit 在 GitHub 上的示例也以类似的方式实现代码,但找不到该模块。
当我尝试在 Sublime Text 上运行代码时,它给出了错误“SyntaxError: Unexpected token import”
如何获取心率数据?