- ios手机调用wx.openBluetoothAdapter 无错误码返回是什么问题?
在ios手机中调用wx.openBluetoothAdapter 没有任何错误码返回,只有一个errMsg显示的是打开成功,代码中有根据errno来处理对应的逻辑,现在没有这个错误了应该如何处理呢? [图片] 这是ios手机的打印 [图片]
2023-02-15 - wx.readBLECharacteristicValue在ios手机上出现10004?
为什么在安卓手机中直接调用wx.readBLECharacteristicValue可以正常从wx.onBLECharacteristicValue拿到数据?在ios手机上必须保证获取服务-->获取特特征值---->读特征值---->订阅特征值这个步骤,直接从读特征值会出现10004错误或者直接获取特征值也会出现10004错误?[图片][图片] async onLoad() { this.setData({ curDeviceId: wx.getStorageSync('curDeviceId') ? wx.getStorageSync('curDeviceId') : '' }) wx.onBLECharacteristicValueChange(res => { console.log(`${LOG_PREFIX} on BLECharacteristicValueChange res:`, res, config.getMiiteeIdcharacteristicId) if (res.characteristicId == config.getMiiteeIdcharacteristicId) { const miiteeId: string = ab2str(res.value) this.setData({ miiteeId: miiteeId }) console.log(`${LOG_PREFIX} get miiteeId:`, miiteeId) this.getDeviceName(miiteeId) } }) await this.handleGetServices() }, async handleGetServices() { console.log("CONNECTION Page handleGetServices", this.data.curDeviceId) return new Promise((resolve, reject) => { wx.getBLEDeviceServices({ deviceId: this.data.curDeviceId, success: (res) => { console.log(`CONNECTION Page getBLEDeviceServices res:`, res) this.handleGetCharacteristics() resolve(0) }, fail: (error) => { console.error(`CONNECTION Page getBLEDeviceServices error:`, error) reject(1) } }) }) }, async handleGetCharacteristics() { console.log(`${LOG_PREFIX} handleGetCharacteristics`, this.data.curDeviceId) return new Promise((resolve, reject) => { wx.getBLEDeviceCharacteristics({ deviceId: this.data.curDeviceId, serviceId: config.serviceId, success: async (res) => { console.log(`${LOG_PREFIX} getBLEDeviceCharacteristics success res:`, res) await this.handleReadCharacteristics() resolve(0) }, fail: (error) => { console.error(`${LOG_PREFIX} getBLEDeviceCharacteristics error:`, error) reject(1) } }) }) }, handleReadCharacteristics() { return new Promise((resolve, reject) => { console.log(`CONNECTION Page handleReadCharacteristics`, config.getMiiteeIdcharacteristicId) wx.readBLECharacteristicValue({ deviceId: wx.getStorageSync('curDeviceId'), serviceId: config.serviceId, characteristicId: config.getMiiteeIdcharacteristicId, success: (res) => { console.log(`CONNECTION Page readBLECharacteristicValue res:`, res) resolve(0) this.handleNotifyCharacteristics() }, fail: (error) => { reject(1) console.error(`CONNECTION Page readBLECharacteristicValue error:`, error) } }) }) }, handleNotifyCharacteristics() { wx.notifyBLECharacteristicValueChange({ deviceId: wx.getStorageSync('curDeviceId'), serviceId: config.serviceId, characteristicId: this.data.characteristicId, state: true, success: (res) => { console.log(`${LOG_PREFIX} notifyBLECharacteristicValueChange success:`, res) }, fail: (error) => { console.error(`${LOG_PREFIX} notifyBLECharacteristicValueChange fail:`, error) } }) },
2022-07-04 - wx.writeBLECharacteristicValue接口频繁报10008错误?
业务场景中:不需要订阅读完特征值之后直接调用wx.writeBLECharacteristicValuea这个接口 d代码如下: onLoad: function (options) { this.setData({ curDeviceId: options.deviceId }) this.handleGetServices() //全局网络监听器 wx.onBLECharacteristicValueChange(res => { console.log(`CONNECTION Page on NetworkStatusBLECharacteristicValueChange res:`, res) }) }, editName(){ console.log("Ssssssssssss") this.setData({ showModal:true }) }, hideModal(){ this.setData({ showModal:false }) }, updateName(){ }, handleGetServices() { let that = this console.log("CONNECTION Page handleGetServices", this.data.curDeviceId) wx.getBLEDeviceServices({ deviceId: this.data.curDeviceId, success: (res) => { console.log(`CONNECTION Page getBLEDeviceServices res:`, res) that.handleGetCharacteristics() }, fail: (error) => { console.error(`CONNECTION Page getBLEDeviceServices error:`, error) } }) }, handleGetCharacteristics() { console.log(`CONNECTION Page handleGetCharacteristics`, this.data.curDeviceId) wx.getBLEDeviceCharacteristics({ deviceId: this.data.curDeviceId, serviceId: '0000180A-1111-2222-0000-123456780000', success: (res) => { console.log(`CONNECTION Page getBLEDeviceCharacteristics res:`, res) this.handleReadCharacteristics() }, fail: (error) => { console.error(`CONNECTION Page getBLEDeviceCharacteristics error:`, error) } }) }, handleReadCharacteristics() { console.log(`CONNECTION Page handleReadCharacteristics`) wx.readBLECharacteristicValue({ deviceId: this.data.curDeviceId, serviceId: '0000180A-1111-2222-0000-123456780000', characteristicId: 'DDDDEEEE-1111-2222-0000-123456780005', success: (res) => { console.log(`CONNECTION Page readBLECharacteristicValue res:`, res) // this.handleNotifyCharacteristics() }, fail: (error) => { console.error(`CONNECTION Page readBLECharacteristicValue error:`, error) } }) }, handleNotifyCharacteristics() { console.log(`CONNECTION Page handleNotifyNetworkStatusCharacteristics`) wx.notifyBLECharacteristicValueChange({ deviceId: this.data.curDeviceId, serviceId: '0000180A-1111-2222-0000-123456780000', characteristicId: 'DDDDEEEE-1111-2222-0000-123456780005', state: true, success: (res) => { console.log(`CONNECTION Page notifyNetworkStatusBLECharacteristicValueChange res:`, res) }, fail: (error) => { console.error(`CONNECTION Page notifyNetworkStatusBLECharacteristicValueChange error:`, error) } }) }, enterKey(e: any) { let keyVal = e.currentTarget.dataset.key console.log("用户按键", keyVal) let value = this.string2buffer(keyVal) console.log("转成arrayBuffer字符串",value) this.handleWriteBLECharacteristic(value) }, handleWriteBLECharacteristic(bufferVal: ArrayBuffer) { console.log("开始写特征值===========",bufferVal,wx.getStorageSync("curDeviceId")) wx.writeBLECharacteristicValue({ deviceId: wx.getStorageSync("curDeviceId"), serviceId: '0000180A-1111-2222-0000-123456780000', characteristicId: 'DDDDEEEE-1111-2222-0000-123456780005', value: bufferVal, success: (res) => { console.log('writeBLECharacteristicValue success', wx.getStorageSync("curDeviceId"), res) // this.setData({ // isInitPage: false // }) if (res.errCode == 0 || res.errCode == -1) { } }, fail: (error: any) => { console.log('writeBLECharacteristicValue error', error) }, complete:(value:any)=>{ console.log('writeBLECharacteristicValue complete', value) } }) },
2022-06-15 - wx.startBluetoothDevicesDiscovery接口出现1509008错误?
之前蓝牙搜索设备一直很正常 最近在某些手机上出现了1509008错误 wx.startBluetoothDevicesDiscovery({ services: ['0000180A-1111-2222-0000-123456780000', ], allowDuplicatesKey: false, success: (result) => { console.log(`${LOG_PREFIX} startBluetoothDevicesDiscovery result:`, result) }, fail: (error: any) => { console.error(`${LOG_PREFIX} startBluetoothDevicesDiscovery error:`, error,error.errno) if (error.errno == '1509009') { this.setData({ showModal: true, title: '无法连接到设备', content: '请输入正确得识别码,并打开定位服务', modalLeftBtnVal: '知道了', openBle: false, deviceList: [] }) } } }) y原来一直正常 最近又出现了错误并且多了一个新的code值 c错误信息为: NETWORKING PAGE startBluetoothDevicesDiscovery error: Object {errCode: -1, errMsg: "startBluetoot... errCode: -1 errMsg: "startBluetoothDevicesDiscovery:fail:location permission is denied" errno: 1509008 isDiscovering: false __proto__: Object 1509008 定位和蓝牙全部确认过了都打开了 依旧报错
2022-05-30 - getConnectedWifi:fail:currentWifi is null报错?
在某些安卓机型中会出现10012错误码 startWfi是初始化成功的 [图片]
2022-03-01