Skip to content

Instantly share code, notes, and snippets.

@ma2shita
Last active November 26, 2019 01:15
Show Gist options
  • Save ma2shita/235d3fc2fe60f05a1db86393cc84333b to your computer and use it in GitHub Desktop.
Save ma2shita/235d3fc2fe60f05a1db86393cc84333b to your computer and use it in GitHub Desktop.
Emit virtual data for Product Line demo on SORACOM Lagoon
#!/bin/bash
source emit_data_a.key # export D_KEY=... ; export D_SEC=... from SORACOM Inventory virtual device
echo "Target device is ${D_ID}"
trap "echo 'done.' ; exit 0" 1 2 3 15
while true
do
if [ $(($RANDOM % 100)) -lt 15 ]; then
V=1 # Line stop
else
V=3 # Line start
fi
echo "Value is $V"
curl -v -X POST -H "X-Device-Secret: $D_SEC" -d "{\"clickType\":$V,\"batteryLevel\":1}" "https://api.soracom.io/v1/devices/${D_ID}/publish"
WAIT_MIN=$(($RANDOM % 7))
echo "Waiting $WAIT_MIN minute(s)"
sleep ${WAIT_MIN}m
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment