wuyongxiang лет назад: 4
Родитель
Сommit
f628bf3023
2 измененных файлов с 40 добавлено и 1 удалено
  1. 1 1
      screenAndroid/WXtrialInterface.html
  2. 39 0
      screenAndroid/helper.js

+ 1 - 1
screenAndroid/WXtrialInterface.html

@@ -388,7 +388,7 @@
 
 				ws.addEventListener('open', function(event) {
 					console.log("发送配置帧");
-					// ws.send(ConfigChannel("RK3923C1201900139"));
+					ws.send(ConfigChannel("RK3923C1201900139"));
 				});
 
 				ws.addEventListener('error', function(event) {

+ 39 - 0
screenAndroid/helper.js

@@ -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\"}";