1

我是 Fiware 的新手,需要帮助。

我想给 IDAS IoT 代理(Lightweight M2M agent)配置一个使用 CoAP 协议的路边设备(传感器),这样这个设备就可以向 IDAS 发送一些数据。

我怎样才能完成这项任务?

4

2 回答 2

0

之前阅读您的评论,我了解到您想要构建一个场景以将您的传感器连接到 IotAgent-LWM2M。

为了使用 LW2M2 IotAgent:

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

技术要求:

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

我建议你在评论之前使用 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"

注意: 蚊子起到传感器的作用

入门:一步一步

第 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

第 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'

第 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]

第四步:连接服务器

LWM2M-Client> connect localhost 5684 robot1 /

第 5 步:更新属性

set /7392/0 1 67

第 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"
       }
   ]
}
于 2018-10-26T08:43:57.177 回答
0

我们是一家通过 FIWARE 技术使用 LwM2M 协议的公司,也许我们的 IoT FIWARE Dockerized 基础设施可以帮助您。

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

于 2018-09-20T13:04:11.567 回答