Socket
Socket
Sign inDemoInstall

qcloud-iotexplorer-bluetooth-adapter

Package Overview
Dependencies
Maintainers
1
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.0.2 to 0.0.3

25

lib/core/BlueToothAdapter.d.ts

@@ -6,10 +6,14 @@ /// <reference types="miniprogram-api-typings" />

export interface BlueToothActions {
initProductIds: () => Promise<{
initProductIds?: () => Promise<{
[propKey: string]: string;
}>;
registerDevice: ({ deviceId: string }: {
deviceId: any;
registerDevice: ({ deviceId, deviceName, productId, }: {
deviceId?: string;
deviceName?: string;
productId?: string;
}) => Promise<any>;
bindDevice: (params: {
deviceId: string;
deviceId?: string;
deviceName?: string;
productId?: string;
familyId?: string;

@@ -19,3 +23,5 @@ roomId?: string;

reportDeviceData: (params: {
deviceId: string;
deviceId?: string;
deviceName?: string;
productId?: string;
data: any;

@@ -30,2 +36,3 @@ timestamp: number;

h5Websocket: EventEmitter;
devMode?: (() => boolean) | boolean;
}

@@ -53,3 +60,5 @@ export interface SearchDeviceBaseParams {

export declare class BlueToothAdapter extends BlueToothBase {
constructor({ deviceAdapters, actions, bluetoothApi, h5Websocket, }: BlueToothAdapterProps);
constructor({ deviceAdapters, actions, bluetoothApi, h5Websocket, devMode, }: BlueToothAdapterProps);
_devMode: (() => boolean) | boolean;
get devMode(): boolean;
_h5Websocket: any;

@@ -67,2 +76,3 @@ _bluetoothApi: any;

_searchDevicePromise: any;
addAdapter(deviceAdapter: any): void;
_filterDevices({ devices, serviceIds, deviceName, ignoreDeviceIds, ignoreServiceIds, extendInfo, }: {

@@ -113,3 +123,3 @@ devices: WechatMiniprogram.BlueToothDevice[];

getDeviceAdapter(deviceId: any): any;
connectDevice({ deviceId, serviceId, mac, deviceName, name, productId, }: {
connectDevice({ deviceId, serviceId, mac, deviceName, name, productId, autoNotify, }: {
deviceId: string;

@@ -121,3 +131,4 @@ serviceId: string;

productId?: string;
autoNotify?: boolean;
}): Promise<any>;
}

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BlueToothAdapter=void 0;var tslib_1=require("tslib"),utillib_1=require("../libs/utillib"),BlueToothBase_1=require("./BlueToothBase"),DeviceAdapter_1=require("./DeviceAdapter"),nativeBluetoothApi_1=tslib_1.__importDefault(require("./nativeBluetoothApi")),throttle_1=require("../libs/throttle"),BlueToothAdapter=function(e){function t(t){var i=t.deviceAdapters,o=void 0===i?[]:i,r=t.actions,n=t.bluetoothApi,c=t.h5Websocket,s=e.call(this)||this;s._bluetoothApi={},s._actions={},s._deviceAdapterMap={},s._productIdMap={},s._deviceMap={},s._inited=!1,s._available=!1,s._discovering=!1,s._onBluetoothDeviceFoundHandler=null,s._initPromise=null,s._searchDevicePromise=null;for(var a=0,l=o.length;a<l;a++)Object.prototype.isPrototypeOf.call(DeviceAdapter_1.DeviceAdapter,o[a])?o[a].serviceId?s._deviceAdapterMap[o[a].serviceId]=o[a]:console.error("非法的设备连接器,未配置serviceId",o[a]):console.error("非法的设备连接器",o[a]);return utillib_1.isEmpty(s._deviceAdapterMap)&&console.error("无合法的deviceAdapter"),s._h5Websocket=c,s._bluetoothApi=n||nativeBluetoothApi_1.default,s._actions=r,s}return tslib_1.__extends(t,e),t.prototype._filterDevices=function(e){var t=this,i=e.devices,o=void 0===i?[]:i,r=e.serviceIds,n=e.deviceName,c=e.ignoreDeviceIds,s=void 0===c?[]:c,a=e.ignoreServiceIds,l=void 0===a?[]:a,u=e.extendInfo,d=void 0===u?{}:u;r&&r.length||(r=this._getSupportServiceIds());var h={};l&&l.length&&(l.forEach((function(e){return h[e]=!0})),r=r.filter((function(e){return!h[e]}))),console.log("support serviceIds",r);for(var v=[],p=r.map((function(e){return t._deviceAdapterMap[e].deviceFilter})),_=function(e,t){if(s.find((function(t){return o[e].deviceId===t})))return{value:void 0};for(var i=void 0,r=0,c=p.length;r<c;r++)if(i=p[r](o[r],d),n){if(i&&i.deviceName===n)return{value:[i]}}else if(i){v.push(i);break}},f=0,b=o.length;f<b;f++){var g=_(f);if("object"==typeof g)return g.value}return v},t.prototype._getSupportServiceIds=function(){return Object.keys(this._deviceAdapterMap)},t.prototype.startBluetoothDevicesDiscovery=function(){return this._bluetoothApi.startBluetoothDevicesDiscovery()},t.prototype.stopBluetoothDevicesDiscovery=function(e){return void 0===e&&(e=!1),this._bluetoothApi.stopBluetoothDevicesDiscovery()},t.prototype.cleanup=function(t){var i=this;e.prototype.cleanup.call(this,t),t||(console.log("cleanup bluetooth adapter"),this._discovering&&this.stopBluetoothDevicesDiscovery(),this._bluetoothApi.closeBluetoothAdapter(),console.log("manually disconnect all device",this._deviceMap),Object.keys(this._deviceMap).forEach((function(e){i._deviceMap[e]&&i._deviceMap[e].disconnectDevice()})))},t.prototype.init=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e=this;return tslib_1.__generator(this,(function(t){return[2,this._initPromise||(this._initPromise=new Promise((function(t,i){return tslib_1.__awaiter(e,void 0,void 0,(function(){var e,o,r,n,c,s,a=this;return tslib_1.__generator(this,(function(l){switch(l.label){case 0:if(l.trys.push([0,4,,5]),this._inited){if(this._available)return this._initPromise=null,[2,t()];throw{errCode:10001}}return[4,this.initProductIds()];case 1:return l.sent(),e=function(e){var i=e.available,o=e.discovering;console.log("onBluetoothAdapterStateChange",{available:i,discovering:o}),a._available=i,a._discovering=o,a.emit("adapterStateChange",{available:i,discovering:o}),i?(a._inited=!0,t(),a._initPromise=null):a.cleanup()},o=function(e){return a.onBleConnectionStateChange(e)},r=function(e){return a.onBLECharacteristicValueChange(e)},n=throttle_1.throttle(1e3,(function(e){return a.onBluetoothDeviceFound(e)})),this._bluetoothApi.onBluetoothAdapterStateChange(e),this._bluetoothApi.onBLEConnectionStateChange(o),this._bluetoothApi.onBLECharacteristicValueChange(r),this._bluetoothApi.onBluetoothDeviceFound(n),this.addCleanupTask("init",(function(){a._available=a._discovering=a._inited=!1,a._initPromise=null,a._bluetoothApi.offBluetoothAdapterStateChange(e),a._bluetoothApi.offBLEConnectionStateChange(o),a._bluetoothApi.offBLECharacteristicValueChange(r),a._bluetoothApi.offBluetoothDeviceFound(n),a._bluetoothApi.closeBluetoothAdapter()})),[4,this._bluetoothApi.openBluetoothAdapter()];case 2:return l.sent(),c=e,[4,this._bluetoothApi.getBluetoothAdapterState()];case 3:return c.apply(void 0,[l.sent()]),[3,5];case 4:return s=l.sent(),this._available=!1,this._inited=!1,this._initPromise=null,i(this._normalizeError(s)),[3,5];case 5:return[2]}}))}))})))]}))}))},t.prototype.initProductIds=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(t){switch(t.label){case 0:return e=this,[4,this._actions.initProductIds()];case 1:return e._productIdMap=t.sent(),[2]}}))}))},t.prototype.onBleConnectionStateChange=function(e){var t=e.deviceId,i=e.connected;console.log("onBLEConnectionStateChange",t,i);var o=this.getDeviceAdapter(t);o?o.onBleConnectionStateChange({connected:i}):console.warn("on bLEConnectionStateChange, but no adapter")},t.prototype.onBLECharacteristicValueChange=function(e){var t=e.deviceId,i=e.serviceId,o=e.characteristicId,r=e.value;console.log("onBLECharacteristicValueChange",t,i,o,r);var n=this._deviceMap[t];if(n)return n.onBLECharacteristicValueChange({serviceId:i,characteristicId:o,value:r});console.warn("on onBLECharacteristicValueChange, but no adapter")},t.prototype.getBluetoothDevices=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return[4,this._bluetoothApi.getBluetoothDevices()];case 1:return[2,e.sent().devices.filter((function(e){return"未知设备"!==e.name}))]}}))}))},t.prototype.onBluetoothDeviceFound=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(t){switch(t.label){case 0:return[4,this.getBluetoothDevices()];case 1:e=t.sent();try{"function"==typeof this._onBluetoothDeviceFoundHandler&&this._onBluetoothDeviceFoundHandler(e)}catch(e){console.error("_onBluetoothDeviceFoundHandler error",e)}return[2,e]}}))}))},t.prototype.startSearch=function(e){var t=e.serviceId,i=e.serviceIds,o=e.ignoreDeviceIds,r=void 0===o?[]:o,n=e.ignoreServiceIds,c=void 0===n?[]:n,s=e.onSearch,a=void 0===s?utillib_1.noop:s,l=e.onError,u=void 0===l?utillib_1.noop:l,d=e.timeout,h=void 0===d?2e4:d,v=e.extendInfo,p=void 0===v?{}:v;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,o,n,s,l=this;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:t&&!i&&(i=[t]),e=0,o=function(e){l.stopSearch(),u(e)},d.label=1;case 1:return d.trys.push([1,3,,4]),[4,this.startBluetoothDevicesDiscovery()];case 2:return d.sent(),this._onBluetoothDeviceFoundHandler=function(t){try{var n=l._filterDevices({devices:t,serviceIds:i,ignoreDeviceIds:r,ignoreServiceIds:c,extendInfo:p});e=n.length,a(n)}catch(e){console.log("onSearch error",e),o(l._normalizeError(e))}},this.onBluetoothDeviceFound(),n=function(e){e.available||o(l._normalizeError({errCode:10001}))},this.on("adapterStateChange",n),this.addCleanupTask("startSearch",(function(){l._onBluetoothDeviceFoundHandler=null,l.off("adapterStateChange",n)})),setTimeout((function(){e||o("未发现设备,请确认设备已开启")}),h),[3,4];case 3:throw s=d.sent(),this.cleanup("startSearch"),this._normalizeError(s);case 4:return[2]}}))}))},t.prototype.stopSearch=function(){this.cleanup("startSearch"),this.stopBluetoothDevicesDiscovery()},t.prototype.searchDevice=function(e){var t=this,i=e.serviceId,o=e.serviceIds,r=e.deviceName,n=e.explorerDeviceId,c=e.ignoreDeviceIds,s=void 0===c?[]:c,a=e.timeout,l=void 0===a?5e3:a,u=e.extendInfo,d=void 0===u?{}:u;if(i&&!o&&(o=[i]),!r&&n){var h=tslib_1.__read(n.split("/"),2)[1];r=h}return console.log("searching for explorerDeviceId => ",r),this._searchDevicePromise||(this._searchDevicePromise=new Promise((function(e,i){return tslib_1.__awaiter(t,void 0,void 0,(function(){var t,n,c,a=this;return tslib_1.__generator(this,(function(u){switch(u.label){case 0:t=function(e){a.stopBluetoothDevicesDiscovery(),i(a._normalizeError(e)),a._searchDevicePromise=null},n=function(t){a.stopBluetoothDevicesDiscovery(),e(t),a._searchDevicePromise=null},this._onBluetoothDeviceFoundHandler=function(e){try{var i=a._filterDevices({devices:e,serviceIds:o,deviceName:r,ignoreDeviceIds:s,extendInfo:d});console.log("matchedDevices: ",i),i.length>0&&(console.log("doFindDevice",i[0]),n(i[0]))}catch(e){t(e)}},u.label=1;case 1:return u.trys.push([1,3,,4]),[4,this.startBluetoothDevicesDiscovery()];case 2:return u.sent(),console.log("startBluetoothDevicesDiscovery succ"),this.onBluetoothDeviceFound(),setTimeout((function(){n(null)}),l),[3,4];case 3:return c=u.sent(),t(c),[3,4];case 4:return[2]}}))}))})))},t.prototype.getDeviceAdapter=function(e){return this._deviceMap[e]},t.prototype.connectDevice=function(e){var t=e.deviceId,i=e.serviceId,o=e.mac,r=e.deviceName,n=e.name,c=e.productId;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,s,a,l=this;return tslib_1.__generator(this,(function(u){switch(u.label){case 0:o&&console.warn("[DEPRECATED] mac is deprecated, please use deviceName instead."),r=r||o,u.label=1;case 1:if(u.trys.push([1,3,,4]),!(e=this._deviceAdapterMap[i]))throw"无匹配serviceId为"+i+"的 deviceAdapter";return this._deviceMap[t]&&this._deviceMap[t].isConnected?(console.log("find device adapter",this._deviceMap[t]),[2,this._deviceMap[t]]):[4,(s=this._deviceMap[t]=new e({deviceId:t,deviceName:r,productId:c||this._productIdMap[i],name:n,actions:this._actions,bluetoothApi:this._bluetoothApi})).connectDevice()];case 2:return u.sent(),console.log("deviceConnected"),s.on("disconnect",(function(){console.log("ondisconnect, cleanup adapter",s),delete l._deviceMap[t]})),console.log("return adapter"),[2,s];case 3:return a=u.sent(),delete this._deviceMap[t],[2,Promise.reject(a)];case 4:return[2]}}))}))},t}(BlueToothBase_1.BlueToothBase);exports.BlueToothAdapter=BlueToothAdapter;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BlueToothAdapter=void 0;var tslib_1=require("tslib"),utillib_1=require("../libs/utillib"),BlueToothBase_1=require("./BlueToothBase"),DeviceAdapter_1=require("./DeviceAdapter"),nativeBluetoothApi_1=tslib_1.__importDefault(require("./nativeBluetoothApi")),throttle_1=require("../libs/throttle"),BlueToothAdapter=function(e){function t(t){var o=t.deviceAdapters,i=void 0===o?[]:o,r=t.actions,n=t.bluetoothApi,c=t.h5Websocket,s=t.devMode,a=e.call(this)||this;return a._devMode=!1,a._bluetoothApi={},a._actions={},a._deviceAdapterMap={},a._productIdMap={},a._deviceMap={},a._inited=!1,a._available=!1,a._discovering=!1,a._onBluetoothDeviceFoundHandler=null,a._initPromise=null,a._searchDevicePromise=null,a._devMode=s,a.addAdapter(i),utillib_1.isEmpty(a._deviceAdapterMap)&&console.warn("无合法的deviceAdapter"),a._h5Websocket=c,a._bluetoothApi=n||nativeBluetoothApi_1.default,a._actions=r,a}return tslib_1.__extends(t,e),Object.defineProperty(t.prototype,"devMode",{get:function(){return"function"==typeof this._devMode?this._devMode():this._devMode},enumerable:!1,configurable:!0}),t.prototype.addAdapter=function(e){var t=this,o=function(e){Object.prototype.isPrototypeOf.call(DeviceAdapter_1.DeviceAdapter,e)?e.serviceId?t._deviceAdapterMap[e.serviceId]=e:console.error("非法的设备适配器,未配置serviceId",e):console.error("非法的设备适配器",e)};e&&e.splice?e.forEach(o):o(e)},t.prototype._filterDevices=function(e){var t=this,o=e.devices,i=void 0===o?[]:o,r=e.serviceIds,n=e.deviceName,c=e.ignoreDeviceIds,s=void 0===c?[]:c,a=e.ignoreServiceIds,u=void 0===a?[]:a,l=e.extendInfo,d=void 0===l?{}:l;r&&r.length||(r=this._getSupportServiceIds());var h={};u&&u.length&&(u.forEach((function(e){return h[e]=!0})),r=r.filter((function(e){return!h[e]}))),console.log("support serviceIds",r);for(var v=[],p=r.map((function(e){return t._deviceAdapterMap[e].deviceFilter})),_=function(e,t){if(s.find((function(t){return i[e].deviceId===t})))return{value:void 0};for(var o=void 0,r=0,c=p.length;r<c;r++)if(o=p[r](i[r],d),n){if(o&&o.deviceName===n)return{value:[o]}}else if(o){v.push(o);break}},f=0,b=i.length;f<b;f++){var g=_(f);if("object"==typeof g)return g.value}return v},t.prototype._getSupportServiceIds=function(){return Object.keys(this._deviceAdapterMap)},t.prototype.startBluetoothDevicesDiscovery=function(){return this._bluetoothApi.startBluetoothDevicesDiscovery()},t.prototype.stopBluetoothDevicesDiscovery=function(e){return void 0===e&&(e=!1),this._bluetoothApi.stopBluetoothDevicesDiscovery()},t.prototype.cleanup=function(t){var o=this;e.prototype.cleanup.call(this,t),t||(console.log("cleanup bluetooth adapter"),this._discovering&&this.stopBluetoothDevicesDiscovery(),this._bluetoothApi.closeBluetoothAdapter(),console.log("manually disconnect all device",this._deviceMap),Object.keys(this._deviceMap).forEach((function(e){o._deviceMap[e]&&o._deviceMap[e].disconnectDevice()})))},t.prototype.init=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e=this;return tslib_1.__generator(this,(function(t){return[2,this._initPromise||(this._initPromise=new Promise((function(t,o){return tslib_1.__awaiter(e,void 0,void 0,(function(){var e,i,r,n,c,s,a=this;return tslib_1.__generator(this,(function(u){switch(u.label){case 0:if(u.trys.push([0,4,,5]),this._inited){if(this._available)return this._initPromise=null,[2,t()];throw{errCode:10001}}return[4,this.initProductIds()];case 1:return u.sent(),e=function(e){var o=e.available,i=e.discovering;console.log("onBluetoothAdapterStateChange",{available:o,discovering:i}),a._available=o,a._discovering=i,a.emit("adapterStateChange",{available:o,discovering:i}),o?(a._inited=!0,t(),a._initPromise=null):a.cleanup()},i=function(e){return a.onBleConnectionStateChange(e)},r=function(e){return a.onBLECharacteristicValueChange(e)},n=throttle_1.throttle(1e3,(function(e){return a.onBluetoothDeviceFound(e)})),this._bluetoothApi.onBluetoothAdapterStateChange(e),this._bluetoothApi.onBLEConnectionStateChange(i),this._bluetoothApi.onBLECharacteristicValueChange(r),this._bluetoothApi.onBluetoothDeviceFound(n),this.addCleanupTask("init",(function(){a._available=a._discovering=a._inited=!1,a._initPromise=null,a._bluetoothApi.offBluetoothAdapterStateChange(e),a._bluetoothApi.offBLEConnectionStateChange(i),a._bluetoothApi.offBLECharacteristicValueChange(r),a._bluetoothApi.offBluetoothDeviceFound(n),a._bluetoothApi.closeBluetoothAdapter()})),[4,this._bluetoothApi.openBluetoothAdapter()];case 2:return u.sent(),c=e,[4,this._bluetoothApi.getBluetoothAdapterState()];case 3:return c.apply(void 0,[u.sent()]),[3,5];case 4:return s=u.sent(),this._available=!1,this._inited=!1,this._initPromise=null,o(this._normalizeError(s)),[3,5];case 5:return[2]}}))}))})))]}))}))},t.prototype.initProductIds=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(t){switch(t.label){case 0:return"function"!=typeof this._actions.initProductIds?[3,2]:(e=this,[4,this._actions.initProductIds()]);case 1:e._productIdMap=t.sent(),t.label=2;case 2:return[2]}}))}))},t.prototype.onBleConnectionStateChange=function(e){var t=e.deviceId,o=e.connected;console.log("onBLEConnectionStateChange",t,o);var i=this.getDeviceAdapter(t);i?i.onBleConnectionStateChange({connected:o}):console.warn("on bLEConnectionStateChange, but no adapter")},t.prototype.onBLECharacteristicValueChange=function(e){var t=e.deviceId,o=e.serviceId,i=e.characteristicId,r=e.value;console.log("onBLECharacteristicValueChange",t,o,i,r);var n=this._deviceMap[t];if(n)return n.onBLECharacteristicValueChange({serviceId:o,characteristicId:i,value:r});console.warn("on onBLECharacteristicValueChange, but no adapter")},t.prototype.getBluetoothDevices=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return[4,this._bluetoothApi.getBluetoothDevices()];case 1:return[2,e.sent().devices.filter((function(e){return"未知设备"!==e.name}))]}}))}))},t.prototype.onBluetoothDeviceFound=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(t){switch(t.label){case 0:return[4,this.getBluetoothDevices()];case 1:e=t.sent();try{"function"==typeof this._onBluetoothDeviceFoundHandler&&this._onBluetoothDeviceFoundHandler(e)}catch(e){console.error("_onBluetoothDeviceFoundHandler error",e)}return[2,e]}}))}))},t.prototype.startSearch=function(e){var t=e.serviceId,o=e.serviceIds,i=e.ignoreDeviceIds,r=void 0===i?[]:i,n=e.ignoreServiceIds,c=void 0===n?[]:n,s=e.onSearch,a=void 0===s?utillib_1.noop:s,u=e.onError,l=void 0===u?utillib_1.noop:u,d=e.timeout,h=void 0===d?2e4:d,v=e.extendInfo,p=void 0===v?{}:v;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,i,n,s,u=this;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:t&&!o&&(o=[t]),e=0,i=function(e){u.stopSearch(),l(e)},d.label=1;case 1:return d.trys.push([1,3,,4]),[4,this.startBluetoothDevicesDiscovery()];case 2:return d.sent(),this._onBluetoothDeviceFoundHandler=function(t){try{var n=u._filterDevices({devices:t,serviceIds:o,ignoreDeviceIds:r,ignoreServiceIds:c,extendInfo:p});e=n.length,a(n)}catch(e){console.log("onSearch error",e),i(u._normalizeError(e))}},this.onBluetoothDeviceFound(),n=function(e){e.available||i(u._normalizeError({errCode:10001}))},this.on("adapterStateChange",n),this.addCleanupTask("startSearch",(function(){u._onBluetoothDeviceFoundHandler=null,u.off("adapterStateChange",n)})),setTimeout((function(){e||i("未发现设备,请确认设备已开启")}),h),[3,4];case 3:throw s=d.sent(),this.cleanup("startSearch"),this._normalizeError(s);case 4:return[2]}}))}))},t.prototype.stopSearch=function(){this.cleanup("startSearch"),this.stopBluetoothDevicesDiscovery()},t.prototype.searchDevice=function(e){var t=this,o=e.serviceId,i=e.serviceIds,r=e.deviceName,n=e.explorerDeviceId,c=e.ignoreDeviceIds,s=void 0===c?[]:c,a=e.timeout,u=void 0===a?5e3:a,l=e.extendInfo,d=void 0===l?{}:l;if(o&&!i&&(i=[o]),!r&&n){var h=tslib_1.__read(n.split("/"),2)[1];r=h}return console.log("searching for explorerDeviceId => ",r),this._searchDevicePromise||(this._searchDevicePromise=new Promise((function(e,o){return tslib_1.__awaiter(t,void 0,void 0,(function(){var t,n,c,a=this;return tslib_1.__generator(this,(function(l){switch(l.label){case 0:t=function(e){a.stopBluetoothDevicesDiscovery(),o(a._normalizeError(e)),a._searchDevicePromise=null},n=function(t){a.stopBluetoothDevicesDiscovery(),e(t),a._searchDevicePromise=null},this._onBluetoothDeviceFoundHandler=function(e){try{var o=a._filterDevices({devices:e,serviceIds:i,deviceName:r,ignoreDeviceIds:s,extendInfo:d});console.log("matchedDevices: ",o),o.length>0&&(console.log("doFindDevice",o[0]),n(o[0]))}catch(e){t(e)}},l.label=1;case 1:return l.trys.push([1,3,,4]),[4,this.startBluetoothDevicesDiscovery()];case 2:return l.sent(),console.log("startBluetoothDevicesDiscovery succ"),this.onBluetoothDeviceFound(),setTimeout((function(){n(null)}),u),[3,4];case 3:return c=l.sent(),t(c),[3,4];case 4:return[2]}}))}))})))},t.prototype.getDeviceAdapter=function(e){return this._deviceMap[e]},t.prototype.connectDevice=function(e){var t=e.deviceId,o=e.serviceId,i=e.mac,r=e.deviceName,n=e.name,c=e.productId,s=e.autoNotify;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,a,u,l=this;return tslib_1.__generator(this,(function(d){switch(d.label){case 0:i&&console.warn("[DEPRECATED] mac is deprecated, please use deviceName instead."),r=r||i,d.label=1;case 1:if(d.trys.push([1,3,,4]),!(e=this._deviceAdapterMap[o]))throw"无匹配serviceId为"+o+"的 deviceAdapter";return this._deviceMap[t]&&this._deviceMap[t].isConnected?(console.log("find device adapter",this._deviceMap[t]),[2,this._deviceMap[t]]):[4,(a=this._deviceMap[t]=new e({deviceId:t,deviceName:r,productId:c||this._productIdMap[o],name:n,actions:this._actions,bluetoothApi:this._bluetoothApi})).connectDevice({autoNotify:s})];case 2:return d.sent(),console.log("deviceConnected"),a.on("disconnect",(function(){console.log("ondisconnect, cleanup adapter",a),delete l._deviceMap[t]})),console.log("return adapter"),[2,a];case 3:return u=d.sent(),delete this._deviceMap[t],[2,Promise.reject(u)];case 4:return[2]}}))}))},t}(BlueToothBase_1.BlueToothBase);exports.BlueToothAdapter=BlueToothAdapter;
//# sourceMappingURL=BlueToothAdapter.js.map

@@ -8,2 +8,7 @@ /// <reference types="miniprogram-api-typings" />

}
export interface BLEMessageResponse {
shouldIgnore?: boolean;
reportData?: any;
[propName: string]: any;
}
declare type DeviceAdapterActions = Omit<BlueToothActions, 'initProductIds'>;

@@ -14,2 +19,7 @@ /**

export declare class DeviceAdapter extends BlueToothBase {
static helper: {
hexToArrayBuffer: (hexString: string) => ArrayBuffer;
arrayBufferToHexStringArray: (arrayBuffer: ArrayBuffer) => string[];
hexToStr: (hexString: string) => string;
};
constructor({ deviceId, productId, deviceName, name, // 设备原始名称

@@ -28,13 +38,15 @@ actions, bluetoothApi, }: {

_deviceConnected: boolean;
_writeIds: any[];
_notifyIds: any[];
_readIds: any[];
_indicateIds: any[];
_productId: string;
_deviceRegistered: boolean;
_services: any[];
_characteristics: any[];
characteristicsMap: {};
_actions: DeviceAdapterActions;
_bluetoothApi: any;
_getNotifyId(): any;
_getNotifyId({ serviceId }?: {
serviceId?: string;
}): any;
get _writeId(): any;
get _notifyId(): any;
get _readId(): any;
get _indicateId(): any;
get deviceId(): string;

@@ -47,3 +59,6 @@ get productId(): string;

get serviceId(): any;
handleBLEMessage(data: any): any;
handleBLEMessage(hexStrArr: string[], { serviceId, characteristicId }: {
serviceId: string;
characteristicId: string;
}): BLEMessageResponse;
/**

@@ -61,8 +76,8 @@ * 匹配各自设备,并返回包含唯一标识的deviceInfo

*/
static deviceFilter(deviceInfo: WechatMiniprogram.BlueToothDevice, extendInfo?: any): DeviceInfo;
static deviceFilter(deviceInfo: WechatMiniprogram.BlueToothDevice, extendInfo?: any): DeviceInfo | false;
static serviceId: string;
registerDevice(): Promise<void>;
bindDevice({ familyId, roomId, }: {
familyId: any;
roomId: any;
bindDevice({ familyId, roomId, }?: {
familyId?: string;
roomId?: string;
}): Promise<string>;

@@ -83,6 +98,30 @@ onBleConnectionStateChange({ connected }: {

*/
connectDevice(): Promise<void>;
write(data: any, writeId?: string): Promise<never>;
_write(value: any, writeId?: string): Promise<never>;
connectDevice({ autoNotify, }?: {
autoNotify?: boolean;
}): Promise<void>;
write(data: any, { writeId, serviceId, }?: {
writeId?: string;
serviceId?: string;
}): Promise<never>;
_write(value: any, { writeId, serviceId, }?: {
writeId?: string;
serviceId?: string;
}): Promise<never>;
getBLEDeviceServices(): Promise<any>;
setCharacteristicsIds(serviceId: any, characteristics: any): void;
getBLEDeviceCharacteristics({ serviceId, }?: {
serviceId?: string;
}): Promise<any>;
notifyBLECharacteristicValueChange({ characteristicId, serviceId, state, }?: {
characteristicId?: string;
serviceId?: string;
state?: boolean;
}): Promise<void>;
readBLECharacteristicValue({ serviceId, characteristicId, }?: {
serviceId?: string;
characteristicId?: string;
}): Promise<void>;
setBLEMTU(params: any): any;
getBLEDeviceRSSI(): any;
}
export {};

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DeviceAdapter=void 0;var tslib_1=require("tslib"),utillib_1=require("../libs/utillib"),BlueToothBase_1=require("./BlueToothBase"),DeviceAdapter=function(e){function t(t){var i=t.deviceId,r=t.productId,c=t.deviceName,o=t.name,n=t.actions,s=t.bluetoothApi,a=e.call(this)||this;if(a._name="",a._deviceId="",a._deviceName="",a._deviceConnected=!1,a._writeIds=[],a._notifyIds=[],a._readIds=[],a._indicateIds=[],a._productId="",a._deviceRegistered=!1,a._services=[],a._characteristics=[],a._actions={},a._bluetoothApi={},!i)throw"无deviceId";if(!r)throw"productId为空";return a._bluetoothApi=s,a._actions=n,a._name=o,a._deviceName=c,a._deviceId=i,a._productId=r,a}return tslib_1.__extends(t,e),t.prototype._getNotifyId=function(){return this._notifyIds[0]||this._indicateIds[0]},Object.defineProperty(t.prototype,"deviceId",{get:function(){return this._deviceId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"productId",{get:function(){return this._productId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deviceName",{get:function(){return this._deviceName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isConnected",{get:function(){return this._deviceConnected},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"originName",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"explorerDeviceId",{get:function(){return this._productId+"/"+this._deviceName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"serviceId",{get:function(){return this.constructor.serviceId},enumerable:!1,configurable:!0}),t.prototype.handleBLEMessage=function(e){return e},t.deviceFilter=function(e,t){throw new Error("具体产品需要自行实现该方法")},t.prototype.registerDevice=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return this._deviceRegistered?[3,2]:[4,this._actions.registerDevice({deviceId:this.explorerDeviceId})];case 1:e.sent(),this._deviceRegistered=!0,e.label=2;case 2:return[2]}}))}))},t.prototype.bindDevice=function(e){var t=e.familyId,i=e.roomId;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,3,,4]),[4,this.registerDevice()];case 1:return r.sent(),[4,this._actions.bindDevice({deviceId:this.explorerDeviceId,familyId:t,roomId:i})];case 2:return r.sent(),[2,this.explorerDeviceId];case 3:return e=r.sent(),[2,Promise.reject(this._normalizeError(e))];case 4:return[2]}}))}))},t.prototype.onBleConnectionStateChange=function(e){var t=e.connected;this._deviceConnected=t,this.emit("bLEConnectionStateChange",{connected:t}),t?this.emit("connect"):this.disconnectDevice()},t.prototype.onBLECharacteristicValueChange=function(e){var t=e.serviceId,i=e.characteristicId,r=e.value;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,c,o,n,s,a,d,u;return tslib_1.__generator(this,(function(h){switch(h.label){case 0:return h.trys.push([0,4,,5]),t!==this.serviceId||i!==this._getNotifyId()?[3,3]:(e=utillib_1.arrayBufferToHexStringArray(r),c=this.handleBLEMessage(e),o=c.shouldIgnore,n=c.reportData,s=tslib_1.__rest(c,["shouldIgnore","reportData"]),console.log("shouldIgnore?",o),o?[2]:(console.log("receive data",e,s),console.log("should report?",!!n,n),a=Date.now(),d=!1,this._deviceName&&n?(d=!0,[4,this._actions.reportDeviceData({deviceId:this.explorerDeviceId,data:n,timestamp:a})]):[3,2]));case 1:h.sent(),h.label=2;case 2:this.emit("message",tslib_1.__assign(tslib_1.__assign({},s),{timestamp:a,dataReported:d})),h.label=3;case 3:return[3,5];case 4:return u=h.sent(),console.error("onBLECharacteristicValueChange onError,",u),[3,5];case 5:return[2]}}))}))},t.prototype.disconnectDevice=function(){this._bluetoothApi.closeBLEConnection({deviceId:this._deviceId}),this.emit("disconnect")},t.prototype.connectDevice=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,i,r,c,o,n=this;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:return s.trys.push([0,8,,9]),e=!1,this._deviceConnected&&(console.log("Device已经连接",this._deviceId),e=!0),e?[3,7]:[4,this.registerDevice()];case 1:return s.sent(),[4,this._bluetoothApi.createBLEConnection({deviceId:this._deviceId})];case 2:return s.sent(),console.log("createBLEConnection succ"),[4,this._bluetoothApi.getBLEDeviceServices({deviceId:this._deviceId})];case 3:if(t=s.sent().services,this._services=t,console.log("getBLEDeviceServices succ",t),!t.find((function(e){return e.uuid===n.serviceId})))throw console.log("BLEDeviceService do not contain main serviceId",this.serviceId),this.disconnectDevice(),"暂不支持该品类设备,请确认设备型号后重新连接";return this.emit("onGetBLEDeviceServices",t),[4,this._bluetoothApi.getBLEDeviceCharacteristics({deviceId:this._deviceId,serviceId:this.serviceId})];case 4:return i=s.sent().characteristics,this._characteristics=i,console.log("getBLEDeviceCharacteristics succ",i),this.emit("onGetBLEDeviceCharacteristics",i),r=function(e,t){-1===e.indexOf(t)&&e.push(t)},i.forEach((function(e){var t=e.uuid,i=e.properties,c=i.notify,o=i.write,s=i.indicate,a=i.read;c?r(n._notifyIds,t):o?r(n._writeIds,t):s?r(n._indicateIds,t):a&&r(n._readIds,t)})),(c=this._getNotifyId())?[3,5]:(console.warn("该设备不支持 notify"),[3,7]);case 5:return[4,this._bluetoothApi.notifyBLECharacteristicValueChange({deviceId:this._deviceId,characteristicId:c,serviceId:this.serviceId,state:!0})];case 6:s.sent(),console.log("notifyBLECharacteristicValueChange succ"),s.label=7;case 7:return[3,9];case 8:throw o=s.sent(),console.error("connectDevice error",o),this._normalizeError(o);case 9:return[2]}}))}))},t.prototype.write=function(e,t){return void 0===t&&(t=""),tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(i){if("string"==typeof e)console.log("writeBLECharacteristicValue",e),e=utillib_1.hexToArrayBuffer(e);else if(e instanceof ArrayBuffer)try{console.log("writeBLECharacteristicValue",utillib_1.arrayBufferToHexStringArray(e).join(""))}catch(e){}return[2,this._write(e,t)]}))}))},t.prototype._write=function(e,t){return void 0===t&&(t=""),tslib_1.__awaiter(this,void 0,void 0,(function(){var i;return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this._bluetoothApi.writeBLECharacteristicValue({deviceId:this._deviceId,characteristicId:t||this._writeIds[0],serviceId:this.serviceId,value:e})];case 1:return r.sent(),[3,3];case 2:return i=r.sent(),[2,Promise.reject(this._normalizeError(i))];case 3:return[2]}}))}))},t.serviceId="",t}(BlueToothBase_1.BlueToothBase);exports.DeviceAdapter=DeviceAdapter;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DeviceAdapter=void 0;var tslib_1=require("tslib"),utillib_1=require("../libs/utillib"),BlueToothBase_1=require("./BlueToothBase"),DeviceAdapter=function(e){function t(t){var i=t.deviceId,r=t.productId,c=t.deviceName,s=t.name,o=t.actions,n=t.bluetoothApi,a=e.call(this)||this;if(a._name="",a._deviceId="",a._deviceName="",a._deviceConnected=!1,a._productId="",a._deviceRegistered=!1,a._services=[],a.characteristicsMap={},a._actions={},a._bluetoothApi={},!i)throw"无deviceId";if(!r)throw"productId为空";return a._bluetoothApi=n,a._actions=o,a._name=s,a._deviceName=c,a._deviceId=i,a._productId=r,a}return tslib_1.__extends(t,e),t.prototype._getNotifyId=function(e){var t=(void 0===e?{}:e).serviceId,i=void 0===t?"":t;i=i||this.serviceId;var r=this.characteristicsMap[i]||{writeIds:[],notifyIds:[],readIds:[],indicateIds:[]};return r.notifyIds[0]||r.indicateIds[0]},Object.defineProperty(t.prototype,"_writeId",{get:function(){return((this.characteristicsMap[this.serviceId]||{}).writeIds||[])[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_notifyId",{get:function(){return((this.characteristicsMap[this.serviceId]||{}).notifyIds||[])[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_readId",{get:function(){return((this.characteristicsMap[this.serviceId]||{}).readIds||[])[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_indicateId",{get:function(){return((this.characteristicsMap[this.serviceId]||{}).indicateIds||[])[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deviceId",{get:function(){return this._deviceId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"productId",{get:function(){return this._productId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deviceName",{get:function(){return this._deviceName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isConnected",{get:function(){return this._deviceConnected},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"originName",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"explorerDeviceId",{get:function(){return this._productId+"/"+this._deviceName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"serviceId",{get:function(){return this.constructor.serviceId},enumerable:!1,configurable:!0}),t.prototype.handleBLEMessage=function(e,t){t.serviceId,t.characteristicId;return{}},t.deviceFilter=function(e,t){throw new Error("具体产品需要自行实现该方法")},t.prototype.registerDevice=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return this._deviceRegistered?[3,2]:[4,this._actions.registerDevice({deviceId:this.explorerDeviceId,deviceName:this._deviceName,productId:this._productId})];case 1:e.sent(),this._deviceRegistered=!0,e.label=2;case 2:return[2]}}))}))},t.prototype.bindDevice=function(e){var t=void 0===e?{}:e,i=t.familyId,r=void 0===i?"":i,c=t.roomId,s=void 0===c?"":c;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,3,,4]),[4,this.registerDevice()];case 1:return t.sent(),[4,this._actions.bindDevice({deviceId:this.explorerDeviceId,deviceName:this._deviceName,productId:this._productId,familyId:r,roomId:s})];case 2:return t.sent(),[2,this.explorerDeviceId];case 3:return e=t.sent(),[2,Promise.reject(this._normalizeError(e))];case 4:return[2]}}))}))},t.prototype.onBleConnectionStateChange=function(e){var t=e.connected;console.log("onBleConnectionStateChange",t,this._deviceConnected),t?this.emit("connect"):this._deviceConnected&&this.disconnectDevice(),this._deviceConnected=t,this.emit("bLEConnectionStateChange",{connected:t})},t.prototype.onBLECharacteristicValueChange=function(e){var t=e.serviceId,i=e.characteristicId,r=e.value;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,c,s,o,n,a,d,u;return tslib_1.__generator(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,4]),e=utillib_1.arrayBufferToHexStringArray(r),c=this.handleBLEMessage(e,{serviceId:t,characteristicId:i}),s=c.shouldIgnore,o=c.reportData,n=tslib_1.__rest(c,["shouldIgnore","reportData"]),console.log("shouldIgnore?",s),s?[2]:(console.log("receive data",e,n),console.log("should report?",!!o,o),a=Date.now(),d=!1,this._deviceName&&o?(d=!0,[4,this._actions.reportDeviceData({deviceId:this.explorerDeviceId,deviceName:this._deviceName,productId:this._productId,data:o,timestamp:a})]):[3,2]);case 1:h.sent(),h.label=2;case 2:return this.emit("message",tslib_1.__assign(tslib_1.__assign({},n),{timestamp:a,dataReported:d})),[3,4];case 3:return u=h.sent(),console.error("onBLECharacteristicValueChange onError,",u),[3,4];case 4:return[2]}}))}))},t.prototype.disconnectDevice=function(){this._bluetoothApi.closeBLEConnection({deviceId:this._deviceId}),this.emit("disconnect")},t.prototype.connectDevice=function(e){var t=(void 0===e?{}:e).autoNotify,i=void 0===t||t;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,r;return tslib_1.__generator(this,(function(c){switch(c.label){case 0:return c.trys.push([0,7,,8]),this._deviceConnected?(console.log("Device已经连接",this._deviceId),[2]):[4,this.registerDevice()];case 1:return c.sent(),[4,this._bluetoothApi.createBLEConnection({deviceId:this._deviceId})];case 2:return c.sent(),console.log("createBLEConnection succ"),i?[4,this.getBLEDeviceServices()]:[3,6];case 3:return e=c.sent(),console.log("getBLEDeviceServices succ",e),this.emit("onGetBLEDeviceServices",e),[4,this.getBLEDeviceCharacteristics()];case 4:return t=c.sent(),console.log("getBLEDeviceCharacteristics succ",t),this.emit("onGetBLEDeviceCharacteristics",t),[4,this.notifyBLECharacteristicValueChange()];case 5:c.sent(),console.log("notifyBLECharacteristicValueChange succ"),c.label=6;case 6:return[3,8];case 7:throw r=c.sent(),console.error("connectDevice error",r),this._normalizeError(r);case 8:return[2]}}))}))},t.prototype.write=function(e,t){var i=void 0===t?{}:t,r=i.writeId,c=void 0===r?"":r,s=i.serviceId,o=void 0===s?"":s;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){if("string"==typeof e)console.log("writeBLECharacteristicValue",e),e=utillib_1.hexToArrayBuffer(e);else if(e instanceof ArrayBuffer)try{console.log("writeBLECharacteristicValue",utillib_1.arrayBufferToHexStringArray(e).join(""))}catch(e){}return[2,this._write(e,{writeId:c,serviceId:o})]}))}))},t.prototype._write=function(e,t){var i=void 0===t?{}:t,r=i.writeId,c=void 0===r?"":r,s=i.serviceId,o=void 0===s?"":s;return tslib_1.__awaiter(this,void 0,void 0,(function(){var t;return tslib_1.__generator(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._bluetoothApi.writeBLECharacteristicValue({deviceId:this._deviceId,characteristicId:c||this._writeId,serviceId:o||this.serviceId,value:e})];case 1:return i.sent(),[3,3];case 2:return t=i.sent(),[2,Promise.reject(this._normalizeError(t))];case 3:return[2]}}))}))},t.prototype.getBLEDeviceServices=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(t){switch(t.label){case 0:return[4,this._bluetoothApi.getBLEDeviceServices({deviceId:this._deviceId})];case 1:return e=t.sent().services,this._services=e,[2,e]}}))}))},t.prototype.setCharacteristicsIds=function(e,t){var i={notifyIds:[],writeIds:[],indicateIds:[],readIds:[]},r=function(e,t){-1===e.indexOf(t)&&e.push(t)};t.forEach((function(e){var t=e.uuid,c=e.properties,s=c.notify,o=c.write,n=c.indicate,a=c.read;s?r(i.notifyIds,t):o?r(i.writeIds,t):n?r(i.indicateIds,t):a&&r(i.readIds,t)})),this.characteristicsMap[e]=i},t.prototype.getBLEDeviceCharacteristics=function(e){var t=(void 0===e?{}:e).serviceId,i=void 0===t?"":t;return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(t){switch(t.label){case 0:return i=i||this.serviceId,[4,this._bluetoothApi.getBLEDeviceCharacteristics({deviceId:this._deviceId,serviceId:i})];case 1:return e=t.sent().characteristics,this.setCharacteristicsIds(i,e),[2,e]}}))}))},t.prototype.notifyBLECharacteristicValueChange=function(e){var t=void 0===e?{}:e,i=t.characteristicId,r=void 0===i?"":i,c=t.serviceId,s=void 0===c?"":c,o=t.state,n=void 0===o||o;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return r=r||this._getNotifyId(),s=s||this.serviceId,r?[3,1]:(console.warn("未找到指定service下的notifyId,该设备可能不支持notify"),[3,3]);case 1:return[4,this._bluetoothApi.notifyBLECharacteristicValueChange({deviceId:this._deviceId,characteristicId:r,serviceId:s,state:n})];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},t.prototype.readBLECharacteristicValue=function(e){var t=void 0===e?{}:e,i=t.serviceId,r=void 0===i?"":i,c=t.characteristicId,s=void 0===c?"":c;return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return r=r||this.serviceId,s||(s=((this.characteristicsMap[this.serviceId]||{}).readIds||[])[0]),s?[3,1]:(console.warn("未找到指定service下的readId,该设备可能不支持read"),[3,3]);case 1:return[4,this._bluetoothApi.readBLECharacteristicValue({deviceId:this._deviceId,characteristicId:s,serviceId:r})];case 2:e.sent(),e.label=3;case 3:return[2]}}))}))},t.prototype.setBLEMTU=function(e){return this._bluetoothApi.setBLEMTU(e)},t.prototype.getBLEDeviceRSSI=function(){return this._bluetoothApi.getBLEDeviceRSSI({deviceId:this._deviceId})},t.helper={hexToArrayBuffer:utillib_1.hexToArrayBuffer,arrayBufferToHexStringArray:utillib_1.arrayBufferToHexStringArray,hexToStr:utillib_1.hexToStr},t.serviceId="",t}(BlueToothBase_1.BlueToothBase);exports.DeviceAdapter=DeviceAdapter;
//# sourceMappingURL=DeviceAdapter.js.map

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),utillib_1=require("../libs/utillib"),pifyApiArr=["closeBluetoothAdapter","stopBluetoothDevicesDiscovery","openBluetoothAdapter","getBluetoothAdapterState","getBluetoothDevices","startBluetoothDevicesDiscovery","closeBLEConnection","getBLEDeviceServices","getBLEDeviceCharacteristics","notifyBLECharacteristicValueChange","offBluetoothAdapterStateChange","offBLEConnectionStateChange","offBLECharacteristicValueChange","offBluetoothDeviceFound","writeBLECharacteristicValue","setBLEMTU"],callbackApiArr=["onBluetoothAdapterStateChange","onBLEConnectionStateChange","onBLECharacteristicValueChange","onBluetoothDeviceFound"],apis={};pifyApiArr.forEach((function(e){apis[e]=function(t){return utillib_1.pify(wx[e])(t)}})),callbackApiArr.forEach((function(e){apis[e]=function(t){return wx[e](t)}})),apis.createBLEConnection=function(e,t){return void 0===t&&(t=!1),tslib_1.__awaiter(void 0,void 0,void 0,(function(){var n,o;return tslib_1.__generator(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,9]),[4,utillib_1.pify(wx.createBLEConnection)(e)];case 1:return r.sent(),[3,9];case 2:if(n=r.sent(),!(!t&&n&&n.errMsg&&n.errMsg.indexOf("already connect")>-1))return[3,7];console.log("already connect, try disconnect"),r.label=3;case 3:return r.trys.push([3,5,,6]),[4,apis.closeBLEConnection(e)];case 4:return r.sent(),console.log("disconnect success",e),[3,6];case 5:return o=r.sent(),console.warn("disconnect fail",o),[3,6];case 6:return console.log("try connect again",e),[2,apis.createBLEConnection(e,!0)];case 7:return[2,Promise.reject(n)];case 8:return[3,9];case 9:return[2]}}))}))},exports.default=apis;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),utillib_1=require("../libs/utillib"),pifyApiArr=["closeBluetoothAdapter","stopBluetoothDevicesDiscovery","readBLECharacteristicValue","openBluetoothAdapter","getBluetoothAdapterState","getBluetoothDevices","startBluetoothDevicesDiscovery","closeBLEConnection","getBLEDeviceServices","getBLEDeviceCharacteristics","notifyBLECharacteristicValueChange","offBluetoothAdapterStateChange","offBLEConnectionStateChange","offBLECharacteristicValueChange","offBluetoothDeviceFound","writeBLECharacteristicValue","setBLEMTU"],callbackApiArr=["onBluetoothAdapterStateChange","onBLEConnectionStateChange","onBLECharacteristicValueChange","onBluetoothDeviceFound"],apis={};pifyApiArr.forEach((function(e){apis[e]=function(t){return utillib_1.pify(wx[e])(t)}})),callbackApiArr.forEach((function(e){apis[e]=function(t){return wx[e](t)}})),apis.createBLEConnection=function(e,t){return void 0===t&&(t=!1),tslib_1.__awaiter(void 0,void 0,void 0,(function(){var r,n;return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,10]),[4,utillib_1.pify(wx.createBLEConnection)(e)];case 1:return o.sent(),[3,10];case 2:if(r=o.sent(),!(!t&&r&&r.errMsg&&r.errMsg.indexOf("already connect")>-1))return[3,8];console.log("already connect, try disconnect"),o.label=3;case 3:return o.trys.push([3,6,,7]),[4,apis.closeBLEConnection(e)];case 4:return o.sent(),[4,utillib_1.delay(1e3)];case 5:return o.sent(),console.log("disconnect success",e),[3,7];case 6:return n=o.sent(),console.warn("disconnect fail",n),[3,7];case 7:return console.log("try connect again",e),[2,apis.createBLEConnection(e,!0)];case 8:return[2,Promise.reject(r)];case 9:return[3,10];case 10:return[2]}}))}))},exports.default=apis;
//# sourceMappingURL=nativeBluetoothApi.js.map
import { BlueToothAdapter, BlueToothAdapterProps } from "../core";
export declare class BlueToothAdapter4H5 extends BlueToothAdapter {
constructor({ bluetoothApi, h5Websocket, ...props }: BlueToothAdapterProps);
_blueToothBridge: any;
constructor({ h5Websocket, devMode, actions, ...props }: BlueToothAdapterProps);
}

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BlueToothAdapter4H5=void 0;var tslib_1=require("tslib"),core_1=require("../core"),BlueToothBridge_1=require("./BlueToothBridge"),BlueToothAdapter4H5=function(e){function t(t){t.bluetoothApi;var o=t.h5Websocket,r=tslib_1.__rest(t,["bluetoothApi","h5Websocket"]);return e.call(this,tslib_1.__assign(tslib_1.__assign({},r),{h5Websocket:o,bluetoothApi:new BlueToothBridge_1.BlueToothBridge({h5Websocket:o})}))||this}return tslib_1.__extends(t,e),t}(core_1.BlueToothAdapter);exports.BlueToothAdapter4H5=BlueToothAdapter4H5;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BlueToothAdapter4H5=void 0;var tslib_1=require("tslib"),core_1=require("../core"),BlueToothBridge_1=require("./BlueToothBridge"),BlueToothAdapter4H5=function(e){function t(t){var r=t.h5Websocket,o=t.devMode,i=t.actions,s=tslib_1.__rest(t,["h5Websocket","devMode","actions"]),d=this,n=new BlueToothBridge_1.BlueToothBridge({h5Websocket:r});return(d=e.call(this,tslib_1.__assign({actions:tslib_1.__assign({registerDevice:function(e){var t=e.deviceName,r=e.productId;return tslib_1.__awaiter(d,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return[4,n.control("registryDevice",{deviceName:t,productId:this.devMode?r:""})];case 1:return e.sent(),[2]}}))}))},bindDevice:function(e){var t=e.deviceName,r=e.productId;return tslib_1.__awaiter(d,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return[4,n.control("bindDevice",{deviceName:t,productId:this.devMode?r:""})];case 1:return e.sent(),[2]}}))}))}},i),devMode:o,h5Websocket:r,bluetoothApi:n},s))||this)._blueToothBridge=n,d}return tslib_1.__extends(t,e),t}(core_1.BlueToothAdapter);exports.BlueToothAdapter4H5=BlueToothAdapter4H5;
//# sourceMappingURL=BlueToothAdapter4H5.js.map

@@ -16,2 +16,3 @@ import EventEmitter from '../libs/event-emmiter';

init(): Promise<void>;
openBluetoothAdapter(): Promise<void>;
control(action: any, payload: any): any;

@@ -18,0 +19,0 @@ callWxApi(api: any, params: any): Promise<any>;

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BlueToothBridge=void 0;var tslib_1=require("tslib"),event_emmiter_1=tslib_1.__importDefault(require("../libs/event-emmiter")),utillib_1=require("../libs/utillib"),BlueToothBridge=function(t){function e(e){var o=e.h5Websocket,n=t.call(this)||this;return n._h5Websocket=null,n._blueToothBridgeEnable=!1,n._h5Websocket=o,n._h5Websocket.h5Websocket.on("message",(function(t){var e=t.action,o=t.payload;return tslib_1.__awaiter(n,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){switch(t.label){case 0:switch(e){case"connect":return[3,1];case"onBluetoothAdapterStateChange":return[3,5];case"onBLEConnectionStateChange":return[3,6];case"onBLECharacteristicValueChange":return[3,7];case"onBluetoothDeviceFound":return[3,8]}return[3,9];case 1:return this._blueToothBridgeEnable?[4,this._h5Websocket.connect()]:[3,4];case 2:return t.sent(),[4,this.init()];case 3:t.sent(),t.label=4;case 4:return[3,9];case 5:return utillib_1.tryCallHandler(this,"onBluetoothAdapterStateChange",o),[3,9];case 6:return utillib_1.tryCallHandler(this,"onBLEConnectionStateChange",o),[3,9];case 7:return utillib_1.tryCallHandler(this,"onBLECharacteristicValueChange",o),[3,9];case 8:return utillib_1.tryCallHandler(this,"onBluetoothDeviceFound",o),[3,9];case 9:return[2]}}))}))})),n}return tslib_1.__extends(e,t),e.prototype.init=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){switch(t.label){case 0:return this._blueToothBridgeEnable=!0,[4,this._h5Websocket.send("Control",{action:"init"})];case 1:return t.sent(),[2]}}))}))},e.prototype.control=function(t,e){return this._h5Websocket.send("Control",{action:t,payload:e})},e.prototype.callWxApi=function(t,e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var o,n;return tslib_1.__generator(this,(function(i){switch(i.label){case 0:return o=Date.now(),[4,this.control("callApi",{api:t,params:e})];case 1:return n=i.sent(),console.log("call api: "+t+" success, time cast: "+(Date.now()-o)+"ms"),[2,n]}}))}))},e.prototype.stopBluetoothDevicesDiscovery=function(t){return this.callWxApi("stopBluetoothDevicesDiscovery",t)},e.prototype.startBluetoothDevicesDiscovery=function(t){return this.callWxApi("startBluetoothDevicesDiscovery",t)},e.prototype.getConnectedBluetoothDevices=function(t){return this.callWxApi("getConnectedBluetoothDevices",t)},e.prototype.getBluetoothDevices=function(t){return this.callWxApi("getBluetoothDevices",t)},e.prototype.getBluetoothAdapterState=function(t){return this.callWxApi("getBluetoothAdapterState",t)},e.prototype.writeBLECharacteristicValue=function(t){return this.callWxApi("writeBLECharacteristicValue",t)},e.prototype.setBLEMTU=function(t){return this.callWxApi("setBLEMTU",t)},e.prototype.readBLECharacteristicValue=function(t){return this.callWxApi("readBLECharacteristicValue",t)},e.prototype.notifyBLECharacteristicValueChange=function(t){return this.callWxApi("notifyBLECharacteristicValueChange",t)},e.prototype.getBLEDeviceServices=function(t){return this.callWxApi("getBLEDeviceServices",t)},e.prototype.getBLEDeviceRSSI=function(t){return this.callWxApi("getBLEDeviceRSSI",t)},e.prototype.getBLEDeviceCharacteristics=function(t){return this.callWxApi("getBLEDeviceCharacteristics",t)},e.prototype.createBLEConnection=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return[2,this.callWxApi("createBLEConnection",t)]}))}))},e.prototype.closeBLEConnection=function(t){return this.callWxApi("closeBLEConnection",t)},e.prototype.onBluetoothAdapterStateChange=function(t){this._onBluetoothAdapterStateChangeHandler=t},e.prototype.offBluetoothAdapterStateChange=function(){this._onBluetoothAdapterStateChangeHandler=null},e.prototype.onBLEConnectionStateChange=function(t){this._onBLEConnectionStateChangeHandler=t},e.prototype.offBLEConnectionStateChange=function(){this._onBLEConnectionStateChangeHandler=null},e.prototype.onBLECharacteristicValueChange=function(t){this._onBLECharacteristicValueChangeHandler=t},e.prototype.offBLECharacteristicValueChange=function(){this._onBLECharacteristicValueChangeHandler=null},e.prototype.onBluetoothDeviceFound=function(t){this._onBluetoothDeviceFoundHandler=t},e.prototype.offBluetoothDeviceFound=function(){this._onBluetoothDeviceFoundHandler=null},e}(event_emmiter_1.default);exports.BlueToothBridge=BlueToothBridge;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BlueToothBridge=void 0;var tslib_1=require("tslib"),event_emmiter_1=tslib_1.__importDefault(require("../libs/event-emmiter")),utillib_1=require("../libs/utillib"),BlueToothBridge=function(t){function e(e){var o=e.h5Websocket,n=t.call(this)||this;return n._h5Websocket=null,n._blueToothBridgeEnable=!1,n._h5Websocket=o,n._h5Websocket.on("message",(function(t){var e=t.action,o=t.payload;return tslib_1.__awaiter(n,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){switch(t.label){case 0:switch(e){case"connect":return[3,1];case"onBluetoothAdapterStateChange":return[3,5];case"onBLEConnectionStateChange":return[3,6];case"onBLECharacteristicValueChange":return[3,7];case"onBluetoothDeviceFound":return[3,8]}return[3,9];case 1:return this._blueToothBridgeEnable?[4,this._h5Websocket.connect()]:[3,4];case 2:return t.sent(),[4,this.init()];case 3:t.sent(),t.label=4;case 4:return[3,9];case 5:return utillib_1.tryCallHandler(this,"onBluetoothAdapterStateChange",o),[3,9];case 6:return utillib_1.tryCallHandler(this,"onBLEConnectionStateChange",o),[3,9];case 7:return utillib_1.tryCallHandler(this,"onBLECharacteristicValueChange",o),[3,9];case 8:return utillib_1.tryCallHandler(this,"onBluetoothDeviceFound",o),[3,9];case 9:return[2]}}))}))})),n}return tslib_1.__extends(e,t),e.prototype.init=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){switch(t.label){case 0:return this._blueToothBridgeEnable=!0,[4,this._h5Websocket.send("Control",{action:"init"})];case 1:return t.sent(),[2]}}))}))},e.prototype.openBluetoothAdapter=function(){return this.init()},e.prototype.control=function(t,e){return this._h5Websocket.send("Control",{action:t,payload:e})},e.prototype.callWxApi=function(t,e){return tslib_1.__awaiter(this,void 0,void 0,(function(){var o,n;return tslib_1.__generator(this,(function(i){switch(i.label){case 0:return o=Date.now(),[4,this.control("callApi",{api:t,params:e})];case 1:return n=i.sent(),console.log("call api: "+t+" success, time cast: "+(Date.now()-o)+"ms"),[2,n]}}))}))},e.prototype.stopBluetoothDevicesDiscovery=function(t){return this.callWxApi("stopBluetoothDevicesDiscovery",t)},e.prototype.startBluetoothDevicesDiscovery=function(t){return this.callWxApi("startBluetoothDevicesDiscovery",t)},e.prototype.getConnectedBluetoothDevices=function(t){return this.callWxApi("getConnectedBluetoothDevices",t)},e.prototype.getBluetoothDevices=function(t){return this.callWxApi("getBluetoothDevices",t)},e.prototype.getBluetoothAdapterState=function(t){return this.callWxApi("getBluetoothAdapterState",t)},e.prototype.writeBLECharacteristicValue=function(t){return this.callWxApi("writeBLECharacteristicValue",t)},e.prototype.setBLEMTU=function(t){return this.callWxApi("setBLEMTU",t)},e.prototype.readBLECharacteristicValue=function(t){return this.callWxApi("readBLECharacteristicValue",t)},e.prototype.notifyBLECharacteristicValueChange=function(t){return this.callWxApi("notifyBLECharacteristicValueChange",t)},e.prototype.getBLEDeviceServices=function(t){return this.callWxApi("getBLEDeviceServices",t)},e.prototype.getBLEDeviceRSSI=function(t){return this.callWxApi("getBLEDeviceRSSI",t)},e.prototype.getBLEDeviceCharacteristics=function(t){return this.callWxApi("getBLEDeviceCharacteristics",t)},e.prototype.createBLEConnection=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return[2,this.callWxApi("createBLEConnection",t)]}))}))},e.prototype.closeBLEConnection=function(t){return this.callWxApi("closeBLEConnection",t)},e.prototype.onBluetoothAdapterStateChange=function(t){this._onBluetoothAdapterStateChangeHandler=t},e.prototype.offBluetoothAdapterStateChange=function(){this._onBluetoothAdapterStateChangeHandler=null},e.prototype.onBLEConnectionStateChange=function(t){this._onBLEConnectionStateChangeHandler=t},e.prototype.offBLEConnectionStateChange=function(){this._onBLEConnectionStateChangeHandler=null},e.prototype.onBLECharacteristicValueChange=function(t){this._onBLECharacteristicValueChangeHandler=t},e.prototype.offBLECharacteristicValueChange=function(){this._onBLECharacteristicValueChangeHandler=null},e.prototype.onBluetoothDeviceFound=function(t){this._onBluetoothDeviceFoundHandler=t},e.prototype.offBluetoothDeviceFound=function(){this._onBluetoothDeviceFoundHandler=null},e}(event_emmiter_1.default);exports.BlueToothBridge=BlueToothBridge;
//# sourceMappingURL=BlueToothBridge.js.map
import { DeviceAdapter } from "../core";
export declare class DeviceAdapter4H5 extends DeviceAdapter {
static helper: {
hexToArrayBuffer: (hexString: string) => ArrayBuffer;
arrayBufferToHexStringArray: (arrayBuffer: ArrayBuffer) => string[];
hexToStr: (hexString: string) => string;
};
write(data: any, writeId: any): Promise<never>;
}

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DeviceAdapter4H5=void 0;var tslib_1=require("tslib"),core_1=require("../core"),utillib_1=require("../libs/utillib"),DeviceAdapter4H5=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return tslib_1.__extends(r,e),r.prototype.write=function(e,r){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){return"string"==typeof e?console.log("writeBLECharacteristicValue",e):e instanceof ArrayBuffer&&(e=utillib_1.arrayBufferToHexStringArray(e).join("")),[2,this._write(e,r)]}))}))},r}(core_1.DeviceAdapter);exports.DeviceAdapter4H5=DeviceAdapter4H5;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DeviceAdapter4H5=void 0;var tslib_1=require("tslib"),core_1=require("../core"),utillib_1=require("../libs/utillib"),DeviceAdapter4H5=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return tslib_1.__extends(r,e),r.prototype.write=function(e,r){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){return"string"==typeof e?console.log("writeBLECharacteristicValue",e):e instanceof ArrayBuffer&&(e=utillib_1.arrayBufferToHexStringArray(e).join("")),[2,this._write(e,r)]}))}))},r.helper=core_1.DeviceAdapter.helper,r}(core_1.DeviceAdapter);exports.DeviceAdapter4H5=DeviceAdapter4H5;
//# sourceMappingURL=DeviceAdapter4H5.js.map

@@ -11,2 +11,3 @@ export function arrayBufferToHexStringArray(buffer: any): string[];

export function isObject(obj: any): boolean;
export function hexToStr(hex: any): string;
export function delay(timeout: any): Promise<any>;

@@ -13,0 +14,0 @@ export function pify(api: any, context?: WechatMiniprogram.Wx): (params: any, ...others: any[]) => Promise<any>;

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.tryCallHandler=exports.appendParams=exports.pify=exports.isObject=exports.usePromise=exports.isEmpty=exports.noop=exports.hexToArrayBuffer=exports.arrayBufferToHexStringArray=exports.delay=void 0;var tslib_1=require("tslib");function arrayBufferToHexStringArray(r){try{if("string"==typeof r){var e=[""];return r.split("").forEach((function(r,t){e[e.length-1]+=r,t%2&&e.push("")})),e.splice(e.length-1,1),e}if("[object ArrayBuffer]"!==Object.prototype.toString.call(r))throw"invalid array buffer";for(var t=new DataView(r),n=[],o=0,i=t.byteLength;o<i;o++){var s=(255&t.getUint8(o)).toString(16);s=1===s.length?"0"+s:s,n.push(s.toUpperCase())}return n}catch(r){return console.error("arrayBufferToHexStringArray error",r),[]}}function hexToArrayBuffer(r){return new Uint8Array(r.match(/[\da-f]{2}/gi).map((function(r){return parseInt(r,16)}))).buffer}function noop(){}function isEmpty(r){if(!r)return!0;if(Array.isArray(r))return 0===r.length;for(var e in r)return!1;return!0}function usePromise(){var r,e;return{promise:new Promise((function(t,n){r=t,e=n})),resolve:r,reject:e}}function isObject(r){var e=typeof r;return"function"===e||"object"===e&&!!r}exports.delay=function(r){return new Promise((function(e){return setTimeout((function(){return e()}),r)}))},exports.arrayBufferToHexStringArray=arrayBufferToHexStringArray,exports.hexToArrayBuffer=hexToArrayBuffer,exports.noop=noop,exports.isEmpty=isEmpty,exports.usePromise=usePromise,exports.isObject=isObject,exports.pify=function(r,e){return void 0===e&&(e=wx),function(t){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];return new Promise((function(o,i){r.call.apply(r,tslib_1.__spread([e,tslib_1.__assign(tslib_1.__assign({},t),{success:o,fail:i})],n))}))}},exports.appendParams=function(r,e){var t=[];for(var n in e)void 0!==e[n]&&(isObject(e[n])&&(e[n]=JSON.stringify(e[n])),t.push(n+"="+encodeURIComponent(e[n])));return t.length?(r.indexOf("?")>-1?r+"&":r+"?")+t.join("&"):r},exports.tryCallHandler=function(r,e){for(var t=[],n=2;n<arguments.length;n++)t[n-2]=arguments[n];"function"==typeof r["_"+e+"Handler"]&&r["_"+e+"Handler"].apply(r,tslib_1.__spread(t))};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.hexToStr=exports.tryCallHandler=exports.appendParams=exports.pify=exports.isObject=exports.usePromise=exports.isEmpty=exports.noop=exports.hexToArrayBuffer=exports.arrayBufferToHexStringArray=exports.delay=void 0;var tslib_1=require("tslib");function arrayBufferToHexStringArray(r){try{if("string"==typeof r){var e=[""];return r.split("").forEach((function(r,t){e[e.length-1]+=r,t%2&&e.push("")})),e.splice(e.length-1,1),e}if("[object ArrayBuffer]"!==Object.prototype.toString.call(r))throw"invalid array buffer";for(var t=new DataView(r),o=[],n=0,s=t.byteLength;n<s;n++){var i=(255&t.getUint8(n)).toString(16);i=1===i.length?"0"+i:i,o.push(i.toUpperCase())}return o}catch(r){return console.error("arrayBufferToHexStringArray error",r),[]}}function hexToArrayBuffer(r){return new Uint8Array(r.match(/[\da-f]{2}/gi).map((function(r){return parseInt(r,16)}))).buffer}function noop(){}function isEmpty(r){if(!r)return!0;if(Array.isArray(r))return 0===r.length;for(var e in r)return!1;return!0}function usePromise(){var r,e;return{promise:new Promise((function(t,o){r=t,e=o})),resolve:r,reject:e}}function isObject(r){var e=typeof r;return"function"===e||"object"===e&&!!r}function hexToStr(r){var e=String(r).trim(),t="0x"===e.substr(0,2).toLowerCase()?e.substr(2):e,o=t.length;if(o%2!=0)throw"Illegal Format ASCII Code";for(var n=[],s=0;s<o;s+=2)parseInt(t.substr(s,2),16),n.push(String.fromCharCode(parseInt(t.substr(s,2),16)));return n.join("")}exports.delay=function(r){return new Promise((function(e){return setTimeout((function(){return e()}),r)}))},exports.arrayBufferToHexStringArray=arrayBufferToHexStringArray,exports.hexToArrayBuffer=hexToArrayBuffer,exports.noop=noop,exports.isEmpty=isEmpty,exports.usePromise=usePromise,exports.isObject=isObject,exports.pify=function(r,e){return void 0===e&&(e=wx),function(t){for(var o=[],n=1;n<arguments.length;n++)o[n-1]=arguments[n];return new Promise((function(n,s){r.call.apply(r,tslib_1.__spread([e,tslib_1.__assign(tslib_1.__assign({},t),{success:n,fail:s})],o))}))}},exports.appendParams=function(r,e){var t=[];for(var o in e)void 0!==e[o]&&(isObject(e[o])&&(e[o]=JSON.stringify(e[o])),t.push(o+"="+encodeURIComponent(e[o])));return t.length?(r.indexOf("?")>-1?r+"&":r+"?")+t.join("&"):r},exports.tryCallHandler=function(r,e){for(var t=[],o=2;o<arguments.length;o++)t[o-2]=arguments[o];"function"==typeof r["_"+e+"Handler"]&&r["_"+e+"Handler"].apply(r,tslib_1.__spread(t))},exports.hexToStr=hexToStr;
//# sourceMappingURL=utillib.js.map
import { BlueToothAdapter, BlueToothAdapterProps, SearchDeviceParams, StartSearchParams } from "../core";
export interface BlueToothAdapter4MpProps extends BlueToothAdapterProps {
devMode?: boolean;
}
/**

@@ -17,3 +14,3 @@ * 小程序版本在核心上拓展了:

_currentProductId: string;
constructor({ devMode, ...props }: BlueToothAdapter4MpProps);
constructor({ bluetoothApi, ...props }: BlueToothAdapterProps);
setCurrentProduct(productId: any): void;

@@ -20,0 +17,0 @@ startBluetoothDevicesDiscovery(isFromH5?: boolean): any;

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BlueToothAdapter4Mp=void 0;var tslib_1=require("tslib"),core_1=require("../core"),utillib_1=require("../libs/utillib"),parseAdvertisData=function(e){var t=tslib_1.__assign({},e);if(t.advertisData)try{t.advertisData=utillib_1.arrayBufferToHexStringArray(t.advertisData)}catch(e){console.error("Parse bluetoothe device advertisData fail",e)}return t},BlueToothAdapter4Mp=function(e){function t(t){var s=t.devMode,r=tslib_1.__rest(t,["devMode"]),o=e.call(this,r)||this;return o._h5ChanelOpened=!1,o._localDiscoveringInUse=!1,o._h5DiscoveringInUse=!1,o._cleanupTimer=null,o._currentProductId="",o._h5Websocket&&"function"==typeof o._h5Websocket.on&&(o.on("adapterStateChange",(function(e){var t=e.available,s=e.discovering;o.response2BlueToothChanel("onBluetoothAdapterStateChange",{available:t,discovering:s})})),o._h5Websocket.on("message",(function(e){var t=e.data,r=e.reqId;return tslib_1.__awaiter(o,void 0,void 0,(function(){var e,o,n,i,a,c,l,u,h,p,v,d,_,g=this;return tslib_1.__generator(this,(function(B){switch(B.label){case 0:switch(console.log("bluetooth ws on message",t),e=t.action,o=t.payload,e){case"bindDevice":return[3,1];case"registryDevice":return[3,5];case"connect":return[3,9];case"disconnect":return[3,10];case"init":return[3,11];case"callApi":return[3,15]}return[3,28];case 1:return B.trys.push([1,3,,4]),i=o.deviceName,a=o.productId,[4,this._actions.bindDevice({deviceId:(s&&a?a:this._currentProductId)+"/"+i})];case 2:return B.sent(),this.response2BlueToothChanel("response",{code:0},r),[3,4];case 3:return n=B.sent(),this.response2BlueToothChanel("response",n,r),[3,4];case 4:return[3,28];case 5:return B.trys.push([5,7,,8]),i=o.deviceName,a=o.productId,[4,this._actions.registerDevice({deviceId:(s&&a?a:this._currentProductId)+"/"+i})];case 6:return B.sent(),this.response2BlueToothChanel("response",{code:0},r),[3,8];case 7:return c=B.sent(),this.response2BlueToothChanel("response",c,r),[3,8];case 8:return[3,28];case 9:return console.log("h5chanel opened"),this._h5ChanelOpened=!0,[3,28];case 10:return console.log("h5chanel closed"),this._h5ChanelOpened=!1,this._h5DiscoveringInUse&&this.stopBluetoothDevicesDiscovery(!0),[3,28];case 11:return B.trys.push([11,13,,14]),[4,this.init()];case 12:return B.sent(),this.response2BlueToothChanel("response",{code:0},r),[3,14];case 13:return l=B.sent(),this.response2BlueToothChanel("response",l,r),[3,14];case 14:return[3,28];case 15:u=o.api,h=o.params,B.label=16;case 16:switch(B.trys.push([16,26,,27]),console.log("call api",u,h),u){case"getBluetoothDevices":return[3,17];case"writeBLECharacteristicValue":return[3,19];case"startBluetoothDevicesDiscovery":return[3,21];case"stopBluetoothDevicesDiscovery":return[3,23]}return[3,25];case 17:return[4,this.getBluetoothDevices()];case 18:return p=B.sent(),this.response2BlueToothChanel("response",{devices:p.map(parseAdvertisData)},r),[2];case 19:return v=h.value,console.log("calling writeBLECharacteristicValue",tslib_1.__assign(tslib_1.__assign({},h),{value:utillib_1.hexToArrayBuffer(v)})),[4,this._bluetoothApi.writeBLECharacteristicValue(tslib_1.__assign(tslib_1.__assign({},h),{value:utillib_1.hexToArrayBuffer(v)}))];case 20:return d=B.sent(),this.response2BlueToothChanel("response",d,r),[2];case 21:return[4,this.startBluetoothDevicesDiscovery(!0)];case 22:return d=B.sent(),this.response2BlueToothChanel("response",d,r),[2];case 23:return[4,this.stopBluetoothDevicesDiscovery(!0)];case 24:return d=B.sent(),this.response2BlueToothChanel("response",d,r),[2];case 25:return[3,27];case 26:return _=B.sent(),console.log("call api fail",_),this.response2BlueToothChanel("response",this._normalizeError(_),r),[3,27];case 27:return wx[u]&&wx[u](tslib_1.__assign(tslib_1.__assign({},h),{success:function(e){console.log("call api success",e),g.response2BlueToothChanel("response",e,r)},fail:function(e){console.log("call api fail",e),g.response2BlueToothChanel("response",g._normalizeError(e),r)}})),[3,28];case 28:return[2]}}))}))}))),o}return tslib_1.__extends(t,e),t.prototype.setCurrentProduct=function(e){this._currentProductId=e},t.prototype.startBluetoothDevicesDiscovery=function(t){return void 0===t&&(t=!1),t?this._h5DiscoveringInUse=!0:this._localDiscoveringInUse=!0,e.prototype.startBluetoothDevicesDiscovery.call(this)},t.prototype.stopBluetoothDevicesDiscovery=function(t){if(void 0===t&&(t=!1),console.log("try call stopBluetoothDevicesDiscovery, isFromH5: "+t+", _h5DiscoveringInUse: "+this._h5DiscoveringInUse+", _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,s){return void 0===t&&(t={}),void 0===s&&(s=""),tslib_1.__awaiter(this,void 0,void 0,(function(){var r;return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this._h5ChanelOpened?(console.log("response2BlueToothChanel",e,t),[4,this._h5Websocket.send("Response",{action:e,payload:t},{reqId:s})]):(console.log("h5 chanel not opened"),[2]);case 1:return o.sent(),[3,3];case 2:return r=o.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),console.log("start cleanup timer"),this._cleanupTimer=setTimeout((function(){console.log("bluetooth searching or deviceMap not empty, reset cleanup timer",e._discovering,e._deviceMap),e._h5ChanelOpened||e._discovering||!utillib_1.isEmpty(e._deviceMap)?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(s){return[2,e.prototype.init.call(this).then((function(){return t.startCleanupTimer()}))]}))}))},t.prototype.onBleConnectionStateChange=function(t){var s=t.deviceId,r=t.connected;return this.response2BlueToothChanel("onBLEConnectionStateChange",{deviceId:s,connected:r}),e.prototype.onBleConnectionStateChange.call(this,{deviceId:s,connected:r})},t.prototype.onBLECharacteristicValueChange=function(t){var s=t.deviceId,r=t.serviceId,o=t.characteristicId,n=t.value;return this.response2BlueToothChanel("onBLECharacteristicValueChange",{deviceId:s,serviceId:r,characteristicId:o,value:utillib_1.arrayBufferToHexStringArray(n)}),e.prototype.onBLECharacteristicValueChange.call(this,{deviceId:s,serviceId:r,characteristicId:o,value:n})},t.prototype.onBluetoothDeviceFound=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:return[4,e.prototype.onBluetoothDeviceFound.call(this)];case 1:return t=s.sent(),this.response2BlueToothChanel("onBluetoothDeviceFound",{devices:t.map(parseAdvertisData)}),[2]}}))}))},t.prototype.startSearch=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(s){switch(s.label){case 0:return[4,e.prototype.startSearch.call(this,t)];case 1:return s.sent(),this.startCleanupTimer(),[2]}}))}))},t.prototype.searchDevice=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(s){switch(s.label){case 0:return[4,e.prototype.searchDevice.call(this,t)];case 1:return s.sent(),this.startCleanupTimer(),[2]}}))}))},t}(core_1.BlueToothAdapter);exports.BlueToothAdapter4Mp=BlueToothAdapter4Mp;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BlueToothAdapter4Mp=void 0;var tslib_1=require("tslib"),core_1=require("../core"),utillib_1=require("../libs/utillib"),parseAdvertisData=function(e){var t=tslib_1.__assign({},e);if(t.advertisData)try{t.advertisData=utillib_1.arrayBufferToHexStringArray(t.advertisData)}catch(e){console.error("Parse bluetoothe device advertisData fail",e)}return t},BlueToothAdapter4Mp=function(e){function t(t){var s=t.bluetoothApi,r=tslib_1.__rest(t,["bluetoothApi"]),o=e.call(this,tslib_1.__assign({bluetoothApi:s},r))||this;return o._h5ChanelOpened=!1,o._localDiscoveringInUse=!1,o._h5DiscoveringInUse=!1,o._cleanupTimer=null,o._currentProductId="",o._h5Websocket&&"function"==typeof o._h5Websocket.on&&(o.on("adapterStateChange",(function(e){var t=e.available,s=e.discovering;o.response2BlueToothChanel("onBluetoothAdapterStateChange",{available:t,discovering:s})})),o._h5Websocket.on("message",(function(e){var t=e.data,s=e.reqId;return tslib_1.__awaiter(o,void 0,void 0,(function(){var e,r,o,n,i,a,c,l,u,h,p,_,d,v=this;return tslib_1.__generator(this,(function(g){switch(g.label){case 0:switch(console.log("bluetooth ws on message",t),e=t.action,r=t.payload,e){case"bindDevice":return[3,1];case"registryDevice":return[3,5];case"connect":return[3,9];case"disconnect":return[3,10];case"init":return[3,11];case"callApi":return[3,15]}return[3,30];case 1:return g.trys.push([1,3,,4]),n=r.deviceName,i=r.productId,[4,this._actions.bindDevice({productId:this.devMode&&i?i:this._currentProductId,deviceName:n})];case 2:return g.sent(),this.response2BlueToothChanel("response",{code:0},s),[3,4];case 3:return o=g.sent(),this.response2BlueToothChanel("response",o,s),[3,4];case 4:return[3,30];case 5:return g.trys.push([5,7,,8]),n=r.deviceName,i=r.productId,[4,this._actions.registerDevice({productId:this.devMode&&i?i:this._currentProductId,deviceName:n})];case 6:return g.sent(),this.response2BlueToothChanel("response",{code:0},s),[3,8];case 7:return a=g.sent(),this.response2BlueToothChanel("response",a,s),[3,8];case 8:return[3,30];case 9:return console.log("h5chanel opened"),this._h5ChanelOpened=!0,[3,30];case 10:return console.log("h5chanel closed"),this._h5ChanelOpened=!1,this._h5DiscoveringInUse&&this.stopBluetoothDevicesDiscovery(!0),[3,30];case 11:return g.trys.push([11,13,,14]),[4,this.init()];case 12:return g.sent(),this.response2BlueToothChanel("response",{code:0},s),[3,14];case 13:return c=g.sent(),this.response2BlueToothChanel("response",c,s),[3,14];case 14:return[3,30];case 15:l=r.api,u=r.params,g.label=16;case 16:switch(g.trys.push([16,28,,29]),console.log("call api",l,u),l){case"createBLEConnection":return[3,17];case"getBluetoothDevices":return[3,19];case"writeBLECharacteristicValue":return[3,21];case"startBluetoothDevicesDiscovery":return[3,23];case"stopBluetoothDevicesDiscovery":return[3,25]}return[3,27];case 17:return[4,this._bluetoothApi.createBLEConnection(u)];case 18:return g.sent(),this.response2BlueToothChanel("response",{},s),[2];case 19:return[4,this.getBluetoothDevices()];case 20:return h=g.sent(),this.response2BlueToothChanel("response",{devices:h.map(parseAdvertisData)},s),[2];case 21:return p=u.value,console.log("calling writeBLECharacteristicValue",tslib_1.__assign(tslib_1.__assign({},u),{value:utillib_1.hexToArrayBuffer(p)})),[4,this._bluetoothApi.writeBLECharacteristicValue(tslib_1.__assign(tslib_1.__assign({},u),{value:utillib_1.hexToArrayBuffer(p)}))];case 22:return _=g.sent(),this.response2BlueToothChanel("response",_,s),[2];case 23:return[4,this.startBluetoothDevicesDiscovery(!0)];case 24:return _=g.sent(),this.response2BlueToothChanel("response",_,s),[2];case 25:return[4,this.stopBluetoothDevicesDiscovery(!0)];case 26:return _=g.sent(),this.response2BlueToothChanel("response",_,s),[2];case 27:return[3,29];case 28:return d=g.sent(),console.log("call api fail",d),this.response2BlueToothChanel("response",this._normalizeError(d),s),[3,29];case 29:return wx[l]&&wx[l](tslib_1.__assign(tslib_1.__assign({},u),{success:function(e){console.log("call api success",e),v.response2BlueToothChanel("response",e,s)},fail:function(e){console.log("call api fail",e),v.response2BlueToothChanel("response",v._normalizeError(e),s)}})),[3,30];case 30:return[2]}}))}))}))),o}return tslib_1.__extends(t,e),t.prototype.setCurrentProduct=function(e){this._currentProductId=e},t.prototype.startBluetoothDevicesDiscovery=function(t){return void 0===t&&(t=!1),t?this._h5DiscoveringInUse=!0:this._localDiscoveringInUse=!0,e.prototype.startBluetoothDevicesDiscovery.call(this)},t.prototype.stopBluetoothDevicesDiscovery=function(t){if(void 0===t&&(t=!1),console.log("try call stopBluetoothDevicesDiscovery, isFromH5: "+t+", _h5DiscoveringInUse: "+this._h5DiscoveringInUse+", _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,s){return void 0===t&&(t={}),void 0===s&&(s=""),tslib_1.__awaiter(this,void 0,void 0,(function(){var r;return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),this._h5ChanelOpened?(console.log("response2BlueToothChanel",e,t),[4,this._h5Websocket.send("Response",{action:e,payload:t},{reqId:s})]):(console.log("h5 chanel not opened"),[2]);case 1:return o.sent(),[3,3];case 2:return r=o.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),console.log("start cleanup timer"),this._cleanupTimer=setTimeout((function(){console.log("bluetooth searching or deviceMap not empty, reset cleanup timer",e._discovering,e._deviceMap),e._h5ChanelOpened||e._discovering||!utillib_1.isEmpty(e._deviceMap)?e.startCleanupTimer():e.cleanup()}),5e3)},t.prototype.init=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t=this;return tslib_1.__generator(this,(function(s){return[2,e.prototype.init.call(this).then((function(){return t.startCleanupTimer()}))]}))}))},t.prototype.onBleConnectionStateChange=function(t){var s=t.deviceId,r=t.connected;return this.response2BlueToothChanel("onBLEConnectionStateChange",{deviceId:s,connected:r}),e.prototype.onBleConnectionStateChange.call(this,{deviceId:s,connected:r})},t.prototype.onBLECharacteristicValueChange=function(t){var s=t.deviceId,r=t.serviceId,o=t.characteristicId,n=t.value;return this.response2BlueToothChanel("onBLECharacteristicValueChange",{deviceId:s,serviceId:r,characteristicId:o,value:utillib_1.arrayBufferToHexStringArray(n)}),e.prototype.onBLECharacteristicValueChange.call(this,{deviceId:s,serviceId:r,characteristicId:o,value:n})},t.prototype.onBluetoothDeviceFound=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t;return tslib_1.__generator(this,(function(s){switch(s.label){case 0:return[4,e.prototype.onBluetoothDeviceFound.call(this)];case 1:return t=s.sent(),this.response2BlueToothChanel("onBluetoothDeviceFound",{devices:t.map(parseAdvertisData)}),[2]}}))}))},t.prototype.startSearch=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(s){switch(s.label){case 0:return[4,e.prototype.startSearch.call(this,t)];case 1:return s.sent(),this.startCleanupTimer(),[2]}}))}))},t.prototype.searchDevice=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(s){switch(s.label){case 0:return[4,e.prototype.searchDevice.call(this,t)];case 1:return s.sent(),this.startCleanupTimer(),[2]}}))}))},t}(core_1.BlueToothAdapter);exports.BlueToothAdapter4Mp=BlueToothAdapter4Mp;
//# sourceMappingURL=BlueToothAdapter4Mp.js.map
import { DeviceAdapter } from "../core";
export declare class DeviceAdapter4Mp extends DeviceAdapter {
static helper: {
hexToArrayBuffer: (hexString: string) => ArrayBuffer;
arrayBufferToHexStringArray: (arrayBuffer: ArrayBuffer) => string[];
hexToStr: (hexString: string) => string;
};
}

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DeviceAdapter4Mp=void 0;var tslib_1=require("tslib"),core_1=require("../core"),DeviceAdapter4Mp=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return tslib_1.__extends(r,e),r}(core_1.DeviceAdapter);exports.DeviceAdapter4Mp=DeviceAdapter4Mp;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DeviceAdapter4Mp=void 0;var tslib_1=require("tslib"),core_1=require("../core"),DeviceAdapter4Mp=function(e){function r(){return null!==e&&e.apply(this,arguments)||this}return tslib_1.__extends(r,e),r.helper=core_1.DeviceAdapter.helper,r}(core_1.DeviceAdapter);exports.DeviceAdapter4Mp=DeviceAdapter4Mp;
//# sourceMappingURL=DeviceAdapter4Mp.js.map
{
"name": "qcloud-iotexplorer-bluetooth-adapter",
"version": "0.0.2",
"version": "0.0.3",
"description": "",

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

"build:lib": "rm -rf lib && npx tsc -p tsconfig.json -t es5 --outDir lib && node bin/minify.js -t lib",
"build": "npm run build:lib"
"build": "npm run build:lib",
"dev": "rm -rf ../iot-weapp/src/lib/bluetooth-debug && npx tsc -p tsconfig.json -t es5 --outDir ../iot-weapp/src/lib/bluetooth-debug --watch"
},

@@ -11,0 +12,0 @@ "author": "xiaoyuze88@gmail.com",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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