forked from Orange-OpenSource/fiware-cepheus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsendUpdates.sh
executable file
·49 lines (41 loc) · 1.24 KB
/
sendUpdates.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
42
43
44
45
46
47
48
49
#!/bin/sh
# Simple script to send updateContext to a NGSI endpoint (supporting v1 with JSON)
. common.sh
if (( "$#" < "8" )); then
echo "Usage: $0 endpoint sleep entity_type entity_id attr_name attr_type attr_value1 ... attr_valueN"
echo "Example: Send temp every sec: $0 http://localhost:8080 1 Room Room1 temperature float 10 12 14 16 18 20"
exit 1
fi
function sendUpdateContext() #(url, entity_type, entity_id, attr_name, type, value)
{
payload='{
"contextElements": [
{
"type": "'$2'",
"isPattern": "false",
"id": "'$3'",
"attributes": [
{
"name": "'$4'",
"type": "'$5'",
"value": "'$6'"
}
]
}
],
"updateAction": "APPEND"
}'
send $1 "updateContext" "$payload"
}
url=$1; shift
sleep=$1 shift
entity_type=$1; shift
entity_id=$1; shift
attr_name=$1; shift
attr_type=$1; shift
while (( "$#" )); do
echo "Send updateContext to $1"
sendUpdateContext $url $entity_type $entity_id $attr_name $attr_type $1
shift
sleep $sleep
done