mosquitto 定时发送脚本

timer_send_mqtt.sh:

#!/bin/bash

# 显示一系列数字

count=1

while [ $count -ne 0 ]; do
    echo $count
     mosquitto_pub -h 192.168.111.104 -p 1883 -t "ESP8266/sample/sub" -m "hello, i am message:$count" --cafile /home/chenwu/TLS/ubuntu_mosquitto_mqtt_ssl/tools/ca/ca.crt --cert /home/chenwu/TLS/ubuntu_mosquitto_mqtt_ssl/tools/client/client.crt --key /home/chenwu/TLS/ubuntu_mosquitto_mqtt_ssl/tools/client/client.key -d
    count=$((count + 1))
    sleep 1
done
echo "finished"

说明:

  • -h: host 主机
  • -p: port 端口
  • -t: topic 发布主题
  • -m: message 定时发布的消息
  • cafile,cert,key 是通过 ESP8266_NONOS_SDK/tools 目录下的 makefile.sh 生成的

你可能感兴趣的:(C)