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


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

本文整理汇总了C++中DataContainer::setCertificationDataHandle方法的典型用法代码示例。如果您正苦于以下问题:C++ DataContainer::setCertificationDataHandle方法的具体用法?C++ DataContainer::setCertificationDataHandle怎么用?C++ DataContainer::setCertificationDataHandle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataContainer的用法示例。


在下文中一共展示了DataContainer::setCertificationDataHandle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: establishHandles

void establishHandles(int instance)
{

    DataContainer *dc = DataContainer::getInstance();

    bt_gatt_characteristic_t* c_manufacturer_name;

    errno= 0;
    int num_characteristics = bt_gatt_characteristics_count(instance);

    if (num_characteristics == -1) {
        qDebug() << "YYYY bt_gatt_characteristics_count failed: " + QString::number(errno) + " (" + QString(strerror(errno)) + ")";
        Utilities::alert("GATT connect service request failed: " + QString::number(errno) + " (" + QString(strerror(errno)) + ")");
        return;
    }

    if (num_characteristics > -1) {
        qDebug() << QString("YYYY # characteristics: %1").arg(num_characteristics);
        bt_gatt_characteristic_t *characteristicList;

        characteristicList = (bt_gatt_characteristic_t*) malloc(num_characteristics * sizeof(bt_gatt_characteristic_t));
        if (NULL == characteristicList) {
            qDebug() << QString("YYYY GATT characteristics: Not enough memory");
            bt_gatt_disconnect_instance(instance);
            return;
        }

        /* BEGIN WORKAROUND - Temporary fix to address race condition */
        int number = 0;
        do {
            number = bt_gatt_characteristics(instance, characteristicList, num_characteristics);
        } while ((number == -1) && (errno== EBUSY));

        int characteristicListSize = number;

        for (int i = 0; i < characteristicListSize; i++) {
            qDebug() << "YYYY characteristic: uuid,handle,value_handle:" << characteristicList[i].uuid << "," << characteristicList[i].handle << "," << characteristicList[i].value_handle;
            if (strcmp(characteristicList[i].uuid, MANUFACTURER_NAME_UUID) == 0) {
                qDebug() << "YYYY found manufacturer name characteristic";
                dc->setManufacturerNameHandle(characteristicList[i].handle);
                dc->setManufacturerNameValueHandle(characteristicList[i].value_handle);
                continue;
            }
            if (strcmp(characteristicList[i].uuid, MODEL_NUMBER_UUID) == 0) {
                qDebug() << "YYYY found model number characteristic";
                dc->setModelNumberHandle(characteristicList[i].handle);
                dc->setModelNumberValueHandle(characteristicList[i].value_handle);
                continue;
            }
            if (strcmp(characteristicList[i].uuid, SERIAL_NUMBER_UUID) == 0) {
                qDebug() << "YYYY found serial number characteristic";
                dc->setSerialNumberHandle(characteristicList[i].handle);
                dc->setSerialNumberValueHandle(characteristicList[i].value_handle);
                continue;
            }
            if (strcmp(characteristicList[i].uuid, HARDWARE_REVISION_UUID) == 0) {
                qDebug() << "YYYY found hardware revision characteristic";
                dc->setHardwareRevisionHandle(characteristicList[i].handle);
                dc->setHardwareRevisionValueHandle(characteristicList[i].value_handle);
                continue;
            }
            if (strcmp(characteristicList[i].uuid, FIRMWARE_REVISION_UUID) == 0) {
                qDebug() << "YYYY found firmware revision characteristic";
                dc->setFirmwareRevisionHandle(characteristicList[i].handle);
                dc->setFirmwareRevisionValueHandle(characteristicList[i].value_handle);
                continue;
            }
            if (strcmp(characteristicList[i].uuid, SOFTWARE_REVISION_UUID) == 0) {
                qDebug() << "YYYY found software revision characteristic";
                dc->setSoftwareRevisionHandle(characteristicList[i].handle);
                dc->setSoftwareRevisionValueHandle(characteristicList[i].value_handle);
                continue;
            }
            if (strcmp(characteristicList[i].uuid, SYSTEM_ID_UUID) == 0) {
                qDebug() << "YYYY found system ID characteristic";
                dc->setSystemIdHandle(characteristicList[i].handle);
                dc->setSystemIdValueHandle(characteristicList[i].value_handle);
                continue;
            }
            if (strcmp(characteristicList[i].uuid, CERTIFICATION_DATA_UUID) == 0) {
                qDebug() << "YYYY found certification data characteristic";
                dc->setCertificationDataHandle(characteristicList[i].handle);
                dc->setCertificationDataValueHandle(characteristicList[i].value_handle);
                continue;
            }
            if (strcmp(characteristicList[i].uuid, PNP_ID_UUID) == 0) {
                qDebug() << "YYYY found PnP ID characteristic";
                dc->setPnpIdHandle(characteristicList[i].handle);
                dc->setPnpIdValueHandle(characteristicList[i].value_handle);
                continue;
            }
            qDebug() << "YYYY other characteristic: uuid,handle,value_handle=" << characteristicList[i].uuid << "," << characteristicList[i].handle << "," << characteristicList[i].value_handle;
        }

        if (characteristicList != NULL) {
            free(characteristicList);
            characteristicList = NULL;
        }

        /* END WORKAROUND */
//.........这里部分代码省略.........
开发者ID:26filip,项目名称:Cascades-Community-Samples,代码行数:101,代码来源:BluetoothHandler.cpp


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