jkyy_yiyun_yuyue_bp_sdk 1.1.1 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1,578 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("jkyy_wx_bluetooth");const t=e.tools;class i extends e.Bluetooth{constructor(e={}){super(e),this.bindList={},this.isHistory=!1,this.historyList=[],this.serviceId="00001810-0000-1000-8000-00805F9B34FB",this.timeServiceId="00001805-0000-1000-8000-00805F9B34FB",this.serviceIdArr=["00001810-0000-1000-8000-00805F9B34FB","00001805-0000-1000-8000-00805F9B34FB"],this.timeWriteId="00002A2B-0000-1000-8000-00805F9B34FB",this.writeId="00002A52-0000-1000-8000-00805F9B34FB",this.notifyId="00002A35-0000-1000-8000-00805F9B34FB"}scan(e={}){var{services:t=[this.serviceId],allowDuplicatesKey:i=!0,powerLevel:s="medium",interval:r=0,timeout:a=15e3,deviceName:n="",containName:e="BP-YE650A"}=e;return this.scanCallback({services:t,allowDuplicatesKey:i,powerLevel:s,interval:r,timeout:a,deviceName:n,containName:e})}stopScan(){return this.stopScanCallback()}async connect(s,r){if(!s)throw new Error("device is undefiend");var e=await this.apiBindList(this.userId);if(this.bindList=e&&e.length?e[0]:{},this.bindList.deviceSn){if(this.bindList.deviceId||"ios"===t.getSystemInfoSync().platform&&await this.apiBindDevice(this.userId,s.name,this.bindList.deviceSn,s.deviceId),this.bindList.deviceSn===s.deviceId||this.bindList.deviceId===s.deviceId)return this._connect_device=s,console.log("当前连接的设备信息存起来",s),this.connectCallback(s,r);throw new Error("解绑原设备后再绑定新设备")}if(await this.apiBindStatus(s.deviceId))throw new Error("设备已被其他用户绑定");{let e=s.deviceId,i="";return"ios"===t.getSystemInfoSync().platform?(console.log(s),e=s.advertisData.slice(5).join(":").toUpperCase(),i=s.deviceId):s.deviceSn=s.deviceId,await this.apiBindDevice(this.userId,s.name,e,i),this._connect_device=s,console.log(3333,s,r),this.connectCallback(s,r)}}disconnect(){return this.disconnectCallback()}registerDidUpdateConnectStatus(e){if("function"!=typeof e)throw new TypeError("connectStatus callback expect function");this.registerDidUpdateConnectStatusCallback(e)}registerDidDiscoverDevice(e){if("function"!=typeof e)throw new TypeError("discoverDevice callback expect function");this.registerDidDiscoverDeviceCallback(e)}read(e={suuid:"",cuuid:""}){return this.readCallback(e)}write(e={}){let{suuid:t=this.serviceId,cuuid:i=this.writeId,value:s}=e;return s=s.join(""),this.writeCallback({suuid:t,cuuid:i,value:s})}notify(e={}){const{suuid:t=this.serviceId,cuuid:i=this.notifyId,state:s=!0}=e;this.notifyCallback({suuid:t,cuuid:i,state:s}).then(()=>{this.registerDidUpdateValueForCharacteristic(i)}),this.notifyCallback({suuid:t,cuuid:this.writeId,state:s}).then(()=>{this.registerDidUpdateValueForCharacteristic(this.writeId)})}registerDidUpdateValueForCharacteristic(i){this.registerDidUpdateValueForCharacteristicCallback(e=>{this.log(`notify: characteristic(${i})`,e.value);const n=e.value;console.log("注册\b特征值改变回调===================",n);let c={};if("06,00,01,01"!==n.toString()){let e=t.num16to10D(n[1]+n[2]),i=t.num16to10D(n[3]+n[4]),s=t.num16to10D(n[14]+n[15]),r=`${t.num16to10D(n[7]+n[8])}-${t.num16to10(n[9])}-${t.num16to10(n[10])} ${t.num16to10(n[11])}:${t.num16to10(n[12])}:${t.num16to10(n[13])}`,a=0;var o;n[17]+n[18]==="0000"||2<(o=t.num16to10D(n[17]+n[18]).toString(2)).length&&(a=0==o[3]?0:1),c.userId=this.userId,c.deviceSn=this._connect_device.deviceSn,c.heartRate=s,c.arrhythmia=a,c.detectionTime=(new Date(r)?new Date(r):new Date(r.replace(/-/g,"/"))).getTime(),c.sbp=e,c.dbp=i,console.log(r)}console.log(c),this.api_yuyue_save_fuc(c,e.value)})}api_yuyue_save_fuc(e,t){let i=[];this.isHistory?"06,00,01,01"!==t.toString()?this.historyList.push(e):(this.api_yuyue_save(this.historyList),this.isHistory=!1,this.historyList=[],this.getHistoryDataCallback(this._setSuccessReturn({value:"获取历史数据结束"}))):(i.push(e),this.api_yuyue_save(i))}_setSuccessReturn(e){return{code:0,data:e,message:"成功"}}_setErrorReturn(e){return{code:1,data:e,message:"失败"}}setDeviceTime(e,t){if("function"!=typeof e)throw new TypeError("arguments callback expect function");this.setDeviceTimeCallback=e;t=t||new Date,t=this.getDateCode(t,5);return this.write({suuid:this.timeServiceId,cuuid:this.timeWriteId,value:[...t,"00","00","00"]}),this.setDeviceTimeCallback(this._setSuccessReturn({value:"写入成功"}))}getHistoryData(e,t){if("function"!=typeof e)throw new TypeError("arguments callback expect function");if(this.getHistoryDataCallback=e,this.isHistory=!0,this.historyList=[],t){const e=this.getDateCode(new Date(t),6);this.write({value:["01","03","02",...e]})}else this.write({value:["01","01"]})}getDateCode(e,i){const s=t.num10to16D(e.getFullYear()),r=t.num10to16D(e.getMonth()+1),a=t.num10to16D(e.getDate()),n=t.num10to16D(e.getHours()),c=t.num10to16D(e.getMinutes()),o=t.num10to16D(e.getSeconds());let u=[];return[s,r,a,n,c,o].slice(0,i).forEach(e=>{u.push(...e)}),u}}exports.YUYUEBP=class extends i{constructor(e){super(e)}apiBindList(e,t=!1){return this.HTTP.request("/iot-data/v1/api/yuyue/device/bindList",{userId:e},{isLoading:t})}apiBindStatus(e,t=!1){return this.HTTP.request("/iot-data/v1/api/yuyue/device/bindStatus",{deviceSn:e},{isLoading:t})}apiBindDevice(e,t,i,s,r=!1){return this.HTTP.request("/iot-data/v1/api/yuyue/device/bind",{userId:e,deviceName:t,deviceSn:i,deviceId:s},{isLoading:r})}apiDeviceUnbind(e,t,i=!1){return this.disconnect(),this.HTTP.request("/iot-data/v1/api/yuyue/device/unbind",{userId:e,deviceSn:t},{isLoading:i})}api_yuyue_save(e,t=!1){return this.HTTP.request("/iot-data/v1/api/yuyue/blood/pressure/report-user-blood-pressure",{reportDateList:e},{isLoading:t})}};
1
+ /**
2
+ * name: jkyy_yiyun_yuyue_bp_sdk
3
+ * version: v1.1.5
4
+ * author: haotengfei
5
+ */
6
+
7
+ 'use strict';
8
+
9
+ Object.defineProperty(exports, '__esModule', { value: true });
10
+
11
+ var jkyy_wx_bluetooth = require('jkyy_wx_bluetooth');
12
+
13
+ const _ = jkyy_wx_bluetooth.tools;
14
+ class BTManager extends jkyy_wx_bluetooth.Bluetooth {
15
+ /**
16
+ * @des 构造函数
17
+ * @param {object} config 配置
18
+ * @property {boolean} debug 是否开启打印调试,默认不开启
19
+ *
20
+ * @discussion 单例模式。
21
+ */
22
+ constructor(config = {}) {
23
+ super(config); // 初始化用户绑定的设备
24
+
25
+ this.bindList = {}; // 同步用户信息
26
+
27
+ this.updateUserInfo(); // 是否是历史数据
28
+
29
+ this.isHistory = false; // 历史数据合集
30
+
31
+ this.historyList = []; // 服务id
32
+
33
+ this.serviceId = "00001810-0000-1000-8000-00805F9B34FB"; // 时间服务id
34
+
35
+ this.timeServiceId = "00001805-0000-1000-8000-00805F9B34FB";
36
+ this.serviceIdArr = ["00001810-0000-1000-8000-00805F9B34FB", "00001805-0000-1000-8000-00805F9B34FB"]; // 时间写入id
37
+
38
+ this.timeWriteId = "00002A2B-0000-1000-8000-00805F9B34FB"; // 写入id
39
+
40
+ this.writeId = "00002A52-0000-1000-8000-00805F9B34FB"; // 监听id
41
+
42
+ this.notifyId = "00002A35-0000-1000-8000-00805F9B34FB";
43
+ }
44
+ /**
45
+ * @des 同步用户信息
46
+ */
47
+
48
+
49
+ updateUserInfo() {
50
+ this.apiUserSave(this.userId);
51
+ }
52
+ /**
53
+ * @des 扫描外设
54
+ * @param {object} options 扫描参数
55
+ * @property {array} services 主service的uuid列表。确认在蓝牙广播中存在此服务id,可以通过服务id过滤掉其他设备
56
+ * @property {boolean} allowDuplicatesKey 是否允许重复上报设备
57
+ * @property {number} interval 上报新设备的间隔,默认为0
58
+ * @property {string} powerLevel 默认 medium 扫描模式,越高扫描越快,也越耗电, 仅安卓 7.0.12 及以上支持。
59
+ * @property {number} timeout 扫描超时时间,毫秒。在该时间内未扫描到符合要求的设备,上报超时。默认15000ms,-1表示无限超时
60
+ * @property {string} deviceName 通过蓝牙名称过滤,需要匹配的设备名称
61
+ * @property {string} containName 通过蓝牙名称过滤,需要包含的设备名称
62
+ * @return Promise对象
63
+ *
64
+ * @discussion 开始扫描外设,注意实现返回对象的then和catch方法,监听接口是否调用成功。此操作比较耗费系统资源,请在搜索到设备后调用stopScan方法停止扫描。重复调用此接口,会清空之前设备存储,再次上报已上报的设备,能够起到刷新的作用。
65
+ *
66
+ * @see registerDidDiscoverDevice
67
+ */
68
+
69
+
70
+ scan(options = {}) {
71
+ const {
72
+ services = [this.serviceId],
73
+ allowDuplicatesKey = true,
74
+ powerLevel = "medium",
75
+ interval = 0,
76
+ timeout = 60000,
77
+ deviceName = "",
78
+ containName = "BP-YE650A"
79
+ } = options;
80
+ return this.scanCallback({
81
+ services,
82
+ allowDuplicatesKey,
83
+ powerLevel,
84
+ interval,
85
+ timeout,
86
+ deviceName,
87
+ containName
88
+ });
89
+ }
90
+ /**
91
+ * @des 停止扫描
92
+ * @return Promise对象
93
+ *
94
+ * @discussion 停止扫描,取消超时延时。
95
+ */
96
+
97
+
98
+ stopScan() {
99
+ return this.stopScanCallback();
100
+ }
101
+ /**
102
+ * @des 连接外设
103
+ * @param {object} device 指定连接的外设对象,从registerDidDiscoverDevice注册的回调中得到
104
+ * @param {number} timeout 连接超时时间,毫秒,默认15000ms,支付宝小程序无效
105
+ * @return Promise对象
106
+ *
107
+ * @discussion 连接指定的外设,需要传入外设对象。注意实现返回对象的then和catch方法,监听接口是否调用成功。
108
+ */
109
+
110
+
111
+ async connect(device, timeout) {
112
+ if (!device) throw new Error("device is undefiend"); // 获取用户设备的绑定的设备
113
+
114
+ const bindList = await this.apiBindList(this.userId);
115
+ this.bindList = bindList && bindList.length ? bindList[0] : {}; // 用户已经绑定设备
116
+
117
+ if (this.bindList.deviceSn) {
118
+ if (!this.bindList.deviceId) {
119
+ const info = _.getSystemInfoSync();
120
+
121
+ if (info.platform === "ios") {
122
+ // 更新一下用户绑定的 deviceId
123
+ await this.apiBindDevice(this.userId, device.name, this.bindList.deviceSn, device.deviceId);
124
+ }
125
+ }
126
+
127
+ if (this.bindList.deviceSn === device.deviceId || this.bindList.deviceId === device.deviceId) {
128
+ // 要连接的设备是已绑定的设备,可以连接
129
+ this._connect_device = device; // 当前连接的设备信息存起来
130
+
131
+ console.log('当前连接的设备信息存起来', device);
132
+ return this.connectCallback(device, timeout);
133
+ } else {
134
+ // 连接的不是已经绑定的设备
135
+ throw new Error("解绑原设备后再绑定新设备");
136
+ }
137
+ } else {
138
+ // 用户没有绑定设备,判断要绑定的设备有没有被别人绑定
139
+ const bindStatus = await this.apiBindStatus(device.deviceId);
140
+
141
+ if (bindStatus) {
142
+ // 此设备已经被绑定过了,不允许再次绑定
143
+ throw new Error("设备已被其他用户绑定");
144
+ } else {
145
+ // 设备没有被绑定过,可以绑定,后连接
146
+ let deviceSn = device.deviceId;
147
+ let deviceId = ""; // ios 特有,连接时候取,android连接取deviceId
148
+
149
+ const info = _.getSystemInfoSync();
150
+
151
+ if (info.platform === "ios") {
152
+ console.log(device); // 获取mac地址
153
+
154
+ deviceSn = device.advertisData.slice(5).join(":").toUpperCase();
155
+ deviceId = device.deviceId;
156
+ } else {
157
+ device.deviceSn = device.deviceId;
158
+ }
159
+
160
+ await this.apiBindDevice(this.userId, device.name, deviceSn, deviceId);
161
+ this._connect_device = device; // 当前连接的设备信息存起来
162
+
163
+ console.log(3333, device, timeout);
164
+ return this.connectCallback(device, timeout);
165
+ }
166
+ }
167
+ }
168
+ /**
169
+ * @des 断开连接
170
+ * @return Promise对象
171
+ */
172
+
173
+
174
+ disconnect() {
175
+ return this.disconnectCallback();
176
+ }
177
+ /**
178
+ * @des 注册状态改变回调
179
+ * @param {function} cb 回调函数
180
+ *
181
+ * @discussion 连接状态发生改变时,回调此方法。
182
+ */
183
+
184
+
185
+ registerDidUpdateConnectStatus(cb) {
186
+ if (typeof cb !== "function") throw new TypeError("connectStatus callback expect function");
187
+ this.registerDidUpdateConnectStatusCallback(cb);
188
+ }
189
+ /**
190
+ * @des 注册发现外设回调
191
+ * @param {function} cb 回调函数
192
+ *
193
+ * @discussion 当扫描到设备时回调,或者达到超时时间回调。
194
+ */
195
+
196
+
197
+ registerDidDiscoverDevice(cb) {
198
+ if (typeof cb !== "function") throw new TypeError("discoverDevice callback expect function");
199
+ this.registerDidDiscoverDeviceCallback(cb);
200
+ }
201
+ /**
202
+ * @des 读特征值
203
+ * @param {object} params 参数
204
+ * @property {string} suuid 特征对应的服务uuid
205
+ * @property {string} cuuid 特征uuid
206
+ * @return Promise对象
207
+ *
208
+ * @discussion 读某个服务下的某个特征值。
209
+ */
210
+
211
+
212
+ read(params = {
213
+ suuid: "",
214
+ cuuid: ""
215
+ }) {
216
+ return this.readCallback(params);
217
+ }
218
+ /**
219
+ * @des 向蓝牙模块写入数据
220
+ * @param {object} params 参数
221
+ * @property {string} suuid 特征对应的服务uuid
222
+ * @property {string} cuuid 特征uuid
223
+ * @property {Hex string} value 16进制字符串
224
+ * @return Promise对象
225
+ *
226
+ * @discussion 向蓝牙模块写入数据。
227
+ */
228
+
229
+
230
+ write(params = {}) {
231
+ let {
232
+ suuid = this.serviceId,
233
+ cuuid = this.writeId,
234
+ value
235
+ } = params;
236
+ value = value.join("");
237
+ return this.writeCallback({
238
+ suuid,
239
+ cuuid,
240
+ value
241
+ });
242
+ }
243
+ /**
244
+ * @des 监听特征值改变
245
+ * @param {object} params 参数
246
+ * @property {string} suuid 特征对应的服务uuid
247
+ * @property {string} cuuid 特征uuid
248
+ * @property {boolean} state 是否启用notify,可以通过重复调用接口改变此属性打开/关闭监听
249
+ * @return Promise对象
250
+ *
251
+ * @discussion 监听某个特征值变化。
252
+ */
253
+
254
+
255
+ notify(params = {}) {
256
+ const {
257
+ suuid = this.serviceId,
258
+ cuuid = this.notifyId,
259
+ state = true
260
+ } = params; //
261
+
262
+ this.notifyCallback({
263
+ suuid,
264
+ cuuid,
265
+ state
266
+ }).then(() => {
267
+ this.registerDidUpdateValueForCharacteristic(cuuid);
268
+ }); //
269
+
270
+ this.notifyCallback({
271
+ suuid,
272
+ cuuid: this.writeId,
273
+ state
274
+ }).then(() => {
275
+ this.registerDidUpdateValueForCharacteristic(this.writeId);
276
+ });
277
+ }
278
+ /**
279
+ * @des 注册特征值改变回调
280
+ * @param {function} cb 回调函数
281
+ * @discussion 当监听的特征值改变时回调,或者读特征值时回调。
282
+ */
283
+
284
+
285
+ registerDidUpdateValueForCharacteristic(characteristic) {
286
+ this.registerDidUpdateValueForCharacteristicCallback(res => {
287
+ // 上报益云
288
+ this.log(`notify: characteristic(${characteristic})`, res.value);
289
+ const resArr = res.value;
290
+ console.log('注册特征值改变回调===================', resArr);
291
+ let reportDate = {};
292
+
293
+ if (this.isHistory == true) {
294
+ this.getHistoryDataCallback(resArr);
295
+ } else {
296
+ if (resArr.toString() !== "06,00,01,01") {
297
+ // 收缩压
298
+ let sbp = _.num16to10D(resArr[1] + resArr[2]); // 舒张压
299
+
300
+
301
+ let dbp = _.num16to10D(resArr[3] + resArr[4]); // 心率(脉搏 )
302
+
303
+
304
+ let heartRate = _.num16to10D(resArr[14] + resArr[15]); // 时间
305
+
306
+
307
+ let time = `${_.num16to10D(resArr[7] + resArr[8])}-${_.num16to10(resArr[9])}-${_.num16to10(resArr[10])} ${_.num16to10(resArr[11])}:${_.num16to10(resArr[12])}:${_.num16to10(resArr[13])}`;
308
+ let arrhythmia = 0;
309
+
310
+ if (resArr[17] + resArr[18] !== '0000') {
311
+ let isArrhythmia = _.num16to10D(resArr[17] + resArr[18]).toString(2);
312
+
313
+ if (isArrhythmia.length > 2) {
314
+ arrhythmia = isArrhythmia[3] == 0 ? 0 : 1;
315
+ }
316
+ }
317
+
318
+ reportDate.userId = this.userId;
319
+ reportDate.deviceSn = this._connect_device.deviceSn;
320
+ reportDate.heartRate = heartRate;
321
+ reportDate.arrhythmia = arrhythmia;
322
+ reportDate.detectionTime = new Date(time).getTime() ? new Date(time).getTime() : new Date(time.replace(/-/g, "/")).getTime();
323
+ reportDate.sbp = sbp;
324
+ reportDate.dbp = dbp;
325
+ console.log(time);
326
+ }
327
+
328
+ console.log(reportDate);
329
+ this.api_yuyue_save_fuc(reportDate, res.value);
330
+ } // if (this.isHistory == true) {
331
+ // this.getHistoryDataCallback(res.value)
332
+ // }else {
333
+ // this.api_yuyue_save_fuc(reportDate, res.value)
334
+ // }
335
+
336
+ });
337
+ }
338
+ /**
339
+ *
340
+ * @param {*} data
341
+ */
342
+
343
+
344
+ api_yuyue_save_fuc(reportDate, val) {
345
+ let reportDateList = []; // 是历史数据
346
+ // if (this.isHistory) {
347
+ // if (val.toString() !== "06,00,01,01") {
348
+ // this.historyList.push(reportDate)
349
+ // } else {
350
+ // this.api_yuyue_save(this.historyList)
351
+ // this.isHistory = false
352
+ // this.historyList = []
353
+ // this.getHistoryDataCallback(this._setSuccessReturn({ value: '获取历史数据结束' }))
354
+ // }
355
+ // } else {
356
+
357
+ if (val.toString() !== "06,00,01,01") {
358
+ reportDateList.push(reportDate);
359
+ this.api_yuyue_save(reportDateList);
360
+ this.getCurrentDataCallback(this._setSuccessReturn({
361
+ value: '获取测量结果结束'
362
+ }));
363
+ } // }
364
+
365
+ }
366
+ /**
367
+ * @des 设置成功返回
368
+ */
369
+
370
+
371
+ _setSuccessReturn(data) {
372
+ return {
373
+ code: 0,
374
+ data,
375
+ message: "成功"
376
+ };
377
+ }
378
+ /**
379
+ * @des 设置失败返回
380
+ */
381
+
382
+
383
+ _setErrorReturn(data) {
384
+ return {
385
+ code: 1,
386
+ data,
387
+ message: "失败"
388
+ };
389
+ }
390
+ /**
391
+ * @des 设置设备时间
392
+ * @param {Date?} date
393
+ */
394
+
395
+
396
+ setDeviceTime(cb, date) {
397
+ if (typeof cb !== "function") throw new TypeError("arguments callback expect function");
398
+ this.setDeviceTimeCallback = cb;
399
+ const newDate = date || new Date();
400
+ const resCode = this.getDateCode(newDate, 5);
401
+ this.write({
402
+ suuid: this.timeServiceId,
403
+ cuuid: this.timeWriteId,
404
+ value: [...resCode, "00", "00", "00"]
405
+ }); // 设置时间成功
406
+
407
+ return this.setDeviceTimeCallback(this._setSuccessReturn({
408
+ value: '写入成功'
409
+ }));
410
+ }
411
+ /**
412
+ * @des 获取历史数据
413
+ * @param {Date} lastTime yy-MM-hh
414
+ */
415
+
416
+
417
+ getHistoryData(cb, lastTimeP) {
418
+ if (typeof cb !== "function") throw new TypeError("arguments callback expect function");
419
+ this.isHistory = true;
420
+ this.historyList = [];
421
+
422
+ if (lastTimeP) {
423
+ const resCode = this.getDateCode(new Date(lastTimeP), 6);
424
+ this.write({
425
+ value: ["01", "03", "02", ...resCode]
426
+ });
427
+ } else {
428
+ this.write({
429
+ value: ["01", "01"]
430
+ });
431
+ }
432
+
433
+ this.getHistoryDataCallback = cb;
434
+ }
435
+ /**
436
+ * @des 获取当前测量结果回调
437
+ * @param {cb} 回调函数
438
+ */
439
+
440
+
441
+ getCurrentData(cb) {
442
+ if (typeof cb !== "function") throw new TypeError("arguments callback expect function");
443
+ this.getCurrentDataCallback = cb;
444
+ }
445
+ /**
446
+ * @des 传入日期获取 对应的指令
447
+ * @param {Date} date、
448
+ * @param {number} index 年 月 日 时 分 秒 从左到右要的索引 slice 全部是 6
449
+ */
450
+
451
+
452
+ getDateCode(date, index) {
453
+ const yeare = _.num10to16D(date.getFullYear());
454
+
455
+ const month = _.num10to16D(date.getMonth() + 1);
456
+
457
+ const day = _.num10to16D(date.getDate());
458
+
459
+ const hour = _.num10to16D(date.getHours());
460
+
461
+ const minute = _.num10to16D(date.getMinutes());
462
+
463
+ const second = _.num10to16D(date.getSeconds());
464
+
465
+ const res = [yeare, month, day, hour, minute, second];
466
+ let resCode = [];
467
+ res.slice(0, index).forEach(item => {
468
+ resCode.push(...item);
469
+ });
470
+ return resCode;
471
+ }
472
+
473
+ }
474
+
475
+ class YUYUEBP extends BTManager {
476
+ constructor(config) {
477
+ super(config);
478
+ }
479
+ /**
480
+ * @des 睿知手环同步用户信息
481
+ * @param {string} userId 接入方的用户ID,如微信的openId
482
+ * ...
483
+ */
484
+
485
+
486
+ apiUserSave(userId, isLoading = false) {
487
+ return this.HTTP.request("/data-center/v1/api/user-info/save", {
488
+ userId
489
+ }, {
490
+ isLoading
491
+ });
492
+ }
493
+ /**
494
+ * @des 鱼跃用户设备绑定列表
495
+ * @param {string} userId 用户id
496
+ */
497
+
498
+
499
+ apiBindList(userId, isLoading = false) {
500
+ return this.HTTP.request("/iot-data/v1/api/yuyue/device/bindList", {
501
+ userId
502
+ }, {
503
+ isLoading
504
+ });
505
+ }
506
+ /**
507
+ * @des 鱼跃血压计获取设备绑定状态
508
+ * @param {string} deviceSn
509
+ */
510
+
511
+
512
+ apiBindStatus(deviceSn, isLoading = false) {
513
+ return this.HTTP.request("/iot-data/v1/api/yuyue/device/bindStatus", {
514
+ deviceSn
515
+ }, {
516
+ isLoading
517
+ });
518
+ }
519
+ /**
520
+ * @des 鱼跃血压计绑定设备绑定用户
521
+ * @param {string} userId 接入方的用户ID,如微信的openId
522
+ * @param {string} deviceName 设备名称
523
+ * @param {string} deviceSn 设备唯一标识 mac地址
524
+ * @param {string} deviceId 设备唯一标识 uuid
525
+ */
526
+
527
+
528
+ apiBindDevice(userId, deviceName, deviceSn, deviceId, isLoading = false) {
529
+ return this.HTTP.request("/iot-data/v1/api/yuyue/device/bind", {
530
+ userId,
531
+ deviceName,
532
+ deviceSn,
533
+ deviceId
534
+ }, {
535
+ isLoading
536
+ });
537
+ }
538
+ /**
539
+ * @des 鱼跃血压计设备解除绑定
540
+ * @param {string} userId 接入方的用户ID,如微信的openId
541
+ * @param {string} deviceSn 设备唯一标识 mac地址
542
+ */
543
+
544
+
545
+ apiDeviceUnbind(userId, deviceSn, isLoading = false) {
546
+ // 断开蓝牙连接
547
+ this.disconnect();
548
+ return this.HTTP.request("/iot-data/v1/api/yuyue/device/unbind", {
549
+ userId,
550
+ deviceSn
551
+ }, {
552
+ isLoading
553
+ });
554
+ }
555
+ /**
556
+ * @des 鱼跃血压数据上报
557
+ * @param {List<Object>} reportDateList 明细
558
+ * @property {String} userId 接入方的用户ID,如微信的openId
559
+ * @property {String} deviceSn 设备唯一标识 mac地址
560
+ * @property {number} heartRate 心率(脉搏 )
561
+ * @property {number} arrhythmia 心率不齐 0:否, 1:是
562
+ * @property {Date} detectionTime 检测时间时间戳
563
+ * @property {number} sbp 收缩压(高压),单位: mmHg ,[30,300]
564
+ * @property {number} dbp 舒张压(低压),单位: mmHg ,[30,300]
565
+ */
566
+
567
+
568
+ api_yuyue_save(reportDateList, isLoading = false) {
569
+ return this.HTTP.request("/iot-data/v1/api/yuyue/blood/pressure/report-user-blood-pressure", {
570
+ reportDateList
571
+ }, {
572
+ isLoading
573
+ });
574
+ }
575
+
576
+ }
577
+
578
+ exports.YUYUEBP = YUYUEBP;