【发布时间】:2021-08-10 18:30:23
【问题描述】:
目标是在 Fitbit Sense 表盘 (SDK 6.0.0) 中将 device.lastSyncTime 从伴侣 index.js 获取到 app/index.js。
我的简单想法是tellSync() 函数会发送一条包含device.lastSyncTime 的消息
function sendVal(data) {
if (messaging.peerSocket.readyState === messaging.peerSocket.OPEN)
messaging.peerSocket.send(data);
}
function tellSync() {
let date = device.lastSyncTime;
let data = {
key: 'lastSync',
newValue: date
};
sendVal(data);
}
但是,在 app/index.js 中,收到的消息不包含device.lastSyncTime:
messaging.peerSocket.onmessage = evt => {
console.log(JSON.stringify(evt))
};
输出是App: {"data":{"key":"lastSync","newValue":{}}}。没有错误,它已连接到当前版本的 Fitbit Sense 设备 (2021-08-10) 和手机。
现在,如果我将 device.lastSyncTime 放入 console.log(),它会将时间戳交给我(例如 Tue Aug 10 2021 19:59:40 GMT+0200 (Central European Summer Time) ),所以我一定做错了什么,但我不太确定是什么。
【问题讨论】:
标签: javascript sdk fitbit