问题:使用onBLEConnectionStateChange监听设备连接成功后调用getBLEDeviceServices任报错no device

解决方案:使用setTimeout定时1秒

setTimeout(() => {
    uni.getBLEDeviceServices({
        deviceId: '设备id',
        success(res) {
            console.log('服务成功', res);
        },
        fail(err) {
            console.log('服务失败', err);
        }
    });
}, 1000);

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐