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


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

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


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

示例1: gatt_service_disconnected

void gatt_service_disconnected(const char *bdaddr, const char *service, int instance, int reason, void *userData)
{

    Q_UNUSED(userData)
    Q_UNUSED(instance)
    Q_UNUSED(reason)

    QString bdaddr_str = QString(bdaddr);
    QString service_str = QString(service);
    qDebug() << QString("XXXX gatt_service_disconnected: bdaddr:%1 : %2 - %3").arg(bdaddr_str).arg(service_str).arg(parse_service_uuid(service));

    DataContainer *dc = DataContainer::getInstance();

    if (instance == dc->getLinkLossServiceInstance()) {
        qDebug() << "XXXX reacting to link loss service disconnection";
        link_loss_connected = false;
        dc->setLinkLossServiceInstance(0);
        _handler->emitSignalLostLink();
    }

    if (instance == dc->getTxPowerServiceInstance()) {
        qDebug() << "XXXX reacting to tx power service disconnection";
        tx_power_connected = false;
        dc->setTxPowerServiceInstance(0);
    }

    if (instance == dc->getAlertServiceInstance()) {
        qDebug() << "XXXX reacting to immediate alert service disconnection";
        immediate_alert_connected = false;
        dc->setAlertServiceInstance(0);
    }

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

示例2: btEvent

void btEvent(const int event, const char *bt_addr, const char *event_data)
{

    Q_UNUSED(bt_addr)

    QString event_name = btEventName(event);
    qDebug() << "XXXX bluetooth event:" << event_name;

    if (event_data != NULL) {
        QString event_data_str = QString(*event_data);
        qDebug() << "XXXX BT event_data=" << event_data_str;
    } else {
        qDebug() << "XXXX BT event_data=NULL";
    }

    if (event == BT_EVT_LE_DEVICE_CONNECTED) {
        _handler->emitSignalSetMessage("Chicken sensor has connected");
        DataContainer *dc = DataContainer::getInstance();
        dc->setDeviceConnected(true);
        _handler->emitSignalLinkEstablished();
        return;
    }

    if (event == BT_EVT_LE_DEVICE_DISCONNECTED) {
        immediate_alert_connected = false;
        link_loss_connected = false;
        tx_power_connected = false;
        rssi_polling_required = false;
        DataContainer *dc = DataContainer::getInstance();
        dc->setDeviceConnected(false);
        dc->setAlertServiceInstance(0);
        dc->setLinkLossServiceInstance(0);
        dc->setTxPowerServiceInstance(0);
        _handler->emitSignalSetMessage("Chicken sensor has disconnected");
        _handler->emitSignalDisableProximityVisualisation();
        return;
    }
}
开发者ID:rascyber,项目名称:Cascades-Community-Samples,代码行数:38,代码来源:BluetoothHandler.cpp

示例3: establishHandles

void establishHandles(int service_type, int instance)
{
    if (service_type < 1 || service_type > 3) {
        qDebug() << "XXXX invalid service type indicator passed to establishAlertLevelHandle function:" << service_type;
        return;
    }

    const char* characteristic_uuids[] = { ALERT_LEVEL_UUID, ALERT_LEVEL_UUID, TX_POWER_LEVEL_UUID };

    DataContainer *dc = DataContainer::getInstance();

    bt_gatt_characteristic_t* alert_level;

// find the handle of the alert level characteristic
    int num_characteristics = bt_gatt_characteristics_count(instance);
    qDebug() << "YYYY # characteristics=" << num_characteristics;

    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, characteristic_uuids[service_type - 1]) == 0) {
                qDebug() << "YYYY found alert level characteristic";
                switch (service_type) {
                case INDEX_IMMEDIATE_ALERT_SERVICE:
                    qDebug() << "XXXX CONNECTED TO IMMEDIATE ALERT SERVICE - saving handles";
                    dc->setAlertServiceInstance(instance);
                    dc->setImmediateAlertLevelHandle(characteristicList[i].handle);
                    dc->setImmediateAlertLevelValueHandle(characteristicList[i].value_handle);
                    break;
                case INDEX_LINK_LOSS_SERVICE:
                    qDebug() << "XXXX CONNECTED TO LINK LOSS SERVICE - saving handles";
                    dc->setLinkLossAlertLevelHandle(characteristicList[i].handle);
                    dc->setLinkLossAlertLevelValueHandle(characteristicList[i].value_handle);
                    dc->setLinkLossServiceInstance(instance);
                    break;
                case INDEX_TX_POWER_SERVICE:
                    qDebug() << "XXXX CONNECTED TO TX POWER SERVICE - saving handles";
                    dc->setTxPowerLevelHandle(characteristicList[i].handle);
                    dc->setTxPowerLevelValueHandle(characteristicList[i].value_handle);
                    dc->setTxPowerServiceInstance(instance);
                    break;
                }
            } else {
                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:rascyber,项目名称:Cascades-Community-Samples,代码行数:73,代码来源:BluetoothHandler.cpp


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