简体   繁体   English

设置 LWM2M 设备与 IDAS 通信

[英]Setting up LWM2M device communicates with IDAS

I am new to Fiware and need help.我是 Fiware 的新手,需要帮助。

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.我想将一个使用CoAP协议的路边设备(传感器)配置到IDAS IoT代理(轻量级M2M代理),这样这个设备就可以向IDAS发送一些数据。

How can I accomplish this task?我怎样才能完成这个任务?

We are a company that works with LwM2M protocol through FIWARE technologies, may be our IoT FIWARE Dockerized infrastructure could help you.我们是一家通过 FIWARE 技术使用 LwM2M 协议的公司,也许我们的 IoT FIWARE Dockerized 基础设施可以帮助您。

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

Reading your comments before, I understand that you want to build an scenario in order to connect your sensors to IotAgent-LWM2M.之前阅读过您的评论,我了解到您想要构建一个场景,以便将您的传感器连接到 IotAgent-LWM2M。

In order to use LW2M2 IotAgent:为了使用 LW2M2 IotAgent:

  1. Install LW2M2 agent: git clone https://github.com/telefonicaid/lightweightm2m-iotagent.git安装 LW2M2 代理:git clone https://github.com/telefonicaid/lightweightm2m-iotagent.git
  2. Install yarm to install all dependencies using npm packages安装 yarm 以使用 npm 包安装所有依赖项
  3. Install Lightweight M2M client: git clone https://github.com/telefonicaid/lwm2m-node-lib.git安装轻量级 M2M 客户端:git clone https://github.com/telefonicaid/lwm2m-node-lib.git

Technical Requirements:技术要求:

  1. Mosquito MQTT v3.1 Broker Mosquito MQTT v3.1 代理
  2. Orion latest猎户座最新
  3. MongoDB v.3.2 MongoDB v.3.2
  4. NodeJS v0.12 NodeJS v0.12

I suggest you to use docker to install dependencies before comment我建议你在评论之前使用 docker 安装依赖项

 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注: Mosquitto 起到传感器的作用

Getting started: StepByStep入门:StepByStep

Step 1 : Create a device第 1 步:创建设备

(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第 2 步:创建服务

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第 3 步:将传感器连接到客户端

(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第 5 步:更新属性

set /7392/0 1 67

Step 6: Query to Orion to see updated attributes步骤 6:查询 Orion 以查看更新的属性

    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"
       }
   ]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM