Shell脚本执行mqtt命令

时间:2019-05-22 13:28:02

标签: shell mqtt

想要脚本中的某些MQTT AT命令。

#!system/bin/sh

#Open the Network
echo -e "AT+CMQTTSTART"

#Acquire a Clienr
echo -e "AT+CMQTTACCQ=0,"client c" "

#set the will topic
echo -e "AT+CMQTTWILLTOPIC=0,10" 

#set the will message 
echo -e "AT+CMQTTWILLMSG=0,56,1"

#connect to the Server
echo -e "AT+CMQTTCONNECT=0,"tcp://192.168.9.27:5141",20,1,”2208e”,"Adff0c=-_""

#Send subscribe message to server
echo -e "AT+CMQTTSUB=0,9,1,1" 

#Send un subscribe message to server 
echo -e "AT+CMQTTUNSUB=0,9,1" 

#Disconnect from the Server 
echo -e "AT+CMQTTDISC=0,60"

#Release Client
echo -e "AT+CMQTTREL=0" 

#Close the Network
echo -e "AT+CMQTTSTOP"

我没有执行此AT命令。但是,我得到了每个AT指令的印图

1 个答案:

答案 0 :(得分:-1)

#!system / bin / sh

#打开网络

echo -e“ AT + CMQTTSTART”> / dev / ttyUSB1

#获取客户

echo -e“ AT + CMQTTACCQ = 0,”客户端c“”> / dev / ttyUSB1

#设置遗嘱主题

echo -e“ AT + CMQTTWILLTOPIC = 0,10”> / dev / ttyUSB1

#设置遗嘱消息

echo -e“ AT + CMQTTWILLMSG = 0,56,1”> / dev / ttyUSB1

#connect到服务器

echo -e“ AT + CMQTTCONNECT = 0,” tcp://192.168.9.27:5141“,20,1,” 2208e“,” Adff0c = -_“”> / dev / ttyUSB1

#将订阅消息发送到服务器

echo -e“ AT + CMQTTSUB = 0,9,1,1”> / dev / ttyUSB1

#将取消订阅消息发送到服务器

echo -e“ AT + CMQTTUNSUB = 0,9,1”> / dev / ttyUSB1

#与服务器断开连接

echo -e“ AT + CMQTTDISC = 0,60”> / dev / ttyUSB1

#Release客户端

echo -e“ AT + CMQTTREL = 0”> / dev / ttyUSB1

#关闭网络

echo -e“ AT + CMQTTSTOP”> / dev / ttyUSB1