收藏
回答

writeBLECharacteristicValue

麻烦帮忙解答下,谢谢 


// 向蓝牙设备发送一个0x00的16进制数据

                              let buffer = new ArrayBuffer(16)

                              let dataView = new DataView(buffer)

                              dataView.setUint8(0, 0x06)

                              dataView.setUint8(0, 0x01)

                              dataView.setUint8(0, 0x01)

                              dataView.setUint8(0, 0x01)

                              dataView.setUint8(0, 0x00)

                              dataView.setUint8(0, 0x00)

                              dataView.setUint8(0, 0x00)

                              dataView.setUint8(0, 0x00)

                              dataView.setUint8(0, 0x00)

                              dataView.setUint8(0, 0x00)

                              dataView.setUint8(0, 0x00)

                              dataView.setUint8(0, 0x00)

                              dataView.setUint8(0, 0x00)

                              dataView.setUint8(0, 0x00)

                              dataView.setUint8(0, 0x00)

                              dataView.setUint8(0, 0x00)

                              wx.writeBLECharacteristicValue({

                                // 这里的 deviceId 需要在上面的 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取

                                deviceId: 'EB:BB:11:14:CA:CA',

                                // 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取

                                serviceId: '0000fee7-0000-1000-8000-00805f9b34fb',

                                // 这里的 characteristicId 需要在上面的 getBLEDeviceCharacteristics 接口中获取

                                characteristicId: '000036f5-0000-1000-8000-00805f9b34fb',

                                // 这里的value是ArrayBuffer类型

                                value: buffer,

                                success: function (res) {

                                  console.log('writeBLECharacteristicValue success', res.errMsg)

                                },

                                fail:function(res){

                                  console.log('失败'+res)

                                  console.log(res)

                                }

                              })


回答关注问题邀请回答
收藏

2 个回答

  • sunny 、
    sunny 、
    2017-11-09

    回调结果老是10008,不知道什么原因

    2017-11-09
    有用
    回复
  • Chao ₅™
    Chao ₅™
    2017-11-08

    你的问题是什么?

    2017-11-08
    有用
    回复
登录 后发表内容