python bluetooth蓝牙信息获取蓝牙设备类型的方法

yipeiwu_com5年前Python基础

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中import机制详解

Python语言中import的使用很简单,直接使用 import module_name 语句导入即可。这里我主要写一下"import"的本质。 Python官方 定义:Python...

特征脸(Eigenface)理论基础之PCA主成分分析法

特征脸(Eigenface)理论基础之PCA主成分分析法

在之前的博客 人脸识别经典算法一:特征脸方法(Eigenface)里面介绍了特征脸方法的原理,但是并没有对它用到的理论基础PCA做介绍,现在做补充。请将这两篇博文结合起来阅读。以下内容大...

Python编写合并字典并实现敏感目录的小脚本

0x00 起因 接触网安快一年了,爱收集一些字典啊敏感目录文件啊什么的。收集多了难免有重复,并且有的也需要合并使用方便。自己就写了一个小小的脚步用来完成这个目的。 0x01 代码 第...

opencv与numpy的图像基本操作

opencv与numpy的图像基本操作

1. 像素基本操作 1.1 读取、修改像素 可以通过[行,列]坐标来访问像素点数据,对于多通道数据,返回一个数组,包含所有通道的值,对于单通道数据(如gray),返回指定坐标的值,也可...

Python实现利用最大公约数求三个正整数的最小公倍数示例

本文实例讲述了Python实现利用最大公约数求三个正整数的最小公倍数。分享给大家供大家参考,具体如下: 在求解两个数的小公倍数的方法时,假设两个正整数分别为a、b的最小公倍数为d,最大公...