本文整理汇总了C++中QBluetoothDeviceInfo类的典型用法代码示例。如果您正苦于以下问题:C++ QBluetoothDeviceInfo类的具体用法?C++ QBluetoothDeviceInfo怎么用?C++ QBluetoothDeviceInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QBluetoothDeviceInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: serviceName
void tst_QBluetoothServiceInfo::tst_construction()
{
const QString serviceName("My Service");
const QBluetoothDeviceInfo deviceInfo(QBluetoothAddress("001122334455"), "Test Device", 0);
{
QBluetoothServiceInfo serviceInfo;
QVERIFY(!serviceInfo.isValid());
QVERIFY(!serviceInfo.isComplete());
}
{
QBluetoothServiceInfo serviceInfo;
serviceInfo.setServiceName(serviceName);
serviceInfo.setDevice(deviceInfo);
QVERIFY(serviceInfo.isValid());
QCOMPARE(serviceInfo.serviceName(), serviceName);
QCOMPARE(serviceInfo.device().address(), deviceInfo.address());
QBluetoothServiceInfo copyInfo(serviceInfo);
QVERIFY(copyInfo.isValid());
QCOMPARE(copyInfo.serviceName(), serviceName);
QCOMPARE(copyInfo.device().address(), deviceInfo.address());
}
}
示例2: Q_D
/*!
Returns true if the \a other QBluetoothDeviceInfo object and this are identical
*/
bool QBluetoothDeviceInfo::operator==(const QBluetoothDeviceInfo &other) const
{
Q_D(const QBluetoothDeviceInfo);
if(d->cached != other.d_func()->cached)
return false;
if(d->valid != other.d_func()->valid)
return false;
if(d->majorDeviceClass != other.d_func()->majorDeviceClass)
return false;
if(d->minorDeviceClass != other.d_func()->minorDeviceClass)
return false;
if(d->serviceClasses != other.d_func()->serviceClasses)
return false;
if(d->name != other.d_func()->name)
return false;
if(d->address != other.d_func()->address)
return false;
if(d->serviceUuidsCompleteness != other.d_func()->serviceUuidsCompleteness)
return false;
if(d->serviceUuids.count() != other.d_func()->serviceUuids.count())
return false;
if(d->serviceUuids != other.d_func()->serviceUuids)
return false;
return true;
}
示例3: tst_manufacturerSpecificData
void tst_QBluetoothDeviceInfo::tst_manufacturerSpecificData()
{
QBluetoothDeviceInfo deviceInfo;
QByteArray data;
bool available;
data = deviceInfo.manufacturerSpecificData(&available);
// Current API implementation returns only empty QByteArray()
QCOMPARE(data, QByteArray());
}
示例4: deviceDiscovered
void Nushabe::deviceDiscovered(const QBluetoothDeviceInfo &device)
{
dev_list.push_back(device);
qDebug() << "Found new device:" << device.name() << '(' << device.address().toString() << ')' ;
if(device.address().toString() == "98:D3:31:60:30:DF")
{
startClient();
}
}
示例5: QFETCH
void tst_QBluetoothDeviceDiscoveryAgent::tst_deviceDiscovery()
{
{
QFETCH(QBluetoothDeviceDiscoveryAgent::InquiryType, inquiryType);
QBluetoothDeviceDiscoveryAgent discoveryAgent;
QVERIFY(discoveryAgent.error() == discoveryAgent.NoError);
QVERIFY(discoveryAgent.errorString().isEmpty());
QVERIFY(!discoveryAgent.isActive());
QVERIFY(discoveryAgent.discoveredDevices().isEmpty());
QSignalSpy finishedSpy(&discoveryAgent, SIGNAL(finished()));
QSignalSpy errorSpy(&discoveryAgent, SIGNAL(error(QBluetoothDeviceDiscoveryAgent::Error)));
QSignalSpy discoveredSpy(&discoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)));
// connect(&discoveryAgent, SIGNAL(finished()), this, SLOT(finished()));
// connect(&discoveryAgent, SIGNAL(deviceDiscovered(const QBluetoothDeviceInfo&)),
// this, SLOT(deviceDiscoveryDebug(const QBluetoothDeviceInfo&)));
discoveryAgent.setInquiryType(inquiryType);
discoveryAgent.start();
QVERIFY(discoveryAgent.isActive());
// Wait for up to MaxScanTime for the scan to finish
int scanTime = MaxScanTime;
while (finishedSpy.count() == 0 && scanTime > 0) {
QTest::qWait(15000);
scanTime -= 15000;
}
qDebug() << scanTime << MaxScanTime;
// verify that we are finished
QVERIFY(!discoveryAgent.isActive());
// stop
discoveryAgent.stop();
QVERIFY(!discoveryAgent.isActive());
qDebug() << "Scan time left:" << scanTime;
// Expect finished signal with no error
QVERIFY(finishedSpy.count() == 1);
QVERIFY(errorSpy.isEmpty());
QVERIFY(discoveryAgent.error() == discoveryAgent.NoError);
QVERIFY(discoveryAgent.errorString().isEmpty());
// verify that the list is as big as the signals received.
QVERIFY(discoveredSpy.count() == discoveryAgent.discoveredDevices().length());
// verify that there really was some devices in the array
QVERIFY(discoveredSpy.count() > 0);
// All returned QBluetoothDeviceInfo should be valid.
while (!discoveredSpy.isEmpty()) {
const QBluetoothDeviceInfo info =
qvariant_cast<QBluetoothDeviceInfo>(discoveredSpy.takeFirst().at(0));
QVERIFY(info.isValid());
}
}
}
示例6: btDeviceDiscovered
void BTDiscovery::btDeviceDiscovered(const QBluetoothDeviceInfo &device)
{
btPairedDevice this_d;
this_d.address = markBLEAddress(&device);
this_d.name = device.name();
btPairedDevices.append(this_d);
QList<QBluetoothUuid> serviceUuids = device.serviceUuids();
foreach (QBluetoothUuid id, serviceUuids) {
addBtUuid(id);
qDebug() << id.toByteArray();
}
示例7: handleDiscoveredService
void LiveViewScanner::handleDiscoveredService(const QBluetoothServiceInfo &info)
{
const QBluetoothDeviceInfo dev = info.device();
QString deviceName = dev.name();
if (deviceName == "LiveView") {
QVariantMap foundInfo;
foundInfo["driver"] = QString("liveview");
foundInfo["address"] = dev.address().toString();
foundInfo["name"] = deviceName;
foundInfo["notification-watchlet"] = QString("com.javispedro.sowatch.liveview.notification");
emit watchFound(foundInfo);
}
}
示例8: QVariant
QVariant QDeclarativeBluetoothDiscoveryModel::data(const QModelIndex &index, int role) const
{
if (!index.isValid() || index.row() < 0)
return QVariant();
if (discoveryMode() != DeviceDiscovery) {
if (index.row() >= d->m_services.count()){
qCWarning(QT_BT_QML) << "index out of bounds";
return QVariant();
}
QDeclarativeBluetoothService *service = d->m_services.value(index.row());
switch (role) {
case Name: {
QString label = service->deviceName();
if (label.isEmpty())
label += service->deviceAddress();
else
label+= QStringLiteral(":");
label += QStringLiteral(" ") + service->serviceName();
return label;
}
case ServiceRole:
return QVariant::fromValue(service);
case DeviceName:
return service->deviceName();
case RemoteAddress:
return service->deviceAddress();
}
} else {
if (index.row() >= d->m_devices.count()) {
qCWarning(QT_BT_QML) << "index out of bounds";
return QVariant();
}
QBluetoothDeviceInfo device = d->m_devices.value(index.row());
switch (role) {
case Name:
return (device.name() + QStringLiteral(" (") + device.address().toString() + QStringLiteral(")"));
case ServiceRole:
break;
case DeviceName:
return device.name();
case RemoteAddress:
return device.address().toString();
}
}
return QVariant();
}
示例9: vDeviceDiscovered
//Read information about the found devices
void BluetoothConnection::vDeviceDiscovered(const QBluetoothDeviceInfo &device)
{
//qDebug() << "Found new device:" << device.name() << '(' << device.address().toString() << ')';
emit deviceFound(device.name(), device.address().toString());
/*
qDebug() << "Discovered service on" << serviceInfo.device().name() << serviceInfo.device().address().toString();
qDebug() << "\tService name:" << serviceInfo.serviceName();
qDebug() << "\tDescription:" << serviceInfo.attribute(QBluetoothServiceInfo::ServiceDescription).toString();
qDebug() << "\tProvider:" << serviceInfo.attribute(QBluetoothServiceInfo::ServiceProvider).toString();
qDebug() << "\tL2CAP protocol service multiplexer:" << serviceInfo.protocolServiceMultiplexer();
qDebug() << "\tRFCOMM server channel:" << serviceInfo.serverChannel();
*/
}
示例10: addDevice
void DeviceDiscoveryDialog::addDevice(const QBluetoothDeviceInfo &info)
{
QString label = QString("%1 %2").arg(info.address().toString()).arg(info.name());
QList<QListWidgetItem *> items = ui->list->findItems(label, Qt::MatchExactly);
if(items.empty()) {
QListWidgetItem *item = new QListWidgetItem(label);
QBluetoothLocalDevice::Pairing pairingStatus = localDevice->pairingStatus(info.address());
if (pairingStatus == QBluetoothLocalDevice::Paired || pairingStatus == QBluetoothLocalDevice::AuthorizedPaired )
item->setTextColor(QColor(Qt::green));
else
item->setTextColor(QColor(Qt::black));
ui->list->addItem(item);
}
}
示例11: QVERIFY
void tst_QBluetoothDeviceInfo::tst_serviceUuids()
{
QBluetoothDeviceInfo deviceInfo;
QBluetoothDeviceInfo copyInfo = deviceInfo;
QList<QBluetoothUuid> servicesList;
servicesList.append(QBluetoothUuid::L2cap);
servicesList.append(QBluetoothUuid::Rfcomm);
QVERIFY(servicesList.count() > 0);
deviceInfo.setServiceUuids(servicesList, QBluetoothDeviceInfo::DataComplete);
QVERIFY(deviceInfo.serviceUuids().count() > 0);
QVERIFY(!(deviceInfo == copyInfo));
QVERIFY(deviceInfo.serviceUuidsCompleteness() == QBluetoothDeviceInfo::DataComplete);
}
示例12: addDevice
//! [les-devicediscovery-3]
void Device::addDevice(const QBluetoothDeviceInfo &info)
{
if (info.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) {
DeviceInfo *d = new DeviceInfo(info);
devices.append(d);
setUpdate("Last device added: " + d->getName());
}
}
示例13: deviceDiscovered
void QDeclarativeBluetoothDiscoveryModel::deviceDiscovered(const QBluetoothDeviceInfo &device)
{
//qDebug() << "Device discovered" << device.address().toString() << device.name();
beginInsertRows(QModelIndex(),d->m_devices.count(), d->m_devices.count());
d->m_devices.append(device);
endInsertRows();
emit deviceDiscovered(device.address().toString());
}
示例14: _q_deviceDiscovered
void QBluetoothServiceDiscoveryAgentPrivate::_q_deviceDiscovered(const QBluetoothDeviceInfo &info)
{
// look for duplicates, and cached entries
for (int i = 0; i < discoveredDevices.count(); i++) {
if (discoveredDevices.at(i).address() == info.address())
discoveredDevices.removeAt(i);
}
discoveredDevices.prepend(info);
}
示例15: handleDiscoveredService
void MetaWatchScanner::handleDiscoveredService(const QBluetoothServiceInfo &info)
{
const QBluetoothDeviceInfo dev = info.device();
QString deviceName = dev.name();
if (deviceName.startsWith("MetaWatch")) {
QVariantMap foundInfo;
foundInfo["address"] = dev.address().toString();
foundInfo["name"] = deviceName;
qDebug() << "metawatch bluetooth scan found:" << deviceName;
if (deviceName.contains("Analog")) {
// This is Analog metawatch.
foundInfo["driver"] = QString("metawatch-analog");
emit watchFound(foundInfo);
} else {
// For now, assume Digital metawatch.
foundInfo["driver"] = QString("metawatch-digital");
foundInfo["idle-watchlet"] = QString("com.javispedro.sowatch.metawatch.watchface");
foundInfo["notification-watchlet"] = QString("com.javispedro.sowatch.metawatch.notification");
emit watchFound(foundInfo);
}
}
}