敷衍,上面已经说的很明了了,难道需要提供设备给你吗? 具体步骤: 1、我有一个蓝牙设备,已经能连接上了,然后在代码里使用 wx.onBLEConnectionStateChange监听链接状态(代码如上) 2、手机预览代码,连接设备后,手动关闭设备,能正常监听到状态变化 3、手机真机调试,连接设备后,手动关闭设备,无法监听设备被关闭的状态
wx.onBLEConnectionStateChange 真机预览无法监听到状态变化?一加5T 微信版本8.0.22 系统版本 android 10 基础库:2.42.2 【手动关闭蓝牙设备】 预览的时候,可以监听到状态变化,但是真机调试的时候,无法检测到状态变化 代码: // 连接蓝牙低功耗设备 wx.createBLEConnection({ deviceId: deviceId, timeout: 10000, success(res) { if (res.errCode == 0) { that.setData({ isConnected: true }); } else { wx.showModal({ title: '提示', content: "不能正常对蓝牙设备进行连接", showCancel: false }) } // 该方法回调中可以用于处理连接意外断开等异常情况 wx.onBLEConnectionStateChange(function(r) { console.log(`device ${r.deviceId} state has changed, connected: ${r.connected}`) if (!r.connected) { that.setData({ isFinded: false, isConnected: false, isFailed: true }) } }) // 停止搜索蓝牙设备 wx.stopBluetoothDevicesDiscovery(); clearInterval(timer) clearInterval(timer2) }, fail(res) { wx.hideLoading(); if (res.errCode == 10012) { wx.showModal({ title: '提示', content: "连接超时", showCancel: false }) } }, complete() { wx.hideLoading(); } })
2022-05-27这个是官方的示例,我也纳闷了,示例里没有5,怎么结果会有5,求解啊
云开发的数据库操作符的setDifference的运算结果有问题{ "_id": 1, "A": [ 1, 2 ], "B": [ 1, 2 ] } { "_id": 2, "A": [ 1, 2 ], "B": [ 2, 1, 2 ] } { "_id": 3, "A": [ 1, 2 ], "B": [ 1, 2, 3 ] } { "_id": 4, "A": [ 1, 2 ], "B": [ 3, 1 ] } { "_id": 5, "A": [ 1, 2 ], "B": [ ] } { "_id": 6, "A": [ 1, 2 ], "B": [ {}, [] ] } { "_id": 7, "A": [ ], "B": [ ] } { "_id": 8, "A": [ ], "B": [ 1 ] } 下面的代码使用 [代码]setDifference[代码],找到只存在于 [代码]B[代码] 中的数字: db.collection('test') .aggregate() .project({ isBOnly: $.setDifference(['$B', '$A']) }) .end() { "_id": 1, "isBOnly": [] } { "_id": 2, "isBOnly": [3] } { "_id": 3, "isBOnly": [3] } { "_id": 4, "isBOnly": [5] } { "_id": 5, "isBOnly": [] } { "_id": 6, "isBOnly": [{}, []] } { "_id": 7, "isBOnly": [] } { "_id": 8, "isBOnly": [1] } 测试结果和官方给出的结果不一样啊 https://developers.weixin.qq.com/miniprogram/dev/wxcloud/reference-sdk-api/database/command/aggregate/AggregateCommand.setDifference.html
2020-12-01