Created
July 30, 2019 20:12
-
-
Save anonymouse64/009b95936d4366c341752a093780e472 to your computer and use it in GitHub Desktop.
Test edgex-device-mqtt as a snap
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/bash -e | |
# remove any previous snaps | |
sudo snap remove edgexfoundry edgex-device-mqtt mosquitto | |
if ! command -v jq > /dev/null; then | |
sudo snap install jq | |
fi | |
# install edgex-device-mqtt, mosquitto, and edgexfoundry | |
edgexSnapInstallChange=$(sudo snap install edgexfoundry --channel=edinburgh --no-wait) | |
sudo snap install edgex-device-mqtt --channel=edinburgh | |
sudo snap install mosquitto | |
# download the example configuration.toml and the example device profile to | |
# $SNAP_DATA | |
for f in configuration.toml mqtt.test.device.profile.yml; do | |
sudo curl -s https://raw.githubusercontent.com/edgexfoundry/device-mqtt-go/master/cmd/res/example/$f --output /var/snap/edgex-device-mqtt/current/config/device-mqtt/res/$f | |
done | |
# replace the ProfilesDir with $SNAP_DATA so that the device profile gets picked up | |
SNAP_REVISION=$(snap run --shell edgex-device-mqtt.device-mqtt -c "echo \$SNAP_REVISION") | |
sudo sed -i \ | |
-e s:'ProfilesDir = \"./res/example\"':"ProfilesDir = \"/var/snap/edgex-device-mqtt/$SNAP_REVISION/config/device-mqtt/res\"": \ | |
/var/snap/edgex-device-mqtt/current/config/device-mqtt/res/configuration.toml | |
# wait for edgex to finish starting up | |
snap watch "$edgexSnapInstallChange" | |
# enable device-mqtt | |
sudo snap start --enable edgex-device-mqtt.device-mqtt | |
# wait 10 seconds for everything to come online | |
sleep 10 | |
# send a reading to device-mqtt | |
mosquitto_pub -t DataTopic -m '{"name":"MQTT test device","cmd":"randfloat32","randfloat32":"1.2"}' | |
# wait a few seconds for it to get sent to core-data | |
sleep 5 | |
# make sure the reading shows up in core-data | |
curl -s localhost:48080/api/v1/reading | jq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment