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