New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

qcloud-iotexplorer-bluetooth-adapter-llsync

Package Overview
Dependencies
Maintainers
6
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

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

Comparing version 3.0.0-alpha.20230507b003 to 3.0.0-alpha.20240118b004

9

dist/cjs/base/LLSync/LLSyncDeviceAdapter.js

@@ -355,2 +355,3 @@ "use strict";

this.emit('eventReport', {
eventId,
eventIndex,

@@ -370,3 +371,3 @@ params,

// 设备绑定到家庭,标准蓝牙协议有自有的绑定逻辑,所以这部分重写
async bindDevice({ familyId, roomId, secureBindInfo, }) {
async bindDevice({ familyId, roomId, secureBindInfo, afterBindHandler, }) {
var _a;

@@ -506,2 +507,8 @@ const { needUserCheck } = this;

bindLogger.success();
try {
afterBindHandler === null || afterBindHandler === void 0 ? void 0 : afterBindHandler(this);
}
catch (error) {
console.error('[LLSyncDeviceAdapter.bindDevice] afterBindHandler error', error);
}
return this.explorerDeviceId;

@@ -508,0 +515,0 @@ }

3

dist/cjs/base/LLSync/LLSyncOtaProcessor.js

@@ -34,2 +34,3 @@ "use strict";

};
const normalizeFirmwareUrl = (url) => String(url).replace(/^http:/i, 'https:');
// 拼接 OTA 数据包

@@ -279,3 +280,3 @@ const getLLOTADataPackage = (seq, fileInfo, nextByteOffset, maxLengthPerPackage) => {

targetVersion: TargetVersion,
otaUrl: FirmwareURL,
otaUrl: normalizeFirmwareUrl(FirmwareURL),
};

@@ -282,0 +283,0 @@ // 版本不等于当前版本就需要升级

@@ -467,2 +467,4 @@ "use strict";

writeId: constants.DEVICE_INFO_WRITE_ID,
// 如果character支持有回复写操作,优先使用
writeType: 'write',
}));

@@ -514,4 +516,5 @@ await bindLogger

const data = `${constants.DEVICE_INFO_WRITE_PREFIX[constants.BIND_AUTH_FAIL]}01`;
this.deviceAdapter.write(data, {
this.deviceAdapter.writeData(data, {
writeId: constants.DEVICE_INFO_WRITE_ID,
writeType: 'write',
});

@@ -572,8 +575,12 @@ }

reportUnbindResult(mode) {
if (this.deviceAdapter.isEncrypted) {
const unbindRes = this.deviceAdapter.encrypt(mode === 'fail' ? 'UnbindFail' : 'UnbindOk', this.deviceAdapter.sessionKey);
const writeId = constants.DEVICE_INFO_WRITE_ID;
const { deviceAdapter } = this;
if (deviceAdapter.isEncrypted) {
const unbindRes = deviceAdapter.encrypt(mode === 'fail' ? 'UnbindFail' : 'UnbindOk', deviceAdapter.sessionKey);
const dataStr = `${constants.DEVICE_INFO_WRITE_PREFIX[constants.UNBIND_RESPONSE]}${unbindRes}`;
const data = this._parseDataBeforeConnect(dataStr, constants.UNBIND_RESPONSE);
return this.deviceAdapter.writeData(data, {
writeId: constants.DEVICE_INFO_WRITE_ID,
return deviceAdapter.writeData(data, {
writeId,
// 如果character支持有回复写操作,优先使用
writeType: 'write',
});

@@ -585,4 +592,6 @@ }

: constants.DEVICE_INFO_WRITE_PREFIX[constants.UNBIND_RESULT_AUTH_SUCCESS];
return this.deviceAdapter.write(unbindRes, {
writeId: constants.DEVICE_INFO_WRITE_ID,
return deviceAdapter.writeData(unbindRes, {
writeId,
// 如果character支持有回复写操作,优先使用
writeType: 'write',
});

@@ -626,5 +635,8 @@ }

const payload = `${head}${byteUtil.byteToHex(nextHeartbeatTimeout)}`;
await this.deviceAdapter.writeData(payload, {
const { deviceAdapter } = this;
await deviceAdapter.writeData(payload, {
writeId: DEVICE_INFO_WRITE_ID,
retryTime: 0,
// 如果character支持无回复写操作,优先使用
writeType: 'writeNoResponse',
});

@@ -631,0 +643,0 @@ }

@@ -190,6 +190,32 @@ "use strict";

writeData(data, params = {}) {
let writeType;
if (params.writeType && this.checkSpecificWriteTypeIsSupport({
characterId: params.writeId,
writeType: params.writeType,
})) {
writeType = params.writeType;
}
return new Promise((resolve, reject) => {
this.writeDataQueue.push(Object.assign({ data, onSuccess: resolve, onError: reject }, params));
this.writeDataQueue.push(Object.assign(Object.assign({ data, onSuccess: resolve, onError: reject }, params), { writeType }));
});
}
checkSpecificWriteTypeIsSupport({ serviceId, characterId, writeType, }) {
if (!writeType || !characterId) {
return false;
}
const characteristicsMap = this.characteristicsMap[serviceId || this.serviceId] || {};
let characterIds;
switch (writeType) {
case 'write':
characterIds = characteristicsMap.writeDefaultIds || [];
break;
case 'writeNoResponse':
characterIds = characteristicsMap.writeNoResponseIds || [];
break;
default:
characterIds = [];
break;
}
return characterIds.includes(characterId);
}
// 业务相关

@@ -210,3 +236,3 @@ async setMtu(mtu) {

let { data } = params;
const { writeId, waitGap = 0, retryTime = 5, } = params;
const { writeId, waitGap = 0, retryTime = 5, writeType, } = params;
if (!Array.isArray(data)) {

@@ -231,2 +257,3 @@ data = [data];

writeId,
writeType,
});

@@ -236,2 +263,3 @@ break;

catch (e) {
// eslint-disable-next-line no-plusplus
retryLeft--;

@@ -238,0 +266,0 @@ if (retryLeft > 0) {

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

this.emit('eventReport', {
eventId,
eventIndex,

@@ -366,3 +367,3 @@ params,

// 设备绑定到家庭,标准蓝牙协议有自有的绑定逻辑,所以这部分重写
async bindDevice({ familyId, roomId, secureBindInfo, }) {
async bindDevice({ familyId, roomId, secureBindInfo, afterBindHandler, }) {
var _a;

@@ -502,2 +503,8 @@ const { needUserCheck } = this;

bindLogger.success();
try {
afterBindHandler === null || afterBindHandler === void 0 ? void 0 : afterBindHandler(this);
}
catch (error) {
console.error('[LLSyncDeviceAdapter.bindDevice] afterBindHandler error', error);
}
return this.explorerDeviceId;

@@ -504,0 +511,0 @@ }

@@ -30,2 +30,3 @@ /* eslint-disable @typescript-eslint/naming-convention */

};
const normalizeFirmwareUrl = (url) => String(url).replace(/^http:/i, 'https:');
// 拼接 OTA 数据包

@@ -275,3 +276,3 @@ const getLLOTADataPackage = (seq, fileInfo, nextByteOffset, maxLengthPerPackage) => {

targetVersion: TargetVersion,
otaUrl: FirmwareURL,
otaUrl: normalizeFirmwareUrl(FirmwareURL),
};

@@ -278,0 +279,0 @@ // 版本不等于当前版本就需要升级

@@ -463,2 +463,4 @@ import * as constants from '../../constants';

writeId: constants.DEVICE_INFO_WRITE_ID,
// 如果character支持有回复写操作,优先使用
writeType: 'write',
}));

@@ -510,4 +512,5 @@ await bindLogger

const data = `${constants.DEVICE_INFO_WRITE_PREFIX[constants.BIND_AUTH_FAIL]}01`;
this.deviceAdapter.write(data, {
this.deviceAdapter.writeData(data, {
writeId: constants.DEVICE_INFO_WRITE_ID,
writeType: 'write',
});

@@ -568,8 +571,12 @@ }

reportUnbindResult(mode) {
if (this.deviceAdapter.isEncrypted) {
const unbindRes = this.deviceAdapter.encrypt(mode === 'fail' ? 'UnbindFail' : 'UnbindOk', this.deviceAdapter.sessionKey);
const writeId = constants.DEVICE_INFO_WRITE_ID;
const { deviceAdapter } = this;
if (deviceAdapter.isEncrypted) {
const unbindRes = deviceAdapter.encrypt(mode === 'fail' ? 'UnbindFail' : 'UnbindOk', deviceAdapter.sessionKey);
const dataStr = `${constants.DEVICE_INFO_WRITE_PREFIX[constants.UNBIND_RESPONSE]}${unbindRes}`;
const data = this._parseDataBeforeConnect(dataStr, constants.UNBIND_RESPONSE);
return this.deviceAdapter.writeData(data, {
writeId: constants.DEVICE_INFO_WRITE_ID,
return deviceAdapter.writeData(data, {
writeId,
// 如果character支持有回复写操作,优先使用
writeType: 'write',
});

@@ -581,4 +588,6 @@ }

: constants.DEVICE_INFO_WRITE_PREFIX[constants.UNBIND_RESULT_AUTH_SUCCESS];
return this.deviceAdapter.write(unbindRes, {
writeId: constants.DEVICE_INFO_WRITE_ID,
return deviceAdapter.writeData(unbindRes, {
writeId,
// 如果character支持有回复写操作,优先使用
writeType: 'write',
});

@@ -622,5 +631,8 @@ }

const payload = `${head}${byteUtil.byteToHex(nextHeartbeatTimeout)}`;
await this.deviceAdapter.writeData(payload, {
const { deviceAdapter } = this;
await deviceAdapter.writeData(payload, {
writeId: DEVICE_INFO_WRITE_ID,
retryTime: 0,
// 如果character支持无回复写操作,优先使用
writeType: 'writeNoResponse',
});

@@ -627,0 +639,0 @@ }

@@ -187,6 +187,32 @@ import { __rest } from "tslib";

writeData(data, params = {}) {
let writeType;
if (params.writeType && this.checkSpecificWriteTypeIsSupport({
characterId: params.writeId,
writeType: params.writeType,
})) {
writeType = params.writeType;
}
return new Promise((resolve, reject) => {
this.writeDataQueue.push(Object.assign({ data, onSuccess: resolve, onError: reject }, params));
this.writeDataQueue.push(Object.assign(Object.assign({ data, onSuccess: resolve, onError: reject }, params), { writeType }));
});
}
checkSpecificWriteTypeIsSupport({ serviceId, characterId, writeType, }) {
if (!writeType || !characterId) {
return false;
}
const characteristicsMap = this.characteristicsMap[serviceId || this.serviceId] || {};
let characterIds;
switch (writeType) {
case 'write':
characterIds = characteristicsMap.writeDefaultIds || [];
break;
case 'writeNoResponse':
characterIds = characteristicsMap.writeNoResponseIds || [];
break;
default:
characterIds = [];
break;
}
return characterIds.includes(characterId);
}
// 业务相关

@@ -207,3 +233,3 @@ async setMtu(mtu) {

let { data } = params;
const { writeId, waitGap = 0, retryTime = 5, } = params;
const { writeId, waitGap = 0, retryTime = 5, writeType, } = params;
if (!Array.isArray(data)) {

@@ -228,2 +254,3 @@ data = [data];

writeId,
writeType,
});

@@ -233,2 +260,3 @@ break;

catch (e) {
// eslint-disable-next-line no-plusplus
retryLeft--;

@@ -235,0 +263,0 @@ if (retryLeft > 0) {

@@ -61,6 +61,7 @@ import { ProductUIDevConfig } from 'iotexplorer-ui-dev-config';

}): Promise<never>;
bindDevice({ familyId, roomId, secureBindInfo, }: {
bindDevice({ familyId, roomId, secureBindInfo, afterBindHandler, }: {
familyId: string;
roomId: string;
secureBindInfo?: constants.LLSyncSecureBindInfo;
afterBindHandler?: (deviceAdapter: LLSyncDeviceAdapter) => void;
}): Promise<string>;

@@ -67,0 +68,0 @@ bindDeviceEncrypted({ secureBindInfo, bindLogger, }: {

@@ -22,2 +22,3 @@ import * as utils from '../libs';

retryTime?: number;
writeType?: 'write' | 'writeNoResponse';
}

@@ -53,2 +54,7 @@ export type LLSyncEventHandlerFn<T> = (data: string[], event: {

writeData(data: any, params?: Omit<WriteDataParams, 'data'>): Promise<void>;
checkSpecificWriteTypeIsSupport({ serviceId, characterId, writeType, }: {
serviceId?: string;
characterId: string;
writeType?: 'write' | 'writeNoResponse';
}): boolean;
setMtu(mtu: any): Promise<{

@@ -55,0 +61,0 @@ mtu: number;

{
"name": "qcloud-iotexplorer-bluetooth-adapter-llsync",
"version": "3.0.0-alpha.20230507b003",
"version": "3.0.0-alpha.20240118b004",
"description": "",

@@ -21,8 +21,8 @@ "bugs": {

"dependencies": {
"event-emitter-for-miniprogram": "3.0.0-alpha.20230507b003",
"iotexplorer-ui-dev-config": "3.0.0-alpha.20230507b003",
"qcloud-iotexplorer-appdev-sdk": "3.0.0-alpha.20230507b003",
"qcloud-iotexplorer-bluetooth-adapter": "3.0.0-alpha.20230507b003",
"qcloud-iotexplorer-common-libs": "3.0.0-alpha.20230507b003",
"qcloud-iotexplorer-logger": "3.0.0-alpha.20230507b003",
"event-emitter-for-miniprogram": "3.0.0-alpha.20240118b004",
"iotexplorer-ui-dev-config": "3.0.0-alpha.20240118b004",
"qcloud-iotexplorer-appdev-sdk": "3.0.0-alpha.20240118b004",
"qcloud-iotexplorer-bluetooth-adapter": "3.0.0-alpha.20240118b004",
"qcloud-iotexplorer-common-libs": "3.0.0-alpha.20240118b004",
"qcloud-iotexplorer-logger": "3.0.0-alpha.20240118b004",
"shortid-for-miniprogram": "^2.2.15",

@@ -35,3 +35,3 @@ "spark-md5": "^3.0.1",

},
"gitHead": "b64540d610a6b02a5400cb1e6e404949d378e5eb"
"gitHead": "6beca018526e761fba4197634612bd6c71179181"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc