QBluetoothDeviceInfo

一、描述

QBluetoothDeviceInfo 类存储有关蓝牙设备的信息。

二、类型成员

1、enum QBluetoothDeviceInfo::CoreConfiguration:此枚举描述了设备的配置。

  • UnknownCoreConfiguration:无法确定蓝牙设备的类型。
  • BaseRateCoreConfiguration:标准蓝牙设备。
  • BaseRateAndLowEnergyCoreConfiguration:蓝牙智能设备,支持标准和低功耗设备。
  • LowEnergyCoreConfiguration:低功耗蓝牙设备。

2、enum class QBluetoothDeviceInfo::Field:此枚举与 QBluetoothDeviceDiscoveryAgent::deviceUpdated() 信号结合使用,用于指示已更改的字段。

  • Field::None:没有任何值改变。
  • Field::RSSI:设备的 rssi() 值已更改。
  • Field::ManufacturerData:manufacturerData() 字段已更改
  • Field::ServiceData:serviceData() 字段已更改
  • Field::All:匹配所有可能的字段。

3、enum QBluetoothDeviceInfo::MajorDeviceClass:此枚举描述了主要蓝牙设备的类型。

  • MiscellaneousDevice:杂项设备。
  • ComputerDevice:计算机或掌上电脑。
  • PhoneDevice:电话设备。
  • NetworkDevice:提供对局域网的访问的设备。
  • AudioVideoDevice:能够播放或捕获音频和/或视频的设备。
  • PeripheralDevice:键盘、鼠标等外围设备。
  • ImagingDevice:成像设备,例如显示器、打印机、扫描仪或照相机。
  • WearableDevice:可穿戴设备,例如手表或寻呼机。
  • ToyDevice:玩具设备。
  • HealthDevice:与健康相关的设备,例如心率或温度监测器。
  • UncategorizedDevice:其他分类的设备。

4、enum QBluetoothDeviceInfo::MinorAudioVideoClass:此枚举描述了音频/视频设备的次要蓝牙设备。

  • UncategorizedAudioVideoDevice:未分类的音频/视频设备。
  • WearableHeadsetDevice:可穿戴耳机设备。
  • HandsFreeDevice:免提设备。
  • Microphone:麦克风。
  • Loudspeaker:一个扬声器。
  • Headphones:耳机。
  • PortableAudioDevice:便携式音频设备。
  • CarAudio:汽车音频设备。
  • SetTopBox:机顶盒。
  • HiFiAudioDevice:HiFi 音频设备。
  • Vcr:录像机。
  • VideoCamera:摄像机。
  • Camcorder:摄像机。
  • VideoMonitor:视频监视器。
  • VideoDisplayAndLoudspeaker:带有内置扬声器的视频显示器。
  • VideoConferencing:视频会议设备。
  • GamingDevice:游戏设备。

5、enum QBluetoothDeviceInfo::MinorComputerClass:此枚举描述了计算机设备的次要蓝牙设备。

  • UncategorizedComputer:未分类的计算机设备。
  • DesktopComputer:台式计算机。
  • ServerComputer:服务器计算机。
  • LaptopComputer:笔记本电脑。
  • HandheldClamShellComputer:翻盖式手持计算机或掌上电脑。
  • HandheldComputer:手持计算机或掌上电脑。
  • WearableComputer:可穿戴计算机。

6、enum QBluetoothDeviceInfo::MinorHealthClass:此枚举描述了健康设备的次要蓝牙设备。

  • UncategorizedHealthDevice:未分类的健康设备。
  • HealthBloodPressureMonitor:血压监测器。
  • HealthThermometer:温度计。
  • HealthWeightScale:体重秤。
  • HealthGlucoseMeter:血糖仪。
  • HealthPulseOximeter:血氧饱和度计。
  • HealthDataDisplay:健康数据显示器。
  • HealthStepCounter:计步器。

7、enum QBluetoothDeviceInfo::MinorImagingClass:此枚举描述了成像设备的次要蓝牙设备。

  • UncategorizedImagingDevice:未分类的成像设备。
  • ImageDisplay:图像显示设备。
  • ImageCamera:摄像头。
  • ImageScanner:图像扫描仪。
  • ImagePrinter:图像打印机。

8、enum QBluetoothDeviceInfo::MinorMiscellaneousClass:此枚举描述了杂项设备的次要蓝牙设备。

  • UncategorizedMiscellaneous:未分类的杂项设备。

9、enum QBluetoothDeviceInfo::MinorNetworkClass:此枚举描述了局域网访问设备的当前的网络利用率。

  • NetworkFullService:100% 的总带宽可用。
  • NetworkLoadFactorOne:当前正在使用总带宽的 0% - 17%。
  • NetworkLoadFactorTwo:当前正在使用总带宽的 17% - 33%。
  • NetworkLoadFactorThree:当前正在使用总带宽的 33% - 50%。
  • NetworkLoadFactorFour:当前正在使用总带宽的 50% - 67%。
  • NetworkLoadFactorFive:当前正在使用总带宽的 67% - 83%。
  • NetworkLoadFactorSix:当前正在使用总带宽的 83% - 99%。
  • NetworkNoService:没有可用的网络服务。

10、enum QBluetoothDeviceInfo::MinorPeripheralClass:此枚举描述外围设备的次要蓝牙设备。

  • UncategorizedPeripheral:未分类的外围设备。
  • KeyboardPeripheral:键盘。
  • PointingDevicePeripheral:指点设备,例如鼠标。
  • KeyboardWithPointingDevicePeripheral:带有内置指针设备的键盘。
  • JoystickPeripheral:操纵杆。
  • GamepadPeripheral:游戏手柄。
  • RemoteControlPeripheral:遥控器。
  • SensingDevicePeripheral:传感设备。
  • DigitizerTabletPeripheral:数位板外设。
  • CardReaderPeripheral:读卡器外围设备。

11、enum QBluetoothDeviceInfo::MinorPhoneClass:此枚举描述电话设备的次要蓝牙设备。

  • UncategorizedPhone:未分类的电话设备。
  • CellularPhone:手机。
  • CordlessPhone:无绳电话。
  • SmartPhone:智能手机。
  • WiredModemOrVoiceGatewayPhone:有线调制解调器或语音网关。
  • CommonIsdnAccessPhone:提供 ISDN 访问的设备。

12、enum QBluetoothDeviceInfo::MinorToyClass:此枚举描述了玩具设备的次要蓝牙设备。

  • UncategorizedToy:未分类的玩具。
  • ToyRobot:玩具机器人。
  • ToyVehicle:玩具车。
  • ToyDoll:玩具娃娃或人偶。
  • ToyController:控制器。
  • ToyGam:游戏。

13、enum QBluetoothDeviceInfo::MinorWearableClass:此枚举描述了可穿戴设备的次要蓝牙设备。

  • UncategorizedWearableDevice:未分类的可穿戴设备。
  • WearableWristWatch:手表。
  • WearablePager:寻呼机。
  • WearableJacket:夹克。
  • WearableHelmet:头盔。
  • WearableGlasses:眼镜。

14、enum QBluetoothDeviceInfo::ServiceClass:此枚举描述了蓝牙设备的服务类型。

  • NoService:不提供任何服务。
  • PositioningService:提供定位服务。
  • NetworkingService:提供网络服务。
  • RenderingService:提供渲染服务。
  • CapturingService:提供捕获服务。
  • ObjectTransferService:提供对象传输服务。
  • AudioService:提供音频服务。
  • TelephonyService:提供电话服务。
  • InformationService:提供信息服务。
  • AllServices:提供所有类型的服务。

三、成员函数

1、QBluetoothAddress address()

返回设备的地址。

在 iOS 和 macOS 上,此地址无效,应该使用 deviceUuid()。 这两个平台不会为找到的蓝牙设备公开蓝牙地址。

2、QBluetoothUuid deviceUuid() / void setDeviceUuid(const QBluetoothUuid &uuid)

返回没有地址的蓝牙设备的唯一标识符。

一般来说,这个 uuid 在除 macOS 和 iOS 之外的所有平台上都是无效的。

3、bool isCached() / void setCached(bool cached)

当前对象是否从缓存数据创建的。缓存的信息可能不如从活动设备中读取的数据准确。

4、bool isValid()

对象是否有效。

5、QByteArray manufacturerData(quint16 manufacturerId) /

bool setManufacturerData(quint16 producerId, const QByteArray &data)

返回与制造商 ID 关联的数据。

制造商数据由蓝牙核心规范的补充定义,由两部分组成:

  • 制造商特定标识符代码
  • 任意数据字节的序列

远程设备可以为每个制造商 ID 提供多个数据条目。此函数仅返回第一个条目。如果需要所有条目,使用 manufacturerData()。

6、QMultiHash<quint16, QByteArray> manufacturerData()

返回所有制造商的完整数据集。

#include "widget.h"
#include "ui_widget.h"
#include <QBluetoothDeviceDiscoveryAgent>Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered,this, &Widget::deviceDiscovered);
}Widget::~Widget()
{delete ui;
}void Widget::deviceDiscovered(const QBluetoothDeviceInfo &device)
{qDebug() << "发现新设备:" << device.name() << '(' << device.address().toString() << ')';QMultiHash<quint16, QByteArray> data = device.manufacturerData();for(auto it = data.cbegin();it != data.cend();++it){qDebug() << it.key()<<QString(it.value().toHex());}
}void Widget::on_pushButton_clicked()
{qDebug() << "开始搜索";discoveryAgent->start();
}

7、QList<quint16> manufacturerIds()

返回所有制造商 ID。

8、QString name() / void setName(const QString &name)

返回分配给设备的名称。

9、qint16 rssi() / void setRssi(qint16 signal)

返回上次扫描设备时的信号强度。

10、QByteArray serviceData(const QBluetoothUuid &serviceId)

bool setServiceData(const QBluetoothUuid &serviceId, const QByteArray &data)

返回与 serviceId 关联的服务数据。

服务数据由蓝牙核心规范的补充定义,由两部分组成:

  • 服务 UUID
  • 任意数据字节的序列

远程设备可以为每个 serviceId 提供多个数据条目。此函数仅返回第一个条目。需要所有条使用 serviceData()。

11、QMultiHash<QBluetoothUuid, QByteArray> serviceData()

返回完整的所有服务数据集。

#include "widget.h"
#include "ui_widget.h"
#include <QBluetoothDeviceDiscoveryAgent>Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered,this, &Widget::deviceDiscovered);
}Widget::~Widget()
{delete ui;
}void Widget::deviceDiscovered(const QBluetoothDeviceInfo &device)
{qDebug() << "发现新设备:" << device.name() << '(' << device.address().toString() << ')';QMultiHash<QBluetoothUuid, QByteArray> data = device.serviceData();for(auto it = data.cbegin();it != data.cend();++it){qDebug() << it.key()<<QString(it.value().toHex());}
}void Widget::on_pushButton_clicked()
{qDebug() << "开始搜索";discoveryAgent->start();
}

12、QList<QBluetoothUuid> serviceIds()

返回所有服务数据 ID。

13、QList<QBluetoothUuid> serviceUuids()

void setServiceUuids(const QList<QBluetoothUuid> &uuids)

返回设备支持的服务 UUID 列表。


QBluetoothAddress

一、描述

此类以独立于平台和协议的方式保存蓝牙地址。

#include "widget.h"
#include "ui_widget.h"
#include <QBluetoothDeviceDiscoveryAgent>Widget::Widget(QWidget *parent): QWidget(parent), ui(new Ui::Widget)
{ui->setupUi(this);discoveryAgent = new QBluetoothDeviceDiscoveryAgent(this);connect(discoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered,this, &Widget::deviceDiscovered);
}Widget::~Widget()
{delete ui;
}void Widget::deviceDiscovered(const QBluetoothDeviceInfo &device)
{qDebug() << "发现新设备:" << device.name() << '(' << device.address().toString() << ')';QBluetoothAddress addr = device.address();qDebug() <<addr.toString();qDebug() <<addr.toUInt64();
}void Widget::on_pushButton_clicked()
{qDebug() << "开始搜索";discoveryAgent->start();
}

二、成员函数

1、void clear()

将蓝牙地址设置为 00:00:00:00:00:00。

2、bool isNull()

蓝牙地址是否有效。

3、QString toString()

以 XX:XX:XX:XX:XX:XX 形式的字符串返回蓝牙地址。

4、quint64 toUInt64()

将蓝牙地址作为 quint64 返回。

Qt蓝牙:QBluetoothDeviceInfo、QBluetoothAddress相关推荐

  1. qt蓝牙开发基本步骤

    部分内容摘抄至https://www.jianshu.com/p/2809ead73d2a 蓝牙常用框架 : CoreBluetooth 蓝牙常用库 :BabyBluetooth . YmsCoreB ...

  2. Qt on android 蓝牙开发(控制小车)

    因为要做一个用蓝牙控制小车的app,就用着QT搞了下,网上关于QT蓝牙开发的资料比较少,我在这里记录下过程希望对看到了人有所帮助 首先在项目文件里添加 QT += bluetooth 这样就可以用QT ...

  3. Qt windows端的蓝牙串口服务

    Qt windows端的蓝牙串口服务 环境 系统 Qt 蓝牙模块 使用步骤 蓝牙模块参数获取 配对 扫描.连接.数据收发 扫描 连接 数据收发 环境 系统 只测试过自己电脑,系统版本如下: 查看方式按 ...

  4. 蓝牙客户端QBluetoothSocket的使用——Qt For Android

    了解蓝牙 经典蓝牙和低功耗蓝牙差异 经典蓝牙(Bluetooth Classic):分为基本速率/增强数据速率(BR/EDR), 79个信道,在2.4GHz的(ISM)频段.支持点对点设备通信,主要用 ...

  5. c++ windows 蓝牙库_c++ - “是否有一个多操作系统蓝牙库?”后续:QT Linux到Windows 10蓝牙 - 堆栈内存溢出...

    在尝试进行研究以解决问题时,我多次打开了这个问题. 过去四年发生了什么变化? 文档说QT蓝牙理论上应该支持我要建立的连接(Linux CentOS 7连接到带有Windows 10的平板电脑-版本16 ...

  6. Qt中低功耗蓝牙模块使用

    最近在Qt下使用opencv库,进行一些图像识别和处理相关的工作,主要是通过摄像头采集运动采样视频,然后进行一些跑姿分析和稳定性测试.但仅仅从视频帧来分析,还是有很多缺陷,后来就想着,如果结合公司的智 ...

  7. 【正点原子Linux连载】 第十九章 CAN Bus 摘自【正点原子】I.MX6U嵌入式Qt开发指南V1.0.2

    1)实验平台:正点原子阿尔法Linux开发板 2)平台购买地址:https://item.taobao.com/item.htm?id=603672744434 3)全套实验源码+手册+视频下载地址: ...

  8. Qt学习笔记之网络和连接

    Qt提供用于高级和低级网络通信的类,用于Web集成的类以及用于进程间通信的类. 对于高级网络流量,Qt Network在使用的操作上提供了一个抽象层,仅显示高级类和功能.Qt Network还可以处理 ...

  9. 翻译 | 正式发布Qt 5.11

    本文翻译自:Qt 5.11 released 原文作者: Qt公司CTO兼Qt开源项目维护官Lars Knoll 翻译校审:Richard Lin.Hongfei Zhang.Haipeng Yu 本 ...

最新文章

  1. mysql数字字符串教程_很全面的mysql字符串函数的教程
  2. 皮卡丘为什么不进化_皮卡丘为啥不进化成雷丘?小智都暗示得这么明显皮卡丘还是拒绝了...
  3. Activity之间的通信方式
  4. exists改写SQL,使其走正确的执行计划
  5. python练习之析构函数
  6. linux 内核设备管理模型sysfs(进阶篇)
  7. linux发布tomcat项目项目流程,linux下tomcat的配置及项目的部署流程
  8. Python程序编译与反编译
  9. Swift 3: let sortedNumbers = numbers.sort { $0 $1 } print(sortedNumbers) 结果显示为()
  10. MySQL 高性能表设计规范
  11. linux查看行数命令 set,Linux显示文件行数之nl命令详解
  12. windows下grep的安装与使用
  13. 单片机与一般微型计算机相比具有哪些特点,单片机原理与接口技术习题答案
  14. 图片怎么无损放大?不影响清晰度这么做
  15. 点评互联网产品经理面试问题汇总(18问)
  16. 华为交换机修改concle密码
  17. 将苹果通讯录.contacts文件导入安卓通讯录提取.contacts文件联系人的教程
  18. 细说强网杯Web辅助
  19. 01-邂逅Vuejs
  20. 可视化系列讲解:css2.5D动画->帧动画

热门文章

  1. 七日年化收益率怎么算「知识普及」
  2. Gauss消元法(特解与通解)
  3. 信息传播渠道多元化日渐明显
  4. 数据结构-图(图的定义、分类、基本术语和存储结构)
  5. Kotlin真的值得学习吗?
  6. 树莓派与ESP8266-MQTT无线通信
  7. nxp的wifi驱动调试
  8. 时序预测之三_傅立叶和小波变换
  9. sap采购申请自动转采购订单
  10. 改变控制台字体的大小