Skip to content

Instantly share code, notes, and snippets.

@drasko
Last active May 11, 2019 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drasko/b0297d6ef718b2bcc02370c92feab3bf to your computer and use it in GitHub Desktop.
Save drasko/b0297d6ef718b2bcc02370c92feab3bf to your computer and use it in GitHub Desktop.
EdgeX Provisioning Procedure
#!/bin/bash
#
# Copyright (c) 2018
# Mainflux
#
# SPDX-License-Identifier: Apache-2.0
#
###
# Core Metadata
###
printf "> Provisioning Addressibles\n"
# Addressable for the Device Service
curl http://localhost:48081/api/v1/addressable -X POST -s -S -d @- <<EOF
{
"name":"camera control",
"protocol":"HTTP",
"address":"172.17.0.1",
"port":49977,
"path":"/cameracontrol",
"publisher":"none",
"user":"none",
"password":"none",
"topic":"none"
}
EOF
echo ""
# Addressable for the Device (the camera in this case)
curl http://localhost:48081/api/v1/addressable -X POST -s -S -d @- <<EOF
{
"name":"camera1 address",
"protocol":"HTTP",
"address":"172.17.0.1",
"port":49999,
"path":"/camera1",
"publisher":"none",
"user":"none",
"password":"none",
"topic":"none"
}
EOF
###
# Core Data
###
printf "\n> Provisioning Value Descriptors\n"
# Value Descriptor for `people count`
curl http://localhost:48080/api/v1/valuedescriptor -X POST -s -S -d @- <<EOF
{
"name":"humancount",
"description":"people count",
"min":"0","max":"100",
"type":"I",
"uomLabel":"count",
"defaultValue":"0",
"formatting":"%s",
"labels":["count","humans"]
}
EOF
echo ""
# Value Descriptor for `dog count`
curl http://localhost:48080/api/v1/valuedescriptor -X POST -s -S -d @- <<EOF
{
"name":"caninecount",
"description":"dog count",
"min":"0","max":"100",
"type":"I",
"uomLabel":"count",
"defaultValue":"0",
"formatting":"%s",
"labels":["count","canines"]
}
EOF
echo ""
# Value Descriptor for `camera scan distance`
curl http://localhost:48080/api/v1/valuedescriptor -X POST -s -S -d @- <<EOF
{
"name":"depth",
"description":"scan distance",
"min":"1","max":"10",
"type":"I",
"uomLabel":"feet",
"defaultValue":"1",
"formatting":"%s",
"labels":["scan","distance"]
}
EOF
echo ""
# Value Descriptor for `time between events`
curl http://localhost:48080/api/v1/valuedescriptor -X POST -s -S -d @- <<EOF
{
"name":"duration",
"description":"time between events",
"min":"10",
"max":"180",
"type":"I",
"uomLabel":"seconds",
"defaultValue":"10",
"formatting":"%s",
"labels":["duration","time"]
}
EOF
echo ""
# Value Descriptor for `error`
curl http://localhost:48080/api/v1/valuedescriptor -X POST -s -S -d @- <<EOF
{
"name":"cameraerror",
"description":"error response message from a camera",
"min":"",
"max":"",
"type":"S",
"uomLabel":"",
"defaultValue":"error",
"formatting":"%s",
"labels":["error","message"]
}
EOF
###
# Create Device Profile
###
printf "\n> Creating Device Profile\n"
# N.B camera_monitor_profile.yml file can be downloaded from https://docs.edgexfoundry.org/Ch-WalkthroughDeviceProfile.html
curl http://localhost:48081/api/v1/deviceprofile/uploadfile -X POST -s -S -F "file=@./camera_monitor_profile.yml"
###
# Create Device Service
###
printf "\n> Creating Device Service\n"
curl http://localhost:48081/api/v1/deviceservice -X POST -s -S -d @- <<EOF
{
"name":"camera control device service",
"description":"Manage human and dog counting cameras",
"labels":["camera","counter"],
"adminState":"unlocked",
"operatingState":"enabled",
"addressable": {
"name":"camera control"
}
}
EOF
###
# Add Device
###
printf "\n> Creating Device\n"
curl http://localhost:48081/api/v1/device -X POST -s -S -d @- <<EOF
{
"name":"countcamera1",
"description":"human and dog counting camera #1",
"adminState":"unlocked",
"operatingState":"enabled",
"addressable":{
"name":"camera1 address"
},
"labels":[
"camera","counter"
],
"location":"",
"service":{
"name":"camera control device service"
},
"profile":{
"name":"camera monitor profile"
}
}
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment