1

I am new to Fiware and need help.

I want to configure a road side device (sensor) using CoAP protocol to the IDAS IoT agent (Lightweight M2M agent), so this device can send some data to IDAS.

How can I accomplish this task?

Roberto Caboni
  • 7,252
  • 10
  • 25
  • 39
arilwan
  • 3,374
  • 5
  • 26
  • 62

2 Answers2

0

We are a company that works with LwM2M protocol through FIWARE technologies, may be our IoT FIWARE Dockerized infrastructure could help you.

https://gitlab.hopu.eu/software/FIWARE/fiware-docker-infrastructure

Germán Molina
  • 133
  • 2
  • 6
  • Hi @German Molina, Not sure how your infrastructure could help me, but here is the scenario at hand. I want the lwm2m client to register with the fiware iot agent, (later, the client should send update to iot agent). Then get context update info from orion. – arilwan Oct 18 '18 at 11:16
0

Reading your comments before, I understand that you want to build an scenario in order to connect your sensors to IotAgent-LWM2M.

In order to use LW2M2 IotAgent:

  1. Install LW2M2 agent: git clone https://github.com/telefonicaid/lightweightm2m-iotagent.git
  2. Install yarm to install all dependencies using npm packages
  3. Install Lightweight M2M client: git clone https://github.com/telefonicaid/lwm2m-node-lib.git

Technical Requirements:

  1. Mosquito MQTT v3.1 Broker
  2. Orion latest
  3. MongoDB v.3.2
  4. NodeJS v0.12

I suggest you to use docker to install dependencies before comment

 version : "2"

services:
  mongo:
    image: mongo:3.2
    command: --nojournal
    ports:
      - "27017:27017"
    expose:
      - "27017"
  orion:
    image: fiware/orion
    links:
      - mongo
    ports:
      - "1026:1026"
    command: -dbhost mongo
    expose:
      - "1026"
  mosquitto:
    image: ansi/mosquitto
    ports:
      - "1883:1883"
    expose:
      - "1883"

Note: Mosquitto play a role like a sensor

Getting started: StepByStep

Step 1 : Create a device

(curl localhost:4041/iot/devices -s -S --header 'Content-Type: application/json' \
--header 'Accept: application/json' --header 'fiware-service: Factory' --header      'fiware-servicepath: /robots' \
-d @- | python -mjson.tool) <<EOF
{
"devices": [
   {
    "device_id": "robot1",
    "entity_type": "Robot",
    "attributes": [
      {
        "name": "Battery",
        "type": "number"
      }
    ],
    "lazy": [
      {
        "name": "Message",
        "type": "string"
      }
    ],
    "commands": [
      {
        "name": "Position",
        "type": "location"
      }
    ],
  "internal_attributes": {
    "lwm2mResourceMapping": {
      "Battery" : {
        "objectType": 7392,
        "objectInstance": 0,
        "objectResource": 1
      },
      "Message" : {
        "objectType": 7392,
        "objectInstance": 0,
        "objectResource": 2
      },
      "Position" : {
        "objectType": 7392,
        "objectInstance": 0,
        "objectResource": 3
      }
    }
  }
}]}
EOF

Step 2 : Create a service

curl -X POST -H "Fiware-Service: myHome" -H "Fiware-ServicePath: /environment" -H  "Content-Type: application/json" -H "Cache-Control: no-cache" -d '{
"services": [
{
      "resource": "/",
      "apikey": "",
      "type": "Robot",
      "cbroker":"localhost:1026"
 }]
}' 'http://localhost:4041/iot/services'

Step 3: connect your sensor to the client

(bin/iotagent-lwm2m-client.js)

Object Creation:
LWM2M-Client> create /7392/0
Battery attribute:
LWM2M-Client> set /7392/0 1 89
Message Attribute:
LWM2M-Client> set /7392/0 2 "First robot here"
Position attribute:
LWM2M-Client> set /7392/0 3 "[0,0]

Step 4: connect with the server

LWM2M-Client> connect localhost 5684 robot1 /

Step 5: Update attributes

set /7392/0 1 67

Step 6: Query to Orion to see updated attributes

    curl -X POST http://localhost:1026/v1/queryContext -s -S 
--header 'Content-Type: application/json' \
--header 'Accept: application/json' --header 'fiware-service: Factory' 
--header 'fiware-servicepath: /robots' \
-d '
{
   "entities": [
       {
           "type": "Robot",
           "isPattern": "false",
           "id": "Robot:robot1"
       }
   ]
}
Community
  • 1
  • 1
  • I have done all the steps stated above and all is well to completion. The scenario I have is: Got an agent on my dataCollectionUnit (system) that gather data from sensors and store in sqliteDB. Now I deployed lwm2m client (wakaama) on same system, that I want to gather sensorData and forward to IDAS (on remote server) for final delivery to OrionCB. LWM2M client registers itself (auto, can confirm from server logs) with IDAS (after running client -4 -h {serverIP} -p {PORT}. How do I make the LWM2M client send the data to Orion? Is it auto (the way it registers) or I need do some configurations. – arilwan Nov 02 '18 at 22:31
  • For your question, did you do step5 & step6 ? – Fernando Méndez Requena Nov 08 '18 at 11:37
  • Hi Fernando, yes sure I did. – arilwan Nov 09 '18 at 01:27
  • So its nice, you response yourself ! From steps before comments, (step 5 ) it sends data to Orion. In steps 6 you can get response from Orion. – Fernando Méndez Requena Nov 13 '18 at 12:21
  • Oh, thank you for your feedback. But what is the use of Node.js above please, it seems we haven't use it here. – arilwan Nov 14 '18 at 23:41
  • OMG! It was running, now I run into issues with curl: { "message": "Request error connecting to the Context Broker: {\"code\":\"400\",\"reasonPhrase\":\"Bad Request\",\"details\":\"JSON Parse Error: unknown field: /contextRegistrations/contextRegistration/attributes/attribute/isDomain\"}", "name": "BAD_REQUEST" } – arilwan Nov 15 '18 at 00:42
  • Hi this error is cause your json is malformed. You can check your payload json here https://jsonlint.com/ – Fernando Méndez Requena Nov 15 '18 at 12:13