怎样获取蓝牙连接设备的mac地址

怎样获取蓝牙连接设备的mac地址,第1张

创建项目,设置plist 实现delegate方法,判断蓝牙状态,如成功则扫描指定UUID设备(如不指定UUID,则无法后台持续连接) 实现delegate方法,当发现指定设备后,连接该设备 实现delegate方法,当连接指定外围设备成功,编写定时器,每秒读取1次RSSI 实现delegate方法,当监听到失去和外围设备连接,重新建立连接 实现delegate方法,当读取到RSSI值,打印出它的值

重启:adb reboot

推文件:adb push E:\xxxtxt storage/sdcard

拉文件:adb push storage/sdcard

将日志保存到电脑文件: adb logcat > xxx xxx电脑文本地址

清除指定应用的数据和缓存:adb shell pm clear 例:adb shell pm clear comyzltest

查看日志缓冲区大小:adb shell logcat-g

设置日志缓冲区大小:adb logcat-G10M

打开蓝牙:adb shell svc bluetooth enable

关闭蓝牙:adb shell svc bluetooth disable

查询蓝牙是否打开:adb shell settingsgetglobalbluetooth_on

获取蓝牙Mac地址:adb shell settingsgetsecure bluetooth_address

获取某个包名的安装路径:adb shell pm path comxxxx

查看所有存活的进程:adb shell ps

过滤关键字查看adb shell ps|findstr xxx

强制安装版本号更低的apk:adb install -r -d "C:\xxapk"

对指定应用进行500次模拟触摸事件:adb shell monkey -p comyzltest -v 500

查看某个apk的应用信息、版本信息:adb shell dumpsys package comyzltest

查看已安装应用列表:adb shell pm list package或adb shell pm list packages-s

MAC地址不叫网卡号,它是媒体接入控制地址,你电脑蓝牙的MAC地址确实是唯一的,要从你的手机里面查到这个地址很简单,下载一个安卓手机串口调试助手,安装后,打开软件,里面有一个连接设备,点击后,你会看到你手机曾经配对过的所有蓝牙的MAC地址,如果你的电脑和手机配对过,就能找到这个MAC地址,但是它是蓝牙的,不是网卡的。如果你的手机是IPONE,这个软件就不行了,希望这种办法对你有用,早日找回自己的电脑。

送上我迟来的答案,不知你这条帮助是哪年留下的,我是通过手机看到你的求助,但是却看不到你是那年留下的问题,能看到下面有人在15年的答复,估计应该是5年之前的问题了,即便能帮助到你也是作用不大了。我这有一款APP可以看到你手机上曾经连接过的所有蓝牙设备的MAC地址,只要是你手机曾连接过的设备,就全部都能看到Mac地址,APP名为

Walkie-Talkie via Bluetooth

只可惜我看到你的求助太迟了,已相隔5年之久,若当时看到多好啊一定会帮得到你^_^

当我们使用中心设备进行扫描的时候,即在

方法中,我们就可以通过扫描到的蓝牙外设的名字(peripheralname)来进行针对性的 *** 作。

有一些公司的外部设备的名字都是一样的,但是进行连接或者其他 *** 作的时候,没必要知道具体的是哪一台设备,那么就可以使用蓝牙外设的UUIDString(即peripheralidentifierUUIDString)来作为唯一标识。但是,需要注意的一点:不同的中心设备(也可以说是不同的手机)对于同一台蓝牙设备,获取到的UUIDString是不一样的。

举例说明一下:对于同一台蓝牙设备,我的手机进行扫描,然后读取它的UUIDString,和你的手机进行扫描,获取到的UUIDString是不同的。

针对这种情况,我们只能获取蓝牙设备的mac地址来作为唯一标识。但是,苹果公司也许是出于安全考虑,并没有对我们开放获取蓝牙设备的mac地址的接口(安卓开发是可以获取的)。那么我们只能自己通过某种手段来获取mac地址,有两种方法可以让我们获取到mac地址:

第一种:将mac地址放在蓝牙设备的广播数据之中,然后在广播的时候,将mac地址以广播的形式发送出来以供我们获取。

第二种:将mac地址写在某一个特征通道中,当我们连接蓝牙设备之后,通过某一个特征通道来获取mac地址。

原文

通常是是关于手机、设置等里面大致是以下的样子

MAC地址也叫MAC码是蓝牙或wifi技术的机身串号需要向美国申请,希望回答对您有所帮助,如有需要进一步咨询请百度我们即可~

流程是这样的:先初始化蓝牙适配器,然后获取本机蓝牙适配器的状态,然后开始搜索,当停止搜索以后在开始搜索,就会触发蓝牙是配置状态变化的事件,搜索完成以后获取所有已经发现的蓝牙设备,就可以将devices中的设备Array取出来了。然后就可以得到所有已经连接的设备了,至于链接功能,还没有真机可测,所以没有测试。

我的电脑上蓝牙连接的设备:

以下是案例代码:

// pages/bluetooth/bluetoothjs

Page({

data:{},

onLoad:function(options){

// 页面初始化 options为页面跳转所带来的参数

},

//初始化蓝牙适配器

openBluetooth:function(){

wxopenBluetoothAdapter({

success: function(res){

consolelog(reserrMsg)

// success

wxshowToast({

title:"初始化蓝牙适配器成功",

duration:2000

})

},

})

},

//关闭蓝牙模块

closeBluetooth:function(){

wxopenBluetoothAdapter()

wxcloseBluetoothAdapter({

success: function(res){

// success

consolelog("success"+res)

}

})

},

//获取本机蓝牙适配器状态

getBluetoothAdapterState:function(){

wxgetBluetoothAdapterState({

success: function(res){

// success

consolelog("res:"+res)

consolelog("errMsg:"+reserrMsg)

}

})

},

//监听蓝牙适配器状态变化事件

onBluetoothAdapterStateChange:function(){

wxonBluetoothAdapterStateChange(function(res) {

consolelog(`adapterState changed, now is`, res)

})

},

// 开始搜寻附近的蓝牙外围设备

startBluetoothDevicesDiscovery:function(){

wxstartBluetoothDevicesDiscovery({

success: function (res) {

consolelog(res)

}

})

},

// 停止搜寻附近的蓝牙外围设备

stopBluetoothDevicesDiscovery:function(){

wxstopBluetoothDevicesDiscovery({

success: function (res) {

consolelog(res)

}

})

},

//获取所有已发现的蓝牙设备

getBluetoothDevices:function(){

wxgetBluetoothDevices({

success: function(res){

// success

consolelog(res)

},

})

},

//监听寻找到新设备的事件

onBluetoothDeviceFound:function(){

wxonBluetoothDeviceFound(function(res) {

// callback

consolelog(res)

})

},

//根据 uuid 获取处于已连接状态的设备

getConnectedBluetoothDevices:function(){

wxgetConnectedBluetoothDevices({

success: function (res) {

consolelog(res)

}

})

},

//连接低功耗蓝牙设备

createBLEConnection:function(){

wxcreateBLEConnection({

deviceId: 'AC:BC:32:C1:47:80',

success: function(res){

// success

consolelog(res)

},

fail: function(res) {

// fail

},

complete: function(res) {

// complete

}

})

},

//断开与低功耗蓝牙设备的连接

closeBLEConnection:function(){

wxcloseBLEConnection({

deviceId: 'AC:BC:32:C1:47:80',

success: function (res) {

consolelog(res)

}

})

},

//监听低功耗蓝牙连接的错误事件,包括设备丢失,连接异常断开等等

onBLEConnectionStateChanged:function(){

wxonBLEConnectionStateChanged(function(res) {

consolelog(`device ${resdeviceId} state has changed, connected: ${resconnected}`)

})

},

//获取蓝牙设备所有 service(服务)

getBLEDeviceServices:function(){

wxgetBLEDeviceServices({

deviceId: '48:3B:38:88:E3:83',

success: function(res){

// success

consolelog('device services:', resservicesserviceId)

},

fail: function(res) {

// fail

},

complete: function(res) {

// complete

}

})

},

//获取蓝牙设备所有 characteristic(特征值)

getBLEDeviceCharacteristics:function(){

wxgetBLEDeviceCharacteristics({

deviceId: '48:3B:38:88:E3:83',

serviceId: 'serviceId',

success: function(res){

// success

},

fail: function(res) {

// fail

},

complete: function(res) {

// complete

}

})

}

})

以上就是关于怎样获取蓝牙连接设备的mac地址全部的内容,包括:怎样获取蓝牙连接设备的mac地址、Android常用的ADB命令、我怎么样通过存在我手机上的蓝牙名字找到对应的这个蓝牙MAC地址等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/9537203.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-29
下一篇2023-04-29

发表评论

登录后才能评论

评论列表(0条)

    保存