搜索不到蓝牙模块HC-06,我的蓝牙模块HC-06的mac值是:00:14:03:05:66:FC。
同时打开手机的蓝牙和订位功能,在微信小程序中真机调试,运行微信蓝牙程序后,页面展示只搜索得到其他的蓝牙设备,没有HC-06。
搜索得到蓝牙模块HC-06
给蓝牙模块HC-06上电,打开微信蓝牙,搜索周围蓝牙设备,界面上会出现搜索到的蓝牙设备。
//搜索设备
lanya3: function () {
var that = this;
wx.startBluetoothDevicesDiscovery({
success: function (res) {
that.setData({
msg: "搜索设备" + JSON.stringify(res),
})
//监听蓝牙适配器状态
wx.onBluetoothAdapterStateChange(function (res) {
that.setData({
sousuo: res.discovering ? "在搜索。" : "未搜索。",
status: res.available ? "可用。" : "不可用。",
})
})
}
})
},
// 获取所有已发现的设备
lanya4: function () {
var that = this;
wx.getBluetoothDevices({
success: function (res) {
//是否有已连接设备
wx.getConnectedBluetoothDevices({
success: function (res) {
console.log(JSON.stringify(res.devices));
that.setData({
connectedDeviceId: res.deviceId
})
}
})
that.setData({
msg: "搜索设备" + JSON.stringify(res.devices),
devices: res.devices,
})
//监听蓝牙适配器状态
wx.onBluetoothAdapterStateChange(function (res) {
that.setData({
sousuo: res.discovering ? "在搜索。" : "未搜索。",
status: res.available ? "可用。" : "不可用。",
})
})
}
})
},
1.先用其他调试APP搜索看下,比如BLE_Debuger这个APP
2.在检查蓝牙模块HC-06自己的广播数据是否正确
3.检查蓝牙模块HC-06与手机通信的交互包数据是否是在符合范围内
HC-06是蓝牙2.0协议。而微信小程序的蓝牙只支持蓝牙4.0协议的,所以之后我买了支持4.0协议的蓝牙HC-08。微信蓝牙小程序就可以搜索到我的HC-08。
你好,我的也是HC-08,小程序可以搜索到它,但是无法读写数据,请问您是怎么解决的呢?
我也是hc-08可以连上可以read但是write,notify,indicate都是false,为什么?用手机调试过,hc-08可以写入呀