/* 自定義代碼塊樣式 */

2017年3月23日 星期四

安裝 Mosquitto MQTT

取得key後進行安裝

  1. sudo wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
  2. sudo apt-key add mosquitto-repo.gpg.key
  3. cd /etc/apt/sources.list.d/
  4. sudo wget http://repo.mosquitto.org/debian/mosquitto-jessie.list
  5. sudo apt-get update
  6. sudo apt-get install mosquitto

安裝三個 Mosquitto proper 會用到的程式庫
mosquitto – the MQTT broker (or in other words, a server)
mosquitto-clients – command line clients, very useful in debugging
python-mosquitto – the Python language bindings

  1. sudo apt-get install mosquitto mosquitto-clients python-mosquitto

安裝完後mosquitto會立即執行,但還需要進行部分設定,所以先停止

  1. sudo /etc/init.d/mosquitto stop

開啟設定檔案

  1. sudo nano /etc/mosquitto/mosquitto.conf

修改找到 log_dest 列,將後面改為 topic,如下

  1. log_dest topic

並再增加下面六個參數後存檔

  1. log_type error
  2. log_type warning
  3. log_type notice
  4. log_type information
  5. connection_messages true
  6. log_timestamp true

重新啟動mosquitto

  1. sudo /etc/init.d/mosquitto start

進行測試,開啟終端機,輸入下列指令

  1. mosquitto_sub -d -t hello/world

再開啟另一個終端機,輸入下列指令

  1. mosquitto_pub -d -t hello/world -m "Hello from Terminal 2!"


會在第一個開啟的終端機看到如上畫面


會在第二個開啟的終端機看到如上畫面





沒有留言:

定義Arduino Flash Partition

在Arduino 的工程目錄中,增加一個 partitions.csv 文字檔案,內容範例如下 # Name, Type, SubType, Offset, Size, Flags nvs, data, nvs, 0x9000, 0x5000, o...