qcloud-iotexplorer-bluetooth-adapter
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -46,3 +46,3 @@ /// <reference types="miniprogram-api-typings" /> | ||
export interface BlueToothAdapterProps { | ||
deviceAdapters: DeviceAdapter[]; | ||
deviceAdapters: (typeof DeviceAdapter)[]; | ||
actions: BlueToothActions; | ||
@@ -49,0 +49,0 @@ bluetoothApi: any; |
@@ -18,7 +18,2 @@ /// <reference types="miniprogram-api-typings" /> | ||
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, // 设备原始名称 | ||
@@ -25,0 +20,0 @@ actions, bluetoothApi, }: { |
@@ -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,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; | ||
"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.serviceId="",t}(BlueToothBase_1.BlueToothBase);exports.DeviceAdapter=DeviceAdapter; | ||
//# sourceMappingURL=DeviceAdapter.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.helper=core_1.DeviceAdapter.helper,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}(core_1.DeviceAdapter);exports.DeviceAdapter4H5=DeviceAdapter4H5; | ||
//# sourceMappingURL=DeviceAdapter4H5.js.map |
@@ -0,3 +1,9 @@ | ||
import { arrayBufferToHexStringArray, hexToArrayBuffer, hexToStr } from "./libs/utillib"; | ||
export * from './core'; | ||
export * from './h5'; | ||
export * from './miniprogram'; | ||
export declare const blueToothHelper: { | ||
hexToArrayBuffer: typeof hexToArrayBuffer; | ||
arrayBufferToHexStringArray: typeof arrayBufferToHexStringArray; | ||
hexToStr: typeof hexToStr; | ||
}; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib");tslib_1.__exportStar(require("./core"),exports),tslib_1.__exportStar(require("./h5"),exports),tslib_1.__exportStar(require("./miniprogram"),exports); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.blueToothHelper=void 0;var tslib_1=require("tslib"),utillib_1=require("./libs/utillib");tslib_1.__exportStar(require("./core"),exports),tslib_1.__exportStar(require("./h5"),exports),tslib_1.__exportStar(require("./miniprogram"),exports),exports.blueToothHelper={hexToArrayBuffer:utillib_1.hexToArrayBuffer,arrayBufferToHexStringArray:utillib_1.arrayBufferToHexStringArray,hexToStr:utillib_1.hexToStr}; | ||
//# sourceMappingURL=index.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.helper=core_1.DeviceAdapter.helper,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}(core_1.DeviceAdapter);exports.DeviceAdapter4Mp=DeviceAdapter4Mp; | ||
//# sourceMappingURL=DeviceAdapter4Mp.js.map |
{ | ||
"name": "qcloud-iotexplorer-bluetooth-adapter", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 2 instances in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
117917
589
14