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,570 +1 @@
1
- /**
2
- * name: jkyy_yiyun_yuyue_bp_sdk
3
- * version: v1.1.4
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 (resArr.toString() !== "06,00,01,01") {
290
- // 收缩压
291
- let sbp = _.num16to10D(resArr[1] + resArr[2]); // 舒张压
292
-
293
-
294
- let dbp = _.num16to10D(resArr[3] + resArr[4]); // 心率(脉搏 )
295
-
296
-
297
- let heartRate = _.num16to10D(resArr[14] + resArr[15]); // 时间
298
-
299
-
300
- let time = `${_.num16to10D(resArr[7] + resArr[8])}-${_.num16to10(resArr[9])}-${_.num16to10(resArr[10])} ${_.num16to10(resArr[11])}:${_.num16to10(resArr[12])}:${_.num16to10(resArr[13])}`;
301
- let arrhythmia = 0;
302
-
303
- if (resArr[17] + resArr[18] !== '0000') {
304
- let isArrhythmia = _.num16to10D(resArr[17] + resArr[18]).toString(2);
305
-
306
- if (isArrhythmia.length > 2) {
307
- arrhythmia = isArrhythmia[3] == 0 ? 0 : 1;
308
- }
309
- }
310
-
311
- reportDate.userId = this.userId;
312
- reportDate.deviceSn = this._connect_device.deviceSn;
313
- reportDate.heartRate = heartRate;
314
- reportDate.arrhythmia = arrhythmia;
315
- reportDate.detectionTime = new Date(time).getTime() ? new Date(time).getTime() : new Date(time.replace(/-/g, "/")).getTime();
316
- reportDate.sbp = sbp;
317
- reportDate.dbp = dbp;
318
- console.log(time);
319
- }
320
-
321
- console.log(reportDate);
322
- this.api_yuyue_save_fuc(reportDate, res.value);
323
-
324
- if (this.isHistory == true) {
325
- this.getHistoryDataCallback(res.value);
326
- } else {
327
- this.api_yuyue_save_fuc(reportDate, res.value);
328
- }
329
- });
330
- }
331
- /**
332
- *
333
- * @param {*} data
334
- */
335
-
336
-
337
- api_yuyue_save_fuc(reportDate, val) {
338
- let reportDateList = []; // 是历史数据
339
- // if (this.isHistory) {
340
- // if (val.toString() !== "06,00,01,01") {
341
- // this.historyList.push(reportDate)
342
- // } else {
343
- // this.api_yuyue_save(this.historyList)
344
- // this.isHistory = false
345
- // this.historyList = []
346
- // this.getHistoryDataCallback(this._setSuccessReturn({ value: '获取历史数据结束' }))
347
- // }
348
- // } else {
349
-
350
- if (val.toString() !== "06,00,01,01") {
351
- reportDateList.push(reportDate);
352
- this.api_yuyue_save(reportDateList);
353
- this.getCurrentDataCallback(this._setSuccessReturn({
354
- value: '获取测量结果结束'
355
- }));
356
- } // }
357
-
358
- }
359
- /**
360
- * @des 设置成功返回
361
- */
362
-
363
-
364
- _setSuccessReturn(data) {
365
- return {
366
- code: 0,
367
- data,
368
- message: "成功"
369
- };
370
- }
371
- /**
372
- * @des 设置失败返回
373
- */
374
-
375
-
376
- _setErrorReturn(data) {
377
- return {
378
- code: 1,
379
- data,
380
- message: "失败"
381
- };
382
- }
383
- /**
384
- * @des 设置设备时间
385
- * @param {Date?} date
386
- */
387
-
388
-
389
- setDeviceTime(cb, date) {
390
- if (typeof cb !== "function") throw new TypeError("arguments callback expect function");
391
- this.setDeviceTimeCallback = cb;
392
- const newDate = date || new Date();
393
- const resCode = this.getDateCode(newDate, 5);
394
- this.write({
395
- suuid: this.timeServiceId,
396
- cuuid: this.timeWriteId,
397
- value: [...resCode, "00", "00", "00"]
398
- }); // 设置时间成功
399
-
400
- return this.setDeviceTimeCallback(this._setSuccessReturn({
401
- value: '写入成功'
402
- }));
403
- }
404
- /**
405
- * @des 获取历史数据
406
- * @param {Date} lastTime yy-MM-hh
407
- */
408
-
409
-
410
- getHistoryData(cb, lastTimeP) {
411
- if (typeof cb !== "function") throw new TypeError("arguments callback expect function");
412
- this.getHistoryDataCallback = cb;
413
- this.isHistory = true;
414
- this.historyList = [];
415
-
416
- if (lastTimeP) {
417
- const resCode = this.getDateCode(new Date(lastTimeP), 6);
418
- this.write({
419
- value: ["01", "03", "02", ...resCode]
420
- });
421
- } else {
422
- this.write({
423
- value: ["01", "01"]
424
- });
425
- }
426
- }
427
- /**
428
- * @des 获取当前测量结果回调
429
- * @param {cb} 回调函数
430
- */
431
-
432
-
433
- getCurrentData(cb) {
434
- if (typeof cb !== "function") throw new TypeError("arguments callback expect function");
435
- this.getCurrentDataCallback = cb;
436
- }
437
- /**
438
- * @des 传入日期获取 对应的指令
439
- * @param {Date} date、
440
- * @param {number} index 年 月 日 时 分 秒 从左到右要的索引 slice 全部是 6
441
- */
442
-
443
-
444
- getDateCode(date, index) {
445
- const yeare = _.num10to16D(date.getFullYear());
446
-
447
- const month = _.num10to16D(date.getMonth() + 1);
448
-
449
- const day = _.num10to16D(date.getDate());
450
-
451
- const hour = _.num10to16D(date.getHours());
452
-
453
- const minute = _.num10to16D(date.getMinutes());
454
-
455
- const second = _.num10to16D(date.getSeconds());
456
-
457
- const res = [yeare, month, day, hour, minute, second];
458
- let resCode = [];
459
- res.slice(0, index).forEach(item => {
460
- resCode.push(...item);
461
- });
462
- return resCode;
463
- }
464
-
465
- }
466
-
467
- class YUYUEBP extends BTManager {
468
- constructor(config) {
469
- super(config);
470
- }
471
- /**
472
- * @des 睿知手环同步用户信息
473
- * @param {string} userId 接入方的用户ID,如微信的openId
474
- * ...
475
- */
476
-
477
-
478
- apiUserSave(userId, isLoading = false) {
479
- return this.HTTP.request("/data-center/v1/api/user-info/save", {
480
- userId
481
- }, {
482
- isLoading
483
- });
484
- }
485
- /**
486
- * @des 鱼跃用户设备绑定列表
487
- * @param {string} userId 用户id
488
- */
489
-
490
-
491
- apiBindList(userId, isLoading = false) {
492
- return this.HTTP.request("/iot-data/v1/api/yuyue/device/bindList", {
493
- userId
494
- }, {
495
- isLoading
496
- });
497
- }
498
- /**
499
- * @des 鱼跃血压计获取设备绑定状态
500
- * @param {string} deviceSn
501
- */
502
-
503
-
504
- apiBindStatus(deviceSn, isLoading = false) {
505
- return this.HTTP.request("/iot-data/v1/api/yuyue/device/bindStatus", {
506
- deviceSn
507
- }, {
508
- isLoading
509
- });
510
- }
511
- /**
512
- * @des 鱼跃血压计绑定设备绑定用户
513
- * @param {string} userId 接入方的用户ID,如微信的openId
514
- * @param {string} deviceName 设备名称
515
- * @param {string} deviceSn 设备唯一标识 mac地址
516
- * @param {string} deviceId 设备唯一标识 uuid
517
- */
518
-
519
-
520
- apiBindDevice(userId, deviceName, deviceSn, deviceId, isLoading = false) {
521
- return this.HTTP.request("/iot-data/v1/api/yuyue/device/bind", {
522
- userId,
523
- deviceName,
524
- deviceSn,
525
- deviceId
526
- }, {
527
- isLoading
528
- });
529
- }
530
- /**
531
- * @des 鱼跃血压计设备解除绑定
532
- * @param {string} userId 接入方的用户ID,如微信的openId
533
- * @param {string} deviceSn 设备唯一标识 mac地址
534
- */
535
-
536
-
537
- apiDeviceUnbind(userId, deviceSn, isLoading = false) {
538
- // 断开蓝牙连接
539
- this.disconnect();
540
- return this.HTTP.request("/iot-data/v1/api/yuyue/device/unbind", {
541
- userId,
542
- deviceSn
543
- }, {
544
- isLoading
545
- });
546
- }
547
- /**
548
- * @des 鱼跃血压数据上报
549
- * @param {List<Object>} reportDateList 明细
550
- * @property {String} userId 接入方的用户ID,如微信的openId
551
- * @property {String} deviceSn 设备唯一标识 mac地址
552
- * @property {number} heartRate 心率(脉搏 )
553
- * @property {number} arrhythmia 心率不齐 0:否, 1:是
554
- * @property {Date} detectionTime 检测时间时间戳
555
- * @property {number} sbp 收缩压(高压),单位: mmHg ,[30,300]
556
- * @property {number} dbp 舒张压(低压),单位: mmHg ,[30,300]
557
- */
558
-
559
-
560
- api_yuyue_save(reportDateList, isLoading = false) {
561
- return this.HTTP.request("/iot-data/v1/api/yuyue/blood/pressure/report-user-blood-pressure", {
562
- reportDateList
563
- }, {
564
- isLoading
565
- });
566
- }
567
-
568
- }
569
-
570
- export { YUYUEBP };
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.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:a=0,timeout:r=6e4,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).getTime()?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),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,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 a extends s{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,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{a as YUYUEBP};