Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Fiware IoT_IDAS_intro_ul20_v2

6,788 views

Published on

FIWARE IoT IDAS GEi (open source Telefonica implementation of Backend Device Management GE).

Published in: Internet
  • Be the first to comment

Fiware IoT_IDAS_intro_ul20_v2

  1. 1. FIWARE IoT: IDAS intro + UL2.0 Carlos Ralli Ucendo, @carlosralli FIWARE, Telefonica I+D http://www.slideshare.net/ FI-WARE/fiware-iotidasintroul20v2
  2. 2. FIWARE (IoT) Target: Developers Context Broker App Logic @FIWARE-Cloud Desktop/Mobile/Tablet User Interface Web 3D GE / Advanced UI Wirecloud GE / Dashboards OAuth2.0 SANTANDER SMARTSPACES SEVILLA 2) IoT Providers. Pretty Heterogeneous solutions/skills. • An incremental approach. Public/Private instances. • KISS philosophy for most (web)developers. • Advanced IoT architecture, e.g. for IoT Advanced Devel. 1) IoT Consumers. Normally not just IoT. • A single point, API & Protocol for IoT, OpenData, etc. • Context: Data Entities + Data Entities events. • A Public & Secured Ecosystem at FIWARE Lab MultiMedia Events Complex Event Processing IoT GEis Smartcities OpenData BigData Analytics
  3. 3. IoT – Typical Scenario I (fully tested, most used so far) • Simplest scenario at FIWARE Wiki IoT Architecture. • Extensively tested with developers. Most Feedback Implemented. • New features are required (Edge management, more Agents).
  4. 4. IDAS4.0 - Modular architecture: IoT-Agents • Monolithic vs Modular -> Easier Installation, Cloud Blueprints • Coded in C++ vs Coded in any language -> Higher flexibility • Extensibility via C++ plugins vs a new IoT Agent -> Easier to get contribs/extensions • Scalability by design FIWARE Context Broker IoT Agent-UL2.0 IoT Agent-TT IoT Agent- lwm2m IoT Agent Manager create/monitor FIWARE IoT Backend Device Management OMA NGSI API (Developers’ Interface) (southbound interfaces) MQTT Ultralight2.0 HTTP OMA LWM2M/IETF CoAP OMA NGSI API BE Device Management (IDAS) SIGFOX
  5. 5. IDAS4.0 – Available IoT-Agents (May 2015) - Ultralight2.0: https://github.com/telefonicaid/fiware-IoTAgent-Cplusplus - MQTT https://github.com/telefonicaid/fiware-IoTAgent-Cplusplus - LWM2M/CoAP: https://github.com/telefonicaid/lightweightm2m-iotagent - SigFox: https://github.com/telefonicaid/sigfox-iotagent - Generic IoT-Agent Skeletons: https://github.com/telefonicaid/iotagent-node-lib (node.js) https://github.com/telefonicaid/fiware-IoTAgent-Cplusplus (C++)
  6. 6. Connect your IoT: IoT-Agent-UltraLight2.0 (IDAS) Step 0 – Create a Service (not in Public Instance) Step 1 – Create Device Step 2 – Send Measurements Step 3 – Send Commands Testing / Hackathons IDAS4.x Testing details: • IPv4: 130.206.80.40 • IPv6: 2001:720:1514:80::40 • IDAS API (Dev/Admin ). Port: 5371 (IPv4) • ContextBroker. Port 1026 (IPv4/IPv6) • Testing Service: fiwareiot • APIKEY: 2015fiwareiot • Service URL: <IDAS_HOST>/iot/ fiwareiot
  7. 7. IoT-Agent-UltraLight2.0 (IDAS) Step 0 – Create Service (REST ADMIN API) Normally, only if you deploy your own IDAS instance. For the FIWARE Lab instance just use fiwareiot service. If ContextBroker in the same VM, use 0.0.0.0 as IP address. HTTP POST: http://130.206.80.40:5371/iot/services Headers: {'content-type': 'application/json’; 'X-Auth-Token' : [TOKEN]; "Fiware-Service: [myservice]”; "Fiware-ServicePath: /"} Payload: { "services": [ { "apikey": ”[myservice-API-KEY]", "token": "token2", "cbroker": "http://0.0.0.0:1026", "entity_type": "thing", "resource": "/iot/d" } ] }
  8. 8. IoT-Agent-UltraLight2.0 (IDAS) Step 1 – Create Device (REST ADMIN API) Payload JSON Format: - Device ID - Entity Name = Entity ID - Protocol (mandatory) - Attributes - Object ID (Alias) - Static Atributes - Commands for Actuators - See step 3 HTTP POST: http://130.206.80.40:5371/iot/devices Headers: {'content-type': 'application/json’; 'X-Auth-Token' : [TOKEN]; "Fiware-Service: fiwareiot”; "Fiware-ServicePath: /"} Payload: {"devices": [ { "device_id": ”[DEV_ID]", "entity_name": ”[ENTITY_ID]”, "entity_type": "thing", "protocol" : "PDI-IoTA-UltraLight”  Added in June 2015. "timezone": ”Europe/Madrid", "attributes": [ { "object_id": "t", "name": "temperature", "type": "int" } ], "static_attributes": [ { "name": "att_name", "type": "string", "value": "value" }]}]}
  9. 9. IoT-Agent-UltraLight2.0 (IDAS) Step 2 – Send Measurements (UL2.0 DEVICE API) Payload JSON Format: - TOKEN = FIWARE Oauth Token. - Device ID (Step 1). HTTP POST: http://130.206.80.40:5371/iot/d?k=[APIKEY]&i=[DEV_ID] Headers: {'content-type': 'application/text’; 'X-Auth-Token' : [TOKEN]; "Fiware-Service: fiwareiot”; "Fiware-ServicePath: /"} Payload: ‘ t|25‘ - Sending multiple measurements with one request: Headers: {'content-type': 'application/text’; 'X-Auth-Token' : [TOKEN]; "Fiware-Service:”fiwareiot”; "Fiware-ServicePath: /"} Payload: ‘t|23#h|80#l|95#m|Quiet‘
  10. 10. IoT-Agent-UltraLight2.0 (IDAS) Step 3 – Sending Commands to Devices IDAS
  11. 11. IoT-Agent-UltraLight2.0 (IDAS) Step 3. PUSH versus POOLING (at Device registration) HTTP POST: http://130.206.80.40:5371/iot/devices Headers: {'content-type': 'application/json’; 'X-Auth-Token' : [TOKEN]; "Fiware-Service: fiwareiot”; "Fiware-ServicePath: /"} Payload: {"devices": [ { "device_id": ”[DEV_ID]", "entity_name": ”[ENTITY_ID]", "entity_type": "thing", "endpoint": "http://[DEVICE_IP]:[PORT]", "timezone": ”Europe/Madrid", "commands": [ { "name": ”RawCommand", "type": "command", "value": “[Dev_ID]@RawCommand|%s" } ], "attributes": [ … HTTP POST: http://130.206.80.40:5371/iot/devices Headers: {'content-type': 'application/json’; 'X-Auth-Token' : [TOKEN]; "Fiware-Service: fiwareiot”; "Fiware-ServicePath: /"} Payload: {"devices": [ { "device_id": “[DEV_ID]", "entity_name": ” [ENTITY_ID]", "entity_type": "thing", "timezone": ”Europe/Madrid", "commands": [ { "name": ”RawCommand", "type": "command", "value": ” [Dev_ID]@RawCommand|%s" } ], "attributes": [ … How to send commands ? Just update the command attribute in the ContextBroker. How to get commands (from device)?
  12. 12. Thanks!Thanks!
  13. 13. Annex I IoT-Agent-UltraLight2.0 (IDAS) – FIGWAY Python2.7 Tools Testing / Hackathons https://github.com/telefonicaid/fiware-figway/python-IDAS4 • Coded in Python. Tested with RaspberryPI, MACOS & Linux. • Tools for (virtual) Sensors via IDAS IoT-Agent (Ultralight2.0) • Tools to access a ContextBroker. • For IDAS 4.x onwards use IDAS4 folder
  14. 14. Annex I: FIGWAY - Configuration figway/python/config.ini [user] # Please, configure here your username at FIWARE Cloud and a valid Oauth2.0 TOKEN for your user (you can use get_token.py to obtain a valid TOKEN). username= token= Configure for the ContextBroker and the IDAS instances: • IP Addresses: Normally 130.206.80.40 • Ports: Normally: 1026 for ContextBroker and 5371 for IDAS. • FIWARE_SERVICE. Change it to fiwareiot . Update API-KEY also. • FIWARE_SERVICE_PATH. Normally / • Oauth2: normally no If you are using the FIWARE Lab instance protected by IdM:
  15. 15. Annex I: FIGWAY – Registering a (UL2.0) Sensor SensorsUL20/> python RegisterDevice.py [DEV_FILE] [DEV_ID] [ENTITY_ID] > python RegisterDevice.py SENSOR_TEMP Sensor1 Temp-Madrid28001 * opening: ./devices/SENSOR_TEMP * Asking to http://130.206.80.40:5371/iot/devices * Headers: {'Fiware-Service': ’fiwareiot', 'content-type': 'application/json', 'Fiware- ServicePath': '/', 'X-Auth-Token': 'NULL'} * Sending PAYLOAD: […] (See Next Slide) * Status Code: 201 * Response:
  16. 16. Annex I: FIGWAY – Registering a (UL2.0) Sensor. Sensor_TEMP FILE { "devices": [ { "device_id": "DEV_ID", "entity_name": "ENTITY_ID", "entity_type": "thing", "timezone": "Europe/Madrid", "attributes": [ { "object_id": "t", "name": "temperature", "type": "int" } ], "static_attributes": [ { "name": "att_name", "type": "string", "value": "value" } ] }]}
  17. 17. Annex I: FIGWAY – Check List of Devices SensorsUL20/> python ListDevices.py > Python ListDevices.py * Asking to http://130.206.80.40:5371/iot/devices * Headers: {'Fiware-Service': ’fiwareiot', 'content-type': 'application/json', 'Fiware-ServicePath': '/', 'X-Auth-Token': 'NULL'} ... * Status Code: 200 * Response: { "count": 6,"devices": [{ "device_id" : "3F:2A:1A:lamp3" },{ "device_id" : "Sensor1" },{ "device_id" : "dev_1" },{ "device_id" : "ej1" },{ "device_id" : "ej2" },{ "device_id" : "ej3" }]}
  18. 18. Annex I: FIGWAY - Sending Sensor Observations/Measurements SensorsUL20/> python SendObservation.py [DEV_ID] ‘[alias1|value1]’ > python SendObservation.py Sensor1 't|34' * Asking to http://130.206.80.40:5371/iot/d?k=2015fiwareiot&i=Sensor1 * Headers: {'Fiware-Service': ’fiwareiot', 'content-type': 'application/json', 'Fiware- ServicePath': '/', 'X-Auth-Token': 'NULL'} * Sending PAYLOAD: t|34 ... * Status Code: 200 * Response:
  19. 19. Annex I: FIGWAY – Read your Sensor data at the ContextBroker ContextBroker/> python GetEntity.py [ENTITY_ID] > python GetEntity.py Temp-Madrid28001 { "contextResponses" : [ { "contextElement" : { "type" : "thing", "isPattern" : "false", "id" : "Temp-Madrid28001", "attributes" : [ { "name" : "att_name", "type" : "string", "value" : "value", "metadatas" : [ { "name" : "TimeInstant", "type" : "ISO8601", "value" : "2015-04-15T09:57:35.488457Z" }]},{ "name" : "temperature", "type" : "int", "value" : "34", "metadatas" : [ { "name" : "TimeInstant", "type" : "ISO8601", "value" : "2015-04-15T09:57:35.488052Z" } …
  20. 20. Annex I: FIGWAY – What if I want to connect Actuators? SensorsUL20/> python RegisterDevice.py SWITCH dev_11 actuator SWITCH FILE: { "devices": [ { "device_id": "DEV_ID", "entity_name": "ENTITY_ID", "entity_type": "thing", "timezone": "Europe/Madrid", "commands": [ { "name": "RawCommand", "type": "command", "value": ”RawCommand|%s" } ], "attributes": [ { "object_id": "s", "name": "status", "type": "string" } ], "static_attributes": [ { "name": "att_name", "type": "string", "value": "value" }]}]}
  21. 21. Annex I: FIGWAY – What if I want to connect Actuators? (II) python SimulateCommand.py [ENTITY_ID] ‘[COMMAND]‘ > python SimulateCommand.py dev_11 actuator * Asking to http://130.206.80.40:5371/iot/ngsi/d/updateContext * Headers: {'Fiware-Service': ’fiwareiot', 'content-type': 'application/json', 'Fiware-ServicePath': '/', 'X-Auth- Token': 'NULL'} * Sending PAYLOAD: { "contextElements": [ { "attributes": [ { "type": "command", "name": "RawCommand", "value": "Set 95-10-45" } ], … * Status Code: 200 * Response: { "statusCode" : { "code":200, "reasonPhrase":"OK"}} Normal Operation: just update command attribute at ContextBroker Today’s Bug: please issue commands manually with this python script.
  22. 22. Annex I: FIGWAY – What if I want to connect Actuators (III) python GetPoolingCommands.py [DEV_ID] > python GetPoolingCommands.py dev_11 * Asking to http://130.206.80.40:5371/iot/d?k=2015fiwareiot&i=dev_11 * Headers: {'Fiware-Service': ’fiwareiot', 'content-type': 'application/json', 'Fiware-ServicePath': '/', 'X-Auth- Token': 'NULL'} * Sending PAYLOAD: ... * Status Code: 200 * Response: [Dev_ID]@RawCommand|Set 95-10-45
  23. 23. Annex I: FIGWAY – Creating an IoT Service Python CreateService.py [FIWARE_SERVICE] [API_KEY] [IP_CB] [Port:CB] > Python CreateService.py MyOwnService secret 0.0.0.0 1026 * Asking to http://130.206.80.40:5371/iot/services * Headers: {'Fiware-Service': 'MyOwnService', 'content-type': 'application/json', 'Fiware-ServicePath': '/', 'X- Auth-Token': 'NULL'} * Sending PAYLOAD: { "services": [ { "token": "token2", "apikey": ”secret", "resource": "/iot/d", "entity_type": "thing", "cbroker": "http://0.0.0.0:1026" } ] } … * Status Code: 201 * Response: This operation is only for your private instances. If you need your own private service in the public instance of IDAS, let the Admins Know!
  24. 24. Thanks!Thanks!

×