本文整理汇总了C++中QBluetoothDeviceInfo::address方法的典型用法代码示例。如果您正苦于以下问题:C++ QBluetoothDeviceInfo::address方法的具体用法?C++ QBluetoothDeviceInfo::address怎么用?C++ QBluetoothDeviceInfo::address使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBluetoothDeviceInfo
的用法示例。
在下文中一共展示了QBluetoothDeviceInfo::address方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tst_construction
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: 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();
}
}
示例3: data
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();
}
示例4: 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);
}
}
示例5: deviceDiscovered
void BtLocalDevice::deviceDiscovered(const QBluetoothDeviceInfo &info)
{
QString services;
if (info.serviceClasses() & QBluetoothDeviceInfo::PositioningService)
services += "Position|";
if (info.serviceClasses() & QBluetoothDeviceInfo::NetworkingService)
services += "Network|";
if (info.serviceClasses() & QBluetoothDeviceInfo::RenderingService)
services += "Rendering|";
if (info.serviceClasses() & QBluetoothDeviceInfo::CapturingService)
services += "Capturing|";
if (info.serviceClasses() & QBluetoothDeviceInfo::ObjectTransferService)
services += "ObjectTra|";
if (info.serviceClasses() & QBluetoothDeviceInfo::AudioService)
services += "Audio|";
if (info.serviceClasses() & QBluetoothDeviceInfo::TelephonyService)
services += "Telephony|";
if (info.serviceClasses() & QBluetoothDeviceInfo::InformationService)
services += "Information|";
services.truncate(services.length()-1); //cut last '/'
qDebug() << "Found new device: " << info.name() << info.isValid() << info.address().toString()
<< info.rssi() << info.majorDeviceClass()
<< info.minorDeviceClass() << services;
}
示例6: _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);
}
示例7: 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());
}
示例8: 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);
}
}
示例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: 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);
}
}
}
示例11: deviceDiscoveryDebug
void tst_QBluetoothDeviceDiscoveryAgent::deviceDiscoveryDebug(const QBluetoothDeviceInfo &info)
{
qDebug() << "Discovered device:" << info.address().toString() << info.name();
}
示例12: tst_assignment
void tst_QBluetoothServiceInfo::tst_assignment()
{
QFETCH(QUuid, uuid);
QFETCH(QBluetoothUuid::ProtocolUuid, protocolUuid);
QFETCH(QBluetoothServiceInfo::Protocol, serviceInfoProtocol);
const QString serviceName("My Service");
const QBluetoothDeviceInfo deviceInfo(QBluetoothAddress("001122334455"), "Test Device", 0);
QBluetoothServiceInfo serviceInfo;
serviceInfo.setServiceName(serviceName);
serviceInfo.setDevice(deviceInfo);
QVERIFY(serviceInfo.isValid());
{
QBluetoothServiceInfo copyInfo = serviceInfo;
QVERIFY(copyInfo.isValid());
QCOMPARE(copyInfo.serviceName(), serviceName);
QCOMPARE(copyInfo.device().address(), deviceInfo.address());
}
{
QBluetoothServiceInfo copyInfo;
QVERIFY(!copyInfo.isValid());
copyInfo = serviceInfo;
QVERIFY(copyInfo.isValid());
QCOMPARE(copyInfo.serviceName(), serviceName);
QCOMPARE(copyInfo.device().address(), deviceInfo.address());
}
{
QBluetoothServiceInfo copyInfo1;
QBluetoothServiceInfo copyInfo2;
QVERIFY(!copyInfo1.isValid());
QVERIFY(!copyInfo2.isValid());
copyInfo1 = copyInfo2 = serviceInfo;
QVERIFY(copyInfo1.isValid());
QVERIFY(copyInfo2.isValid());
QCOMPARE(copyInfo1.serviceName(), serviceName);
QCOMPARE(copyInfo2.serviceName(), serviceName);
QCOMPARE(copyInfo1.device().address(), deviceInfo.address());
QCOMPARE(copyInfo2.device().address(), deviceInfo.address());
}
{
QBluetoothServiceInfo copyInfo;
QVERIFY(!copyInfo.isValid());
copyInfo = serviceInfo;
copyInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, uuid);
QVERIFY(copyInfo.contains(QBluetoothServiceInfo::ProtocolDescriptorList));
QVERIFY(copyInfo.isComplete());
QVERIFY(copyInfo.attributes().count() > 0);
copyInfo.removeAttribute(QBluetoothServiceInfo::ProtocolDescriptorList);
QVERIFY(!copyInfo.contains(QBluetoothServiceInfo::ProtocolDescriptorList));
QVERIFY(!copyInfo.isComplete());
}
{
QBluetoothServiceInfo copyInfo;
QVERIFY(!copyInfo.isValid());
copyInfo = serviceInfo;
QVERIFY(copyInfo.serverChannel() == -1);
QVERIFY(copyInfo.protocolServiceMultiplexer() == -1);
QBluetoothServiceInfo::Sequence protocolDescriptorList;
QBluetoothServiceInfo::Sequence protocol;
protocol << QVariant::fromValue(QBluetoothUuid(protocolUuid));
protocolDescriptorList.append(QVariant::fromValue(protocol));
protocol.clear();
protocolDescriptorList.append(QVariant::fromValue(protocol));
copyInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList,
protocolDescriptorList);
QVERIFY(copyInfo.serverChannel() == -1);
QVERIFY(copyInfo.protocolServiceMultiplexer() != -1);
QVERIFY(copyInfo.socketProtocol() == serviceInfoProtocol);
}
{
QBluetoothServiceInfo copyInfo;
QVERIFY(!copyInfo.isValid());
copyInfo = serviceInfo;
QVERIFY(!copyInfo.isRegistered());
QVERIFY(copyInfo.registerService());
QVERIFY(copyInfo.isRegistered());
//.........这里部分代码省略.........
示例13: addNewDevice
/* slot for discoveryAgent.deviceDiscovered()
*/
void BluetoothAdapter::addNewDevice(const QBluetoothDeviceInfo &info)
{
emit newDeviceDetected(QString("%1 %2").arg(info.address().toString()).arg(info.name()));
}
示例14: tst_assignment
void tst_QBluetoothServiceInfo::tst_assignment()
{
QFETCH(QUuid, uuid);
QFETCH(QBluetoothUuid::ProtocolUuid, protocolUuid);
QFETCH(QBluetoothServiceInfo::Protocol, serviceInfoProtocol);
QFETCH(bool, protocolSupported);
const QString serviceName("My Service");
const QBluetoothDeviceInfo deviceInfo(QBluetoothAddress("001122334455"), "Test Device", 0);
QBluetoothServiceInfo serviceInfo;
serviceInfo.setServiceName(serviceName);
serviceInfo.setDevice(deviceInfo);
QVERIFY(serviceInfo.isValid());
QVERIFY(!serviceInfo.isRegistered());
QVERIFY(!serviceInfo.isComplete());
{
QBluetoothServiceInfo copyInfo = serviceInfo;
QVERIFY(copyInfo.isValid());
QVERIFY(!copyInfo.isRegistered());
QVERIFY(!copyInfo.isComplete());
QCOMPARE(copyInfo.serviceName(), serviceName);
QCOMPARE(copyInfo.device().address(), deviceInfo.address());
}
{
QBluetoothServiceInfo copyInfo;
QVERIFY(!copyInfo.isValid());
QVERIFY(!copyInfo.isRegistered());
QVERIFY(!copyInfo.isComplete());
copyInfo = serviceInfo;
QVERIFY(copyInfo.isValid());
QVERIFY(!copyInfo.isRegistered());
QVERIFY(!copyInfo.isComplete());
QCOMPARE(copyInfo.serviceName(), serviceName);
QCOMPARE(copyInfo.device().address(), deviceInfo.address());
}
{
QBluetoothServiceInfo copyInfo1;
QBluetoothServiceInfo copyInfo2;
QVERIFY(!copyInfo1.isValid());
QVERIFY(!copyInfo1.isRegistered());
QVERIFY(!copyInfo1.isComplete());
QVERIFY(!copyInfo2.isValid());
QVERIFY(!copyInfo2.isRegistered());
QVERIFY(!copyInfo2.isComplete());
copyInfo1 = copyInfo2 = serviceInfo;
QVERIFY(copyInfo1.isValid());
QVERIFY(!copyInfo1.isRegistered());
QVERIFY(!copyInfo1.isComplete());
QVERIFY(copyInfo2.isValid());
QVERIFY(!copyInfo2.isRegistered());
QVERIFY(!copyInfo2.isComplete());
QCOMPARE(copyInfo1.serviceName(), serviceName);
QCOMPARE(copyInfo2.serviceName(), serviceName);
QCOMPARE(copyInfo1.device().address(), deviceInfo.address());
QCOMPARE(copyInfo2.device().address(), deviceInfo.address());
}
{
QBluetoothServiceInfo copyInfo;
QVERIFY(!copyInfo.isValid());
QVERIFY(!copyInfo.isRegistered());
QVERIFY(!copyInfo.isComplete());
copyInfo = serviceInfo;
QVERIFY(copyInfo.contains(QBluetoothServiceInfo::ServiceName));
copyInfo.setAttribute(QBluetoothServiceInfo::ProtocolDescriptorList, QBluetoothUuid(uuid));
QVERIFY(copyInfo.contains(QBluetoothServiceInfo::ProtocolDescriptorList));
QVERIFY(copyInfo.isComplete());
QVERIFY(copyInfo.attributes().count() > 0);
copyInfo.removeAttribute(QBluetoothServiceInfo::ProtocolDescriptorList);
QVERIFY(!copyInfo.contains(QBluetoothServiceInfo::ProtocolDescriptorList));
QVERIFY(!copyInfo.isComplete());
}
{
QBluetoothServiceInfo copyInfo;
QVERIFY(!copyInfo.isValid());
copyInfo = serviceInfo;
QVERIFY(copyInfo.serverChannel() == -1);
QVERIFY(copyInfo.protocolServiceMultiplexer() == -1);
QBluetoothServiceInfo::Sequence protocolDescriptorList;
QBluetoothServiceInfo::Sequence protocol;
//.........这里部分代码省略.........
示例15: tst_construction
void tst_QBluetoothServiceInfo::tst_construction()
{
const QString serviceName("My Service");
const QString alternateServiceName("Another ServiceName");
const QBluetoothDeviceInfo deviceInfo(QBluetoothAddress("001122334455"), "Test Device", 0);
const QBluetoothDeviceInfo alternatedeviceInfo(QBluetoothAddress("554433221100"), "Test Device2", 0);
QList<QBluetoothUuid::ProtocolUuid> protUuids;
//list taken from qbluetoothuuid.h
protUuids << QBluetoothUuid::Sdp;
protUuids << QBluetoothUuid::Udp;
protUuids << QBluetoothUuid::Rfcomm;
protUuids << QBluetoothUuid::Tcp;
protUuids << QBluetoothUuid::TcsBin;
protUuids << QBluetoothUuid::TcsAt;
protUuids << QBluetoothUuid::Att;
protUuids << QBluetoothUuid::Obex;
protUuids << QBluetoothUuid::Ip;
protUuids << QBluetoothUuid::Ftp;
protUuids << QBluetoothUuid::Http;
protUuids << QBluetoothUuid::Wsp;
protUuids << QBluetoothUuid::Bnep;
protUuids << QBluetoothUuid::Upnp;
protUuids << QBluetoothUuid::Hidp;
protUuids << QBluetoothUuid::HardcopyControlChannel;
protUuids << QBluetoothUuid::HardcopyDataChannel;
protUuids << QBluetoothUuid::HardcopyNotification;
protUuids << QBluetoothUuid::Avctp;
protUuids << QBluetoothUuid::Avdtp;
protUuids << QBluetoothUuid::Cmtp;
protUuids << QBluetoothUuid::UdiCPlain;
protUuids << QBluetoothUuid::McapControlChannel;
protUuids << QBluetoothUuid::McapDataChannel;
protUuids << QBluetoothUuid::L2cap;
{
QBluetoothServiceInfo serviceInfo;
QVERIFY(!serviceInfo.isValid());
QVERIFY(!serviceInfo.isComplete());
QVERIFY(!serviceInfo.isRegistered());
QCOMPARE(serviceInfo.serviceName(), QString());
QCOMPARE(serviceInfo.serviceDescription(), QString());
QCOMPARE(serviceInfo.serviceProvider(), QString());
QCOMPARE(serviceInfo.serviceUuid(), QBluetoothUuid());
QCOMPARE(serviceInfo.serviceClassUuids().count(), 0);
QCOMPARE(serviceInfo.attributes().count(), 0);
QCOMPARE(serviceInfo.serverChannel(), -1);
QCOMPARE(serviceInfo.protocolServiceMultiplexer(), -1);
foreach (QBluetoothUuid::ProtocolUuid u, protUuids)
QCOMPARE(serviceInfo.protocolDescriptor(u).count(), 0);
}
{
QBluetoothServiceInfo serviceInfo;
serviceInfo.setServiceName(serviceName);
serviceInfo.setDevice(deviceInfo);
QVERIFY(serviceInfo.isValid());
QVERIFY(!serviceInfo.isComplete());
QVERIFY(!serviceInfo.isRegistered());
QCOMPARE(serviceInfo.serviceName(), serviceName);
QCOMPARE(serviceInfo.device().address(), deviceInfo.address());
QBluetoothServiceInfo copyInfo(serviceInfo);
QVERIFY(copyInfo.isValid());
QVERIFY(!copyInfo.isComplete());
QVERIFY(!copyInfo.isRegistered());
QCOMPARE(copyInfo.serviceName(), serviceName);
QCOMPARE(copyInfo.device().address(), deviceInfo.address());
copyInfo.setAttribute(QBluetoothServiceInfo::ServiceName, alternateServiceName);
copyInfo.setDevice(alternatedeviceInfo);
QCOMPARE(copyInfo.serviceName(), alternateServiceName);
QCOMPARE(copyInfo.attribute(QBluetoothServiceInfo::ServiceName).toString(), alternateServiceName);
QCOMPARE(serviceInfo.serviceName(), alternateServiceName);
QCOMPARE(copyInfo.device().address(), alternatedeviceInfo.address());
QCOMPARE(serviceInfo.device().address(), alternatedeviceInfo.address());
foreach (QBluetoothUuid::ProtocolUuid u, protUuids)
QCOMPARE(serviceInfo.protocolDescriptor(u).count(), 0);
foreach (QBluetoothUuid::ProtocolUuid u, protUuids)
QCOMPARE(copyInfo.protocolDescriptor(u).count(), 0);
}
}