guowenxue
2023-07-10 5e9d03d507aad324a803eb8795e0eed6fb671761
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
 
progname=mosquitto_sub
 
hostname="master.iot-yun.club"
port=10883
uid="lingyun"
pwd="lingyun-emb"
dltopic="\$Sys/Studio/Downlink"
uptopic="\$Sys/Studio/Uplink"
 
sub_command="$progname -h $hostname -p $port -u $uid -P $pwd -t "
 
topics=("" "$uptopic" "$dltopic" ) 
 
echo ""
echo "Please select a subscribe topic:" 
echo "1, < Uplink Topic >: Device ---> Server message"
echo "2, <Downlink Topic>: Server ---> Device message" 
echo ""
 
stty erase '^H' 
read -p "Enter your choise [1/2] : " choice
 
if [ $choice -gt 2 ] ; then
    echo "ERROR: Invalid input choice, exit now..."
    exit 1;
fi
 
topic=${topics[$choice]}
 
set -x
 
$sub_command $topic