jkyy_yiyun_yuyue_bp_sdk 1.1.4 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,574 +1 @@
1
- /**
2
- * name: jkyy_yiyun_yuyue_bp_sdk
3
- * version: v1.1.4
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 (resArr.toString() !== "06,00,01,01") {
294
- // 收缩压
295
- let sbp = _.num16to10D(resArr[1] + resArr[2]); // 舒张压
296
-
297
-
298
- let dbp = _.num16to10D(resArr[3] + resArr[4]); // 心率(脉搏 )
299
-
300
-
301
- let heartRate = _.num16to10D(resArr[14] + resArr[15]); // 时间
302
-
303
-
304
- let time = `${_.num16to10D(resArr[7] + resArr[8])}-${_.num16to10(resArr[9])}-${_.num16to10(resArr[10])} ${_.num16to10(resArr[11])}:${_.num16to10(resArr[12])}:${_.num16to10(resArr[13])}`;
305
- let arrhythmia = 0;
306
-
307
- if (resArr[17] + resArr[18] !== '0000') {
308
- let isArrhythmia = _.num16to10D(resArr[17] + resArr[18]).toString(2);
309
-
310
- if (isArrhythmia.length > 2) {
311
- arrhythmia = isArrhythmia[3] == 0 ? 0 : 1;
312
- }
313
- }
314
-
315
- reportDate.userId = this.userId;
316
- reportDate.deviceSn = this._connect_device.deviceSn;
317
- reportDate.heartRate = heartRate;
318
- reportDate.arrhythmia = arrhythmia;
319
- reportDate.detectionTime = new Date(time).getTime() ? new Date(time).getTime() : new Date(time.replace(/-/g, "/")).getTime();
320
- reportDate.sbp = sbp;
321
- reportDate.dbp = dbp;
322
- console.log(time);
323
- }
324
-
325
- console.log(reportDate);
326
- this.api_yuyue_save_fuc(reportDate, res.value);
327
-
328
- if (this.isHistory == true) {
329
- this.getHistoryDataCallback(res.value);
330
- } else {
331
- this.api_yuyue_save_fuc(reportDate, res.value);
332
- }
333
- });
334
- }
335
- /**
336
- *
337
- * @param {*} data
338
- */
339
-
340
-
341
- api_yuyue_save_fuc(reportDate, val) {
342
- let reportDateList = []; // 是历史数据
343
- // if (this.isHistory) {
344
- // if (val.toString() !== "06,00,01,01") {
345
- // this.historyList.push(reportDate)
346
- // } else {
347
- // this.api_yuyue_save(this.historyList)
348
- // this.isHistory = false
349
- // this.historyList = []
350
- // this.getHistoryDataCallback(this._setSuccessReturn({ value: '获取历史数据结束' }))
351
- // }
352
- // } else {
353
-
354
- if (val.toString() !== "06,00,01,01") {
355
- reportDateList.push(reportDate);
356
- this.api_yuyue_save(reportDateList);
357
- this.getCurrentDataCallback(this._setSuccessReturn({
358
- value: '获取测量结果结束'
359
- }));
360
- } // }
361
-
362
- }
363
- /**
364
- * @des 设置成功返回
365
- */
366
-
367
-
368
- _setSuccessReturn(data) {
369
- return {
370
- code: 0,
371
- data,
372
- message: "成功"
373
- };
374
- }
375
- /**
376
- * @des 设置失败返回
377
- */
378
-
379
-
380
- _setErrorReturn(data) {
381
- return {
382
- code: 1,
383
- data,
384
- message: "失败"
385
- };
386
- }
387
- /**
388
- * @des 设置设备时间
389
- * @param {Date?} date
390
- */
391
-
392
-
393
- setDeviceTime(cb, date) {
394
- if (typeof cb !== "function") throw new TypeError("arguments callback expect function");
395
- this.setDeviceTimeCallback = cb;
396
- const newDate = date || new Date();
397
- const resCode = this.getDateCode(newDate, 5);
398
- this.write({
399
- suuid: this.timeServiceId,
400
- cuuid: this.timeWriteId,
401
- value: [...resCode, "00", "00", "00"]
402
- }); // 设置时间成功
403
-
404
- return this.setDeviceTimeCallback(this._setSuccessReturn({
405
- value: '写入成功'
406
- }));
407
- }
408
- /**
409
- * @des 获取历史数据
410
- * @param {Date} lastTime yy-MM-hh
411
- */
412
-
413
-
414
- getHistoryData(cb, lastTimeP) {
415
- if (typeof cb !== "function") throw new TypeError("arguments callback expect function");
416
- this.getHistoryDataCallback = cb;
417
- this.isHistory = true;
418
- this.historyList = [];
419
-
420
- if (lastTimeP) {
421
- const resCode = this.getDateCode(new Date(lastTimeP), 6);
422
- this.write({
423
- value: ["01", "03", "02", ...resCode]
424
- });
425
- } else {
426
- this.write({
427
- value: ["01", "01"]
428
- });
429
- }
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
- exports.YUYUEBP = YUYUEBP;
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.updateUserInfo(),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"}updateUserInfo(){this.apiUserSave(this.userId)}scan(e={}){var{services:t=[this.serviceId],allowDuplicatesKey:i=!0,powerLevel:s="medium",interval:r=0,timeout:a=6e4,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).getTime()?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),1==this.isHistory?"06,00,01,01"!==val.toString()?this.historyList.push(c):this.getHistoryDataCallback(this.historyList):this.api_yuyue_save_fuc(c,e.value)})}api_yuyue_save_fuc(e,t){let i=[];"06,00,01,01"!==t.toString()&&(i.push(e),this.api_yuyue_save(i),this.getCurrentDataCallback(this._setSuccessReturn({value:"获取测量结果结束"})))}_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");this.isHistory=!0,this.historyList=[],this.write({value:["01","01"]}),this.getHistoryDataCallback=e}getCurrentData(e){if("function"!=typeof e)throw new TypeError("arguments callback expect function");this.getCurrentDataCallback=e}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)}apiUserSave(e,t=!1){return this.HTTP.request("/data-center/v1/api/user-info/save",{userId:e},{isLoading:t})}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})}};