Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
qcloud-iotexplorer-bluetooth-adapter-llsync
Advanced tools
腾讯连连 llsync sdk 开发文档,小程序可以通过本 sdk 完成和标准蓝牙设备进行连接,绑定,控制等流程。通过下面的图片可以直观地了解整个流程:
腾讯连连 llsync sdk 开发文档,小程序可以通过本 sdk 完成和标准蓝牙设备进行连接,绑定,控制等流程。通过下面的图片可以直观地了解整个流程:
<img src=https://iot-public-1256872341.cos.ap-guangzhou.myqcloud.com/shuaisguo/1629101191691.gif style="width: 200px">
bluetoothAdapter 可以用来搜索设备,连接到设备。代码如下:
import { BlueToothAdapter } from 'qcloud-iotexplorer-bluetooth-adapter';
import { LLSyncDeviceAdapter } from 'qcloud-iotexplorer-bluetooth-adapter-llsync';
// 关于appDevSdk文档,详见https://www.npmjs.com/package/qcloud-iotexplorer-appdev-sdk
const options = {
appDevSdk, // 通过qcloud-iotexplorer-appdev-sdk得到的实例
}
LLSyncDeviceAdapter.injectOptions(options);
export const bluetoothAdapter = new BlueToothAdapter({
deviceAdapters: [
LLSyncDeviceAdapter,
],
});
通过 bluetoothAdapter.startSearch方法,我们可以发现设备,获得设备列表。
const serviceIds = [BleComboLLSyncDeviceAdapter.serviceId];
await bluetoothAdapter.startSearch({
ignoreDeviceIds,
serviceIds,
ignoreServiceIds,
onError: (error) => {
console.log('----error', error);
// 搜索设备出错
bluetoothAdapter.stopSearch();
},
onSearch: (devices) => {
console.log('searched devices', devices);
if (devices.length > 0) {
console.log('找到设备', devices); // 此时可以在页面上展示
}
},
timeout: 1.4 * 15 * 1000,
});
在上面的 onSearch 回调函数中,我们可以获得搜寻到的设备列表,这时可以将设备列表展示到页面上,供用户选择要连接哪个设备。
tip: 如果设备无法搜索到,请确认设备没有被绑定
用户从上面获取到的设备中选择一个,并发起连接操作时,可以调用 bluetoothAdapter.connectDevice
方法进行连接。连接成功后会返回一个 deviceAdapter,可以用来向连接的设备发送Wi-Fi,token等数据。
tip: 如果在连接时提示没有权限操作该产品,请到控制台/应用开发对应用和产品进行关联
try {
// device 参数是上一步 onSearch 回调中获取 devices 数组的某一项
const deviceAdapter = await bluetoothAdapter.connectDevice(device);
if (!deviceAdapter) {
throw {
code: 'CONNECT_ERROR',
}
}
} catch (err) {
console.error('连接到设备出错');
}
在这一步中,可以通过连接设备获得 deviceAdapter ,通过 deviceAdapter 可以完成后续设备的绑定和解绑操作
绑定设备时,可以传入familyId, roomId, 从而将设备绑定到特定的家庭和房间
try {
const deviceId = await deviceAdapter.bindDevice({ familyId, roomId });
} catch (err) {
console.log(err);
}
设备绑定后,也可以通过小程序发起删除设备的操作,这时需要调用解绑api,解绑完成后设备会恢复未绑定的状态。
try{
await deviceAdapter.unbindDevice({ familyId, deviceId });
} catch (err) {
console.log(err);
}
事件 | 描述 | 参数 |
---|---|---|
connect | 蓝牙设备连接时触发 | DeviceInfo |
disconnect | 蓝牙设备连接断开时触发 | DeviceInfo |
authorized | 蓝牙设备授权完成时触发 | { version, mtu, otaVersion, } |
FAQs
腾讯连连 llsync sdk 开发文档,小程序可以通过本 sdk 完成和标准蓝牙设备进行连接,绑定,控制等流程。通过下面的图片可以直观地了解整个流程:
The npm package qcloud-iotexplorer-bluetooth-adapter-llsync receives a total of 11 weekly downloads. As such, qcloud-iotexplorer-bluetooth-adapter-llsync popularity was classified as not popular.
We found that qcloud-iotexplorer-bluetooth-adapter-llsync demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.