当前位置: 首页>>代码示例>>C++>>正文


C++ DataContainer::getCurrentDeviceAddr方法代码示例

本文整理汇总了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";
    }

}
开发者ID:26filip,项目名称:Cascades-Community-Samples,代码行数:46,代码来源:BluetoothHandler.cpp

示例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";
    }

}
开发者ID:rascyber,项目名称:Cascades-Community-Samples,代码行数:83,代码来源:BluetoothHandler.cpp


注:本文中的DataContainer::getCurrentDeviceAddr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。