Skip to content
This repository has been archived by the owner on Jun 10, 2023. It is now read-only.

Commit

Permalink
issue #24 UL20 helper enhanced
Browse files Browse the repository at this point in the history
  • Loading branch information
justb4 committed Nov 17, 2015
1 parent fc7c551 commit d70c84f
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/fiware/client/UL20/RegisterDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@
DEVICE_FILE=sys.argv[1]
DEVICE_ID=sys.argv[2]
ENTITY_ID=sys.argv[3]
elif sys.argv[1] == 'DEVICE_ANY':
DEVICE_FILE=sys.argv[1]
DEVICE_ID=sys.argv[2]
ENTITY_ID=sys.argv[3]
ATTR_ID=sys.argv[4]
ATTR_NAME=sys.argv[5]
ATTR_TYPE=sys.argv[6]
ORG_NAME=sys.argv[7]
LAT_LON=sys.argv[8]

else:
print 'Usage: '+COMMAND+' [DEVICE_FILE] [DEVICE_ID] [ENTITY_ID]'
print ' Where DEVICE_FILE is the name of the file in the devices folder containing the JSON description of a device model. See examples at .devices/ '
Expand Down Expand Up @@ -66,7 +76,14 @@

PAYLOAD_json["devices"][0]["device_id"]=DEVICE_ID
PAYLOAD_json["devices"][0]["entity_name"]=ENTITY_ID


if DEVICE_FILE == 'DEVICE_ANY':
PAYLOAD_json["devices"][0]["attributes"][0]["object_id"]=ATTR_ID
PAYLOAD_json["devices"][0]["attributes"][0]["name"]=ATTR_NAME
PAYLOAD_json["devices"][0]["attributes"][0]["type"]=ATTR_TYPE
PAYLOAD_json["devices"][0]["static_attributes"][0]["value"]=ORG_NAME
PAYLOAD_json["devices"][0]["static_attributes"][1]["value"]=LAT_LON

PAYLOAD = json.dumps(PAYLOAD_json, indent=4)

HEADERS = {'content-type': 'application/json' , 'X-Auth-Token' : TOKEN, 'Fiware-Service' : FIWARE_SERVICE, 'Fiware-ServicePath' : FIWARE_SERVICE_PATH }
Expand Down
37 changes: 37 additions & 0 deletions src/fiware/client/UL20/devices/DEVICE_ANY
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"devices": [
{ "device_id": "DEV_ID",
"entity_name": "ENTITY_ID",
"entity_type": "thing",
"protocol": "PDI-IoTA-UltraLight",
"timezone": "Europe/Amsterdam",
"attributes": [
{
"object_id": "ATTR_ID",
"name": "ATTR_NAME",
"type": "ATTR_TYPE"
}
],
"static_attributes": [
{ "name": "name",
"type": "string",
"value": "ORG_NAME"
},
{
"name": "position",
"type": "coords",
"value": "LAT_LON",
"metadatas": [
{
"name": "location",
"type": "string",
"value": "WGS84"
}
]
}

]
}
]
}

4 changes: 4 additions & 0 deletions src/fiware/client/UL20/setup-workshop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
python CreateService.py fiwareiot 4jggokgpepnvsb2uv4s40d59ov 185.21.189.59 1026
python RegisterDevice.py GEONOVUM_TEMP DavisDev TempGeonovumWS1Ent
python SendObservation.py DavisDev 'temp|11#pos|52.152435,5.37241'
python ListDevices.py
6 changes: 6 additions & 0 deletions src/fiware/client/UL20/setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
python CreateService.py fiwareiot 4jggokgpepnvsb2uv4s40d59ov 185.21.189.59 1026
python RegisterDevice.py GEONOVUM_TEMP DavisDev TempGeonovumEnt
python SendObservation.py DavisDev 'temp|11#pos|52.152435,5.37241'

# Populate generic device/sensor
# DEVICE_ANY requires: device_name, entity_name, object_id, sensor_type, sensor_unit, place_name, "lat,lon"
python RegisterDevice.py DEVICE_ANY NexusTempDev1 NexusEnt1 t temperature int Boshut "52.091223,5.763600"
python SendObservation.py NexusTempDev1 't|12'
python ListDevices.py

4 changes: 4 additions & 0 deletions src/fiware/client/UL20/stress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,9 @@ do
# temperature=12
python SendObservation.py DavisDev "temp|${temperature}#pos|52.152435,5.37241"

temperature=$RANDOM
let "temperature %= $RANGE"
python SendObservation.py NexusTempDev1 "t|${temperature}"

sleep 4
done
2 changes: 1 addition & 1 deletion src/fiware/client/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ OAuth=no
# Here you need to configure the IDAS service your devices will be sending data to.
# By default the OpenIoT service is provided.
#
#fiware-service=fiwareiot
fiware-service=fiwareiot
# fiware-service=workshop
# fiware-service=bus_auto
fiware-service-path=/
#apikey=4jggokgpepnvsb2uv4s40d59ov
Expand Down

0 comments on commit d70c84f

Please sign in to comment.