本文整理汇总了C++中QBluetoothAddress函数的典型用法代码示例。如果您正苦于以下问题:C++ QBluetoothAddress函数的具体用法?C++ QBluetoothAddress怎么用?C++ QBluetoothAddress使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QBluetoothAddress函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QBluetoothAddress
QBluetoothAddress HciManager::addressForConnectionHandle(quint16 handle) const
{
if (!isValid())
return QBluetoothAddress();
hci_conn_info *info;
hci_conn_list_req *infoList;
const int maxNoOfConnections = 20;
infoList = (hci_conn_list_req *)
malloc(sizeof(hci_conn_list_req) + maxNoOfConnections * sizeof(hci_conn_info));
if (!infoList)
return QBluetoothAddress();
QScopedPointer<hci_conn_list_req, QScopedPointerPodDeleter> p(infoList);
p->conn_num = maxNoOfConnections;
p->dev_id = hciDev;
info = p->conn_info;
if (ioctl(hciSocket, HCIGETCONNLIST, (void *) infoList) < 0) {
qCWarning(QT_BT_BLUEZ) << "Cannot retrieve connection list";
return QBluetoothAddress();
}
for (int i = 0; i < infoList->conn_num; i++) {
if (info[i].handle == handle)
return QBluetoothAddress(convertAddress(info[i].bdaddr.b));
}
return QBluetoothAddress();
}
示例2: QL2capServer
int QDeclarativeBluetoothServicePrivate::listen() {
if (m_protocol == "l2cap") {
QL2capServer *server = new QL2capServer();
server->setMaxPendingConnections(1);
server->listen(QBluetoothAddress(), m_port);
m_port = server->serverPort();
m_listen = server;
}
else if (m_protocol == "rfcomm") {
QRfcommServer *server = new QRfcommServer();
server->setMaxPendingConnections(1);
server->listen(QBluetoothAddress(), m_port);
m_port = server->serverPort();
m_listen = server;
}
else {
qDebug() << "Unknown protocol, can't make service" << m_protocol;
}
return m_port;
}
示例3: QBluetoothAddress
void tst_QBluetoothAddress::tst_comparison_data()
{
QTest::addColumn<QBluetoothAddress>("address1");
QTest::addColumn<QBluetoothAddress>("address2");
QTest::addColumn<bool>("result");
QTest::newRow("invalid == invalid") << QBluetoothAddress() << QBluetoothAddress() << true;
QTest::newRow("valid != invalid") << QBluetoothAddress(Q_UINT64_C(0x112233445566)) << QBluetoothAddress() << false;
QTest::newRow("valid == valid") << QBluetoothAddress(Q_UINT64_C(0x112233445566)) << QBluetoothAddress(Q_UINT64_C(0x112233445566)) << true;
}
示例4: QBluetoothAddress
void tst_QL2capServer::tst_listen_data()
{
QTest::addColumn<QBluetoothAddress>("address");
QTest::addColumn<quint16>("port");
QTest::newRow("default") << QBluetoothAddress() << quint16(0);
QTest::newRow("specified address") << QBluetoothAddress("00:11:B1:08:AD:B8") << quint16(0);
QTest::newRow("specified port") << QBluetoothAddress() << quint16(24160);
QTest::newRow("specified address/port") << QBluetoothAddress("00:11:B1:08:AD:B8") << quint16(10);
}
示例5: QBluetoothAddress
QBluetoothAddress QBluetoothSocketPrivate::peerAddress() const
{
if (!remoteDevice.isValid())
return QBluetoothAddress();
const QString address = remoteDevice.callObjectMethod("getAddress",
"()Ljava/lang/String;").toString();
return QBluetoothAddress(address);
}
示例6: QBluetoothAddress
void tst_QBluetoothLocalDevice::tst_pairingStatus_data()
{
QTest::addColumn<QBluetoothAddress>("deviceAddress");
QTest::addColumn<QBluetoothLocalDevice::Pairing>("pairingExpected");
QTest::newRow("UnPaired Device: DUMMY") << QBluetoothAddress("11:00:00:00:00:00") << QBluetoothLocalDevice::Unpaired;
#ifdef Q_OS_SYMBIAN
QTest::newRow("UNPAIR Device: BH-604") << QBluetoothAddress("00:0d:3c:b0:77:1c") << QBluetoothLocalDevice::Unpaired;
QTest::newRow("Paired Device: TESTMACHINE") << QBluetoothAddress("00:09:DD:50:93:DD") << QBluetoothLocalDevice::Paired;
#endif // Q_OS_SYMBIAN
}
示例7: QBluetoothAddress
static PyObject *meth_QBluetoothServiceInfo_registerService(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds)
{
PyObject *sipParseErr = NULL;
{
const QBluetoothAddress& a0def = QBluetoothAddress();
const QBluetoothAddress* a0 = &a0def;
QBluetoothServiceInfo *sipCpp;
static const char *sipKwdList[] = {
sipName_localAdapter,
};
if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, NULL, "B|J9", &sipSelf, sipType_QBluetoothServiceInfo, &sipCpp, sipType_QBluetoothAddress, &a0))
{
bool sipRes;
sipRes = sipCpp->registerService(*a0);
return PyBool_FromLong(sipRes);
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QBluetoothServiceInfo, sipName_registerService, doc_QBluetoothServiceInfo_registerService);
return NULL;
}
示例8: Q_Q
void QBluetoothServerPrivate::controlReply(ppsResult result)
{
Q_Q(QBluetoothServer);
if (result.msg == QStringLiteral("register_server")) {
qCDebug(QT_BT_QNX) << "SPP: Server registration succesfull";
} else if (result.msg == QStringLiteral("get_mount_point_path")) {
qCDebug(QT_BT_QNX) << "SPP: Mount point for server" << result.dat.first();
int socketFD = ::open(result.dat.first().toStdString().c_str(), O_RDWR | O_NONBLOCK);
if (socketFD == -1) {
m_lastError = QBluetoothServer::InputOutputError;
emit q->error(m_lastError);
qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "RFCOMM Server: Could not open socket FD" << errno;
} else {
if (!socket) { // Should never happen
qCWarning(QT_BT_QNX) << "Socket not valid";
m_lastError = QBluetoothServer::UnknownError;
emit q->error(m_lastError);
return;
}
socket->setSocketDescriptor(socketFD, QBluetoothServiceInfo::RfcommProtocol,
QBluetoothSocket::ConnectedState);
socket->connectToService(QBluetoothAddress(nextClientAddress), m_uuid);
activeSockets.append(socket);
socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol, this);
socket->setSocketState(QBluetoothSocket::ListeningState);
emit q->newConnection();
}
}
}
示例9: Q_Q
void QBluetoothServerPrivate::setBtCallbackParameters(int receivedSocket)
{
Q_Q(QBluetoothServer);
if (receivedSocket == -1) {
qCDebug(QT_BT_QNX) << "Socket error: " << qt_error_string(errno);
m_lastError = QBluetoothServer::InputOutputError;
emit q->error(m_lastError);
return;
}
socket->setSocketDescriptor(receivedSocket, QBluetoothServiceInfo::RfcommProtocol,
QBluetoothSocket::ConnectedState,
QBluetoothSocket::ReadWrite);
char addr[18];
if (bt_spp_get_address(receivedSocket, addr) == -1) {
qCDebug(QT_BT_QNX) << "Could not obtain the remote address. "
<< qt_error_string(errno);
m_lastError = QBluetoothServer::InputOutputError;
emit q->error(m_lastError);
return;
}
socket->d_ptr->m_peerAddress = QBluetoothAddress(addr);
activeSockets.append(socket);
socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol, this);
socket->setSocketState(QBluetoothSocket::ListeningState);
emit q->newConnection();
}
示例10: QObject
BluetoothMultiplexer::BluetoothMultiplexer(const QString &address, const QString &service_uuid, QObject *parent)
: QObject(parent)
, m_socket(NULL)
, m_connections()
, m_connections_nextid(1)
, m_buffer_in_required(0)
, m_buffer_in_data()
, m_buffer_in_version(0)
, m_buffer_in_type(0)
, m_buffer_out_data()
{
qDebug() << this << "Creating";
m_buffer_out_data.clear();
m_socket = new QBluetoothSocket(QBluetoothServiceInfo::RfcommProtocol, this);
connect(m_socket, &QBluetoothSocket::connected, this, &BluetoothMultiplexer::_connected);
connect(m_socket, &QBluetoothSocket::disconnected, this, &BluetoothMultiplexer::_disconnected);
connect(m_socket, &QBluetoothSocket::readyRead, this, &BluetoothMultiplexer::_read);
connect(m_socket, &QBluetoothSocket::stateChanged, this, &BluetoothMultiplexer::_stateChanged);
connect(m_socket, static_cast<void(QBluetoothSocket::*)(QBluetoothSocket::SocketError)>(&QBluetoothSocket::error),
this, &BluetoothMultiplexer::_error);
processNext(2, &BluetoothMultiplexer::_processInHeader);
m_socket->connectToService(QBluetoothAddress(address), QBluetoothUuid(service_uuid));
}
示例11: QBluetoothAddress
/*!
Returns the remote device address. If setRemoteAddress is not called, the function
will return default QBluetoothAddress.
*/
QBluetoothAddress QBluetoothServiceDiscoveryAgent::remoteAddress() const
{
if (d_ptr->singleDevice == true)
return d_ptr->deviceAddress;
else
return QBluetoothAddress();
}
示例12: ppsReadRemoteDevice
bool ppsReadRemoteDevice(int fd, pps_decoder_t *decoder, QBluetoothAddress *btAddr, QString *deviceName)
{
char buf[ppsBufferSize * 2];
char addr_buf[18];
addr_buf[17] = '\0';
if (qt_safe_read(fd, &buf, sizeof(buf)) == -1) {
qCWarning(QT_BT_QNX) << Q_FUNC_INFO << "Could not qt_safe_read from pps remote device file";
return false;
}
qCDebug(QT_BT_QNX) << "Remote device" << buf;
//the address of the BT device is stored at the beginning of the qt_safe_read
if (buf[0] != '-') {
memcpy(&addr_buf, &buf[1], 17);
} else { //The device was removed
memcpy(&addr_buf, &buf[2], 17);
return false;
}
*btAddr = QBluetoothAddress(QString::fromUtf8(addr_buf));
if (pps_decoder_parse_pps_str(decoder, buf) == PPS_DECODER_OK) {
const char* name;
pps_decoder_push(decoder, 0);
if (pps_decoder_get_string(decoder, "name", &name) == PPS_DECODER_OK)
(*deviceName) = QString::fromUtf8(name);
return true;
}
return false;
}
示例13: QBluetoothAddress
//! [Connect to remote service]
void Chat::connectClicked()
{
ui->connectButton->setEnabled(false);
// scan for services
const QBluetoothAddress adapter = localAdapters.isEmpty() ?
QBluetoothAddress() :
localAdapters.at(currentAdapterIndex).address();
RemoteSelector remoteSelector(adapter);
remoteSelector.startDiscovery(QBluetoothUuid(serviceUuid));
if (remoteSelector.exec() == QDialog::Accepted) {
QBluetoothServiceInfo service = remoteSelector.service();
qDebug() << "Connecting to service 2" << service.serviceName()
<< "on" << service.device().name();
// Create client
qDebug() << "Going to create client";
ChatClient *client = new ChatClient(this);
qDebug() << "Connecting...";
connect(client, SIGNAL(messageReceived(QString,QString)),
this, SLOT(showMessage(QString,QString)));
connect(client, SIGNAL(disconnected()), this, SLOT(clientDisconnected()));
connect(client, SIGNAL(connected(QString)), this, SLOT(connected(QString)));
connect(this, SIGNAL(sendMessage(QString)), client, SLOT(sendMessage(QString)));
qDebug() << "Start client";
client->startClient(service);
clients.append(client);
}
ui->connectButton->setEnabled(true);
}
示例14: QVariant
void tst_QBluetoothTransferRequest::tst_construction_data()
{
QTest::addColumn<QBluetoothAddress>("address");
QTest::addColumn<QMap<int, QVariant> >("parameters");
QMap<int, QVariant> inparameters;
inparameters.insert((int)QBluetoothTransferRequest::DescriptionAttribute, "Desciption");
inparameters.insert((int)QBluetoothTransferRequest::LengthAttribute, QVariant(1024));
inparameters.insert((int)QBluetoothTransferRequest::TypeAttribute, "OPP");
QTest::newRow("0x000000 COD") << QBluetoothAddress("000000000000") << inparameters;
QTest::newRow("0x000100 COD") << QBluetoothAddress("000000000000") << inparameters;
QTest::newRow("0x000104 COD") << QBluetoothAddress("000000000000") << inparameters;
QTest::newRow("0x000118 COD") << QBluetoothAddress("000000000000") << inparameters;
QTest::newRow("0x000200 COD") << QBluetoothAddress("000000000000") << inparameters;
}
示例15: QBluetoothAddress
void tst_QBluetoothLocalDevice::tst_pairingStatus_data()
{
QTest::addColumn<QBluetoothAddress>("deviceAddress");
QTest::addColumn<QBluetoothLocalDevice::Pairing>("pairingExpected");
QTest::newRow("UnPaired Device: DUMMY") << QBluetoothAddress("11:00:00:00:00:00")
<< QBluetoothLocalDevice::Unpaired;
}