温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

python中如何获取蓝牙设备类型

发布时间:2021-05-11 11:32:38 来源:亿速云 阅读:250 作者:小新 栏目:开发技术

这篇文章将为大家详细讲解有关python中如何获取蓝牙设备类型,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。

Python主要用来做什么

Python主要应用于:1、Web开发;2、数据科学研究;3、网络爬虫;4、嵌入式应用开发;5、游戏开发;6、桌面应用开发。

python 获取蓝牙设备类型

扫描蓝牙设备获取到的信息中,无法判断扫描到的蓝牙设备属于什么类型的设备。

扫描蓝牙信息使用的是python 里面的bluetooth模块。

首先扫描出来的是这样的信息

('74:60:FA:FD:FC:49','HUAWEI P30',5898764)

可根据5898764来判断是什么蓝牙设备。

收集了一些设备,可以成功的转化为设备类型

def bt_device_type(device_type):
  if device_type == 5898764 or device_type == 'Android':
    return 'Android'
  if device_type == 7078144 or device_type == 'computer_ubuntu14':
    return 'computer_ubuntu14'
  if device_type == 786700 or device_type == 'computer_ubuntu16':
    return 'computer_ubuntu16'
  if device_type == 655620 or device_type == 'computer_windows':
    return 'computer_windows'
  if device_type == 2360324 or device_type == 'headset':
    return 'headset' #耳机
  if device_type == 2360328 or device_type =='speaker':
    return 'speaker' # 扩音器
  if device_type == 263208 or device_type == 'SV':
    return 'SV' #蓝牙音响
  if device_type == 7995916 or device_type == 'phone':
    return 'phone' #苹果设备
  if device_type == 3670284 or device_type == 'MACBook':
    return 'MACBook'
  if device_type == 7936 or device_type == 2752780 or device_type == 'PC':
    return 'PC'
  if device_type == 6947088 or device_type == 'iPad':
    return 'iPad'
  return 'unknown'

关于“python中如何获取蓝牙设备类型”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,使各位可以学到更多知识,如果觉得文章不错,请把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI