Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #when connecting to AWSIOT , a cert , privatekey and certificate authority file is required .
- #after downloading the cert files when creating a thing , it is possible rename the files so that it is easier to
- #call the file when writing the script and cli
- #also note that aws things shadow update requires message to be in json to update
- #to catch messages sent to things but are rejected due to improper json format , subscribe to things shadow update through mqtt.
- # do remember to check the activity page for the AWsiot " thing" u have created to see whether the message is accepted or rejected
- HOST="a1k3lzqvylq236.iot.ap-southeast-1.amazonaws.com"
- CERT="/root/81.pem.crt"
- KEY="/root/81.pem.key"
- CA="/root/CA.pem"
- MSG="temp=$1"
- MGS2="temp=$1,hum=$2"
- #the $1 refers to the additional data sent from arduino code ( the add parameter command )
- data1=$1
- #rssi=$2
- #mosquitto_pub --cert $CERT --key $KEY --cafile $CA -h $HOST -p 8883 -d -q 0 -t yhtest -m "temp=$1"
- mosquitto_pub --cert $CERT --key $KEY --cafile $CA -h $HOST -p 8883 -d -q 0 -t yhtest -m "MSG"
- # type in linux shell with mosquitto cli installed
- # -h is the url of the broker , -t is the topic
- # -d enable debug messages to show what is going on in mosquitto cli
- # for both -h and -t of sub client it is possible to set it as a variable in the script and call the variable instead of typing everything on a single line
Add Comment
Please, Sign In to add comment