好久之前朋友送了一个闹钟音箱,只能使用小程序通过蓝牙同步时间,以及设置闹钟等功能,小程序叫 ZGO 正港,现在尝试多次使用小程序无法连接上设备。
想着小程序不过也是向设备发送一段数据同步的,尝试自己通过调试软件发送,解包了小程序,其中有如下跟时间相关的代码:
var n = (new Date).getFullYear(),
a = (new Date).getMonth() + 1,
o = (new Date).getDate(),
i = (new Date).getHours(),
c = (new Date).getMinutes(),
s = (new Date).getSeconds(),
l = new ArrayBuffer(11),
u = new DataView(l);
u.setUint8(0, 105), u.setUint8(1, 150), u.setUint8(2, 8), u.setUint8(3, 2), u.setUint8(4, (65280 & n) >> 8), u.setUint8(5, 255 & n), u.setUint8(6, a), u.setUint8(7, o), u.setUint8(8, i), u.setUint8(9, c), u.setUint8(10, s);
发送的部分:
write: function(t) {
var a = this;
0 != a.globalData.isWriteFinsh && (a.globalData.isWriteFinsh = 0, wx.writeBLECharacteristicValue({
deviceId: a.globalData.deviceId,
serviceId: a.globalData.serviceUUID,
characteristicId: a.globalData.writeCharacteristicUUID,
value: t,
success: function(a) {
console.log("发送的数据:" + e.arrayBuffer2HexString(t)), console.log("发送成功")
},
fail: function(e) {},
complete: function(e) {
a.globalData.isWriteFinsh = 1
}
}))
}
询问了 GPT ,尝试根据代码拼的格式自己 write 给闹钟,在手机使用调试软件发送:6996080207E902180F1E2D ( 2025 年 2 月 24 日 15:30:45 )。
没有反应,几个能 write 的 UUID 都尝试了,也试了随便写入点什么,设备均没有反应,有一个 UUID 在写入后能读取相同的内容,但是设备没有反应,求问是发送的格式不对还是什么。