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


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

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


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

示例1: readInfo

void readInfo()
{

    if (!device_information_connected) {
        _handler->emitSignalLogMessage("Not connected to device information service");
        return;
    }

    DataContainer* dc = DataContainer::getInstance();

    if (dc->getManufacturerNameHandle() != 0) {
        qDebug() << "XXXX reading manufacturer name from service instance " << dc->getDeviceInformationServiceInstance();
        int mfn_max_len = 80;
        uint8_t *manufacturer_name_bytes;
        manufacturer_name_bytes = (uint8_t*) calloc(mfn_max_len,sizeof(uint8_t));
        errno= 0;
        int result = bt_gatt_read_value(dc->getDeviceInformationServiceInstance(), dc->getManufacturerNameValueHandle(), 0, manufacturer_name_bytes, mfn_max_len, 0);
        if (result < 0) {
            qDebug() << "XXXX bt_gatt_read_value manufacturer name - errno=(" << errno<< ") :" << strerror(errno);
        } else {
            char *manufacturer_name_string = (char*) manufacturer_name_bytes;
            dc->setManufacturerName(QString(manufacturer_name_string));
            _handler->emitSignalLogMessage("MANUFACTURER NAME:"+dc->getManufacturerName());
        }
        free(manufacturer_name_bytes);
    } else {
        _handler->emitSignalLogMessage("MANUFACTURER NAME:not present");
    }

    if (dc->getModelNumberHandle() != 0) {
        qDebug() << "XXXX reading model number from service instance " << dc->getDeviceInformationServiceInstance();
        int mon_max_len = 80;
        uint8_t *model_number_bytes;
        model_number_bytes = (uint8_t*) calloc(mon_max_len, sizeof(uint8_t));
        errno= 0;
        int result = bt_gatt_read_value(dc->getDeviceInformationServiceInstance(), dc->getModelNumberValueHandle(), 0, model_number_bytes, mon_max_len, 0);
        if (result < 0) {
            qDebug() << "XXXX bt_gatt_read_value model number - errno=(" << errno<< ") :" << strerror(errno);
        } else {
            char *model_number_string = (char*) model_number_bytes;
            dc->setModelNumber(QString(model_number_string));
            _handler->emitSignalLogMessage("MODEL NUMBER:"+dc->getModelNumber());
        }
        free(model_number_bytes);
    } else {
        _handler->emitSignalLogMessage("MODEL NUMBER:not present");
    }

    if (dc->getSerialNumberHandle() != 0) {
        qDebug() << "XXXX reading serial number from service instance " << dc->getDeviceInformationServiceInstance();
        int sen_max_len = 80;
        uint8_t *serial_number_bytes;
        serial_number_bytes = (uint8_t*) calloc(sen_max_len,sizeof(uint8_t));
        errno= 0;
        int result = bt_gatt_read_value(dc->getDeviceInformationServiceInstance(), dc->getSerialNumberValueHandle(), 0, serial_number_bytes, sen_max_len, 0);
        if (result < 0) {
            qDebug() << "XXXX bt_gatt_read_value serial number - errno=(" << errno<< ") :" << strerror(errno);
        } else {
            char *serial_number_string = (char*) serial_number_bytes;
            dc->setSerialNumber(QString(serial_number_string));
            _handler->emitSignalLogMessage("SERIAL NUMBER:"+dc->getSerialNumber());
        }
        free(serial_number_bytes);
    } else {
        _handler->emitSignalLogMessage("SERIAL NUMBER:not present");
    }

    if (dc->getHardwareRevisionHandle() != 0) {
        qDebug() << "XXXX reading hardware revision from service instance " << dc->getDeviceInformationServiceInstance();
        int hwr_max_len = 80;
        uint8_t *hardware_revision_bytes;
        hardware_revision_bytes = (uint8_t*) calloc(hwr_max_len,sizeof(uint8_t));
        errno= 0;
        int result = bt_gatt_read_value(dc->getDeviceInformationServiceInstance(), dc->getHardwareRevisionValueHandle(), 0, hardware_revision_bytes, hwr_max_len, 0);
        if (result < 0) {
            qDebug() << "XXXX bt_gatt_read_value hardware revision - errno=(" << errno<< ") :" << strerror(errno);
        } else {
            char *hardware_revision_string = (char*) hardware_revision_bytes;
            dc->setHardwareRevision(QString(hardware_revision_string));
            _handler->emitSignalLogMessage("HARDWARE REVISION:"+dc->getHardwareRevision());
        }
        free(hardware_revision_bytes);
    } else {
        _handler->emitSignalLogMessage("HARDWARE REVISION:not present");
    }

    if (dc->getFirmwareRevisionHandle() != 0) {
        qDebug() << "XXXX reading firmware revision from service instance " << dc->getDeviceInformationServiceInstance();
        int fwr_max_len = 80;
        uint8_t *firmware_revision_bytes;
        firmware_revision_bytes = (uint8_t*) calloc(fwr_max_len,sizeof(uint8_t));
        errno= 0;
        int result = bt_gatt_read_value(dc->getDeviceInformationServiceInstance(), dc->getFirmwareRevisionValueHandle(), 0, firmware_revision_bytes, fwr_max_len, 0);
        if (result < 0) {
            qDebug() << "XXXX bt_gatt_read_value firmware revision - errno=(" << errno<< ") :" << strerror(errno);
        } else {
            char *firmware_revision_string = (char*) firmware_revision_bytes;
            dc->setFirmwareRevision(QString(firmware_revision_string));
            _handler->emitSignalLogMessage("FIRMWARE REVISION:"+dc->getFirmwareRevision());
        }
//.........这里部分代码省略.........
开发者ID:26filip,项目名称:Cascades-Community-Samples,代码行数:101,代码来源:BluetoothHandler.cpp


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