コード例 #1
0
ファイル: mainwindow.cpp プロジェクト: humlium/iv_monitor
void MainWindow::onMQTT_Received(const QMQTT::Message &message)
{
    if(message.topic()==DEV1S){
        ui->d1v->display(message.payload().toInt());
    }
    qDebug() << QString::fromUtf8(message.payload());
}
コード例 #2
0
ファイル: messagetest.cpp プロジェクト: Kampfgnom/qmqtt
TEST_F(MessageTest, assignmentOperator_Test)
{
    QMQTT::Message originalMessage(5, "topic", "payload", 5, true, true);
    QMQTT::Message copy;

    copy = originalMessage;

    EXPECT_EQ(5, copy.id());
    EXPECT_EQ(5, copy.qos());
    EXPECT_TRUE(copy.retain());
    EXPECT_TRUE(copy.dup());
    EXPECT_EQ(QString("topic"), copy.topic());
    EXPECT_EQ(QByteArray("payload"), copy.payload());
}
コード例 #3
0
ファイル: mqttbridge.cpp プロジェクト: tipih/mqtttodbudbridge
void MqttBridge::received(const QMQTT::Message &message){
    //Now we have to pass on the different command to the DBUS command
    //That will be done by emitting signals, as we have no
    //knowlege of the dBus class, We will try to have a clean interface

    qDebug()<<"Message Topic and payload "<<message.topic() << message.payload();
    if      (message.topic()==mediaPlayCommand) emit setPlay();
    else if (message.topic()==mediaNextCommand) emit setNext();
    else if (message.topic()==mediaPrevCommand) emit setPrevious();
    else if (message.topic()==mediaVolumeCommand) {
        double volume = message.payload().toDouble()/100;
        emit setVolume(volume);
        }
    else if (message.topic()==mediaPlayIdCommand) {
     QDBusObjectPath _path;
     _path.setPath(message.payload());
     emit setPlayId(_path);
    }
    else if (message.topic()==mediaPlayPauseCommand) emit setPlayPause();
    else if (message.topic()==mediaRepeatCommand){
        if (message.payload()=="0") emit setLoop("None");
        else emit setLoop("Playlist");
    }
    else if (message.topic()==mediaMixCommand){
     if (message.payload()=="0") emit setShuffle(false);
     else emit setShuffle(true);
    }



}
コード例 #4
0
ファイル: mainwindow.cpp プロジェクト: similarJ/qmqtt-client
void MainWindow::onMQTT_Received(const QMQTT::Message &message)
{
    log(tr("message recevied from %1: qos=%2").arg(message.topic()).arg(message.qos()));
    log(message.payload());
}
コード例 #5
0
ファイル: mainwindow.cpp プロジェクト: similarJ/qmqtt-client
void MainWindow::onMQTT_Published(QMQTT::Message &message)
{
    log(tr("message published to %1").arg(message.topic()));
    log(message.payload());
}
コード例 #6
0
ファイル: mqtt.cpp プロジェクト: tipih/qtModeratorDemo
void MQTT::processPendingDatagrams()
{
//! [2]
  while (udpSocket->hasPendingDatagrams()) {

      QByteArray buf;
      buf.resize(udpSocket->pendingDatagramSize());
      QDataStream s(&buf, QIODevice::ReadOnly);
      udpSocket->readDatagram(buf.data(), buf.size());

      s >> dataGram.speed >> dataGram.gear >> dataGram.is >> dataGram.lka >> dataGram.fwc;
      qDebug()<<dataGram.speed <<" "<<dataGram.gear<<" "<<dataGram.lka<<" "<<dataGram.fwc;
      QMQTT::Message message;

      message.setTopic("speed");
      QString messagePayload= QString::number(dataGram.speed);
      message.setPayload(messagePayload.toLatin1());
      this->client->publish(message);

      message.setTopic("gear_pos");
      messagePayload= QString::number(dataGram.gear);
      message.setPayload(messagePayload.toLatin1());
      this->client->publish(message);

      message.setTopic("is_active");
      messagePayload= QString::number(dataGram.is);
      message.setPayload(messagePayload.toLatin1());
      this->client->publish(message);

      message.setTopic("fcw_active");
      messagePayload= QString::number(dataGram.fwc);
      message.setPayload(messagePayload.toLatin1());
      this->client->publish(message);

      message.setTopic("lka_active");
      messagePayload= QString::number(dataGram.lka);
      message.setPayload(messagePayload.toLatin1());
      this->client->publish(message);




}
//! [2]
}