|
|
@@ -117,6 +117,45 @@
|
|
|
// var sn = "RK3923C1201900139";
|
|
|
return makeFrame(sn, 0, data);
|
|
|
}
|
|
|
+ function makeFrameExtend(sn, dataType, body)
|
|
|
+ {
|
|
|
+ var index = 0;
|
|
|
+ var dataLen = body.length;
|
|
|
+ var frameLen = dataLen + 26;
|
|
|
+ var outPut = new Uint8Array(frameLen);
|
|
|
+ outPut[index++] = 0x68;
|
|
|
+ outPut[index++] = (dataLen & 0xff000000) >> 24;
|
|
|
+ outPut[index++] = (dataLen & 0x00ff0000) >> 16;
|
|
|
+ outPut[index++] = (dataLen & 0x0000ff00) >> 8;
|
|
|
+ outPut[index++] = dataLen & 0x000000ff;
|
|
|
+ outPut[index++] = 0;//类型为client
|
|
|
+
|
|
|
+ //sn号赋值,string转ascii
|
|
|
+ for( i = 0;i< sn.length;i++)
|
|
|
+ {
|
|
|
+ outPut[index++] = sn[i].charCodeAt();
|
|
|
+ }
|
|
|
+
|
|
|
+ outPut[index++] = dataType;//指定数据类型为json
|
|
|
+ //json string转ascii
|
|
|
+ for( i = 0;i < body.length;i++)
|
|
|
+ {
|
|
|
+ outPut[index++] = body[i];
|
|
|
+ }
|
|
|
+
|
|
|
+ var bccBuffer = outPut.slice(1, frameLen-3 + 1);//忽略协议头和协议尾
|
|
|
+ outPut[index++] = calBcc(bccBuffer);
|
|
|
+ outPut[index++] = 0x16;
|
|
|
+ var str = PrintArry(outPut);
|
|
|
+ //console.log("打印数组:%s", PrintArry(outPut));
|
|
|
+ //return PrintArry(outPut);
|
|
|
+ return outPut;
|
|
|
+ }
|
|
|
+
|
|
|
+ function ConfigChannel(sn) {
|
|
|
+ var outPut = new Uint8Array([0x07])
|
|
|
+ return makeFrameExtend(sn, 6, outPut)
|
|
|
+ }
|
|
|
//示例:
|
|
|
//var sn = "RK3923C1201900139";
|
|
|
//var json = "{\"data\":{\"keyCode\":24},\"type\":\"keyDown\"}";
|