Ejemplo n.º 1
0
void Task::dump() const
{
    qDebug() << "[Task " << this << "] task id:" << id() << "- name:" << name()
             << " - parent:" << parent() << " - subscribed:" << subscribed()
             << " - valid from:" << validFrom() << " - valid until:"
             << validUntil() << " - trackable:" << trackable();
}
void BLECharacteristic::discover(const bt_gatt_attr_t *attr,
			                     bt_gatt_discover_params_t *params)
{
    if (!attr)
    {
        // Discovery complete
        _discoverying = false;
        return;
    }
    
    // Chracteristic Char
    if (params->uuid == this->uuid())
    {
        // Set Discover CCCD parameter
        params->start_handle = attr->handle + 2;
        if (subscribed())
        {
            // Include CCCD
            params->type = BT_GATT_DISCOVER_DESCRIPTOR;
            params->uuid = this->getClientCharacteristicConfigUuid();
        }
        else
        {
            // Complete the discover
            _discoverying = false;
        }
    }
    else if (params->uuid == this->getClientCharacteristicConfigUuid())
    {
        params->start_handle = attr->handle + 1;
        _discoverying = false;
    }
}
Ejemplo n.º 3
0
void MQTT::initializeConnection()
{

    //Init UDP



    DEBUG;
    if(m_host.isEmpty() || !m_port || m_topic.isEmpty())
    {
        DEBUG << "Please define a host and a port and a topic";
        //disconnect();
        return;
    }
    this->client = new QMQTT::Client(m_host, m_port);
    this->client->setClientId(QString(QUuid::createUuid().toString()));
//    this->client->setUsername("user");
//    this->client->setPassword("password");
    this->client->connect();
    QObject::connect(this->client, SIGNAL(received(const QMQTT::Message&)),
            this, SLOT(processReceivedMessage(const QMQTT::Message&)));
    QObject::connect(this->client, SIGNAL(connacked(quint8)),
                     this, SLOT(subscribeToTopic(quint8)));
    QObject::connect(this->client, SIGNAL(subscribed(QString)),
                     this, SLOT(subscribedToTopic(QString)));
    QObject::connect(this->client, SIGNAL(disconnected()),
                     this, SIGNAL(disconnected()));
    QObject::connect(this->client, SIGNAL(connected()),
                     this, SIGNAL(connected()));
}
Ejemplo n.º 4
0
bool Task::operator == ( const Task& other ) const
{
    return other.id() == id()
        && other.parent() == parent()
        && other.name() == name()
        && other.subscribed() == subscribed()
        && other.m_trackable == m_trackable
        && other.validFrom() == validFrom()
        && other.validUntil() == validUntil();
}
Ejemplo n.º 5
0
 void context_base::wait( scheduler_i * sched )
 {
     CNC_ASSERT( !distributed() || distributor::distributed_env() || distributor::myPid() == 0 );
     if( sched == NULL ) sched = m_scheduler;
     sched->wait_loop();
     if( subscribed() && sched->subscribed() ) {
         if( distributor::myPid() == 0 ) cleanup_distributables( true );
         sched->wait_loop();
     }
 }
Ejemplo n.º 6
0
MqttBridge::MqttBridge(QObject *parent) :
    QObject(parent)
{
qDebug()<<"Initilization of the mqtt client";
_messageId=0;
client = new QMQTT::Client("localhost",1883);

connect(client,SIGNAL(connected()),this,SLOT(connected()));
connect(client,SIGNAL(subscribed(QString)),this,SLOT(subscribed(QString)));
connect(client,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(error(QAbstractSocket::SocketError)));
connect(client,SIGNAL(disconnected()),this,SLOT(disconnected()));
connect(client,SIGNAL(published(QMQTT::Message&)),this,SLOT(published(QMQTT::Message&)));
connect(client,SIGNAL(received(QMQTT::Message)),this,SLOT(received(QMQTT::Message)));

client->setAutoReconnect(true);
client->setClientId("mqttToDbusBridge");
client->setKeepAlive(1000);
client->connect();


}
Ejemplo n.º 7
0
void YouTube::subscribeToChannel(const QString &username) {
    QUrl url("http://gdata.youtube.com/feeds/api/users/default/subscriptions");
    QByteArray xml("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" \
                   "<entry xmlns=\"http://www.w3.org/2005/Atom\"\n" \
                   "xmlns:yt=\"http://gdata.youtube.com/schemas/2007\">\n" \
                   "<category scheme=\"http://gdata.youtube.com/schemas/2007/subscriptiontypes.cat\"\n" \
                   "term=\"channel\"/>\n" \
                   "<yt:username>" + username.toAscii() + "</yt:username>\n" \
                   "</entry>");
    postRequest(url, xml);
    connect(this, SIGNAL(postSuccessful()), this, SIGNAL(subscribed()));
}
Ejemplo n.º 8
0
QDomElement Task::toXml(QDomDocument document) const
{
    QDomElement element = document.createElement( tagName() );
    element.setAttribute(TaskIdElement, id());
    element.setAttribute(TaskParentId, parent());
    element.setAttribute(TaskSubscribed, (subscribed() ? 1 : 0));
        element.setAttribute(TaskTrackable, (trackable() ? 1 : 0));
        if (!name().isEmpty())
    {
        QDomText taskName = document.createTextNode(name());
        element.appendChild(taskName);
    }
    if (validFrom().isValid())
    {
        element.setAttribute(TaskValidFrom, validFrom().toString(Qt::ISODate));
    }
    if (validUntil().isValid())
    {
        element.setAttribute(TaskValidUntil, validUntil().toString(Qt::ISODate));
    }
    return element;
}
Ejemplo n.º 9
0
quint16 Client::subscribe(const QString &topic, quint8 qos)
{
    quint16 msgid = pd_func()->sendSubscribe(topic, qos);
    emit subscribed(topic);
    return msgid;
}