Last active
February 15, 2018 06:01
-
-
Save YongHuax/bb3af3fc817e10169fafeb69f58c5386 to your computer and use it in GitHub Desktop.
LG01-P Linux Script to AWSIot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Trivial demonstrations rarely get the acclaim they deserve.