diff --git a/pages/asyntest/asyntest.js b/pages/asyntest/asyntest.js index 2149b65..4f04ac4 100644 --- a/pages/asyntest/asyntest.js +++ b/pages/asyntest/asyntest.js @@ -35,7 +35,26 @@ Page({ this.openLock(userTelephone, userPassword, pwd, openLockType) }, - + + btntest3(event){ + var that = this + let managerTelephone = "19270949446" + let managerPassword = "123456" + let userTelephone = "38580151200" + let userPassword = "385801" + let userStartTime = "20210813010101" + let userEndTime = "20680813010101" + let fpDataLength = 2048 + let fpStartTime = "20210813010101" + let fpEndTime = "20680813010101" + let times = 255 + let recycleTime = 65535 + + this.startFingerprint(managerTelephone, managerPassword, userTelephone, userPassword, userStartTime, userEndTime, + fpDataLength, fpStartTime, fpEndTime, times, recycleTime) +}, + + //获取输入框的数据 getmsg(event){ this.setData({ @@ -44,7 +63,7 @@ Page({ }, - btntest3(event){ + btntest4(event){ var that = this; this.closeblue() }, @@ -129,6 +148,73 @@ Page({ console.log(b) app.globalData.ble.send(cmd, b, length) }, + + startFingerprint(managerTelephone, managerPassword, userTelephone, userPassword, userStartTime, userEndTime, + fpDataLength, fpStartTime, fpEndTime, times, recycleTime) { + + wx.showLoading({ + title: "正在发送...", + }); + setTimeout(() => { + wx.hideLoading() + }, 1000); + + let cmd = 0x87 + let mt = util.stringToUint8Array(managerTelephone) + let mp = util.stringToUint8Array(managerPassword) + let ut = util.stringToUint8Array(userTelephone) + let up = util.stringToUint8Array(userPassword) + + let ust = util.time40ToBytes(userStartTime) + let uet = util.time40ToBytes(userEndTime) + + let fpPacketCount = (fpDataLength+511)/512 + + let crc = 0xAAFF46D3; + + let fst = util.time40ToBytes(fpStartTime) + let fet = util.time40ToBytes(fpEndTime) + + let length = 1 + 11 + 6 + 11 + 6 + 5 + 5 + 4 + 4 + 4 + 5 + 5 + 1 + 2 + + let b = new Uint8Array(length) + + b[0] = cmd + b.set(mt, 1) + b.set(mp, 12) + b.set(ut, 18) + b.set(up, 29) + b.set(ust, 35) + b.set(uet, 40) + + b[45] = (fpDataLength>>24)&0xff; + b[46] = (fpDataLength>>16)&0xff; + b[47] = (fpDataLength>>8)&0xff; + b[48] = fpDataLength&0xff; + + b[49] = (fpPacketCount>>24)&0xff; + b[50] = (fpPacketCount>>16)&0xff; + b[51] = (fpPacketCount>>8)&0xff; + b[52] = fpPacketCount&0xff; + + b[53] = (crc>>24)&0xff; + b[54] = (crc>>16)&0xff; + b[55] = (crc>>8)&0xff; + b[56] = crc&0xff; + + b.set(fst, 57) + b.set(fet, 62) + + b[67] = times; + + b[68] = (recycleTime>>8)&0xff; + b[69] = recycleTime&0xff; + + console.log(b) + app.globalData.ble.send(cmd, b, length) + }, + + }) diff --git a/pages/asyntest/asyntest.wxml b/pages/asyntest/asyntest.wxml index 26c9c68..48d2825 100644 --- a/pages/asyntest/asyntest.wxml +++ b/pages/asyntest/asyntest.wxml @@ -12,7 +12,8 @@ - - + + + \ No newline at end of file diff --git a/project.config.json b/project.config.json index ec5a2b0..424c89a 100644 --- a/project.config.json +++ b/project.config.json @@ -1,74 +1,74 @@ { - "description": "项目配置文件", - "packOptions": { - "ignore": [] - }, - "setting": { - "urlCheck": true, - "es6": true, - "enhance": true, - "postcss": true, - "preloadBackgroundData": false, - "minified": true, - "newFeature": false, - "coverView": true, - "nodeModules": false, - "autoAudits": false, - "showShadowRootInWxmlPanel": true, - "scopeDataCheck": false, - "uglifyFileName": false, - "checkInvalidKey": true, - "checkSiteMap": true, - "uploadWithSourceMap": true, - "compileHotReLoad": false, - "lazyloadPlaceholderEnable": false, - "useMultiFrameRuntime": true, - "useApiHook": true, - "useApiHostProcess": true, - "babelSetting": { - "ignore": [], - "disablePlugins": [], - "outputPath": "" + "description": "项目配置文件", + "packOptions": { + "ignore": [] }, - "enableEngineNative": false, - "useIsolateContext": true, - "userConfirmedBundleSwitch": false, - "packNpmManually": false, - "packNpmRelationList": [], - "minifyWXSS": true, - "showES6CompileOption": false - }, - "compileType": "miniprogram", - "libVersion": "2.19.4", - "appid": "wx7775ba175d855273", - "projectname": "%E8%93%9D%E7%89%99%E6%B5%8B%E8%AF%95", - "debugOptions": { - "hidedInDevtools": [] - }, - "scripts": {}, - "staticServerOptions": { - "baseURL": "", - "servePath": "" - }, - "isGameTourist": false, - "condition": { - "search": { - "list": [] + "setting": { + "urlCheck": true, + "es6": true, + "enhance": true, + "postcss": true, + "preloadBackgroundData": false, + "minified": true, + "newFeature": false, + "coverView": true, + "nodeModules": false, + "autoAudits": false, + "showShadowRootInWxmlPanel": true, + "scopeDataCheck": false, + "uglifyFileName": false, + "checkInvalidKey": true, + "checkSiteMap": true, + "uploadWithSourceMap": true, + "compileHotReLoad": false, + "lazyloadPlaceholderEnable": false, + "useMultiFrameRuntime": true, + "useApiHook": true, + "useApiHostProcess": true, + "babelSetting": { + "ignore": [], + "disablePlugins": [], + "outputPath": "" + }, + "enableEngineNative": false, + "useIsolateContext": true, + "userConfirmedBundleSwitch": false, + "packNpmManually": false, + "packNpmRelationList": [], + "minifyWXSS": true, + "showES6CompileOption": false }, - "conversation": { - "list": [] + "compileType": "miniprogram", + "libVersion": "2.19.4", + "appid": "wx7775ba175d855273", + "projectname": "%E8%93%9D%E7%89%99%E6%B5%8B%E8%AF%95", + "debugOptions": { + "hidedInDevtools": [] }, - "game": { - "list": [] + "scripts": {}, + "staticServerOptions": { + "baseURL": "", + "servePath": "" }, - "plugin": { - "list": [] - }, - "gamePlugin": { - "list": [] - }, - "miniprogram": { - "list": [] + "isGameTourist": false, + "condition": { + "search": { + "list": [] + }, + "conversation": { + "list": [] + }, + "game": { + "list": [] + }, + "plugin": { + "list": [] + }, + "gamePlugin": { + "list": [] + }, + "miniprogram": { + "list": [] + } } - } } \ No newline at end of file diff --git a/utils/btls/bleHandler.js b/utils/btls/bleHandler.js index 40e0477..a12dadf 100644 --- a/utils/btls/bleHandler.js +++ b/utils/btls/bleHandler.js @@ -296,7 +296,7 @@ class BLEHandler { let result = new Uint8Array(dataLength) for (let i = 0; i < dataLength; i++) { result[i] = arrbf[i + data_offset]; - result[i] = (result[i] ^ (key ^ ((byte) i))); + result[i] = (result[i] ^ (key ^ i)); result[i] += (dataLength - i) ^ key; } diff --git a/utils/btls/tools.js b/utils/btls/tools.js index 9ee2d16..db9d87c 100644 --- a/utils/btls/tools.js +++ b/utils/btls/tools.js @@ -384,7 +384,7 @@ function _sentOrder(cmd, payload){ let timestamp = new Date().getTime(); let ts = timestamp.toString(16) - let t = util.hexStringToBytes(ts) + let t = util.timeStringToBytes(ts, 12) b.set(t, 4) b[3] = b[9]; b[10] = (payloadLength>>8)&0xff; diff --git a/utils/util.js b/utils/util.js index 5e703a9..b5f1bf6 100644 --- a/utils/util.js +++ b/utils/util.js @@ -108,16 +108,16 @@ function hexStringToBytesWithPadding(str, byteLen, padding) { } -function hexStringToBytes(str) { - let s = str; - if(s.length < 12) +function timeStringToBytes(timeStr, timeLen) { + let s = timeStr; + if(s.length < timeLen) { - let tmp = 12-s.length + let tmp = timeLen-s.length for(let i = 0; i< tmp; i++) s = "0" + s; } else - s = str.substr(s.length-12, s.length); + s = timeStr.substr(s.length-timeLen, s.length); let start = 0 let length = s.length @@ -139,6 +139,18 @@ function hexStringToBytes(str) { return [0]; } +function time40ToBytes(dt) { + + var cs = dt.substring(0,4) + "/" + dt.substring(4,6) + "/" + dt.substring(6,8) + " " + dt.substring(8,10) + ":" + dt.substring(10,12) + + ":" + dt.substring(12,14) + ":100"; + + var milliTs = new Date(cs).getTime(); + var secondTs = milliTs/1000 + let ts = secondTs.toString(16) + let t = timeStringToBytes(ts, 10) + return t; +} + module.exports = { formatTime: formatTime, uint8ArrayToString: uint8ArrayToString, @@ -149,5 +161,6 @@ module.exports = { decodeHexNibble, decodeHexNibble: decodeHexByte, hexStringToBytesWithPadding: hexStringToBytesWithPadding, - hexStringToBytes: hexStringToBytes + timeStringToBytes: timeStringToBytes, + time40ToBytes: time40ToBytes }