Added setSyncDelta method to the library

This commit is contained in:
Luxferre
2022-12-23 17:02:10 +02:00
parent 760ad02672
commit 9a6d2acc31
3 changed files with 7 additions and 5 deletions
+4 -3
View File
@@ -16,6 +16,7 @@ RCVD = (function(nav) {
}),
watchModel = '',
localgatt = null, //local GATT reference for disconnection
syncDelta = 500, //the delta value (in milliseconds) to make up for BLE transmission latency, 500 ms by default
TD = new TextDecoder(),
ids = s => `26eb00${s}-b012-49a8-b1f8-394fb2032b0f`,
scanids = ['00001804-0000-1000-8000-00805f9b34fb', ids('0d')],
@@ -83,7 +84,7 @@ RCVD = (function(nav) {
plgen = k => [...Array(6)].map((a,i)=>[k,i]), //property list generator
cyclePresyncProperties = _ => new Promise((res, rej) => {
var slist = [...plgen(30),...plgen(31)]
var slist = [...plgen(30),...plgen(31)] //full property list for primary targets, GW-B/GMW-B models
if(watchModel.indexOf('OCW') > 5)
slist = [[30,0],[30,1]]
else if(watchModel.indexOf('B2100') > 5 || watchModel.indexOf('B001') > 5 || watchModel.indexOf('DW-B5600') > 5 )
@@ -122,10 +123,10 @@ RCVD = (function(nav) {
getModel: _ => watchModel,
rawRead: execReadCmd,
rawWrite: execWriteCmd,
setSyncDelta: val => {syncDelta = +val; if(isNaN(syncDelta)) syncDelta = 500},
sync: dObj => new Promise((res, rej) => {
cyclePresyncProperties().then(_ => {
//set to the next second to make up for latency
var d = dObj || new Date(Date.now() + 500), year = d.getFullYear()
var d = dObj || new Date(Date.now() + syncDelta), year = d.getFullYear()
execWriteCmd(Uint8Array.from([
9,
year&255, year>>>8,