本文整理汇总了C++中DataContainer::getCurrentDeviceAddr方法的典型用法代码示例。如果您正苦于以下问题:C++ DataContainer::getCurrentDeviceAddr方法的具体用法?C++ DataContainer::getCurrentDeviceAddr怎么用?C++ DataContainer::getCurrentDeviceAddr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataContainer
的用法示例。
在下文中一共展示了DataContainer::getCurrentDeviceAddr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getInfo
void BluetoothHandler::getInfo()
{
qDebug() << "YYYY getInfo()";
// connect to the device information service
// read the various characteristic values
if (!bt_initialised) {
qDebug() << "Bluetooth libraries are not initialised!";
return;
}
bt_gatt_conn_parm_t conParm;
conParm.minConn = 0x30;
conParm.maxConn = 0x50;
conParm.latency = 0;
conParm.superTimeout = 50;
errno= 0;
DataContainer* dc = DataContainer::getInstance();
QString device_addr = dc->getCurrentDeviceAddr();
// connect to the device information service
int function_result = 0;
int retry_count = 0;
_handler->emitSignalInfoMessage("Connecting to Device Information Service");
/* BEGIN WORKAROUND - Temporary fix to address race condition */
do {
function_result = bt_gatt_connect_service(device_addr.toAscii().constData(), DEVICE_INFORMATION_SERVICE_UUID, NULL, &conParm, this);
retry_count++;
delay(50);
} while ((retry_count < 50) && (function_result == -1) && (errno== EBUSY));
if (function_result < 0) {
qDebug() << "YYYY GATT connect service request DEVICE_INFORMATION_SERVICE_UUID failed: " + QString::number(errno) + " (" + QString(strerror(errno)) + ")";
Utilities::alert("GATT connect service request DEVICE_INFORMATION_SERVICE_UUID failed: " + QString::number(errno));
} else {
qDebug() << "YYYY requested connection to DEVICE_INFORMATION_SERVICE_UUID OK";
}
}
示例2: startProximityMonitoring
void BluetoothHandler::startProximityMonitoring()
{
qDebug() << "YYYY setting up proximity monitoring";
// connect to the immediate alert service
// connect to the link loss service
// connect to the TX power service
// switch on link loss alerts by writing the Alert Level characteristic
// read the TX Power Level periodically
if (!bt_initialised) {
qDebug() << "Bluetooth libraries are not initialised!";
return;
}
bt_gatt_conn_parm_t conParm;
conParm.minConn = 0x30;
conParm.maxConn = 0x50;
conParm.latency = 0;
conParm.superTimeout = 50;
errno= 0;
DataContainer* dc = DataContainer::getInstance();
QString device_addr = dc->getCurrentDeviceAddr();
// connect to the immediate alert service
int function_result = 0;
int retry_count = 0;
/* BEGIN WORKAROUND - Temporary fix to address race condition */
do {
function_result = bt_gatt_connect_service(device_addr.toAscii().constData(), IMMEDIATE_ALERT_SERVICE_UUID, NULL, &conParm, this);
retry_count++;
delay(50);
} while ((retry_count < 50) && (function_result == -1) && (errno== EBUSY));
if (function_result < 0) {
qDebug() << "YYYY GATT connect service request IMMEDIATE_ALERT_SERVICE_UUID failed: " + QString::number(errno) + " (" + QString(strerror(errno)) + ")";
Utilities::alert("GATT connect service request IMMEDIATE_ALERT_SERVICE_UUID failed: " + QString::number(errno));
} else {
qDebug() << "YYYY requested connection to IMMEDIATE_ALERT_SERVICE_UUID OK";
}
// connect to the link loss service
function_result = 0;
retry_count = 0;
/* BEGIN WORKAROUND - Temporary fix to address race condition */
do {
function_result = bt_gatt_connect_service(device_addr.toAscii().constData(), LINK_LOSS_SERVICE_UUID, NULL, &conParm, this);
retry_count++;
delay(50);
} while ((retry_count < 50) && (function_result == -1) && (errno== EBUSY));
if (function_result < 0) {
qDebug() << "YYYY GATT connect service request LINK_LOSS_SERVICE_UUID failed: " + QString::number(errno) + " (" + QString(strerror(errno)) + ")";
Utilities::alert("GATT connect service request LINK_LOSS_SERVICE_UUID failed: " + QString::number(errno));
} else {
qDebug() << "YYYY requested connection to LINK_LOSS_SERVICE_UUID OK";
}
// connect to the TX power service
function_result = 0;
retry_count = 0;
/* BEGIN WORKAROUND - Temporary fix to address race condition */
do {
function_result = bt_gatt_connect_service(device_addr.toAscii().constData(), TX_POWER_SERVICE_UUID, NULL, &conParm, this);
retry_count++;
delay(50);
} while ((retry_count < 50) && (function_result == -1) && (errno== EBUSY));
if (function_result < 0) {
Utilities::alert("GATT connect service request TX_POWER_SERVICE_UUID failed: " + QString::number(errno));
} else {
qDebug() << "YYYY requested connection to TX_POWER_SERVICE_UUID OK";
}
}