jkyy_yiyun_yuyue_bp_sdk 1.1.7 → 1.1.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
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: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"===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,a);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,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(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]),a=`${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])}`,r=0;var u;n[17]+n[18]==="0000"||2<(u=t.num16to10D(n[17]+n[18]).toString(2)).length&&(r=0==u[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=i,console.log(a)}console.log(c),this.api_yuyue_save_fuc(c,e.value),1==this.isHistory?this.getHistoryDataCallback(c):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()),a=t.num10to16D(e.getMonth()+1),r=t.num10to16D(e.getDate()),n=t.num10to16D(e.getHours()),c=t.num10to16D(e.getMinutes()),u=t.num10to16D(e.getSeconds());let o=[];return[s,a,r,n,c,u].slice(0,i).forEach(e=>{o.push(...e)}),o}}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,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})}};
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})}};
@@ -1 +1 @@
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?this.getHistoryDataCallback(c):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};
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};
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("jkyy_wx_bluetooth")):"function"==typeof define&&define.amd?define(["exports","jkyy_wx_bluetooth"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jkyy_yiyun_yuyue_bp_sdk={},e.jkyy_wx_bluetooth)}(this,function(e,t){"use strict";const u=t.tools;class i extends t.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: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(i,s){if(!i)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"===u.getSystemInfoSync().platform&&await this.apiBindDevice(this.userId,i.name,this.bindList.deviceSn,i.deviceId),this.bindList.deviceSn===i.deviceId||this.bindList.deviceId===i.deviceId)return this._connect_device=i,console.log("当前连接的设备信息存起来",i),this.connectCallback(i,s);throw new Error("解绑原设备后再绑定新设备")}if(await this.apiBindStatus(i.deviceId))throw new Error("设备已被其他用户绑定");{let e=i.deviceId,t="";return"ios"===u.getSystemInfoSync().platform?(console.log(i),e=i.advertisData.slice(5).join(":").toUpperCase(),t=i.deviceId):i.deviceSn=i.deviceId,await this.apiBindDevice(this.userId,i.name,e,t),this._connect_device=i,console.log(3333,i,s),this.connectCallback(i,s)}}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 r=e.value;console.log("注册\b特征值改变回调===================",r);let n={};if("06,00,01,01"!==r.toString()){let e=u.num16to10D(r[1]+r[2]),t=u.num16to10D(r[3]+r[4]),i=u.num16to10D(r[14]+r[15]),s=`${u.num16to10D(r[7]+r[8])}-${u.num16to10(r[9])}-${u.num16to10(r[10])} ${u.num16to10(r[11])}:${u.num16to10(r[12])}:${u.num16to10(r[13])}`,a=0;var c;r[17]+r[18]==="0000"||2<(c=u.num16to10D(r[17]+r[18]).toString(2)).length&&(a=0==c[3]?0:1),n.userId=this.userId,n.deviceSn=this._connect_device.deviceSn,n.heartRate=i,n.arrhythmia=a,n.detectionTime=(new Date(s).getTime()?new Date(s):new Date(s.replace(/-/g,"/"))).getTime(),n.sbp=e,n.dbp=t,console.log(s)}console.log(n),this.api_yuyue_save_fuc(n,e.value),1==this.isHistory?this.getHistoryDataCallback(n):this.api_yuyue_save_fuc(n,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 i=u.num10to16D(e.getFullYear()),s=u.num10to16D(e.getMonth()+1),a=u.num10to16D(e.getDate()),r=u.num10to16D(e.getHours()),n=u.num10to16D(e.getMinutes()),c=u.num10to16D(e.getSeconds());let o=[];return[i,s,a,r,n,c].slice(0,t).forEach(e=>{o.push(...e)}),o}}e.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,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})}},Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("jkyy_wx_bluetooth")):"function"==typeof define&&define.amd?define(["exports","jkyy_wx_bluetooth"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).jkyy_yiyun_yuyue_bp_sdk={},e.jkyy_wx_bluetooth)}(this,function(e,t){"use strict";const u=t.tools;class i extends t.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: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(i,s){if(!i)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"===u.getSystemInfoSync().platform&&await this.apiBindDevice(this.userId,i.name,this.bindList.deviceSn,i.deviceId),this.bindList.deviceSn===i.deviceId||this.bindList.deviceId===i.deviceId)return this._connect_device=i,console.log("当前连接的设备信息存起来",i),this.connectCallback(i,s);throw new Error("解绑原设备后再绑定新设备")}if(await this.apiBindStatus(i.deviceId))throw new Error("设备已被其他用户绑定");{let e=i.deviceId,t="";return"ios"===u.getSystemInfoSync().platform?(console.log(i),e=i.advertisData.slice(5).join(":").toUpperCase(),t=i.deviceId):i.deviceSn=i.deviceId,await this.apiBindDevice(this.userId,i.name,e,t),this._connect_device=i,console.log(3333,i,s),this.connectCallback(i,s)}}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 r=e.value;console.log("注册\b特征值改变回调===================",r);let n={};if("06,00,01,01"!==r.toString()){let e=u.num16to10D(r[1]+r[2]),t=u.num16to10D(r[3]+r[4]),i=u.num16to10D(r[14]+r[15]),s=`${u.num16to10D(r[7]+r[8])}-${u.num16to10(r[9])}-${u.num16to10(r[10])} ${u.num16to10(r[11])}:${u.num16to10(r[12])}:${u.num16to10(r[13])}`,a=0;var o;r[17]+r[18]==="0000"||2<(o=u.num16to10D(r[17]+r[18]).toString(2)).length&&(a=0==o[3]?0:1),n.userId=this.userId,n.deviceSn=this._connect_device.deviceSn,n.heartRate=i,n.arrhythmia=a,n.detectionTime=(new Date(s).getTime()?new Date(s):new Date(s.replace(/-/g,"/"))).getTime(),n.sbp=e,n.dbp=t,console.log(s)}console.log(n),this.api_yuyue_save_fuc(n,e.value),1==this.isHistory?"06,00,01,01"!==val.toString()?this.historyList.push(n):this.getHistoryDataCallback(this.historyList):this.api_yuyue_save_fuc(n,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 i=u.num10to16D(e.getFullYear()),s=u.num10to16D(e.getMonth()+1),a=u.num10to16D(e.getDate()),r=u.num10to16D(e.getHours()),n=u.num10to16D(e.getMinutes()),o=u.num10to16D(e.getSeconds());let c=[];return[i,s,a,r,n,o].slice(0,t).forEach(e=>{c.push(...e)}),c}}e.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,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})}},Object.defineProperty(e,"__esModule",{value:!0})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jkyy_yiyun_yuyue_bp_sdk",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
4
4
  "files": [
5
5
  "dist",
6
6
  "README.md",