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

作者:TigerOrTiger 时间:2023-08-23 00:57:16 

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'

最终是这样的,想显示成中文,那就改为中文的。有帮助请点一下赞

来源:https://blog.csdn.net/wuyou1995/article/details/103276689

标签:python,bluetooth,蓝牙
0
投稿

猜你喜欢

  • [Oracle] 浅析令人抓狂的ORA-01555问题

    2024-01-21 09:13:28
  • pandas进行时间数据的转换和计算时间差并提取年月日

    2021-03-14 02:22:22
  • Python开发自定义Web框架的示例详解

    2023-05-23 19:43:43
  • VUE中如何动态绑定类名和样式

    2024-04-26 17:41:35
  • 记一次Vue中$route序列号报错

    2024-05-02 17:04:03
  • python类参数self使用示例

    2023-05-27 17:15:18
  • JAVA正则表达式匹配多个空格的解决方案

    2022-07-29 14:39:31
  • 利用django model save方法对未更改的字段依然进行了保存

    2021-12-21 21:24:18
  • go日志库logrus的安装及快速使用

    2024-04-26 17:31:40
  • Python正规则表达式学习指南

    2021-04-11 15:21:16
  • go语言开发环境安装及第一个go程序(推荐)

    2024-05-05 09:34:22
  • 基于Django框架利用Ajax实现点赞功能实例代码

    2022-01-29 02:35:38
  • python中pdb模块实例用法

    2023-10-14 19:04:48
  • php面象对象数据库操作类实例

    2023-10-13 22:33:05
  • Python延时操作实现方法示例

    2023-08-25 04:04:50
  • Python 统计列表中重复元素的个数并返回其索引值的实现方法

    2023-07-15 12:31:24
  • Python连接HDFS实现文件上传下载及Pandas转换文本文件到CSV操作

    2023-09-28 13:34:17
  • Data Source与数据库连接池简介(JDBC简介)

    2024-01-26 03:59:45
  • python中Switch/Case实现的示例代码

    2021-09-18 22:03:39
  • 利用Python发送邮件或发带附件的邮件

    2023-01-17 12:40:31
  • asp之家 网络编程 m.aspxhome.com