Browse Source

新增支持 CL837 心率带

wzx 2 years ago
parent
commit
f334b490db
2 changed files with 9 additions and 7 deletions
  1. 2 2
      package.json
  2. 7 5
      src/ble.js

+ 2 - 2
package.json

@@ -3,8 +3,8 @@
   "version": "0.1.0",
   "private": true,
   "scripts": {
-    "serve": "vue-cli-service serve",
-    "build": "vue-cli-service build"
+    "serve": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service serve",
+    "build": "set NODE_OPTIONS=--openssl-legacy-provider && vue-cli-service build"
   },
   "dependencies": {
     "animate.css": "^4.1.1",

+ 7 - 5
src/ble.js

@@ -22,7 +22,7 @@ var targetDevPreNameArr = [
     'CL831',    //小飞龙心率带 OK
     'CL880',    //带屏心率带 OK
     'CL820',    //CL820W 心率胸带 OK
-    // 'CL837',    //扁平化心率带
+    'CL837',    //扁平化心率带
 ];
 
 export function getBleDiscovery() {
@@ -201,7 +201,9 @@ export function listenerDeviceFound() {
                 VendorID = parseInt(new Uint16Array(devices[i].advertisData, 0, 2));
                 DevType = parseInt(new Uint8Array(devices[i].advertisData, 2, 1));
                 
-                if (VendorID == 0xff04 && DevType == 0xa1) {    // [新版] CL831 中性版本 RSP 广播
+                // DevType == 0xa1 [新版] CL831 中性版本 RSP 广播
+                // DevType == 0xa2 [新版] CL837 中性版本 RSP 广播
+                if (VendorID == 0xff04 && (DevType == 0xa1 || DevType == 0xa2)) {
                     Power = parseInt(new Uint8Array(devices[i].advertisData, 8, 1));
                     HeartRate = parseInt(new Uint8Array(devices[i].advertisData, 7, 1));
                     Sn = parseInt(devices[i].localName.substr(6, devices[i].localName.length));
@@ -233,9 +235,9 @@ export function listenerDeviceFound() {
                     dataRcvArr.push(data);
                 }                
             }
-            /* else {
-                console.log(i+': '+JSON.stringify(devices[i]));
-            } */
+            // else {
+            //     console.log(i+': '+JSON.stringify(devices[i]));
+            // }
         }
     });
 }