小程序
小游戏
企业微信
微信支付
扫描小程序码分享
为什么我的发送指令成功后 接受不到蓝牙通知响应了 望大神指点下 对蓝牙确实很陌生
21 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
是我项目还没配人正确的域名的问题吗
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
还是一样 这个蓝牙很不好调啊 到底小程序蓝牙能不能用啊
可以加下您的qq咨询下详情问题吗
官方能推出一个蓝牙的demo吗
现在没发现有iOS11不兼容的反馈。
那能具体说下真正有问题的代码逻辑么?
能成功打印 但这都是第一进去蓝牙自动发过来的数据 我给他发握手指令并不会返回数据 是不是小程序蓝牙不兼容我ios11的微信 我发的握手指令也和他们安卓一样经过分装 应该是没问题的 但就是不返回握手指令过来 我们公司是用这个想做ETC圈存的
你好,这边怀疑是vConsole的兼容性问题,能否帮忙配合定位下问题呢?
在 wx.onBLECharacteristicValueChange 里 打印一个固定字符串 console.log('onBLECharacteristicValueChange') ,看是否有进入这个回调中
可能存在 console.log 无法打印出你的变量 str 的可能,有办法每次进入 wx.onBLECharacteristicValueChange 将收到的值打印在页面上么?
好的 多谢了
我这边尝试复现你的问题,需要一段时间,稍等。
onLoad:
function
(opt) {
var
that =
this
;
console.log(
"onLoad"
);
'丽江deviceId='
+ opt.deviceId);
'name='
+ opt.name);
that.setData({ deviceId: opt.deviceId });
/**
* 监听设备的连接状态
*/
wx.onBLEConnectionStateChanged(
(res) {
wx.showModal({
title:
'2'
,
content:
''
+ res.connected,
})
console.log(`device ${res.deviceId} state has changed, connected: ${res.connected}`)
* 连接设备
wx.createBLEConnection({
deviceId: that.data.deviceId,
success:
// success
console.log(res);
'连接'
+ that.data.deviceId,
'丽江2'
+ that.data.deviceId)
//获取服务
wx.getBLEDeviceServices({
(res){
'李建'
+ res.services[0].uuid)
//获取特征
wx.getBLEDeviceCharacteristics({
serviceId:
'0000FEE7-0000-1000-8000-00805F9B34FB'
(){
//接受信息
wx.notifyBLECharacteristicValueChange({
state:
true
characteristicId:
'0000FEC8-0000-1000-8000-00805F9B34FB'
'notifyBLECharacteristicValueChange success'
, res.errMsg)
},
fail:
'aa'
+ res.errMsg,
}
});
//notify成功后的回调
wx.onBLECharacteristicValueChange(
(characteristic) {
let valll = characteristic.value
let aa =
new
Uint8Array(valll)
let str =
""
for
(let i = 0; i < aa.length; i++) {
let temp = aa[i].toString(16)
temp = temp.length == 1 ?
"0"
+ temp : temp;
str += temp
'faguolai:'
+str)
that.setData({ result: str })
// fail
complete:
// complete
正在加载...
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
是我项目还没配人正确的域名的问题吗
还是一样 这个蓝牙很不好调啊 到底小程序蓝牙能不能用啊
可以加下您的qq咨询下详情问题吗
官方能推出一个蓝牙的demo吗
现在没发现有iOS11不兼容的反馈。
那能具体说下真正有问题的代码逻辑么?
能成功打印 但这都是第一进去蓝牙自动发过来的数据 我给他发握手指令并不会返回数据 是不是小程序蓝牙不兼容我ios11的微信 我发的握手指令也和他们安卓一样经过分装 应该是没问题的 但就是不返回握手指令过来 我们公司是用这个想做ETC圈存的
你好,这边怀疑是vConsole的兼容性问题,能否帮忙配合定位下问题呢?
在 wx.onBLECharacteristicValueChange 里 打印一个固定字符串 console.log('onBLECharacteristicValueChange') ,看是否有进入这个回调中
可能存在 console.log 无法打印出你的变量 str 的可能,有办法每次进入 wx.onBLECharacteristicValueChange 将收到的值打印在页面上么?
好的 多谢了
我这边尝试复现你的问题,需要一段时间,稍等。
onLoad:
function
(opt) {
var
that =
this
;
console.log(
"onLoad"
);
console.log(
'丽江deviceId='
+ opt.deviceId);
console.log(
'name='
+ opt.name);
that.setData({ deviceId: opt.deviceId });
/**
* 监听设备的连接状态
*/
wx.onBLEConnectionStateChanged(
function
(res) {
wx.showModal({
title:
'2'
,
content:
''
+ res.connected,
})
console.log(`device ${res.deviceId} state has changed, connected: ${res.connected}`)
})
/**
* 连接设备
*/
wx.createBLEConnection({
deviceId: that.data.deviceId,
success:
function
(res) {
// success
console.log(res);
wx.showModal({
content:
'连接'
+ that.data.deviceId,
})
console.log(
'丽江2'
+ that.data.deviceId)
//获取服务
wx.getBLEDeviceServices({
deviceId: that.data.deviceId,
success:
function
(res){
console.log(
'李建'
+ res.services[0].uuid)
//获取特征
wx.getBLEDeviceCharacteristics({
deviceId: that.data.deviceId,
serviceId:
'0000FEE7-0000-1000-8000-00805F9B34FB'
,
success:
function
(){
//接受信息
wx.notifyBLECharacteristicValueChange({
state:
true
,
deviceId: that.data.deviceId,
serviceId:
'0000FEE7-0000-1000-8000-00805F9B34FB'
,
characteristicId:
'0000FEC8-0000-1000-8000-00805F9B34FB'
,
success:
function
(res) {
console.log(
'notifyBLECharacteristicValueChange success'
, res.errMsg)
},
fail:
function
(res) {
wx.showModal({
content:
'aa'
+ res.errMsg,
})
}
});
//notify成功后的回调
wx.onBLECharacteristicValueChange(
function
(characteristic) {
let valll = characteristic.value
let aa =
new
Uint8Array(valll)
let str =
""
;
for
(let i = 0; i < aa.length; i++) {
let temp = aa[i].toString(16)
temp = temp.length == 1 ?
"0"
+ temp : temp;
str += temp
}
console.log(
'faguolai:'
+str)
that.setData({ result: str })
})
}
})
}
})
},
fail:
function
(res) {
// fail
},
complete:
function
(res) {
// complete
}
})
},