Socket
Socket
Sign inDemoInstall

qcloud-iotexplorer-bluetooth-adapter

Package Overview
Dependencies
Maintainers
5
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qcloud-iotexplorer-bluetooth-adapter - npm Package Compare versions

Comparing version 0.12.4 to 0.12.5

2

lib/miniprogram/BlueToothAdapter4Mp.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BlueToothAdapter4Mp=void 0;var tslib_1=require("tslib"),base_1=require("../base"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),_a=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils,arrayBufferToHexStringArray=_a.arrayBufferToHexStringArray,hexToArrayBuffer=_a.hexToArrayBuffer,parseAdvertisData=function(e){var t=tslib_1.__assign({},e);if(e.advertisData)try{t.advertisData=arrayBufferToHexStringArray(e.advertisData)}catch(e){console.error("Parse bluetoothe device advertisData fail",e)}return e.serviceData&&"object"==typeof e.serviceData&&(t.serviceData={},Object.entries(e.serviceData).forEach((function(e){var o=tslib_1.__read(e,2),n=o[0],r=o[1];r instanceof ArrayBuffer&&(t.serviceData[n]=arrayBufferToHexStringArray(r))}))),t},BlueToothAdapter4Mp=function(e){function t(t){var o=t.bluetoothApi,n=tslib_1.__rest(t,["bluetoothApi"]),r=e.call(this,tslib_1.__assign({bluetoothApi:o},n))||this;return r._h5ChanelOpened=!1,r._localDiscoveringInUse=!1,r._h5DiscoveringInUse=!1,r._cleanupTimer=null,r._currentProductId="",r.handleH5WsMessage=null,r.deviceDelayDisconnectQueue=[],r._mpBleConnectionStateCache={},r._h5Websocket&&"function"==typeof r._h5Websocket.on&&(r.on("adapterStateChange",(function(e){var t=e.available,o=e.discovering;r.response2BlueToothChanel("onBluetoothAdapterStateChange",{available:t,discovering:o})})),r._h5Websocket.on("message",(function(e){var t=e.data,o=e.reqId;return tslib_1.__awaiter(r,void 0,void 0,(function(){var e,n,r,s,i,c,a,l,u,h,d,p,v,_,f,D,g,y=this;return tslib_1.__generator(this,(function(C){switch(C.label){case 0:if(console.log("bluetooth ws on message",t),"function"==typeof this.handleH5WsMessage)try{if(this.handleH5WsMessage({data:t,reqId:o}))return console.log("h5 message already handled by handleH5WsMessage implement."),[2]}catch(e){console.error("call handleH5WsMessage error",e)}switch(e=t.action,n=t.payload,e){case"reportDeviceConnectStatus":return[3,1];case"syncDeviceConnectStatus":return[3,2];case"bindDevice":return[3,3];case"registryDevice":return[3,7];case"connect":return[3,11];case"disconnect":return[3,12];case"init":return[3,13];case"callApi":return[3,17]}return[3,32];case 1:return r=n.connected,s=n.explorerDeviceId,i=n.deviceId,this.onDeviceConnectStatusChange({connected:r,explorerDeviceId:s,deviceId:i}),[3,32];case 2:c=n.devices,(_=void 0===c?[]:c).forEach((function(e){var t=e.deviceId,o=e.connected,n=y._mpBleConnectionStateCache[t]||!1;n!==o&&(console.log("[syncDeviceConnectStatus] deviceId="+t+",","h5.connected="+o+", actualConnected="+n),y.response2BlueToothChanel("onBLEConnectionStateChange",{deviceId:t,connected:n}))})),C.label=3;case 3:return C.trys.push([3,5,,6]),l=n.deviceName,u=n.productId,[4,this._actions.bindDevice({productId:this.devMode&&u?u:this._currentProductId,deviceName:l})];case 4:return C.sent(),this.response2BlueToothChanel("response",{code:0},o),[3,6];case 5:return a=C.sent(),this.response2BlueToothChanel("response",a,o),[3,6];case 6:return[3,32];case 7:return C.trys.push([7,9,,10]),l=n.deviceName,u=n.productId,[4,this._actions.registerDevice({productId:this.devMode&&u?u:this._currentProductId,deviceName:l})];case 8:return C.sent(),this.response2BlueToothChanel("response",{code:0},o),[3,10];case 9:return h=C.sent(),this.response2BlueToothChanel("response",h,o),[3,10];case 10:return[3,32];case 11:return console.log("h5chanel opened"),this._h5ChanelOpened=!0,[3,32];case 12:return console.log("h5chanel closed"),this._h5ChanelOpened=!1,this._h5DiscoveringInUse&&this.stopBluetoothDevicesDiscovery(!0),[3,32];case 13:return C.trys.push([13,15,,16]),[4,this.init()];case 14:return C.sent(),this.response2BlueToothChanel("response",{code:0},o),[3,16];case 15:return d=C.sent(),this.response2BlueToothChanel("response",d,o),[3,16];case 16:return[3,32];case 17:p=n.api,v=n.params,C.label=18;case 18:switch(C.trys.push([18,30,,31]),console.log("call api",p,v),p){case"createBLEConnection":return[3,19];case"getBluetoothDevices":return[3,21];case"writeBLECharacteristicValue":return[3,23];case"startBluetoothDevicesDiscovery":return[3,25];case"stopBluetoothDevicesDiscovery":return[3,27]}return[3,29];case 19:return this.tryCancelDisconnectDevice(v.deviceId),[4,this._bluetoothApi.createBLEConnection(v)];case 20:return C.sent(),this.response2BlueToothChanel("response",{},o),[2];case 21:return[4,this.getBluetoothDevices()];case 22:return _=C.sent(),this.response2BlueToothChanel("response",{devices:_.map(parseAdvertisData)},o),[2];case 23:return f=v.value,console.log("calling writeBLECharacteristicValue",tslib_1.__assign(tslib_1.__assign({},v),{value:hexToArrayBuffer(f)})),[4,this._bluetoothApi.writeBLECharacteristicValue(tslib_1.__assign(tslib_1.__assign({},v),{value:hexToArrayBuffer(f)}))];case 24:return D=C.sent(),this.response2BlueToothChanel("response",D,o),[2];case 25:return[4,this.startBluetoothDevicesDiscovery({isFromH5:!0,interval:1e3})];case 26:return D=C.sent(),this.response2BlueToothChanel("response",D,o),[2];case 27:return[4,this.stopBluetoothDevicesDiscovery(!0)];case 28:return D=C.sent(),this.response2BlueToothChanel("response",D,o),[2];case 29:return[3,31];case 30:return g=C.sent(),console.error("[BlueToothAdapter4Mp] call bluetoothApi fail",g),this.response2BlueToothChanel("response",this._normalizeError(g),o),[2];case 31:return wx[p]&&wx[p](tslib_1.__assign(tslib_1.__assign({},v),{success:function(e){console.log("[BlueToothAdapter4Mp] call wx api success",e),y.response2BlueToothChanel("response",e,o)},fail:function(e){console.log("call api fail",e),y.response2BlueToothChanel("response",y._normalizeError(e),o)}})),[3,32];case 32:return[2]}}))}))}))),r}return tslib_1.__extends(t,e),t.prototype.tryCancelDisconnectDevice=function(e){var t=this.deviceDelayDisconnectQueue.findIndex((function(t){return t.deviceId===e}));if(t>-1){var o=this.deviceDelayDisconnectQueue[t];return clearTimeout(o.timer),this.deviceDelayDisconnectQueue.splice(t,1),console.log("Cancel disconnect device: "+e),!0}return console.log("Try cancel disconnect device: "+e+", but not found in queue, maybe it's already disconnected"),!1},t.prototype.disconnectDevice=function(e,t){var o=this,n=e.deviceId,r=e.explorerDeviceId;void 0===t&&(t=0),console.log("call disconnectDevice",{deviceId:n,explorerDeviceId:r});var s=this._deviceConnectStatusStore.get({deviceId:n,explorerDeviceId:r});if(null==s?void 0:s.connected)if(t>0){var i=setTimeout((function(){console.log("execute closeBLEConnection for deviceId: "+n+" after "+t+"ms"),o._bluetoothApi.closeBLEConnection({deviceId:n})}),t);console.log("Will disconnect device: "+n+" after "+t+"ms..."),this.deviceDelayDisconnectQueue.push({deviceId:n,timer:i})}else this._bluetoothApi.closeBLEConnection({deviceId:n});else console.log("call disconnectDevice, but device maybe not connected",s,this._deviceConnectStatusStore.getAll())},t.prototype.setCurrentProduct=function(e){this._currentProductId=e},t.prototype.startBluetoothDevicesDiscovery=function(t){void 0===t&&(t={});var o=t.isFromH5,n=void 0!==o&&o,r=tslib_1.__rest(t,["isFromH5"]);return n?this._h5DiscoveringInUse=!0:this._localDiscoveringInUse=!0,e.prototype.startBluetoothDevicesDiscovery.call(this,r)},t.prototype.stopBluetoothDevicesDiscovery=function(t){if(void 0===t&&(t=!1),console.log("try call stopBluetoothDevicesDiscovery,\n isFromH5: "+t+", _h5DiscoveringInUse: "+this._h5DiscoveringInUse+",\n _localDiscoveringInUse: "+this._localDiscoveringInUse),t?this._h5DiscoveringInUse=!1:this._localDiscoveringInUse=!1,this._h5DiscoveringInUse||!this._localDiscoveringInUse)return e.prototype.stopBluetoothDevicesDiscovery.call(this)},t.prototype.response2BlueToothChanel=function(e,t,o){return void 0===t&&(t={}),void 0===o&&(o=""),tslib_1.__awaiter(this,void 0,void 0,(function(){var n;return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),this._h5ChanelOpened?[4,this._h5Websocket.send("Response",{action:e,payload:t},{reqId:o})]:[2];case 1:return r.sent(),[3,3];case 2:return n=r.sent(),console.warn("try send bluetooth message fail",n),[3,3];case 3:return[2]}}))}))},t.prototype.startCleanupTimer=function(){var e=this;clearTimeout(this._cleanupTimer),this._cleanupTimer=setTimeout((function(){var t=e._deviceAdapterStore.getAll().filter((function(e){return e.isConnected}));console.log("bluetooth searching or deviceMap not empty, reset cleanup timer",e._discovering,t),e._h5ChanelOpened||e._discovering||t.length?e.startCleanupTimer():e.cleanup()}),3e4)},t.prototype.init=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t=this;return tslib_1.__generator(this,(function(o){return[2,e.prototype.init.call(this).then((function(){return t.startCleanupTimer()}))]}))}))},t.prototype.onBleConnectionStateChange=function(t){var o=t.deviceId,n=t.connected;return this.response2BlueToothChanel("onBLEConnectionStateChange",{deviceId:o,connected:n}),this._mpBleConnectionStateCache[o]=n,e.prototype.onBleConnectionStateChange.call(this,{deviceId:o,connected:n})},t.prototype.onBLECharacteristicValueChange=function(t){var o=t.deviceId,n=t.serviceId,r=t.characteristicId,s=t.value;return this.response2BlueToothChanel("onBLECharacteristicValueChange",{deviceId:o,serviceId:n,characteristicId:r,value:arrayBufferToHexStringArray(s)}),e.prototype.onBLECharacteristicValueChange.call(this,{deviceId:o,serviceId:n,characteristicId:r,value:s})},t.prototype.getBluetoothDevices=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,o=this;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return[4,e.prototype.getBluetoothDevices.call(this)];case 1:return(t=n.sent()).forEach((function(e){e.lastFoundTime=o._deviceLastFoundTime[e.deviceId]})),[2,t]}}))}))},t.prototype.onBluetoothDeviceFound=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var o,n,r=this;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:return o=Date.now(),Array.isArray(t.devices)&&t.devices.forEach((function(e){r._deviceLastFoundTime[e.deviceId]=o})),[4,e.prototype.onBluetoothDeviceFound.call(this,t)];case 1:return n=s.sent(),this.response2BlueToothChanel("onBluetoothDeviceFound",{devices:n.map(parseAdvertisData)}),[2]}}))}))},t.prototype.startSearch=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,e.prototype.startSearch.call(this,t)];case 1:return o.sent(),this.startCleanupTimer(),[2]}}))}))},t.prototype.searchDevice=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var o;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return[4,e.prototype.searchDevice.call(this,t)];case 1:return o=n.sent(),this.startCleanupTimer(),[2,o]}}))}))},t.prototype.cleanup=function(t){e.prototype.cleanup.call(this,t),this._mpBleConnectionStateCache={}},t}(base_1.BlueToothAdapter);exports.BlueToothAdapter4Mp=BlueToothAdapter4Mp;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BlueToothAdapter4Mp=void 0;var tslib_1=require("tslib"),base_1=require("../base"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),_a=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils,arrayBufferToHexStringArray=_a.arrayBufferToHexStringArray,hexToArrayBuffer=_a.hexToArrayBuffer,parseAdvertisData=function(e){var t=tslib_1.__assign({},e);if(e.advertisData)try{t.advertisData=arrayBufferToHexStringArray(e.advertisData)}catch(e){console.error("Parse bluetoothe device advertisData fail",e)}return e.serviceData&&"object"==typeof e.serviceData&&(t.serviceData={},Object.entries(e.serviceData).forEach((function(e){var o=tslib_1.__read(e,2),r=o[0],n=o[1];n instanceof ArrayBuffer&&(t.serviceData[r]=arrayBufferToHexStringArray(n))}))),t},BlueToothAdapter4Mp=function(e){function t(t){var o=t.bluetoothApi,r=tslib_1.__rest(t,["bluetoothApi"]),n=e.call(this,tslib_1.__assign({bluetoothApi:o},r))||this;return n._h5ChanelOpened=!1,n._localDiscoveringInUse=!1,n._h5DiscoveringInUse=!1,n._cleanupTimer=null,n._currentProductId="",n.handleH5WsMessage=null,n.deviceDelayDisconnectQueue=[],n._mpBleConnectionStateCache={},n._h5Websocket&&"function"==typeof n._h5Websocket.on&&(n.on("adapterStateChange",(function(e){var t=e.available,o=e.discovering;n.response2BlueToothChanel("onBluetoothAdapterStateChange",{available:t,discovering:o})})),n._h5Websocket.on("message",(function(e){var t=e.data,o=e.reqId;return tslib_1.__awaiter(n,void 0,void 0,(function(){var e,r,n,s,i,c,a,l,u,h,d,p,v,_,f,D,g,y=this;return tslib_1.__generator(this,(function(C){switch(C.label){case 0:if(console.log("bluetooth ws on message",t),"function"==typeof this.handleH5WsMessage)try{if(this.handleH5WsMessage({data:t,reqId:o}))return console.log("h5 message already handled by handleH5WsMessage implement."),[2]}catch(e){console.error("call handleH5WsMessage error",e)}switch(e=t.action,r=t.payload,e){case"reportDeviceConnectStatus":return[3,1];case"syncDeviceConnectStatus":return[3,2];case"bindDevice":return[3,3];case"registryDevice":return[3,7];case"connect":return[3,11];case"disconnect":return[3,12];case"init":return[3,13];case"callApi":return[3,17]}return[3,32];case 1:return n=r.connected,s=r.explorerDeviceId,i=r.deviceId,this.onDeviceConnectStatusChange({connected:n,explorerDeviceId:s,deviceId:i}),[3,32];case 2:return c=r.devices,(_=void 0===c?[]:c).forEach((function(e){var t=e.deviceId,o=e.connected,r=y._mpBleConnectionStateCache[t]||!1;r!==o&&(console.log("[syncDeviceConnectStatus] deviceId="+t+",","h5.connected="+o+", actualConnected="+r),y.response2BlueToothChanel("onBLEConnectionStateChange",{deviceId:t,connected:r}))})),[3,32];case 3:return C.trys.push([3,5,,6]),l=r.deviceName,u=r.productId,[4,this._actions.bindDevice({productId:this.devMode&&u?u:this._currentProductId,deviceName:l})];case 4:return C.sent(),this.response2BlueToothChanel("response",{code:0},o),[3,6];case 5:return a=C.sent(),this.response2BlueToothChanel("response",a,o),[3,6];case 6:return[3,32];case 7:return C.trys.push([7,9,,10]),l=r.deviceName,u=r.productId,[4,this._actions.registerDevice({productId:this.devMode&&u?u:this._currentProductId,deviceName:l})];case 8:return C.sent(),this.response2BlueToothChanel("response",{code:0},o),[3,10];case 9:return h=C.sent(),this.response2BlueToothChanel("response",h,o),[3,10];case 10:return[3,32];case 11:return console.log("h5chanel opened"),this._h5ChanelOpened=!0,[3,32];case 12:return console.log("h5chanel closed"),this._h5ChanelOpened=!1,this._h5DiscoveringInUse&&this.stopBluetoothDevicesDiscovery(!0),[3,32];case 13:return C.trys.push([13,15,,16]),[4,this.init()];case 14:return C.sent(),this.response2BlueToothChanel("response",{code:0},o),[3,16];case 15:return d=C.sent(),this.response2BlueToothChanel("response",d,o),[3,16];case 16:return[3,32];case 17:p=r.api,v=r.params,C.label=18;case 18:switch(C.trys.push([18,30,,31]),console.log("call api",p,v),p){case"createBLEConnection":return[3,19];case"getBluetoothDevices":return[3,21];case"writeBLECharacteristicValue":return[3,23];case"startBluetoothDevicesDiscovery":return[3,25];case"stopBluetoothDevicesDiscovery":return[3,27]}return[3,29];case 19:return this.tryCancelDisconnectDevice(v.deviceId),[4,this._bluetoothApi.createBLEConnection(v)];case 20:return C.sent(),this.response2BlueToothChanel("response",{},o),[2];case 21:return[4,this.getBluetoothDevices()];case 22:return _=C.sent(),this.response2BlueToothChanel("response",{devices:_.map(parseAdvertisData)},o),[2];case 23:return f=v.value,console.log("calling writeBLECharacteristicValue",tslib_1.__assign(tslib_1.__assign({},v),{value:hexToArrayBuffer(f)})),[4,this._bluetoothApi.writeBLECharacteristicValue(tslib_1.__assign(tslib_1.__assign({},v),{value:hexToArrayBuffer(f)}))];case 24:return D=C.sent(),this.response2BlueToothChanel("response",D,o),[2];case 25:return[4,this.startBluetoothDevicesDiscovery({isFromH5:!0,interval:1e3})];case 26:return D=C.sent(),this.response2BlueToothChanel("response",D,o),[2];case 27:return[4,this.stopBluetoothDevicesDiscovery(!0)];case 28:return D=C.sent(),this.response2BlueToothChanel("response",D,o),[2];case 29:return[3,31];case 30:return g=C.sent(),console.error("[BlueToothAdapter4Mp] call bluetoothApi fail",g),this.response2BlueToothChanel("response",this._normalizeError(g),o),[2];case 31:return wx[p]&&wx[p](tslib_1.__assign(tslib_1.__assign({},v),{success:function(e){console.log("[BlueToothAdapter4Mp] call wx api success",e),y.response2BlueToothChanel("response",e,o)},fail:function(e){console.log("call api fail",e),y.response2BlueToothChanel("response",y._normalizeError(e),o)}})),[3,32];case 32:return[2]}}))}))}))),n}return tslib_1.__extends(t,e),t.prototype.tryCancelDisconnectDevice=function(e){var t=this.deviceDelayDisconnectQueue.findIndex((function(t){return t.deviceId===e}));if(t>-1){var o=this.deviceDelayDisconnectQueue[t];return clearTimeout(o.timer),this.deviceDelayDisconnectQueue.splice(t,1),console.log("Cancel disconnect device: "+e),!0}return console.log("Try cancel disconnect device: "+e+", but not found in queue, maybe it's already disconnected"),!1},t.prototype.disconnectDevice=function(e,t){var o=this,r=e.deviceId,n=e.explorerDeviceId;void 0===t&&(t=0),console.log("call disconnectDevice",{deviceId:r,explorerDeviceId:n});var s=this._deviceConnectStatusStore.get({deviceId:r,explorerDeviceId:n});if(null==s?void 0:s.connected)if(t>0){var i=setTimeout((function(){console.log("execute closeBLEConnection for deviceId: "+r+" after "+t+"ms"),o._bluetoothApi.closeBLEConnection({deviceId:r})}),t);console.log("Will disconnect device: "+r+" after "+t+"ms..."),this.deviceDelayDisconnectQueue.push({deviceId:r,timer:i})}else this._bluetoothApi.closeBLEConnection({deviceId:r});else console.log("call disconnectDevice, but device maybe not connected",s,this._deviceConnectStatusStore.getAll())},t.prototype.setCurrentProduct=function(e){this._currentProductId=e},t.prototype.startBluetoothDevicesDiscovery=function(t){void 0===t&&(t={});var o=t.isFromH5,r=void 0!==o&&o,n=tslib_1.__rest(t,["isFromH5"]);return r?this._h5DiscoveringInUse=!0:this._localDiscoveringInUse=!0,e.prototype.startBluetoothDevicesDiscovery.call(this,n)},t.prototype.stopBluetoothDevicesDiscovery=function(t){if(void 0===t&&(t=!1),console.log("try call stopBluetoothDevicesDiscovery,\n isFromH5: "+t+", _h5DiscoveringInUse: "+this._h5DiscoveringInUse+",\n _localDiscoveringInUse: "+this._localDiscoveringInUse),t?this._h5DiscoveringInUse=!1:this._localDiscoveringInUse=!1,this._h5DiscoveringInUse||!this._localDiscoveringInUse)return e.prototype.stopBluetoothDevicesDiscovery.call(this)},t.prototype.response2BlueToothChanel=function(e,t,o){return void 0===t&&(t={}),void 0===o&&(o=""),tslib_1.__awaiter(this,void 0,void 0,(function(){var r;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),this._h5ChanelOpened?[4,this._h5Websocket.send("Response",{action:e,payload:t},{reqId:o})]:[2];case 1:return n.sent(),[3,3];case 2:return r=n.sent(),console.warn("try send bluetooth message fail",r),[3,3];case 3:return[2]}}))}))},t.prototype.startCleanupTimer=function(){var e=this;clearTimeout(this._cleanupTimer),this._cleanupTimer=setTimeout((function(){var t=e._deviceAdapterStore.getAll().filter((function(e){return e.isConnected}));console.log("bluetooth searching or deviceMap not empty, reset cleanup timer",e._discovering,t),e._h5ChanelOpened||e._discovering||t.length?e.startCleanupTimer():e.cleanup()}),3e4)},t.prototype.init=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t=this;return tslib_1.__generator(this,(function(o){return[2,e.prototype.init.call(this).then((function(){return t.startCleanupTimer()}))]}))}))},t.prototype.onBleConnectionStateChange=function(t){var o=t.deviceId,r=t.connected;return this.response2BlueToothChanel("onBLEConnectionStateChange",{deviceId:o,connected:r}),this._mpBleConnectionStateCache[o]=r,e.prototype.onBleConnectionStateChange.call(this,{deviceId:o,connected:r})},t.prototype.onBLECharacteristicValueChange=function(t){var o=t.deviceId,r=t.serviceId,n=t.characteristicId,s=t.value;return this.response2BlueToothChanel("onBLECharacteristicValueChange",{deviceId:o,serviceId:r,characteristicId:n,value:arrayBufferToHexStringArray(s)}),e.prototype.onBLECharacteristicValueChange.call(this,{deviceId:o,serviceId:r,characteristicId:n,value:s})},t.prototype.getBluetoothDevices=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,o=this;return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return[4,e.prototype.getBluetoothDevices.call(this)];case 1:return(t=r.sent()).forEach((function(e){e.lastFoundTime=o._deviceLastFoundTime[e.deviceId]})),[2,t]}}))}))},t.prototype.onBluetoothDeviceFound=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var o,r,n=this;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:return o=Date.now(),Array.isArray(t.devices)&&t.devices.forEach((function(e){n._deviceLastFoundTime[e.deviceId]=o})),[4,e.prototype.onBluetoothDeviceFound.call(this,t)];case 1:return r=s.sent(),this.response2BlueToothChanel("onBluetoothDeviceFound",{devices:r.map(parseAdvertisData)}),[2]}}))}))},t.prototype.startSearch=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,e.prototype.startSearch.call(this,t)];case 1:return o.sent(),this.startCleanupTimer(),[2]}}))}))},t.prototype.searchDevice=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var o;return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return[4,e.prototype.searchDevice.call(this,t)];case 1:return o=r.sent(),this.startCleanupTimer(),[2,o]}}))}))},t.prototype.cleanup=function(t){e.prototype.cleanup.call(this,t),this._mpBleConnectionStateCache={}},t}(base_1.BlueToothAdapter);exports.BlueToothAdapter4Mp=BlueToothAdapter4Mp;
//# sourceMappingURL=BlueToothAdapter4Mp.js.map
{
"name": "qcloud-iotexplorer-bluetooth-adapter",
"version": "0.12.4",
"version": "0.12.5",
"description": "",

@@ -26,3 +26,3 @@ "main": "lib/index.js",

},
"gitHead": "3021168608c0306697ad6f655890eaf533d08145"
"gitHead": "7995401b5e4aac9eb9a481d2f146e5c03cf8603e"
}

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc