调硬件开门
Eapp.this.kaimen = function (name, cmds) {
if (typeof cmds == "string") {
cmds = [cmds];
}
JsBridge.require("SerialPort").open({
name: name,
stop_bits: 1,
baud_rate: 9600,
data_bits: 8,
parity: "none", //odd even
},
function (ret) {
for (var i = 0; i < cmds.length; i++) {
setTimeout(
function () {
JsBridge.require("SerialPort").write({
id: this.sid,
data: cmds[this.i],
data_type: "hex",
},
function (a, b) {
console.log(arguments);
}
);
}.bind({
i: i,
sid: ret.id
}),
i === 0 ? 10 : (i * 200)
);
}
}
);
};