SOURCE

// 错误代码
let dat1 = 'aa80020301070205'

let data1 = dat1.slice(12,-2)

console.log(data1)

// 实时压力
let dat2 = 'aa800208010500010000050049'

let data2 = dat2.slice(12,-2)
console.log(data2)
console.log(data2.length)

// let data  = 01*256+01^05
let dataHigh = parseInt(data2.slice(2,4),16)
let dataLow = parseInt(data2.slice(-4,-2),16)
let data = dataHigh * 256 + dataLow
str = `当前实时压力:${data}mmHg`
console.log(str)

let string = '01'
console.log(parseInt(string,16))

let dat3 = 'aa80020f01060016061b0c181f00850056004990'
let code = dat3.slice(14,-2)

console.log(code)
console.log(code.length)
let code_time = code.slice(0,12)
let code_bp = code.slice(12,24)
let time = code2time(code_time)
console.log(`${time.Y}年${time.M}月${time.D}日 ${time.h}点${time.m}分${time.s}秒`)
// code_bp = '00780050004B'
let BP = code2bp(code_bp)
console.log(`测量结果为:高压 ${BP.SYS} 低压 ${BP.DIA} 心跳 ${BP.PUL}`)

function code2time(code){
    let time={}
    time.Y = 2000 + parseInt(code.slice(0,2),16)
    time.M = parseInt(code.slice(2,4),16)
    time.D = parseInt(code.slice(4,6),16)
    time.h = parseInt(code.slice(6,8),16)
    time.m = parseInt(code.slice(8,10),16)
    time.s = parseInt(code.slice(10,12),16)

    return time;
}

function code2bp(code){
    let BP = {}
    let SYS={},DIA={},PUL={}
    SYS.H = parseInt(code.slice(0,2),16)
    SYS.L = parseInt(code.slice(2,4),16)

    DIA.H = parseInt(code.slice(4,6),16)
    DIA.L = parseInt(code.slice(6,8),16)

    PUL.H = parseInt(code.slice(8,10),16)
    PUL.L = parseInt(code.slice(10,12),16)

    BP.SYS = SYS.H * 256 + SYS.L
    BP.DIA = DIA.H * 256 + DIA.L
    BP.PUL = PUL.H * 256 + PUL.L

    return BP
}
console 命令行工具 X clear

                    
>
console