
手机系统上面未开启显示蓝牙电量。
显示电量的方法。1、耳机的通知栏右上角会出现一个蓝牙耳机标志加电池标志的图标,这个图标就代表着耳机的电池信息了。
2、可以根据电池图标内的电量符号下降程度来判断小米air蓝牙耳机的剩余电量,当电量符号内降至底部时,说明耳机电量极低,需要为耳机充电。
3、如果手机的通知栏上没有显示耳机电量信息的话,也可以通过小米air蓝牙耳机的状态指示灯来判断,正常连接使用耳机后,耳机的指示灯是不亮。
4、当小米air蓝牙耳机低电量时,耳机指示灯会闪烁提示。
在iOS蓝牙开发当中,现在的主流是使用蓝牙40,使用CoreBluetooth来进行开发,蓝牙40的好处就不多说了,大家自行google,HID也是一种蓝牙协议,单向传输数据,主要是做蓝牙键盘用的,比如罗技的蓝牙键盘k480。
那么我们可以像蓝牙40一样直接获取HID的设备信息,跟发送的数据吗?很可惜,这是不行的,HID是系统层的,我们在应用层是没办法获取到她的任何数据跟信息的 参考这里
答案是:有两种方法
1使用IOKIT库是可以拿到的,但是这个库比较底层,而且使用了这个库的话,发布apple store 会被拒(只是搜索到有人这么说,楼主并没有验证真实性);
2另外一种是在楼主玩弄公司的蓝牙键盘时想到的,键盘上有音乐控制键,可以控制iPhone的音乐播放,让我想到了apple耳机的线控,那么会不会两种控制的方法是一样的呢?话不多说,赶快验证一下;
4使用AVAudioPlayer获取键值
首先我们需要成为第一响应者,而且开始接受远程控制事件
然后初始化播放器
设置事件监听
最后播放器开始播放之后, *** 作耳机线控或者蓝牙键上的音乐控制,就可以获得相应的值,然后做你想执行的 *** 作,但是eventsubtype只有十个键值,这也算是一个小小的限制吧,以上!
我的目标是世界和平!
参考资料点击这里
talk is cheap, show me the code
//初始化蓝牙
initBlue() {
var that = this;
wxopenBluetoothAdapter({ //调用微信小程序api 打开蓝牙适配器接口
success: function (res) {
consolelog('1初始化蓝牙成功')
},
//监听手机蓝牙的开关
monitorTheBlue:function(){
var that =this;
wxonBluetoothAdapterStateChange(function(res){
})
},
//开始获取附近的蓝牙设备
// 获取到附近的蓝牙数组 通过蓝牙特定的名称获取自己想要连接的蓝牙设备
// 获取附近蓝牙设备的数组
findBlue() {
consolelog(new Date())
var that = this
wxstartBluetoothDevicesDiscovery({
allowDuplicatesKey: false,
interval: 0,
success: function (res) {
consolelog('2正在搜索设备')
if (thatdataisFirestShow) {
wxshowLoading({
title: '正在搜索设备'
})
}
},
//搜索获取附近的所有蓝牙设备 获取附近所有的蓝牙设备的相关信息 获取需要连接蓝牙设备的deviceID
// 通过bluetoothDeviceName 和 localName 来确定制定蓝牙
// 一般根据制定设备的名字去连接 设备的名字 是出产厂家设定
getBlue() {
var that = this
wxgetBluetoothDevices({
success: function (res) {
consolelog('3找到设备列表')
wxhideLoading()
// return false
var index = 10
for (var i = 0; i < resdeviceslength; i++) {
if (resdevices[i]name && resdevices[i]localName) {
var arr = resdevices[i]namesplit("-")
var secArr = resdevices[i]localNamesplit("-")
if (arr[0] == thatdatabluetoothDeviceName || secArr[0] == thatdatabluetoothDeviceName) {
},
//连接蓝牙设备
//通过deviceId 连接蓝牙
/
},
//6 连接上需要的蓝牙设备之后,获取这个蓝牙设备的服务uuid
//获取设备的uuid
getServiceId() {
var that = this
wxgetBLEDeviceServices({
// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
deviceId: thatdatadeviceId,
success: function (res) {
var model = resservices[1]
thatsetData({
servicesUUID: modeluuid
})
consolelog('7获取设备 uuid 成功')
thatgetCharacteId() //60
}
})
},
//7 如果一个蓝牙设备需要进行数据的写入以及数据传输,就必须具有某些特征值,所以通过上面步骤获取的id可以查看当前蓝牙设备的特征值
//notify write read 当只有 notify为true的时候才能 接收蓝牙设备传来的数据,
//write 为true 才能传入数据
//read 为true 才能读取设备数据
getCharacteId() {
var that = this
wxgetBLEDeviceCharacteristics({
// 这里的 deviceId 需要已经通过 createBLEConnection 与对应设备建立链接
deviceId: thatdatadeviceId,
// 这里的 serviceId 需要在上面的 getBLEDeviceServices 接口中获取
serviceId: thatdataservicesUUID,
success: function (res) {
for (var i = 0; i < rescharacteristicslength; i++) { //2个值
var model = rescharacteristics[i]
if (modelpropertiesnotify == true) {
thatsetData({
characteristicId: modeluuid //监听的值
})
consolelog('8modelpropertiesnotify == true')
thatstartNotice(modeluuid) //70
}
// if (modelpropertiesread == true) {
// thatreadData(modeluuid)
// }
// if (modelpropertieswrite == true) {
// thatsetData({
// writeId: modeluuid//用来写入的值
// })
// }
}
}
})
},
fordateTime1(){
let now = new Date(),hour = nowgetHours()
consolelog(hour)
let str = ''
if(hour < 7){str = '早餐前'}
else if ((7< hour) && (hour<= 9)){str = '早餐后'}
else if ((9< hour) && (hour<= 11)){str = '午餐前'}
else if ((11< hour) && (hour<= 13)){str = '午餐后'}
else if ((13< hour) && (hour<= 17)){str = '晚餐前'}
else if ((17< hour) && (hour<= 19)){str = '晚餐后'}
else if ((19< hour) && (hour<= 24)){str = '睡觉前'}
return str
},
//8 如果一个蓝牙设备需要进行数据的写入以及数据传输,就必须具有某些特征值,所以通过上面步骤获取的id可以查看当前蓝牙设备的特征值
//开启设备数据监听 监听蓝牙设备返回来的数据
startNotice(uuid) {
var that = this;
wxnotifyBLECharacteristicValueChanged({
state: true, // 启用 notify 功能
deviceId: thatdatadeviceId,
serviceId: thatdataservicesUUID,
characteristicId: uuid, //第一步 开启监听 notityid 第二步发送指令 write
success: function (res) {
// thatcloseConnect(thatdatadeviceId)
// 设备返回的方法
let tip = 0
wxonBLECharacteristicValueChange(res1 => {
},
/
//监听蓝牙设备是否会异常断开
getTheBlueDisConnectWithAccident() {
},
// 断开设备连接
closeConnect: function(v) {
var that = this
if (v) {
wxcloseBLEConnection({
deviceId: v,
success: function(res) {
consolelog("蓝牙断开连接")
thatcloseBluetoothAdapter()
},
fail(res) {
}
})
} else {
thatcloseBluetoothAdapter()
}
},
// 关闭蓝牙模块
closeBluetoothAdapter:function () {
wxcloseBluetoothAdapter({
success: function(res) {
consolelog("关闭蓝牙模块")
},
fail: function(err) {
}
})
},
1、蓝牙打印机未开启:首先需要确保蓝牙打印机已经开启,并且处于可以被其他设备搜索到的状态。
2、设备不兼容:需要确保你的设备支持与蓝牙打印机进行连接,并且支持打印机所使用的通信协议。
3、未授权连接:需要授权连接蓝牙打印机,否则就会无法获取读写特征值。
4、特征值错误:需要确保获取特征值的UUID是正确的,否则就会无法获取读写特征值。
5、其他原因:还有可能是蓝牙连接信号不稳定,或者设备与打印机之间距离过远等原因导致连接失败。
其实蓝牙这一块, 真心建议官方做成H5+ API, 不应该遇到硬件掉用, 就得依靠Nativejs。 1是性能问题, 2是不利于H5+/MUI的发展, 能熟练使用Nativejs的人, 可能都不会来捣腾H5+/MUI了。。。。
以上就是关于mui13不显示耳机电量全部的内容,包括:mui13不显示耳机电量、iOS BlueTooth HID(Human Interface Device) 键值获取方法、小程序 蓝牙连接等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)