Browse Source

修改启动蓝牙下发

master
zw_git 3 years ago
parent
commit
8fdc628377
2 changed files with 63 additions and 5 deletions
  1. +46
    -5
      pages/asyntest/asyntest.js
  2. +17
    -0
      utils/util.js

+ 46
- 5
pages/asyntest/asyntest.js View File

@ -38,6 +38,14 @@ Page({
btntest3(event){
var that = this
let deviceNum = "yxwl01680000000362"
this.startFingerprint(deviceNum)
},
/*
btntest3(event){
var that = this
let managerTelephone = "19270949446"
let managerPassword = "123456"
let userTelephone = "38580151200"
@ -53,7 +61,7 @@ Page({
this.startFingerprint(managerTelephone, managerPassword, userTelephone, userPassword, userStartTime, userEndTime,
fpDataLength, fpStartTime, fpEndTime, times, recycleTime)
},
*/
//获取输入框的数据
getmsg(event){
@ -148,8 +156,41 @@ Page({
console.log(b)
app.globalData.ble.send(cmd, b, length)
},
startFingerprint(deviceNum) {
wx.showLoading({
title: "正在发送...",
});
setTimeout(() => {
wx.hideLoading()
}, 1000);
let cmd = 0x29
let dn = util.stringToUint8ArrayWithPadding(deviceNum, 20, 'F')
let data = 0x00360008
let length = 1 + 20 + 4 + 1 + 1
let b = new Uint8Array(length)
b[0] = cmd
b.set(dn, 1)
b[21] = (data>>24)&0xff;
b[22] = (data>>16)&0xff;
b[23] = (data>>8)&0xff;
b[24] = data&0xff;
b[25] = 0x03
b[26] = 0x01
console.log(b)
app.globalData.ble.send(cmd, b, length)
},
startFingerprint(managerTelephone, managerPassword, userTelephone, userPassword, userStartTime, userEndTime,
startFingerprint_1(managerTelephone, managerPassword, userTelephone, userPassword, userStartTime, userEndTime,
fpDataLength, fpStartTime, fpEndTime, times, recycleTime) {
wx.showLoading({
@ -212,9 +253,9 @@ Page({
console.log(b)
app.globalData.ble.send(cmd, b, length)
},
},
})


+ 17
- 0
utils/util.js View File

@ -31,6 +31,22 @@ function stringToUint8Array(str){
let tmpUint8Array = new Uint8Array(arr);
return tmpUint8Array
}
function stringToUint8ArrayWithPadding(str, length, padding){
let arr = [];
for (let i = 0, j = str.length; i < j; ++i) {
arr.push(str.charCodeAt(i));
}
for (let i = str.length; i < length; i++) {
arr.push(padding);
}
let tmpUint8Array = new Uint8Array(arr);
return tmpUint8Array
}
// 微信官方给的ArrayBuffer转十六进制示例
@ -155,6 +171,7 @@ module.exports = {
formatTime: formatTime,
uint8ArrayToString: uint8ArrayToString,
stringToUint8Array: stringToUint8Array,
stringToUint8ArrayWithPadding: stringToUint8ArrayWithPadding,
ab2hex: ab2hex,
hexCharCodeToStr,
hexCharCodeToStr: buf2string,


Loading…
Cancel
Save