Guest User

Untitled

a guest
Feb 21st, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. #when connecting to AWSIOT , a cert , privatekey and certificate authority file is required .
  4. #after downloading the cert files when creating a thing , it is possible rename the files so that it is easier to
  5. #call the file when writing the script and cli
  6. #also note that aws things shadow update requires message to be in json to update
  7. #to catch messages sent to things but are rejected due to improper json format , subscribe to things shadow update through mqtt.
  8. # do remember to check the activity page for the AWsiot " thing" u have created to see whether the message is accepted or rejected
  9.  
  10. HOST="a1k3lzqvylq236.iot.ap-southeast-1.amazonaws.com"
  11.  
  12. CERT="/root/81.pem.crt"
  13.  
  14. KEY="/root/81.pem.key"
  15.  
  16. CA="/root/CA.pem"
  17.  
  18. MSG="temp=$1"
  19.  
  20. MGS2="temp=$1,hum=$2"
  21.  
  22. #the $1 refers to the additional data sent from arduino code ( the add parameter command )
  23. data1=$1
  24. #rssi=$2
  25.  
  26. #mosquitto_pub --cert $CERT --key $KEY --cafile $CA -h $HOST -p 8883 -d -q 0 -t yhtest -m "temp=$1"
  27.  
  28.  
  29. mosquitto_pub --cert $CERT --key $KEY --cafile $CA -h $HOST -p 8883 -d -q 0 -t yhtest -m "MSG"
  30.  
  31.  
  32.  
  33.  
  34. # type in linux shell with mosquitto cli installed
  35. # -h is the url of the broker , -t is the topic
  36. # -d enable debug messages to show what is going on in mosquitto cli
  37. # 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