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


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

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


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

示例1: readInfo


//.........这里部分代码省略.........
            dc->setFirmwareRevision(QString(firmware_revision_string));
            _handler->emitSignalLogMessage("FIRMWARE REVISION:"+dc->getFirmwareRevision());
        }
        free(firmware_revision_bytes);
    } else {
        _handler->emitSignalLogMessage("FIRMWARE REVISION:not present");
    }

    if (dc->getSoftwareRevisionHandle() != 0) {
        qDebug() << "XXXX reading software revision from service instance " << dc->getDeviceInformationServiceInstance();
        int swr_max_len = 80;
        uint8_t *software_revision_bytes;
        software_revision_bytes = (uint8_t*) calloc(swr_max_len,sizeof(uint8_t));
        errno= 0;
        int result = bt_gatt_read_value(dc->getDeviceInformationServiceInstance(), dc->getSoftwareRevisionValueHandle(), 0, software_revision_bytes, swr_max_len, 0);
        if (result < 0) {
            qDebug() << "XXXX bt_gatt_read_value software revision - errno=(" << errno<< ") :" << strerror(errno);
        } else {
            char *software_revision_string = (char*) software_revision_bytes;
            dc->setSoftwareRevision(QString(software_revision_string));
            _handler->emitSignalLogMessage("SOFTWARE REVISION:"+dc->getSoftwareRevision());
        }
        free(software_revision_bytes);
    } else {
        _handler->emitSignalLogMessage("SOFTWARE REVISION:not present");
    }

    qDebug() << "XXXX system ID next....";

    if (dc->getSystemIdHandle() != 0) {
        qDebug() << "XXXX reading system ID from service instance " << dc->getDeviceInformationServiceInstance();
        int sid_max_len = 8;
        uint8_t *system_id_bytes;
        system_id_bytes = (uint8_t*) calloc(sid_max_len,sizeof(uint8_t));
        errno= 0;
        int result = bt_gatt_read_value(dc->getDeviceInformationServiceInstance(), dc->getSystemIdValueHandle(), 0, system_id_bytes, sid_max_len, 0);
        if (result < 0) {
            qDebug() << "XXXX bt_gatt_read_value system ID - errno=(" << errno<< ") :" << strerror(errno);
        } else {
            uint64_t manufacturer_identifier=((system_id_bytes[4] << 40) + (system_id_bytes[3] << 32) + (system_id_bytes[2] << 16) + (system_id_bytes[1] << 8) + (system_id_bytes[0]));
            dc->setManufacturerIdentifier(manufacturer_identifier);
            _handler->emitSignalLogMessage(QString("MANUFACTURER ID:%1").arg(dc->getManufacturerIdentifier()));
            uint32_t organizationally_unique_identifier=((system_id_bytes[7] << 16) + (system_id_bytes[6] << 8) + (system_id_bytes[5]));
            dc->setOrgUniqueIdentifier(organizationally_unique_identifier);
            _handler->emitSignalLogMessage(QString("ORG UNIQUE ID:%1").arg(dc->getOrgUniqueIdentifier()));
        }
        free(system_id_bytes);
    } else {
        _handler->emitSignalLogMessage("SYSTEM ID:not present");
    }

    qDebug() << "XXXX certification data next....";
    if (dc->getCertificationDataHandle() != 0) {
        qDebug() << "XXXX reading certification data list from service instance " << dc->getDeviceInformationServiceInstance();
        int cdl_max_len = 80;
        uint8_t *certification_data_list_bytes;
        certification_data_list_bytes = (uint8_t*) calloc(cdl_max_len,sizeof(uint8_t));
        errno= 0;
        int result = bt_gatt_read_value(dc->getDeviceInformationServiceInstance(), dc->getCertificationDataHandle(), 0, certification_data_list_bytes, cdl_max_len, 0);
        if (result < 0) {
            qDebug() << "XXXX bt_gatt_read_value certification data - errno=(" << errno<< ") :" << strerror(errno);
        } else {
            QByteArray cdl_ba = QByteArray::fromRawData(reinterpret_cast<const char *>(certification_data_list_bytes), cdl_max_len);
            QString cdl = QString::fromAscii(cdl_ba.toHex());
            dc->setCertificationData(cdl_ba);
            _handler->emitSignalLogMessage("CERTIFICATION DATA:"+cdl);
        }
        free(certification_data_list_bytes);
    } else {
        _handler->emitSignalLogMessage("CERTIFICATION DATA:not present");
    }

    qDebug() << "XXXX PnP ID next....";
    if (dc->getPnpIdHandle() != 0) {
        qDebug() << "XXXX reading PnP ID from service instance " << dc->getDeviceInformationServiceInstance();
        int pnp_max_len = 7;
        uint8_t *pnp_id_bytes;
        pnp_id_bytes = (uint8_t*) calloc(pnp_max_len,sizeof(uint8_t));
        errno= 0;
        int result = bt_gatt_read_value(dc->getDeviceInformationServiceInstance(), dc->getPnpIdHandle(), 0, pnp_id_bytes, pnp_max_len, 0);
        if (result < 0) {
            qDebug() << "XXXX bt_gatt_read_value PnP ID - errno=(" << errno<< ") :" << strerror(errno);
        } else {
            QByteArray pnp_ba = QByteArray::fromRawData(reinterpret_cast<const char *>(pnp_id_bytes), pnp_max_len);
            dc->setPnpId(pnp_ba);
            uint8_t vendor_id_source = pnp_id_bytes[6];
            _handler->emitSignalLogMessage(QString("VENDOR SOURCE ID:%1").arg(vendor_id_source));
            uint16_t vendor_id = (pnp_id_bytes[5] << 8) + (pnp_id_bytes[4]);
            _handler->emitSignalLogMessage(QString("VENDOR ID:%1").arg(vendor_id));
            uint16_t product_id = (pnp_id_bytes[3] << 8) + (pnp_id_bytes[2]);
            _handler->emitSignalLogMessage(QString("PRODUCT ID:%1").arg(product_id));
            uint16_t product_version = (pnp_id_bytes[1] << 8) + (pnp_id_bytes[0]);
            _handler->emitSignalLogMessage(QString("PRODUCT VERSION:%1").arg(product_version));
        }
        free(pnp_id_bytes);
    } else {
        _handler->emitSignalLogMessage("PNP ID:not present");
    }

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


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