• ubuntu 16.4 安装MQTT


    root@ros-OptiPlex-3050:~# sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa

    More info: https://launchpad.net/~mosquitto-dev/+archive/ubuntu/mosquitto-ppa
    Press [ENTER] to continue or ctrl-c to cancel adding it

    gpg: keyring `/tmp/tmpdwr_iinr/secring.gpg' created
    gpg: keyring `/tmp/tmpdwr_iinr/pubring.gpg' created
    gpg: requesting key 262C4500 from hkp server keyserver.ubuntu.com
    gpg: /tmp/tmpdwr_iinr/trustdb.gpg: trustdb created
    gpg: key 262C4500: public key "Launchpad mosquitto" imported
    gpg: Total number processed: 1
    gpg: imported: 1 (RSA: 1)
    OK

    root@ros-OptiPlex-3050:~# sudo apt-get update

    root@ros-OptiPlex-3050:~# sudo apt-get install mosquitto

    root@ros-OptiPlex-3050:~# sudo apt-get install mosquitto-dev

    root@ros-OptiPlex-3050:~# sudo apt-get instaroot@ros-OptiPlex-3050:~# sudo apt-get install mosquitto-clientsll mosquitto-clients

    root@ros-OptiPlex-3050:~# sudo service mosquitto status
    ● mosquitto.service - Mosquitto MQTT v3.1/v3.1.1 Broker
    Loaded: loaded (/lib/systemd/system/mosquitto.service; disabled; vendor preset: enabled)
    Active: inactive (dead)
    Docs: man:mosquitto.conf(5)
    man:mosquitto(8)

    #打开一个终端,执行以下命令订阅主题"mqtt"
    mosquitto_sub -h localhost -t "mqtt" -v
    
    #打开另外一个终端,发布消息到主题 “mqtt”
    mosquitto_pub -h localhost -t "mqtt" -m "Hello MQTT"
    
    #现在你会看到消息被显示在前一个终端上了.

    #通过以下命令,可以定于到官放所有测试的mqtt信息,当然你发布的信息别人也能订阅到
    mosquitto_sub -h test.mosquitto.org -t "#"   -v
    
    #也可以在官方mqtt服务下发布自己专属的信息
    mosquitto_sub -h test.mosquitto.org -t  "myxyz123"  -v
    
    #订阅自己的信息
    mosquitto_pub -h test.mosquitto.org -t "myxyz123"  -m  "hello mqtt"
  • 相关阅读:
    CABasicAnimation 使用
    CABasicAnimation(CAKeyframeAnimation)keypath 取值
    c++的应用领域
    QT 状态机详解 statemachine (转)
    C++默认实参
    String隐式共享
    可重入函数与不可重入函数
    堆和栈的区别(转过无数次的文章)
    Qt Model/View(转)
    C++虚函数和纯虚函数
  • 原文地址:https://www.cnblogs.com/youran-he/p/12055176.html
Copyright © 2020-2023  润新知