Ejemplo n.º 1
0
void MainWindow::onMQTT_Received(const QMQTT::Message &message)
{
    if(message.topic()==DEV1S){
        ui->d1v->display(message.payload().toInt());
    }
    qDebug() << QString::fromUtf8(message.payload());
}
Ejemplo n.º 2
0
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());
}
Ejemplo n.º 3
0
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);
    }



}
Ejemplo n.º 4
0
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());
}
Ejemplo n.º 5
0
void MainWindow::onMQTT_Published(QMQTT::Message &message)
{
    log(tr("message published to %1").arg(message.topic()));
    log(message.payload());
}
Ejemplo n.º 6
0
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]
}