SOURCE

function parseRaw(bytes) {
    var subBytes = function(bytes, from, to) {
        var buff = [];
        for(var i = from; i < to; i ++) {
            buff.push(bytes[i]);
        }
        return buff;
    }s
    if(bytes[0] != 0xFB || bytes[bytes.length - 1] != 0xFC) {
        return {}
    }
    var obj = {}
    if(bytes[1] == 0x1) {
        obj["temp"] = bytes[2];
    } else if(bytes[1] == 0x2) {
        obj["humidity"] = bytes[2];
    }
    return obj
}
var s = parseRaw([0xFB, 0x01, 0x27, 0xFC]);
console.log("result=", s)
console 命令行工具 X clear

                    
>
console