Socket
Socket
Sign inDemoInstall

qcloud-iotexplorer-appdev-plugin-wificonf-blecombo

Package Overview
Dependencies
Maintainers
3
Versions
174
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qcloud-iotexplorer-appdev-plugin-wificonf-blecombo - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2-beta.0

2

lib/index.d.ts

@@ -13,5 +13,5 @@ import { BleComboLLSyncTaskOptions, BleComboEspTaskOptions } from './protocols';

}
export { BleComboEspDeviceAdapter, BleComboLLSyncDeviceAdapter, BleComboDualModeDeviceAdapter, } from './protocols';
export { BleComboEspDeviceAdapter, BleComboLLSyncDeviceAdapter, BleComboDualModeDeviceAdapter, BleComboDualModeDeviceAdapter4H5, } from './protocols';
export default class BleComboPlugin implements AppDevPlugin {
static install(sdk: AppDevSdk): void;
}

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_plugin_wificonf_core_1=require("qcloud-iotexplorer-appdev-plugin-wificonf-core"),protocols_1=require("./protocols"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),iotexplorer_ui_dev_config_1=require("iotexplorer-ui-dev-config"),delay=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.delay,WifiConfStepCode=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.constants.WifiConfStepCode,WifiConfStepDesp=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.constants.WifiConfStepDesp,protocols_2=require("./protocols");Object.defineProperty(exports,"BleComboEspDeviceAdapter",{enumerable:!0,get:function(){return protocols_2.BleComboEspDeviceAdapter}}),Object.defineProperty(exports,"BleComboLLSyncDeviceAdapter",{enumerable:!0,get:function(){return protocols_2.BleComboLLSyncDeviceAdapter}}),Object.defineProperty(exports,"BleComboDualModeDeviceAdapter",{enumerable:!0,get:function(){return protocols_2.BleComboDualModeDeviceAdapter}});var getBleComboProtoHandler=function(e){switch(e.wifiConfType){case iotexplorer_ui_dev_config_1.WifiConfType.BLEComboEsp:return new protocols_1.BleComboEspTask(e);case iotexplorer_ui_dev_config_1.WifiConfType.BLEComboLLSync:case iotexplorer_ui_dev_config_1.WifiConfType.DualMode:return new protocols_1.BleComboLLSyncTask(e);default:console.warn("没有找到 wifiConfType 对应的 bleComboHandler:",e.wifiConfType)}},BleComboPlugin=function(){function e(){}return e.install=function(e){e.plugins.wifiConfBleCombo={start:function(o){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,i,n,s,c,d,_,a,l,p,u,f,C,S,b,v=this;return tslib_1.__generator(this,(function(T){switch(T.label){case 0:t=o.onError,r=o.onProgress,i=o.onComplete,n=o.wifiConfToken,s=o.familyId,c=function(e){return void 0===e&&(e=1e3),tslib_1.__awaiter(v,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,delay(e)];case 1:return o.sent(),[2]}}))}))},r({code:WifiConfStepCode.PROTOCOL_START}),T.label=1;case 1:T.trys.push([1,22,,23]),d=Date.now(),_=getBleComboProtoHandler(tslib_1.__assign(tslib_1.__assign({},o),{reporter:{info:function(e,o){void 0===o&&(o={}),r({code:WifiConfStepCode.PROTOCOL_DETAIL,detail:{message:WifiConfStepCode.PROTOCOL_DETAIL+"("+WifiConfStepDesp[WifiConfStepCode.PROTOCOL_DETAIL]+": "+e+")",data:o}})},error:function(e){t({code:"PROTOCOL_FAIL",detail:{error:e}})}}})),T.label=2;case 2:return T.trys.push([2,4,,5]),[4,_.start()];case 3:return T.sent(),[3,5];case 4:throw a=T.sent(),console.error(a),tslib_1.__assign({code:"PROTOCOL_FAIL"},a);case 5:return r({code:WifiConfStepCode.PROTOCOL_SUCCESS,detail:{timeCost:Date.now()-d}}),[4,c()];case 6:T.sent(),r({code:WifiConfStepCode.BUSINESS_START}),r({code:"BLE_SEND_TOKEN_START",detail:{data:{wifiConfToken:n}}}),l=Date.now(),p=void 0,T.label=7;case 7:return T.trys.push([7,9,,10]),[4,_.sendToken()];case 8:return p=T.sent(),[3,10];case 9:throw u=T.sent(),tslib_1.__assign({code:"BLE_SEND_TOKEN_ERROR"},u);case 10:return[4,r({code:"BLE_SEND_TOKEN_SUCCESS",detail:{timeCost:Date.now()-l,response:p}})];case 11:if(T.sent(),f=p.productId,C=p.deviceName,o.wifiConfType!==iotexplorer_ui_dev_config_1.WifiConfType.DualMode)return[3,17];T.label=12;case 12:return T.trys.push([12,15,,16]),[4,qcloud_iotexplorer_appdev_plugin_wificonf_core_1.queryTokenStateAndBind({token:o.wifiConfToken,productId:f,deviceName:C,familyId:s,roomId:"",onProgress:r,sdk:e,skipBind:!0})];case 13:return T.sent(),[4,o.deviceAdapter.bindDevice({familyId:s,roomId:""})];case 14:return T.sent(),[3,16];case 15:throw S=T.sent(),tslib_1.__assign({code:"BLE_BIND_DEVICE_ERROR"},S);case 16:return[3,19];case 17:return[4,qcloud_iotexplorer_appdev_plugin_wificonf_core_1.queryTokenStateAndBind({token:o.wifiConfToken,productId:f,deviceName:C,familyId:s,roomId:"",onProgress:r,sdk:e})];case 18:T.sent(),T.label=19;case 19:return[4,r({code:WifiConfStepCode.BUSINESS_QUERY_TOKEN_STATE_SUCCESS,detail:{timeCost:Date.now()-l,response:p}})];case 20:return T.sent(),[4,c()];case 21:return T.sent(),i({productId:f,deviceName:C}),_.interrupt(),r({code:WifiConfStepCode.WIFI_CONF_SUCCESS,detail:{timeCost:Date.now()-d}}),[3,23];case 22:return b=T.sent(),t({code:"",detail:{error:b}}),[3,23];case 23:return[2]}}))}))}}},e}();exports.default=BleComboPlugin;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_plugin_wificonf_core_1=require("qcloud-iotexplorer-appdev-plugin-wificonf-core"),protocols_1=require("./protocols"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),iotexplorer_ui_dev_config_1=require("iotexplorer-ui-dev-config"),delay=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.delay,WifiConfStepCode=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.constants.WifiConfStepCode,WifiConfStepDesp=qcloud_iotexplorer_appdev_plugin_wificonf_core_1.constants.WifiConfStepDesp,protocols_2=require("./protocols");Object.defineProperty(exports,"BleComboEspDeviceAdapter",{enumerable:!0,get:function(){return protocols_2.BleComboEspDeviceAdapter}}),Object.defineProperty(exports,"BleComboLLSyncDeviceAdapter",{enumerable:!0,get:function(){return protocols_2.BleComboLLSyncDeviceAdapter}}),Object.defineProperty(exports,"BleComboDualModeDeviceAdapter",{enumerable:!0,get:function(){return protocols_2.BleComboDualModeDeviceAdapter}}),Object.defineProperty(exports,"BleComboDualModeDeviceAdapter4H5",{enumerable:!0,get:function(){return protocols_2.BleComboDualModeDeviceAdapter4H5}});var getBleComboProtoHandler=function(e){switch(e.wifiConfType){case iotexplorer_ui_dev_config_1.WifiConfType.BLEComboEsp:return new protocols_1.BleComboEspTask(e);case iotexplorer_ui_dev_config_1.WifiConfType.BLEComboLLSync:case iotexplorer_ui_dev_config_1.WifiConfType.DualMode:return new protocols_1.BleComboLLSyncTask(e);default:console.warn("没有找到 wifiConfType 对应的 bleComboHandler:",e.wifiConfType)}},BleComboPlugin=function(){function e(){}return e.install=function(e){e.plugins.wifiConfBleCombo={start:function(o){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,r,i,n,s,c,d,a,l,_,p,u,f,C,b,S,v=this;return tslib_1.__generator(this,(function(m){switch(m.label){case 0:t=o.onError,r=o.onProgress,i=o.onComplete,n=o.wifiConfToken,s=o.familyId,c=function(e){return void 0===e&&(e=1e3),tslib_1.__awaiter(v,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,delay(e)];case 1:return o.sent(),[2]}}))}))},r({code:WifiConfStepCode.PROTOCOL_START}),m.label=1;case 1:m.trys.push([1,22,,23]),d=Date.now(),a=getBleComboProtoHandler(tslib_1.__assign(tslib_1.__assign({},o),{reporter:{info:function(e,o){void 0===o&&(o={}),r({code:WifiConfStepCode.PROTOCOL_DETAIL,detail:{message:WifiConfStepCode.PROTOCOL_DETAIL+"("+WifiConfStepDesp[WifiConfStepCode.PROTOCOL_DETAIL]+": "+e+")",data:o}})},error:function(e){t({code:"PROTOCOL_FAIL",detail:{error:e}})}}})),m.label=2;case 2:return m.trys.push([2,4,,5]),[4,a.start()];case 3:return m.sent(),[3,5];case 4:throw l=m.sent(),console.error(l),tslib_1.__assign({code:"PROTOCOL_FAIL"},l);case 5:return r({code:WifiConfStepCode.PROTOCOL_SUCCESS,detail:{timeCost:Date.now()-d}}),[4,c()];case 6:m.sent(),r({code:WifiConfStepCode.BUSINESS_START}),r({code:"BLE_SEND_TOKEN_START",detail:{data:{wifiConfToken:n}}}),_=Date.now(),p=void 0,m.label=7;case 7:return m.trys.push([7,9,,10]),[4,a.sendToken()];case 8:return p=m.sent(),[3,10];case 9:throw u=m.sent(),tslib_1.__assign({code:"BLE_SEND_TOKEN_ERROR"},u);case 10:return[4,r({code:"BLE_SEND_TOKEN_SUCCESS",detail:{timeCost:Date.now()-_,response:p}})];case 11:if(m.sent(),f=p.productId,C=p.deviceName,o.wifiConfType!==iotexplorer_ui_dev_config_1.WifiConfType.DualMode)return[3,17];m.label=12;case 12:return m.trys.push([12,15,,16]),[4,qcloud_iotexplorer_appdev_plugin_wificonf_core_1.queryTokenStateAndBind({token:o.wifiConfToken,productId:f,deviceName:C,familyId:s,roomId:"",onProgress:r,sdk:e,skipBind:!0})];case 13:return m.sent(),[4,o.deviceAdapter.bindDevice({familyId:s,roomId:""})];case 14:return m.sent(),[3,16];case 15:throw b=m.sent(),tslib_1.__assign({code:"BLE_BIND_DEVICE_ERROR"},b);case 16:return[3,19];case 17:return[4,qcloud_iotexplorer_appdev_plugin_wificonf_core_1.queryTokenStateAndBind({token:o.wifiConfToken,productId:f,deviceName:C,familyId:s,roomId:"",onProgress:r,sdk:e})];case 18:m.sent(),m.label=19;case 19:return[4,r({code:WifiConfStepCode.BUSINESS_QUERY_TOKEN_STATE_SUCCESS,detail:{timeCost:Date.now()-_,response:p}})];case 20:return m.sent(),[4,c()];case 21:return m.sent(),i({productId:f,deviceName:C}),a.interrupt(),r({code:WifiConfStepCode.WIFI_CONF_SUCCESS,detail:{timeCost:Date.now()-d}}),[3,23];case 22:return S=m.sent(),t({code:"",detail:{error:S}}),[3,23];case 23:return[2]}}))}))}}},e}();exports.default=BleComboPlugin;
//# sourceMappingURL=index.js.map

@@ -0,3 +1,3 @@

import { BleComboLLSyncDeviceAdapterBase, LLSyncComboDeviceAdapterOptions } from '../BleComboLLSync';
import { DeviceFilterFunction } from 'qcloud-iotexplorer-bluetooth-adapter';
import { BleComboLLSyncDeviceAdapter, LLSyncComboDeviceAdapterOptions } from '../BleComboLLSync';
import { LLSyncDeviceAdapter } from 'qcloud-iotexplorer-bluetooth-adapter-llsync';

@@ -12,3 +12,3 @@ import { AppDevSdk } from 'qcloud-iotexplorer-appdev-sdk';

}
export declare class BleComboDualModeDeviceAdapter extends BleComboLLSyncDeviceAdapter {
export declare class BleComboDualModeDeviceAdapterBase extends BleComboLLSyncDeviceAdapterBase {
static serviceId16: string;

@@ -28,2 +28,181 @@ static serviceId: string;

}
export declare const BleComboDualModeDeviceAdapter: (new (...args: any[]) => {
bluetoothAdapter: import("qcloud-iotexplorer-bluetooth-adapter").BlueToothAdapter;
extendInfo: any;
_h5Websocket: any;
_name: string;
_deviceId: string;
_deviceName: string;
_deviceConnected: boolean;
_productId: string;
_deviceRegistered: boolean;
_services: any[];
characteristicsMap: {};
_actions: Pick<import("qcloud-iotexplorer-bluetooth-adapter/lib/base/types").BlueToothActions, "registerDevice" | "bindDevice" | "reportDeviceData">;
_bluetoothApi: any;
_getNotifyId({ serviceId }?: {
serviceId?: string;
}): any;
readonly _writeId: any;
readonly _notifyId: any;
readonly _readId: any;
readonly _indicateId: any;
readonly deviceId: string;
readonly productId: string;
deviceName: string;
readonly isConnected: boolean;
readonly originName: string;
readonly explorerDeviceId: string;
readonly serviceId: any;
readonly deviceInfo: {
productId: string;
deviceName: string;
deviceId: string;
explorerDeviceId: string;
name: string;
};
init(): Promise<void>;
handleBLEMessage(hexStrArr: string[], { serviceId, characteristicId }: {
serviceId: string;
characteristicId: string;
}): import("qcloud-iotexplorer-bluetooth-adapter").BLEMessageResponse;
registerDevice(): Promise<void>;
bindDevice({ familyId, roomId, }?: {
familyId?: string;
roomId?: string;
}): Promise<string>;
onBleConnectionStateChange({ connected }: {
connected: any;
}): void;
onBLECharacteristicValueChange({ serviceId, characteristicId, value, }: {
serviceId: any;
characteristicId: any;
value: any;
}): Promise<void>;
disconnectDevice(): void;
connectDevice({ autoNotify, }?: {
autoNotify?: boolean;
}): Promise<void>;
write(data: any, { writeId, serviceId, }?: {
writeId?: string;
serviceId?: string;
}): Promise<void>;
_write(value: any, { writeId, serviceId, }?: {
writeId?: string;
serviceId?: string;
}): Promise<void>;
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;
destroy(): void;
_cleanupMap: {};
_normalizeError(error: any): any;
cleanup(action?: string): void;
addCleanupTask(action: any, cleanupFn: any): void;
on: (type: string, listener: import("event-emitter-for-miniprogram").listenerCallback) => import("event-emitter-for-miniprogram").default;
once: (type: any, listener: import("event-emitter-for-miniprogram").listenerCallback) => import("event-emitter-for-miniprogram").default;
off: (type: any, listener?: import("event-emitter-for-miniprogram").listenerCallback) => import("event-emitter-for-miniprogram").default;
emit: (type: any, ...argus: any[]) => Promise<any>;
}) & typeof BleComboDualModeDeviceAdapterBase;
export declare const BleComboDualModeDeviceAdapter4H5: (new (...props: any[]) => {
write(data: any, writeId: any): Promise<void>;
bluetoothAdapter: import("qcloud-iotexplorer-bluetooth-adapter").BlueToothAdapter;
extendInfo: any;
_h5Websocket: any;
_name: string;
_deviceId: string;
_deviceName: string;
_deviceConnected: boolean;
_productId: string;
_deviceRegistered: boolean;
_services: any[];
characteristicsMap: {};
_actions: Pick<import("qcloud-iotexplorer-bluetooth-adapter/lib/base/types").BlueToothActions, "registerDevice" | "bindDevice" | "reportDeviceData">;
_bluetoothApi: any;
_getNotifyId({ serviceId }?: {
serviceId?: string;
}): any;
readonly _writeId: any;
readonly _notifyId: any;
readonly _readId: any;
readonly _indicateId: any;
readonly deviceId: string;
readonly productId: string;
deviceName: string;
readonly isConnected: boolean;
readonly originName: string;
readonly explorerDeviceId: string;
readonly serviceId: any;
readonly deviceInfo: {
productId: string;
deviceName: string;
deviceId: string;
explorerDeviceId: string;
name: string;
};
init(): Promise<void>;
handleBLEMessage(hexStrArr: string[], { serviceId, characteristicId }: {
serviceId: string;
characteristicId: string;
}): import("qcloud-iotexplorer-bluetooth-adapter").BLEMessageResponse;
registerDevice(): Promise<void>;
bindDevice({ familyId, roomId, }?: {
familyId?: string;
roomId?: string;
}): Promise<string>;
onBleConnectionStateChange({ connected }: {
connected: any;
}): void;
onBLECharacteristicValueChange({ serviceId, characteristicId, value, }: {
serviceId: any;
characteristicId: any;
value: any;
}): Promise<void>;
disconnectDevice(): void;
connectDevice({ autoNotify, }?: {
autoNotify?: boolean;
}): Promise<void>;
_write(value: any, { writeId, serviceId, }?: {
writeId?: string;
serviceId?: string;
}): Promise<void>;
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;
destroy(): void;
_cleanupMap: {};
_normalizeError(error: any): any;
cleanup(action?: string): void;
addCleanupTask(action: any, cleanupFn: any): void;
on: (type: string, listener: import("event-emitter-for-miniprogram").listenerCallback) => import("event-emitter-for-miniprogram").default;
once: (type: any, listener: import("event-emitter-for-miniprogram").listenerCallback) => import("event-emitter-for-miniprogram").default;
off: (type: any, listener?: import("event-emitter-for-miniprogram").listenerCallback) => import("event-emitter-for-miniprogram").default;
emit: (type: any, ...argus: any[]) => Promise<any>;
}) & typeof BleComboDualModeDeviceAdapterBase;
export {};

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BleComboDualModeDeviceAdapter=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_bluetooth_adapter_1=require("qcloud-iotexplorer-bluetooth-adapter"),BleComboLLSync_1=require("../BleComboLLSync"),qcloud_iotexplorer_bluetooth_adapter_llsync_1=require("qcloud-iotexplorer-bluetooth-adapter-llsync"),hex2str=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.hex2str,REPORT_EVENT_TYPE=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,arrayBufferToHexStringArray=qcloud_iotexplorer_bluetooth_adapter_1.blueToothHelper.arrayBufferToHexStringArray,DUALMODE_SERVICEID="0000FFE8-65D0-4E20-B56A-E493541BA4E2",DUALMODE_SERVICEID16="0000FFE8-0000-1000-8000-00805F9B34FB",LLSyncDualModeDeviceAdapter=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return tslib_1.__extends(t,e),t.serviceId16=DUALMODE_SERVICEID16,t.serviceId=DUALMODE_SERVICEID,t}(qcloud_iotexplorer_bluetooth_adapter_llsync_1.LLSyncDeviceAdapter),BleComboDualModeDeviceAdapter=function(e){function t(t){var o=e.call(this,t)||this;return o._bleDeviceAdapter=new LLSyncDualModeDeviceAdapter(t),["CONNECT_AUTH","DEVICE_INFO","BIND_AUTH","UNBIND_AUTH"].forEach((function(e){o.on(e,(function(){for(var t,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];console.info("emit connect_auth from dualmode adapter",r),(t=o._bleDeviceAdapter).emit.apply(t,tslib_1.__spread([e],r))}))})),o.on("connect",(function(e){console.info("ble connected",e),o._bleDeviceAdapter._deviceConnected=!0})),o.on("disconnect",(function(e){console.info("ble disconnect",e),o._bleDeviceAdapter._deviceConnected=!1})),o}return tslib_1.__extends(t,e),t.injectOptions=function(e){t.options=e,qcloud_iotexplorer_bluetooth_adapter_llsync_1.LLSyncDeviceAdapter.injectOptions(e)},t.prototype.toString=function(){return"[BleComboDualModeDeviceAdapter]"},Object.defineProperty(t.prototype,"authorized",{get:function(){return this._bleDeviceAdapter.authorized},enumerable:!1,configurable:!0}),t.prototype.authenticateConnection=function(e){return this._bleDeviceAdapter.authenticateConnection(e)},t.prototype.bindDevice=function(e){return this._bleDeviceAdapter.bindDevice(e)},t.prototype.unbindDevice=function(e){return this._bleDeviceAdapter.unbindDevice.call(this._bleDeviceAdapter,e)},t.prototype.controlDevice=function(e){return this._bleDeviceAdapter.controlDevice.call(this._bleDeviceAdapter,e)},t.prototype.init=function(){return this._bleDeviceAdapter.init()},t.serviceId16=DUALMODE_SERVICEID16,t.serviceId=DUALMODE_SERVICEID,t.deviceFilter=function(e,o){if(!e.advertisServiceUUIDs||!e.advertisServiceUUIDs.find((function(e){return e===t.serviceId16}))||!e.advertisData)return null;try{var r=Math.floor(10*Math.random())%10==1||!0,i=arrayBufferToHexStringArray(e.advertisData);r&&t.options.reporter.info(REPORT_EVENT_TYPE,{message:"收到广播",serviceId:t.serviceId,hexArr:i.join(",")});var n=parseInt(i[2],16)-(parseInt(i[2],16)>>2<<2),c=parseInt(i[2],16)>>4,l=o.productId&&o.deviceName?o.productId+"/"+o.deviceName:"",a=l?qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.get8ByteFromStr(""+l.replace("/","")):"",d=!!l,_="",s="",u="",p=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_STATE_MAP[n],D=[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_HAS_BINDED,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_HAS_CONNECTED].indexOf(p)>-1;if(D)u=i.slice(3,11).join("").toLocaleLowerCase(),s=i.slice(11).join("").toLocaleLowerCase(),_=o.productId;else{var v=i.slice(3,9);e.name&&-1===e.name.indexOf("_")&&(e.name=e.name+"_"+v.slice(0,2).join("")),_=hex2str(i.slice(9))}r&&t.options.reporter.info(REPORT_EVENT_TYPE,{message:"解析广播",serviceId:t.serviceId,data:{bindState:p||"x",targetDeviceId:l,targetDeviceIdentify:a,deviceUserIdentify:s||"x",deviceProductId:_||"x",deviceIdentify:u||"x"}});var E=function(){var r=tslib_1.__assign(tslib_1.__assign({},e),{standard:!0,bindState:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_STATE_MAP[p],serviceId:t.serviceId,deviceName:o.deviceName||"",productId:_,extendInfo:{moduleVersion:c}});return console.log("---设备匹配成功---",r),r};return d&&D&&u===a?E():d||D?null:E()}catch(e){console.error("llsync device filter error",e),t.options.reporter.error(REPORT_EVENT_TYPE,{message:"协议广播出错",error:e})}},t}(BleComboLLSync_1.BleComboLLSyncDeviceAdapter);exports.BleComboDualModeDeviceAdapter=BleComboDualModeDeviceAdapter;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BleComboDualModeDeviceAdapter4H5=exports.BleComboDualModeDeviceAdapter=exports.BleComboDualModeDeviceAdapterBase=void 0;var tslib_1=require("tslib"),BleComboLLSync_1=require("../BleComboLLSync"),qcloud_iotexplorer_bluetooth_adapter_1=require("qcloud-iotexplorer-bluetooth-adapter"),qcloud_iotexplorer_bluetooth_adapter_llsync_1=require("qcloud-iotexplorer-bluetooth-adapter-llsync"),hex2str=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.hex2str,REPORT_EVENT_TYPE=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,arrayBufferToHexStringArray=qcloud_iotexplorer_bluetooth_adapter_1.blueToothHelper.arrayBufferToHexStringArray,DUALMODE_SERVICEID="0000FFE8-65D0-4E20-B56A-E493541BA4E2",DUALMODE_SERVICEID16="0000FFE8-0000-1000-8000-00805F9B34FB",LLSyncDualModeDeviceAdapter=function(e){function o(){return null!==e&&e.apply(this,arguments)||this}return tslib_1.__extends(o,e),o.serviceId16=DUALMODE_SERVICEID16,o.serviceId=DUALMODE_SERVICEID,o}(qcloud_iotexplorer_bluetooth_adapter_llsync_1.LLSyncDeviceAdapter),BleComboDualModeDeviceAdapterBase=function(e){function o(o){var t=e.call(this,o)||this;return t._bleDeviceAdapter=new LLSyncDualModeDeviceAdapter(o),["CONNECT_AUTH","DEVICE_INFO","BIND_AUTH","UNBIND_AUTH"].forEach((function(e){t.on(e,(function(){for(var o,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];console.info("emit connect_auth from dualmode adapter",r),(o=t._bleDeviceAdapter).emit.apply(o,tslib_1.__spread([e],r))}))})),t.on("connect",(function(e){console.info("ble connected",e),t._bleDeviceAdapter._deviceConnected=!0})),t.on("disconnect",(function(e){console.info("ble disconnect",e),t._bleDeviceAdapter._deviceConnected=!1})),t}return tslib_1.__extends(o,e),o.injectOptions=function(e){exports.BleComboDualModeDeviceAdapter.options=e,qcloud_iotexplorer_bluetooth_adapter_llsync_1.LLSyncDeviceAdapter.injectOptions(e)},o.prototype.toString=function(){return"[BleComboDualModeDeviceAdapter]"},Object.defineProperty(o.prototype,"authorized",{get:function(){return this._bleDeviceAdapter.authorized},enumerable:!1,configurable:!0}),o.prototype.authenticateConnection=function(e){return this._bleDeviceAdapter.authenticateConnection(e)},o.prototype.bindDevice=function(e){return this._bleDeviceAdapter.bindDevice(e)},o.prototype.unbindDevice=function(e){return this._bleDeviceAdapter.unbindDevice.call(this._bleDeviceAdapter,e)},o.prototype.controlDevice=function(e){return this._bleDeviceAdapter.controlDevice.call(this._bleDeviceAdapter,e)},o.prototype.init=function(){return this._bleDeviceAdapter.init()},o.serviceId16=DUALMODE_SERVICEID16,o.serviceId=DUALMODE_SERVICEID,o.deviceFilter=function(e,o){var t,r,i;if(!e.advertisServiceUUIDs||!e.advertisServiceUUIDs.find((function(e){return e===exports.BleComboDualModeDeviceAdapter.serviceId16}))||!e.advertisData)return null;try{var l=Math.floor(10*Math.random())%10==1||!0,a=arrayBufferToHexStringArray(e.advertisData);l&&(null===(t=exports.BleComboDualModeDeviceAdapter.options.reporter)||void 0===t||t.info(REPORT_EVENT_TYPE,{message:"收到广播",serviceId:exports.BleComboDualModeDeviceAdapter.serviceId,hexArr:a.join(",")}));var n=parseInt(a[2],16)-(parseInt(a[2],16)>>2<<2),c=parseInt(a[2],16)>>4,d=o.productId&&o.deviceName?o.productId+"/"+o.deviceName:"",_=d?qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.get8ByteFromStr(""+d.replace("/","")):"",p=!!d,s="",u="",D="",v=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_STATE_MAP[n],b=[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_HAS_BINDED,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_HAS_CONNECTED].indexOf(v)>-1;if(b)D=a.slice(3,11).join("").toLocaleLowerCase(),u=a.slice(11).join("").toLocaleLowerCase(),s=o.productId;else{var A=a.slice(3,9);e.name&&-1===e.name.indexOf("_")&&(e.name=e.name+"_"+A.slice(0,2).join("")),s=hex2str(a.slice(9))}l&&(null===(r=exports.BleComboDualModeDeviceAdapter.options.reporter)||void 0===r||r.info(REPORT_EVENT_TYPE,{message:"解析广播",serviceId:exports.BleComboDualModeDeviceAdapter.serviceId,data:{bindState:v||"x",targetDeviceId:d,targetDeviceIdentify:_,deviceUserIdentify:u||"x",deviceProductId:s||"x",deviceIdentify:D||"x"}}));var E=function(){var t=tslib_1.__assign(tslib_1.__assign({},e),{standard:!0,bindState:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_STATE_MAP[v],serviceId:exports.BleComboDualModeDeviceAdapter.serviceId,deviceName:o.deviceName||"",productId:s,extendInfo:{moduleVersion:c}});return console.log("---设备匹配成功---",t),t};return p&&b&&D===_?E():p||b?null:E()}catch(e){console.error("llsync device filter error",e),null===(i=exports.BleComboDualModeDeviceAdapter.options.reporter)||void 0===i||i.error(REPORT_EVENT_TYPE,{message:"协议广播出错",error:e})}},o}(BleComboLLSync_1.BleComboLLSyncDeviceAdapterBase);exports.BleComboDualModeDeviceAdapterBase=BleComboDualModeDeviceAdapterBase,exports.BleComboDualModeDeviceAdapter=qcloud_iotexplorer_bluetooth_adapter_1.AdapterDeviceAdapter4Mp(BleComboDualModeDeviceAdapterBase),exports.BleComboDualModeDeviceAdapter4H5=qcloud_iotexplorer_bluetooth_adapter_1.AdapterDeviceAdapter4H5(BleComboDualModeDeviceAdapterBase);
//# sourceMappingURL=BleComboDualModeDeviceAdapter.js.map

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BleComboEspDeviceAdapter=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_bluetooth_adapter_1=require("qcloud-iotexplorer-bluetooth-adapter"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),constants=tslib_1.__importStar(require("./constants")),qcloud_iotexplorer_bluetooth_adapter_llsync_1=require("qcloud-iotexplorer-bluetooth-adapter-llsync"),_a=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils,envDetect=_a.envDetect,byteUtil=_a.byteUtil,hex2str=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.hex2str,BleComboEspDeviceAdapter=function(t){function e(e){var n,i,s=t.call(this,e)||this;return s.version=0,s.supportSendSplitDataMinimumVersion=512,s.sequence=0,s.waitVersionReplyTimeout=3e3,s.waitCustomDataTimeout=3e4,s.waitWiFiStateTimeout=3e4,s.MODE_TYPE_MAP=((n={})[constants.REPORT_CONNECT_STATE_SUB_TYPE]="wifiConnectStateChange",n[constants.SEND_TOKEN_SUB_TYPE]="tokenStateChange",n[constants.MODULE_ERROR_LOG_REPORT_SUB_TYPE]="moduleLogReport",n),s.MODE_TYPE_MAP_V2=((i={})[constants.REPORT_CONNECT_STATE_SUB_TYPE_V2]="wifiConnectStateChange",i[constants.GET_CUSTOM_DATA_V2]="CustomDataReport",i[constants.VERSION_REPLY_V2]="versionReport",i),s.on("message",s.handleMessageToEmitEvent),s.on("disconnect",(function(){s.initSequence()})),s}return tslib_1.__extends(e,t),e.prototype.initSequence=function(){this.sequence=0},e.prototype.getSequence=function(){return this.sequence++},e.prototype.handleBLEMessage=function(t){var e=parseInt(t[0],16),n=e>>2;return{type:0===this.version?this.MODE_TYPE_MAP[n]||this.MODE_TYPE_MAP_V2[n]:1===this.version?this.MODE_TYPE_MAP[n]:this.MODE_TYPE_MAP_V2[n],subType:n,data:t}},e.prototype.handleMessageToEmitEvent=function(t){var e=t.type,n=t.subType,i=t.data;this.emit(e,{subType:n,data:i})},e.prototype.connectDevice=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return[4,t.prototype.connectDevice.call(this,e)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,6,,7]),[4,this.getVersion()];case 3:return n.sent().version>=this.supportSendSplitDataMinimumVersion?[4,this.setMtu(constants.DEFAULT_MTU)]:[3,5];case 4:n.sent(),n.label=5;case 5:return[3,7];case 6:return n.sent(),[3,7];case 7:return[2]}}))}))},e.prototype.setMtu=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return console.log("---set---mtu",t),envDetect.isIOS?[2]:[4,this.setBLEMTU({deviceId:this.deviceId,mtu:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.buildBleData=function(t){var e=t.mode,n=t.subType,i=t.data,s=[],o=[];if(s[0]=n<<2|e,s[1]=constants.BLE_DATA_TYPE_P2E,s[2]>=255)throw{code:"BLE_GATT_SERVER_NEED_RESTART"};if(i instanceof Int8Array!=!0)throw{msg:"传入的数据用于组装BleData的格式不对,需要Int8Array"};if(i.length>=255)throw{code:"SSID_OR_PASSWORD_OVERLOAD"};if(this.version>=this.supportSendSplitDataMinimumVersion&&i.length>constants.DEFAULT_DATA_LENGTH_CONSIDER_MTU-4)for(var r=constants.DEFAULT_DATA_LENGTH_CONSIDER_MTU-4-2,a=0;a<i.length;a+=r){var c=Math.min(i.length-a,r),_=i.length-a;_-r>0?o.push(tslib_1.__spread([s[0],s[1]|constants.SPLIT_FLAG,this.getSequence(),c+2,_,0],i.slice(a,a+r))):o.push(tslib_1.__spread([s[0],s[1],this.getSequence(),c],i.slice(a)))}else s[2]=this.getSequence(),s[3]=i.length,0===i.length?s[4]=0:i.map((function(t){return s.push(t)})),o.push(s);return o},e.prototype.writeData=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:e=0,n.label=1;case 1:return e<t.length?(console.log("===data===",e,t[e]),[4,this.write(byteUtil.byteArrayToHex(t[e]))]):[3,4];case 2:n.sent(),n.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))},e.prototype.getVersion=function(){var t=this;return new Promise((function(e,n){t.writeData(t.buildBleData({mode:constants.CONTROL_MODE,subType:constants.GET_VERSION_V2,data:new Int8Array([])})).catch((function(t){n(tslib_1.__assign(tslib_1.__assign({},t),{code:"WRITE_ERROR"}))}));var i=setTimeout((function(){n({code:"TIMEOUT"})}),t.waitVersionReplyTimeout);t.on("moduleLogReport",(function(){t.version=1,clearTimeout(i),e({version:t.version})})),t.on("versionReport",(function(n){var s=n.data;clearTimeout(i);var o=parseInt(s[3]);t.version=2===o?2:parseInt(s.slice(s.length-2).join(""),16),console.log("get---version--",t.version),e({version:t.version})}))}))},e.prototype.sendSwitchWiFi=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t;return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return t=this.buildBleData({mode:constants.CONTROL_MODE,subType:constants["STA_SUB_TYPE"+(this.version>1?"_V2":"")],data:new Int8Array([1])}),[4,this.writeData(t)];case 1:return e.sent(),[2,t]}}))}))},e.prototype.sendSsid=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return e=this.buildBleData({mode:constants.DATA_MODE,subType:constants["SSID_SUB_TYPE"+(this.version>1?"_V2":"")],data:byteUtil.getBytesByString(t)}),[4,this.writeData(e)];case 1:return n.sent(),[2,e]}}))}))},e.prototype.sendPassword=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return e=this.buildBleData({mode:constants.DATA_MODE,subType:constants["PASSWORD_SUB_TYPE"+(this.version>1?"_V2":"")],data:byteUtil.getBytesByString(t)}),[4,this.writeData(e)];case 1:return n.sent(),[2,e]}}))}))},e.prototype.getCustomData=function(t){var e=this,n=t.mode,i=t.subType,s=t.data;return new Promise((function(t,o){if(e.version>=2){var r=i===constants.SEND_TOKEN_SUB_TYPE?{cmdType:3,token:s}:{cmdType:4,log:"1"};s=JSON.stringify(r),i=constants.GET_CUSTOM_DATA_V2,n=constants.DATA_MODE,console.log("send data",i,n,s)}s instanceof Int8Array!=!0&&("string"==typeof s?s=byteUtil.getBytesByString(s):Array.isArray(s)&&(s=new Int8Array(s))),e.writeData(e.buildBleData({mode:n,subType:i,data:s})).catch((function(t){o(tslib_1.__assign(tslib_1.__assign({},t),{code:"WRITE_ERROR"}))}));var a=setTimeout((function(){o({code:"TIMEOUT"})}),e.waitCustomDataTimeout),c="";c=e.version<=1?i===constants.SEND_TOKEN_SUB_TYPE?"tokenStateChange":"moduleLogReport":"CustomDataReport";var _=[];e.on(c,(function(e){var n=e.data;if(clearTimeout(a),"14"!==n[1]){_=_.concat(n.slice(4));var i=hex2str(_);try{~i.indexOf("{")?t(JSON.parse(i)):t(i)}catch(t){return o(tslib_1.__assign({code:"ERROR"},t))}}else _=_.concat(n.slice(6))}))}))},e.prototype.getWifiConnectState=function(){var t=this;return new Promise((function(e,n){t.writeData(t.buildBleData({mode:constants.CONTROL_MODE,subType:constants["CONNECT_AP_SUB_TYPE"+(t.version>1?"_V2":"")],data:new Int8Array([])}));var i,s,o=setTimeout((function(){n({code:"TIMEOUT"})}),t.waitWiFiStateTimeout),r=[];t.on("wifiConnectStateChange",(function(t){var a,c=t.data;if(clearTimeout(o),void 0===i){i="14"===c[1].toString();var _=parseInt(c[i?7:5],16);if(_!==constants.CONNECT_WIFI_SUCCESS)return n({code:"ERROR",connectState:_})}if(i&&r.length){var u="14"===c[1].toString()?6:4;a=c.slice(u)}else{u=i?11:9;s=parseInt(c[u-1],16),a=c.length>u?c.slice(u):[]}(r=r.concat(a)).length!==s&&i||e(r)}))}))},e.serviceId="0000FFFF-0000-1000-8000-00805F9B34FB",e.PRODUCT_INITED=!0,e.BLECOMBO_ESP_PRODUCTID="BLECOMBO",e.deviceFilter=function(t){if(t.advertisServiceUUIDs&&t.advertisServiceUUIDs.find((function(t){return e.serviceId===t})))return tslib_1.__assign(tslib_1.__assign({},t),{serviceId:e.serviceId,deviceName:"",productId:e.BLECOMBO_ESP_PRODUCTID})},e}(qcloud_iotexplorer_bluetooth_adapter_1.DeviceAdapter4Mp);exports.BleComboEspDeviceAdapter=BleComboEspDeviceAdapter;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BleComboEspDeviceAdapter=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_bluetooth_adapter_1=require("qcloud-iotexplorer-bluetooth-adapter"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),constants=tslib_1.__importStar(require("./constants")),qcloud_iotexplorer_bluetooth_adapter_llsync_1=require("qcloud-iotexplorer-bluetooth-adapter-llsync"),_a=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils,envDetect=_a.envDetect,byteUtil=_a.byteUtil,hex2str=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.hex2str,BleComboEspDeviceAdapter=function(t){function e(e){var n,i,s=t.call(this,e)||this;return s.version=0,s.supportSendSplitDataMinimumVersion=512,s.sequence=0,s.waitVersionReplyTimeout=3e3,s.waitCustomDataTimeout=3e4,s.waitWiFiStateTimeout=3e4,s.MODE_TYPE_MAP=((n={})[constants.REPORT_CONNECT_STATE_SUB_TYPE]="wifiConnectStateChange",n[constants.SEND_TOKEN_SUB_TYPE]="tokenStateChange",n[constants.MODULE_ERROR_LOG_REPORT_SUB_TYPE]="moduleLogReport",n),s.MODE_TYPE_MAP_V2=((i={})[constants.REPORT_CONNECT_STATE_SUB_TYPE_V2]="wifiConnectStateChange",i[constants.GET_CUSTOM_DATA_V2]="CustomDataReport",i[constants.VERSION_REPLY_V2]="versionReport",i),s.on("message",s.handleMessageToEmitEvent),s.on("disconnect",(function(){s.initSequence()})),s}return tslib_1.__extends(e,t),e.prototype.initSequence=function(){this.sequence=0},e.prototype.getSequence=function(){return this.sequence++},e.prototype.handleBLEMessage=function(t){var e=parseInt(t[0],16)>>2;return{type:0===this.version?this.MODE_TYPE_MAP[e]||this.MODE_TYPE_MAP_V2[e]:1===this.version?this.MODE_TYPE_MAP[e]:this.MODE_TYPE_MAP_V2[e],subType:e,data:t}},e.prototype.handleMessageToEmitEvent=function(t){var e=t.type,n=t.subType,i=t.data;this.emit(e,{subType:n,data:i})},e.prototype.connectDevice=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return[4,t.prototype.connectDevice.call(this,e)];case 1:n.sent(),n.label=2;case 2:return n.trys.push([2,6,,7]),[4,this.getVersion()];case 3:return n.sent().version>=this.supportSendSplitDataMinimumVersion?[4,this.setMtu(constants.DEFAULT_MTU)]:[3,5];case 4:n.sent(),n.label=5;case 5:return[3,7];case 6:return n.sent(),[3,7];case 7:return[2]}}))}))},e.prototype.setMtu=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return console.log("---set---mtu",t),envDetect.isIOS?[2]:[4,this.setBLEMTU({deviceId:this.deviceId,mtu:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.buildBleData=function(t){var e=t.mode,n=t.subType,i=t.data,s=[],o=[];if(s[0]=n<<2|e,s[1]=constants.BLE_DATA_TYPE_P2E,s[2]>=255)throw{code:"BLE_GATT_SERVER_NEED_RESTART"};if(i instanceof Int8Array!=!0)throw{msg:"传入的数据用于组装BleData的格式不对,需要Int8Array"};if(i.length>=255)throw{code:"SSID_OR_PASSWORD_OVERLOAD"};if(this.version>=this.supportSendSplitDataMinimumVersion&&i.length>constants.DEFAULT_DATA_LENGTH_CONSIDER_MTU-4)for(var r=constants.DEFAULT_DATA_LENGTH_CONSIDER_MTU-4-2,a=0;a<i.length;a+=r){var c=Math.min(i.length-a,r),_=i.length-a;_-r>0?o.push(tslib_1.__spread([s[0],s[1]|constants.SPLIT_FLAG,this.getSequence(),c+2,_,0],i.slice(a,a+r))):o.push(tslib_1.__spread([s[0],s[1],this.getSequence(),c],i.slice(a)))}else s[2]=this.getSequence(),s[3]=i.length,0===i.length?s[4]=0:i.map((function(t){return s.push(t)})),o.push(s);return o},e.prototype.writeData=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:e=0,n.label=1;case 1:return e<t.length?(console.log("===data===",e,t[e]),[4,this.write(byteUtil.byteArrayToHex(t[e]))]):[3,4];case 2:n.sent(),n.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))},e.prototype.getVersion=function(){var t=this;return new Promise((function(e,n){t.writeData(t.buildBleData({mode:constants.CONTROL_MODE,subType:constants.GET_VERSION_V2,data:new Int8Array([])})).catch((function(t){n(tslib_1.__assign(tslib_1.__assign({},t),{code:"WRITE_ERROR"}))}));var i=setTimeout((function(){n({code:"TIMEOUT"})}),t.waitVersionReplyTimeout);t.on("moduleLogReport",(function(){t.version=1,clearTimeout(i),e({version:t.version})})),t.on("versionReport",(function(n){var s=n.data;clearTimeout(i);var o=parseInt(s[3]);t.version=2===o?2:parseInt(s.slice(s.length-2).join(""),16),console.log("get---version--",t.version),e({version:t.version})}))}))},e.prototype.sendSwitchWiFi=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t;return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return t=this.buildBleData({mode:constants.CONTROL_MODE,subType:constants["STA_SUB_TYPE"+(this.version>1?"_V2":"")],data:new Int8Array([1])}),[4,this.writeData(t)];case 1:return e.sent(),[2,t]}}))}))},e.prototype.sendSsid=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return e=this.buildBleData({mode:constants.DATA_MODE,subType:constants["SSID_SUB_TYPE"+(this.version>1?"_V2":"")],data:byteUtil.getBytesByString(t)}),[4,this.writeData(e)];case 1:return n.sent(),[2,e]}}))}))},e.prototype.sendPassword=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return e=this.buildBleData({mode:constants.DATA_MODE,subType:constants["PASSWORD_SUB_TYPE"+(this.version>1?"_V2":"")],data:byteUtil.getBytesByString(t)}),[4,this.writeData(e)];case 1:return n.sent(),[2,e]}}))}))},e.prototype.getCustomData=function(t){var e=this,n=t.mode,i=t.subType,s=t.data;return new Promise((function(t,o){if(e.version>=2){var r=i===constants.SEND_TOKEN_SUB_TYPE?{cmdType:3,token:s}:{cmdType:4,log:"1"};s=JSON.stringify(r),i=constants.GET_CUSTOM_DATA_V2,n=constants.DATA_MODE,console.log("send data",i,n,s)}s instanceof Int8Array!=!0&&("string"==typeof s?s=byteUtil.getBytesByString(s):Array.isArray(s)&&(s=new Int8Array(s))),e.writeData(e.buildBleData({mode:n,subType:i,data:s})).catch((function(t){o(tslib_1.__assign(tslib_1.__assign({},t),{code:"WRITE_ERROR"}))}));var a=setTimeout((function(){o({code:"TIMEOUT"})}),e.waitCustomDataTimeout),c="";c=e.version<=1?i===constants.SEND_TOKEN_SUB_TYPE?"tokenStateChange":"moduleLogReport":"CustomDataReport";var _=[];e.on(c,(function(e){var n=e.data;if(clearTimeout(a),"14"!==n[1]){_=_.concat(n.slice(4));var i=hex2str(_);try{~i.indexOf("{")?t(JSON.parse(i)):t(i)}catch(t){return o(tslib_1.__assign({code:"ERROR"},t))}}else _=_.concat(n.slice(6))}))}))},e.prototype.getWifiConnectState=function(){var t=this;return new Promise((function(e,n){t.writeData(t.buildBleData({mode:constants.CONTROL_MODE,subType:constants["CONNECT_AP_SUB_TYPE"+(t.version>1?"_V2":"")],data:new Int8Array([])}));var i,s,o=setTimeout((function(){n({code:"TIMEOUT"})}),t.waitWiFiStateTimeout),r=[];t.on("wifiConnectStateChange",(function(t){var a,c=t.data;if(clearTimeout(o),void 0===i){i="14"===c[1].toString();var _=parseInt(c[i?7:5],16);if(_!==constants.CONNECT_WIFI_SUCCESS)return n({code:"ERROR",connectState:_})}if(i&&r.length){var u="14"===c[1].toString()?6:4;a=c.slice(u)}else{u=i?11:9;s=parseInt(c[u-1],16),a=c.length>u?c.slice(u):[]}(r=r.concat(a)).length!==s&&i||e(r)}))}))},e.serviceId="0000FFFF-0000-1000-8000-00805F9B34FB",e.PRODUCT_INITED=!0,e.BLECOMBO_ESP_PRODUCTID="BLECOMBO",e.deviceFilter=function(t){if(t.advertisServiceUUIDs&&t.advertisServiceUUIDs.find((function(t){return e.serviceId===t})))return tslib_1.__assign(tslib_1.__assign({},t),{serviceId:e.serviceId,deviceName:"",productId:e.BLECOMBO_ESP_PRODUCTID})},e}(qcloud_iotexplorer_bluetooth_adapter_1.DeviceAdapter4Mp);exports.BleComboEspDeviceAdapter=BleComboEspDeviceAdapter;
//# sourceMappingURL=BleComboEspDeviceAdapter.js.map
import { Reporter } from 'qcloud-iotexplorer-appdev-sdk';
import { DeviceFilterFunction } from 'qcloud-iotexplorer-bluetooth-adapter';
import { LLSyncDeviceAdapterBase } from 'qcloud-iotexplorer-bluetooth-adapter-llsync';
export declare const LLSyncComboConfig: {

@@ -14,2 +15,50 @@ waitGetDeviceInfoTime: number;

}
export declare class BleComboLLSyncDeviceAdapterBase extends LLSyncDeviceAdapterBase {
static options: LLSyncComboDeviceAdapterOptions;
static serviceId16: string;
static serviceId: string;
static deviceFilter: DeviceFilterFunction;
static injectOptions(options: LLSyncComboDeviceAdapterOptions): void;
bleVersion: any;
reporter: Reporter;
notifyMessage({ type, data }?: any): Promise<any>;
connectDevice(params: any): Promise<void>;
afterConnectDevice(): Promise<string>;
getDeviceInfo(): Promise<{
version: number;
mtu: number;
needSetMtu: boolean;
deviceName: string;
}>;
/**
* @description WiFi模式设置
* @returns boolean 表示设置WiFi模式成功或者失败
*/
setWiFiMode(mode?: string): Promise<boolean>;
/**
*
* @param params0 {Object} 配网的WiFi信息
* @param parmas0.ssid {String} WiFi的ssid
* @param params0.password {String} WiFi的密码
* @returns {boolean} 传输WiFi结果
*/
setWiFiInfo({ ssid, password, }: {
ssid: string;
password: string;
}): Promise<boolean>;
/**
* @description 下发WiFi连接请求,并获取连接状态
* @returns {boolean} WiFi连接状态
*/
sendConnectWiFiAndGetWiFiConnectState(): Promise<{
connected: boolean;
ssid: string;
}>;
sendToken({ token, }: {
token: string;
}): Promise<boolean>;
getModuleLog(): Promise<{
logStr: string;
}>;
}
export declare const BleComboLLSyncDeviceAdapter: (new (...args: any[]) => {

@@ -105,149 +154,90 @@ bluetoothAdapter: import("qcloud-iotexplorer-bluetooth-adapter").BlueToothAdapter;

emit: (type: any, ...argus: any[]) => Promise<any>;
}) & {
new (props: any): {
bleVersion: any;
reporter: Reporter;
notifyMessage({ type, data }?: any): Promise<any>;
connectDevice(params: any): Promise<void>;
afterConnectDevice(): Promise<string>;
getDeviceInfo(): Promise<{
version: number;
mtu: number;
needSetMtu: boolean;
deviceName: string;
}>;
/**
* @description WiFi模式设置
* @returns boolean 表示设置WiFi模式成功或者失败
*/
setWiFiMode(mode?: string): Promise<boolean>;
/**
*
* @param params0 {Object} 配网的WiFi信息
* @param parmas0.ssid {String} WiFi的ssid
* @param params0.password {String} WiFi的密码
* @returns {boolean} 传输WiFi结果
*/
setWiFiInfo({ ssid, password, }: {
ssid: string;
password: string;
}): Promise<boolean>;
/**
* @description 下发WiFi连接请求,并获取连接状态
* @returns {boolean} WiFi连接状态
*/
sendConnectWiFiAndGetWiFiConnectState(): Promise<{
connected: boolean;
ssid: string;
}>;
sendToken({ token, }: {
token: string;
}): Promise<boolean>;
getModuleLog(): Promise<{
logStr: string;
}>;
mtu: number;
protocol: import("qcloud-iotexplorer-bluetooth-adapter-llsync/lib/base/LLSync/LLSyncProtocol").LLSyncProtocol;
handleBLEMessage(hex: any): {
type: any;
data: any;
};
wait4EventResponse<T>(eventName: string, handler: (data: any) => T, { timeout, timeoutCode, timeoutHandler, wrapSplitDataMode, shouldWrapSplitDataFn, afterBindEvent, }?: import("qcloud-iotexplorer-bluetooth-adapter-llsync").Wait4EventResponseOptions): Promise<T>;
writeAndWait4Response<T_1>(data2Write: any, eventName: string, handler: (data: any) => T_1, { timeout, timeoutCode, timeoutHandler, writeId, wrapSplitDataMode, shouldWrapSplitDataFn, }?: import("qcloud-iotexplorer-bluetooth-adapter-llsync").WriteAndWait4ResponseOptions): Promise<T_1>;
writeMtuResult(type: "success" | "fail"): void;
sliceData(data: any, tmpData: any, mode: any): string[];
writeData(data: any, { writeId, waitGap, retryTime, }?: {
writeId?: string;
waitGap?: number;
retryTime?: number;
}): Promise<any>;
setMtu(mtu: any): Promise<any>;
bluetoothAdapter: import("qcloud-iotexplorer-bluetooth-adapter").BlueToothAdapter;
extendInfo: any;
_h5Websocket: any;
_name: string;
_deviceId: string;
_deviceName: string;
_deviceConnected: boolean;
_productId: string;
_deviceRegistered: boolean;
_services: any[];
characteristicsMap: {};
_actions: Pick<import("qcloud-iotexplorer-bluetooth-adapter/lib/base/types").BlueToothActions, "registerDevice" | "bindDevice" | "reportDeviceData">;
_bluetoothApi: any;
_getNotifyId({ serviceId }?: {
serviceId?: string;
}): any;
readonly _writeId: any;
readonly _notifyId: any;
readonly _readId: any;
readonly _indicateId: any;
readonly deviceId: string;
readonly productId: string;
}) & typeof BleComboLLSyncDeviceAdapterBase;
export declare const BleComboLLSyncDeviceAdapter4H5: (new (...props: any[]) => {
write(data: any, writeId: any): Promise<void>;
bluetoothAdapter: import("qcloud-iotexplorer-bluetooth-adapter").BlueToothAdapter;
extendInfo: any;
_h5Websocket: any;
_name: string;
_deviceId: string;
_deviceName: string;
_deviceConnected: boolean;
_productId: string;
_deviceRegistered: boolean;
_services: any[];
characteristicsMap: {};
_actions: Pick<import("qcloud-iotexplorer-bluetooth-adapter/lib/base/types").BlueToothActions, "registerDevice" | "bindDevice" | "reportDeviceData">;
_bluetoothApi: any;
_getNotifyId({ serviceId }?: {
serviceId?: string;
}): any;
readonly _writeId: any;
readonly _notifyId: any;
readonly _readId: any;
readonly _indicateId: any;
readonly deviceId: string;
readonly productId: string;
deviceName: string;
readonly isConnected: boolean;
readonly originName: string;
readonly explorerDeviceId: string;
readonly serviceId: any;
readonly deviceInfo: {
productId: string;
deviceName: string;
readonly isConnected: boolean;
readonly originName: string;
readonly explorerDeviceId: string;
readonly serviceId: any;
readonly deviceInfo: {
productId: string;
deviceName: string;
deviceId: string;
explorerDeviceId: string;
name: string;
};
init(): Promise<void>;
registerDevice(): Promise<void>;
bindDevice({ familyId, roomId, }?: {
familyId?: string;
roomId?: string;
}): Promise<string>;
onBleConnectionStateChange({ connected }: {
connected: any;
}): void;
onBLECharacteristicValueChange({ serviceId, characteristicId, value, }: {
serviceId: any;
characteristicId: any;
value: any;
}): Promise<void>;
disconnectDevice(): void;
write(data: any, { writeId, serviceId, }?: {
writeId?: string;
serviceId?: string;
}): Promise<void>;
_write(value: any, { writeId, serviceId, }?: {
writeId?: string;
serviceId?: string;
}): Promise<void>;
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;
destroy(): void;
_cleanupMap: {};
_normalizeError(error: any): any;
cleanup(action?: string): void;
addCleanupTask(action: any, cleanupFn: any): void;
on: (type: string, listener: import("event-emitter-for-miniprogram").listenerCallback) => import("event-emitter-for-miniprogram").default;
once: (type: any, listener: import("event-emitter-for-miniprogram").listenerCallback) => import("event-emitter-for-miniprogram").default;
off: (type: any, listener?: import("event-emitter-for-miniprogram").listenerCallback) => import("event-emitter-for-miniprogram").default;
emit: (type: any, ...argus: any[]) => Promise<any>;
deviceId: string;
explorerDeviceId: string;
name: string;
};
options: LLSyncComboDeviceAdapterOptions;
serviceId16: string;
serviceId: string;
deviceFilter: DeviceFilterFunction;
injectOptions(options: LLSyncComboDeviceAdapterOptions): void;
};
init(): Promise<void>;
handleBLEMessage(hexStrArr: string[], { serviceId, characteristicId }: {
serviceId: string;
characteristicId: string;
}): import("qcloud-iotexplorer-bluetooth-adapter").BLEMessageResponse;
registerDevice(): Promise<void>;
bindDevice({ familyId, roomId, }?: {
familyId?: string;
roomId?: string;
}): Promise<string>;
onBleConnectionStateChange({ connected }: {
connected: any;
}): void;
onBLECharacteristicValueChange({ serviceId, characteristicId, value, }: {
serviceId: any;
characteristicId: any;
value: any;
}): Promise<void>;
disconnectDevice(): void;
connectDevice({ autoNotify, }?: {
autoNotify?: boolean;
}): Promise<void>;
_write(value: any, { writeId, serviceId, }?: {
writeId?: string;
serviceId?: string;
}): Promise<void>;
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;
destroy(): void;
_cleanupMap: {};
_normalizeError(error: any): any;
cleanup(action?: string): void;
addCleanupTask(action: any, cleanupFn: any): void;
on: (type: string, listener: import("event-emitter-for-miniprogram").listenerCallback) => import("event-emitter-for-miniprogram").default;
once: (type: any, listener: import("event-emitter-for-miniprogram").listenerCallback) => import("event-emitter-for-miniprogram").default;
off: (type: any, listener?: import("event-emitter-for-miniprogram").listenerCallback) => import("event-emitter-for-miniprogram").default;
emit: (type: any, ...argus: any[]) => Promise<any>;
}) & typeof BleComboLLSyncDeviceAdapterBase;

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

"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.BleComboLLSyncDeviceAdapter=exports.LLSyncComboConfig=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),qcloud_iotexplorer_bluetooth_adapter_1=require("qcloud-iotexplorer-bluetooth-adapter"),qcloud_iotexplorer_bluetooth_adapter_llsync_1=require("qcloud-iotexplorer-bluetooth-adapter-llsync"),hex2str=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.hex2str,U16ToHexString=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.U16ToHexString,U8ToHexString=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.U8ToHexString,REPORT_EVENT_TYPE=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,arrayBufferToHexStringArray=qcloud_iotexplorer_bluetooth_adapter_1.blueToothHelper.arrayBufferToHexStringArray,byteUtil=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.byteUtil;exports.LLSyncComboConfig={waitGetDeviceInfoTime:1e4,waitSetWiFiModeTime:1e4,waitSetWiFiInfoTime:1e4,waitSetWiFiConnectTime:2e4,waitSetWiFiTokenTime:1e4,waitDevLogInfoTime:1e4},exports.BleComboLLSyncDeviceAdapter=qcloud_iotexplorer_bluetooth_adapter_1.AdapterDeviceAdapter4Mp(((_a=function(t){function e(){var o=null!==t&&t.apply(this,arguments)||this;return o.reporter={info:function(t,_){void 0===t&&(t=""),void 0===_&&(_={});var r=_.message,n=void 0===r?"":r,i=tslib_1.__rest(_,["message"]),l=o,s=l.explorerDeviceId,a=l.deviceId,c=l.isConnected;e.options.reporter.info(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{serviceId:e.serviceId,message:n||(t&&qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ACTION_DESC[t]?t+"("+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ACTION_DESC[t]+")":t),timeCost:i.timeCost||0,action:t,data:tslib_1.__assign({deviceId:s,bleDeviceId:a,isConnected:c},i)})},error:function(t,_){void 0===t&&(t=""),void 0===_&&(_={});var r=_.error,n=tslib_1.__rest(_,["error"]),i=o,l=i.explorerDeviceId,s=i.deviceId,a=i.isConnected;r.code&&qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[r.code]&&(r.msg=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[r.code]),e.options.reporter.error(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{message:t&&qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[t]&&t+"("+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[t]+":"+(r&&(r.message||r.errMsg||r.msg||r.code))+")",timeCost:n.timeCost||0,action:t,error:r,data:tslib_1.__assign(tslib_1.__assign({deviceId:l,bleDeviceId:s,isConnected:a},n),r)})}},o}return tslib_1.__extends(e,t),e.injectOptions=function(t){e.options=t},e.prototype.notifyMessage=function(t){var e=void 0===t?{}:t,o=e.type,_=e.data;if("unknown"!==o)return console.log("check this in notifyMessage",this,{type:o,data:_}),this.emit(o,{type:o,data:_})},e.prototype.connectDevice=function(e){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,t.prototype.connectDevice.call(this,e)];case 1:return o.sent(),[4,this.afterConnectDevice()];case 2:return o.sent(),[2]}}))}))},e.prototype.afterConnectDevice=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var t,e,o,_,r;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return[4,this.getDeviceInfo()];case 1:if(t=n.sent(),e=t.version,o=t.mtu,_=t.needSetMtu,r=t.deviceName,this.deviceName=r,this.bleVersion=e,this.mtu=o,this.reporter.info("CONNECT_DEVICE",{data:{version:e,mtu:o,needSetMtu:_,deviceName:r}}),!_)return[3,5];n.label=2;case 2:return n.trys.push([2,4,,5]),[4,this.setMtu(this.mtu)];case 3:return n.sent(),this.writeMtuResult("success"),[3,5];case 4:return n.sent(),this.writeMtuResult("fail"),[3,5];case 5:return[2,r]}}))}))},e.prototype.getDeviceInfo=function(){return this.writeAndWait4Response(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEVICE_INFO],qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_INVALID};var e=parseInt(t.slice(2,3).join(""),16),o=parseInt(t.slice(3,5).join(""),16),_=!!(o>>15),r=8191&o,n=parseInt(t[5],16),i=hex2str(t.slice(6).join(""));if(n!==i.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_INVALID};return{version:e,mtu:r,needSetMtu:_,deviceName:i}}),{timeout:exports.LLSyncComboConfig.waitGetDeviceInfoTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.WAIT_GET_DEVICE_INFO_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.setWiFiMode=function(t){void 0===t&&(t=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.STA_WIFI_MODE);var e=""+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE]+U8ToHexString(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.WIFI_MODE_MAP[t]);return this.writeAndWait4Response(e,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE_RESULT,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE_RESULT_INVALID};return!parseInt(t.slice(2,3).join(""),16)}),{timeout:exports.LLSyncComboConfig.waitSetWiFiModeTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.setWiFiInfo=function(t){var e=t.ssid,o=t.password,_=byteUtil.hexString2hexArray(byteUtil.byteArrayToHex(byteUtil.getBytesByString(e)))||[],r=byteUtil.hexString2hexArray(byteUtil.byteArrayToHex(byteUtil.getBytesByString(o)))||[];console.log("----data----",{ssid:e,password:o,ssidHexArray:_,passwordHexArray:r});var n=this.sliceData(tslib_1.__spread([qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO],U16ToHexString(_.length+r.length),U8ToHexString(_.length)],_,[U8ToHexString(r.length)],r),[tslib_1.__spread([U8ToHexString(_.length)],_),tslib_1.__spread([U8ToHexString(r.length)],r)],qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO);return this.writeAndWait4Response(n,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO_RESULT,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO_RESULT_INVALID};return!parseInt(t.slice(2,3).join(""),16)}),{timeout:exports.LLSyncComboConfig.waitSetWiFiInfoTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.sendConnectWiFiAndGetWiFiConnectState=function(){var t=""+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT];return this.writeAndWait4Response(t,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT_RESULT,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT_RESULT_INVALID};var e=parseInt(t.slice(3,4).join(""),16),o=parseInt(t.slice(5,6).join(""),16),_="";return o&&(_=hex2str(t.slice(6,6+o))),{connected:!e,ssid:_}}),{timeout:exports.LLSyncComboConfig.waitSetWiFiConnectTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.sendToken=function(t){var e=t.token,o=byteUtil.hexString2hexArray(byteUtil.byteArrayToHex(byteUtil.getBytesByString(e)));console.log("----data----",{token:e,tokenHexArray:o});var _=this.sliceData(tslib_1.__spread([qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN],U16ToHexString(o.length)],o),[o],qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN);return this.writeAndWait4Response(_,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN_RESULT,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN_RESULT_INVALID};return!parseInt(t.slice(2,3).join(""),16)}),{timeout:exports.LLSyncComboConfig.waitSetWiFiTokenTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e.prototype.getModuleLog=function(){var t=""+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG];return this.writeAndWait4Response(t,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG_INFO,(function(t){if(!t.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG_INFO_INVALID};var e=parseInt(t.slice(1,3).join(""),16);return{logStr:hex2str(t.slice(4,4+e))}}),{timeout:exports.LLSyncComboConfig.waitDevLogInfoTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG_INFO_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},e}(qcloud_iotexplorer_bluetooth_adapter_llsync_1.LLSyncDeviceAdapterBase)).options={reporter:console},_a.serviceId16="0000FFF0-0000-1000-8000-00805F9B34FB",_a.serviceId="0000FFF0-65D0-4E20-B56A-E493541BA4E2",_a.deviceFilter=function(t){if(!t.advertisServiceUUIDs||!t.advertisServiceUUIDs.find((function(t){return t===_a.serviceId16}))||!t.advertisData)return null;try{var e=Math.floor(10*Math.random())%10==1||!0,o=arrayBufferToHexStringArray(t.advertisData);e&&_a.options.reporter.info(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{message:"收到广播",serviceId:_a.serviceId,hexArr:o.join(",")});var _,r=parseInt(o[2],16)>>4,n=o.slice(3,9);return t.name&&-1===t.name.indexOf("_")&&(t.name=t.name+"_"+n.slice(0,2).join("")),_=hex2str(o.slice(9)),e&&_a.options.reporter.info(REPORT_EVENT_TYPE,{message:"解析广播",serviceId:_a.serviceId,data:{deviceProductId:_||"x"}}),tslib_1.__assign(tslib_1.__assign({},t),{standardBleCombo:!0,serviceId:_a.serviceId,deviceName:"",productId:_,extendInfo:{moduleVersion:r}})}catch(t){_a.options.reporter.error(REPORT_EVENT_TYPE,{message:"协议广播出错",error:t})}},_a));
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.BleComboLLSyncDeviceAdapter4H5=exports.BleComboLLSyncDeviceAdapter=exports.BleComboLLSyncDeviceAdapterBase=exports.LLSyncComboConfig=void 0;var tslib_1=require("tslib"),qcloud_iotexplorer_appdev_sdk_1=require("qcloud-iotexplorer-appdev-sdk"),qcloud_iotexplorer_bluetooth_adapter_1=require("qcloud-iotexplorer-bluetooth-adapter"),qcloud_iotexplorer_bluetooth_adapter_llsync_1=require("qcloud-iotexplorer-bluetooth-adapter-llsync"),hex2str=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.hex2str,U16ToHexString=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.U16ToHexString,U8ToHexString=qcloud_iotexplorer_bluetooth_adapter_llsync_1.utils.U8ToHexString,arrayBufferToHexStringArray=qcloud_iotexplorer_bluetooth_adapter_1.blueToothHelper.arrayBufferToHexStringArray,byteUtil=qcloud_iotexplorer_appdev_sdk_1.AppDevSdk.utils.byteUtil;exports.LLSyncComboConfig={waitGetDeviceInfoTime:1e4,waitSetWiFiModeTime:1e4,waitSetWiFiInfoTime:1e4,waitSetWiFiConnectTime:2e4,waitSetWiFiTokenTime:1e4,waitDevLogInfoTime:1e4};var BleComboLLSyncDeviceAdapterBase=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.reporter={info:function(e,o){void 0===e&&(e=""),void 0===o&&(o={});var r=o.message,_=void 0===r?"":r,n=tslib_1.__rest(o,["message"]),l=t,i=l.explorerDeviceId,s=l.deviceId,a=l.isConnected;exports.BleComboLLSyncDeviceAdapter.options.reporter.info(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{serviceId:exports.BleComboLLSyncDeviceAdapter.serviceId,message:_||(e&&qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ACTION_DESC[e]?e+"("+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ACTION_DESC[e]+")":e),timeCost:n.timeCost||0,action:e,data:tslib_1.__assign({deviceId:i,bleDeviceId:s,isConnected:a},n)})},error:function(e,o){void 0===e&&(e=""),void 0===o&&(o={});var r=o.error,_=tslib_1.__rest(o,["error"]),n=t,l=n.explorerDeviceId,i=n.deviceId,s=n.isConnected;r.code&&qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[r.code]&&(r.msg=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[r.code]),exports.BleComboLLSyncDeviceAdapter.options.reporter.error(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{message:e&&qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[e]&&e+"("+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.ERROR_MESSAGES[e]+":"+(r&&(r.message||r.errMsg||r.msg||r.code))+")",timeCost:_.timeCost||0,action:e,error:r,data:tslib_1.__assign(tslib_1.__assign({deviceId:l,bleDeviceId:i,isConnected:s},_),r)})}},t}return tslib_1.__extends(t,e),t.injectOptions=function(e){exports.BleComboLLSyncDeviceAdapter.options=e},t.prototype.notifyMessage=function(e){var t=void 0===e?{}:e,o=t.type,r=t.data;if("unknown"!==o)return console.log("check this in notifyMessage",this,{type:o,data:r}),this.emit(o,{type:o,data:r})},t.prototype.connectDevice=function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,e.prototype.connectDevice.call(this,t)];case 1:return o.sent(),[4,this.afterConnectDevice()];case 2:return o.sent(),[2]}}))}))},t.prototype.afterConnectDevice=function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e,t,o,r,_;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return[4,this.getDeviceInfo()];case 1:if(e=n.sent(),t=e.version,o=e.mtu,r=e.needSetMtu,_=e.deviceName,this.deviceName=_,this.bleVersion=t,this.mtu=o,this.reporter.info("CONNECT_DEVICE",{data:{version:t,mtu:o,needSetMtu:r,deviceName:_}}),!r)return[3,5];n.label=2;case 2:return n.trys.push([2,4,,5]),[4,this.setMtu(this.mtu)];case 3:return n.sent(),this.writeMtuResult("success"),[3,5];case 4:return n.sent(),this.writeMtuResult("fail"),[3,5];case 5:return[2,_]}}))}))},t.prototype.getDeviceInfo=function(){return this.writeAndWait4Response(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEVICE_INFO],qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO,(function(e){if(!e.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_INVALID};var t=parseInt(e.slice(2,3).join(""),16),o=parseInt(e.slice(3,5).join(""),16),r=!!(o>>15),_=8191&o,n=parseInt(e[5],16),l=hex2str(e.slice(6).join(""));if(n!==l.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_INVALID};return{version:t,mtu:_,needSetMtu:r,deviceName:l}}),{timeout:exports.LLSyncComboConfig.waitGetDeviceInfoTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.WAIT_GET_DEVICE_INFO_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},t.prototype.setWiFiMode=function(e){void 0===e&&(e=qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.STA_WIFI_MODE);var t=""+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE]+U8ToHexString(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.WIFI_MODE_MAP[e]);return this.writeAndWait4Response(t,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE_RESULT,(function(e){if(!e.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE_RESULT_INVALID};return!parseInt(e.slice(2,3).join(""),16)}),{timeout:exports.LLSyncComboConfig.waitSetWiFiModeTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_MODE_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},t.prototype.setWiFiInfo=function(e){var t=e.ssid,o=e.password,r=byteUtil.hexString2hexArray(byteUtil.byteArrayToHex(byteUtil.getBytesByString(t)))||[],_=byteUtil.hexString2hexArray(byteUtil.byteArrayToHex(byteUtil.getBytesByString(o)))||[];console.log("----data----",{ssid:t,password:o,ssidHexArray:r,passwordHexArray:_});var n=this.sliceData(tslib_1.__spread([qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO],U16ToHexString(r.length+_.length),U8ToHexString(r.length)],r,[U8ToHexString(_.length)],_),[tslib_1.__spread([U8ToHexString(r.length)],r),tslib_1.__spread([U8ToHexString(_.length)],_)],qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO);return this.writeAndWait4Response(n,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO_RESULT,(function(e){if(!e.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO_RESULT_INVALID};return!parseInt(e.slice(2,3).join(""),16)}),{timeout:exports.LLSyncComboConfig.waitSetWiFiInfoTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_INFO_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},t.prototype.sendConnectWiFiAndGetWiFiConnectState=function(){var e=""+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT];return this.writeAndWait4Response(e,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT_RESULT,(function(e){if(!e.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT_RESULT_INVALID};var t=parseInt(e.slice(3,4).join(""),16),o=parseInt(e.slice(5,6).join(""),16),r="";return o&&(r=hex2str(e.slice(6,6+o))),{connected:!t,ssid:r}}),{timeout:exports.LLSyncComboConfig.waitSetWiFiConnectTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_CONNECT_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},t.prototype.sendToken=function(e){var t=e.token,o=byteUtil.hexString2hexArray(byteUtil.byteArrayToHex(byteUtil.getBytesByString(t)));console.log("----data----",{token:t,tokenHexArray:o});var r=this.sliceData(tslib_1.__spread([qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN],U16ToHexString(o.length)],o),[o],qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN);return this.writeAndWait4Response(r,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN_RESULT,(function(e){if(!e.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN_RESULT_INVALID};return!parseInt(e.slice(2,3).join(""),16)}),{timeout:exports.LLSyncComboConfig.waitSetWiFiTokenTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.SET_WIFI_TOKEN_RESULT_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},t.prototype.getModuleLog=function(){var e=""+qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_PREFIX[qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG];return this.writeAndWait4Response(e,qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG_INFO,(function(e){if(!e.length)throw{code:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG_INFO_INVALID};var t=parseInt(e.slice(1,3).join(""),16);return{logStr:hex2str(e.slice(4,4+t))}}),{timeout:exports.LLSyncComboConfig.waitDevLogInfoTime,timeoutCode:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.GET_DEV_LOG_INFO_TIMEOUT,writeId:qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.DEVICE_INFO_WRITE_ID})},t.options={reporter:console},t.serviceId16="0000FFF0-0000-1000-8000-00805F9B34FB",t.serviceId="0000FFF0-65D0-4E20-B56A-E493541BA4E2",t.deviceFilter=function(e){if(!e.advertisServiceUUIDs||!e.advertisServiceUUIDs.find((function(e){return e===exports.BleComboLLSyncDeviceAdapter.serviceId16}))||!e.advertisData)return null;try{var t=Math.floor(10*Math.random())%10==1||!0,o=arrayBufferToHexStringArray(e.advertisData);t&&exports.BleComboLLSyncDeviceAdapter.options.reporter.info(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{message:"收到广播",serviceId:exports.BleComboLLSyncDeviceAdapter.serviceId,hexArr:o.join(",")});var r,_=parseInt(o[2],16)>>4,n=o.slice(3,9);return e.name&&-1===e.name.indexOf("_")&&(e.name=e.name+"_"+n.slice(0,2).join("")),r=hex2str(o.slice(9)),t&&exports.BleComboLLSyncDeviceAdapter.options.reporter.info(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{message:"解析广播",serviceId:exports.BleComboLLSyncDeviceAdapter.serviceId,data:{deviceProductId:r||"x"}}),tslib_1.__assign(tslib_1.__assign({},e),{standardBleCombo:!0,serviceId:exports.BleComboLLSyncDeviceAdapter.serviceId,deviceName:"",productId:r,extendInfo:{moduleVersion:_}})}catch(e){exports.BleComboLLSyncDeviceAdapter.options.reporter.error(qcloud_iotexplorer_bluetooth_adapter_llsync_1.constants.REPORT_EVENT_TYPE,{message:"协议广播出错",error:e})}},t}(qcloud_iotexplorer_bluetooth_adapter_llsync_1.LLSyncDeviceAdapterBase);exports.BleComboLLSyncDeviceAdapterBase=BleComboLLSyncDeviceAdapterBase,exports.BleComboLLSyncDeviceAdapter=qcloud_iotexplorer_bluetooth_adapter_1.AdapterDeviceAdapter4Mp(BleComboLLSyncDeviceAdapterBase),exports.BleComboLLSyncDeviceAdapter4H5=qcloud_iotexplorer_bluetooth_adapter_1.AdapterDeviceAdapter4H5(BleComboLLSyncDeviceAdapterBase);
//# sourceMappingURL=BleComboLLSyncDeviceAdapter.js.map
{
"name": "qcloud-iotexplorer-appdev-plugin-wificonf-blecombo",
"version": "1.2.1",
"version": "1.2.2-beta.0",
"description": "",

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

"dependencies": {
"iotexplorer-ui-dev-config": "^1.0.23",
"iotexplorer-ui-dev-config": "^1.0.22",
"qcloud-iotexplorer-appdev-plugin-wificonf-core": "^1.1.14",

@@ -22,0 +22,0 @@ "qcloud-iotexplorer-appdev-sdk": "^1.1.13",

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