https://developers.weixin.qq.com/doc/offiaccount/Connecting_devices/Introduction_to_Features.html
[图片] [图片] 而且,另外的设备审核过了,但是订阅消息模板中并没有相应的设备选择。
基础库版本:2.24.1 微信版本:8.0.22 手机型号:MI 9 安卓版本:9 描述: writeBLECharacteristicValue 写入接口调用后无任何回调。success,fail,complete 都没有回调。onBLECharacteristicValueChange 也没有触发 但数据似乎写入进去了。通过 readBLECharacteristicValue 读取到的 特征value 为我写入进去的值。虽然我不是要我写入的值,而是要通过写入 让设备反馈给我数据。 readBLECharacteristicValue 有回调 success ,fail,complete,onBLECharacteristicValueChange 都能触发。 真机调试截图: [图片][图片] 部分代码: getBLEDeviceServices(deviceId) { wx.getBLEDeviceServices({ deviceId, success: (res) => { for (let i = 0; i < res.services.length; i++) { if (res.services[i].isPrimary) { console.log(res.services[i]) } } // this.getBLEDeviceCharacteristics(deviceId, res.services[4].uuid) this.getBLEDeviceCharacteristics(deviceId, res.services[2].uuid) this.getBLEDeviceCharacteristics(deviceId, res.services[3].uuid) this.getBLEDeviceCharacteristics(deviceId, res.services[4].uuid) this.getBLEDeviceCharacteristics(deviceId, res.services[5].uuid) } }) }, getBLEDeviceCharacteristics(deviceId, serviceId) { wx.getBLEDeviceCharacteristics({ deviceId, serviceId, success: (res) => { console.log('getBLEDeviceCharacteristics success', res.characteristics) for (let i = 0; i < res.characteristics.length; i++) { let item = res.characteristics[i] console.log(item) if (item.properties.read) { wx.readBLECharacteristicValue({ deviceId, serviceId, characteristicId: item.uuid, success: (res) => { console.log(res) console.log('读取成功') } }) } if (item.properties.write) { this.setData({ canWrite: true }) this._deviceId = deviceId this._serviceId = serviceId this._characteristicId = item.uuid let data = 0 if (serviceId === '0000FFF0-0000-1000-8000-00805F9B34FB') { data = 0xff } if (serviceId === '0000FFE0-0000-1000-8000-00805F9B34FB') { data = 0x11 } if (serviceId === '0000FFB1-0000-1000-8000-00805F9B34FB') { data = 0x14 } this.writeBLECharacteristicValue(data) } if (item.properties.notify || item.properties.indicate) { wx.notifyBLECharacteristicValueChange({ deviceId, serviceId, characteristicId: item.uuid, state: true, }) } } }, fail(res) { console.error('getBLEDeviceCharacteristics', res) } }) // 操作之前先监听,保证第一时间获取数据 wx.onBLECharacteristicValueChange((characteristic) => { console.log('接受') console.log(characteristic) const idx = inArray(this.data.chs, 'uuid', characteristic.characteristicId) const data = {} if (idx === -1) { data[`chs[${this.data.chs.length}]`] = { uuid: characteristic.characteristicId, value: ab2hex(characteristic.value) } } else { data[`chs[${idx}]`] = { uuid: characteristic.characteristicId, value: ab2hex(characteristic.value) } } // data[`chs[${this.data.chs.length}]`] = { // uuid: characteristic.characteristicId, // value: ab2hex(characteristic.value) // } this.setData(data) }) }, writeBLECharacteristicValue(data) { // 向蓝牙设备发送一个0x00的16进制数据 let buffer = new ArrayBuffer(1) let dataView = new DataView(buffer) data = data || 0x10 dataView.setUint8(0, data) console.log('写入数据') console.log(buffer) wx.writeBLECharacteristicValue({ deviceId: this._deviceId, serviceId: this._serviceId, characteristicId: this._characteristicId, writeType: 'write', value: buffer, success: () => { console.log('成功!') }, fail: () => { console.log('失败!') }, complete: () => { console.log('结束!') } }) },
现有需求在WMPF平板上面选择文件上传(非图片和视频),可能是excel,word,pdf. 我们的WMPF公用平板是有时候需要导入一些excel,目前wx.chooseMessageFile,在没有安装微信的情况下肯定是不能使用的.所以想咨询下是否有计划开发WMPF专用的选择本地文件的API? 举例场景: WMPF开发的设备公共检修平板.需要导入一些检修设备的表单和其他内容.需要选择excel.目前无法上传,只能先从小程序打开再上传
我这边是一个微信小程序开发公司,和另一个做单片机等智能电子开发的公司,为公司甲开发一个硬件设备控制芯片和小程序,需要给使用用户发送设备的状态信息,比如离线、通讯故障、恢复等。用公司甲的营业执照注册的微信小程序,公司甲经营范围本身没有涉及智能硬件设备,像这种情况下能否放宽一下限制?
https://developers.weixin.qq.com/miniprogram/dev/api-backend/open-api/hardware-device/hardwareDevice.getSnTicket.html
[图片] 这个sn是必填的,但由于android的限制,sn很可能获取不到,那此时怎么办?
我们目前WMPF硬件设备是不需要授权微信扫码登录的.现在需要打开蓝牙, 直接调用授权蓝牙的API wx.openBluetoothAdapter 会提示没有权限. 调用授权API会弹出授权,但是确认后,再次调用openBluetoothAdapter,还是没有权限.(扫码登录后,下次进来授权蓝牙,就会有蓝牙的设置) 目前看起来权限是跟登录的账号走的.那WMPF设备无需扫码登录需要蓝牙权限的该怎么处理? 我们的WMPF平板设备本身是没有登录功能的.所以不允许出现扫码. 目前没有WMPF板块提问.先提到其他板块吧
已知硬件设备的serviceId和characterId,按流程初始化蓝牙模块(openBluetoothAdapter)-> 连接蓝牙设备(createBLEConnection) ->读取服务(getBLEDeviceServices)->根据服务ID获取特征(getBLEDeviceCharacteristics)-> 写入数据(writeBLECharacteristicValue)。通过wx调用获得的serviceId没有问题,获得characterId的属性也是可写的,但在ios平台报错10008错误信息this character cloud not found,安卓没有此问题想问这是为什么?
「硬件服务」是微信团队为智能硬件提供的设备连接、设备消息、设备控制等方面的服务。为了开发者快速了解和学习最新的硬件能力和使用场景,特此建立了开发者交流主页。
hardwareDevice.send 请求参数的中modelId的参数错误,实际要改为model_id,请微信文档的人员修改一下
设备消息是长期订阅消息的一种,用户只需订阅一次,后续可根据设备状态的更新向用户发送服务通知。
1、硬件设备消息能力已通过 2、长期订阅消息已通过并申请。 问:调用时报 {"errcode":0,"errmsg":"ok","list":[{"to_openid":"oYpv947f4aaugMCZZTa6v2P0QvUM","errcode":9800006,"msgid":0}]} 或 [图片]
[图片]
你好,上述情况属于没用合适的消息模板,可以发邮件申请新增模板,我们将评估后予以回复。详细查看
https://developers.weixin.qq.com/community/minihome/article/doc/0008c6c30e04b09075cd7e26254c13