【问题标题】:Setting up LWM2M device communicates with IDAS设置 LWM2M 设备与 IDAS 通信
【发布时间】:2018-09-14 10:53:24
【问题描述】:

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

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

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

【问题讨论】:

    标签: fiware lwm2m


    【解决方案1】:

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

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

    【讨论】:

    • 嗨@German Molina,不确定您的基础设施如何帮助我,但这是手头的场景。我希望 lwm2m 客户端向 fiware iot 代理注册,(稍后,客户端应该向 iot 代理发送更新)。然后从 orion 获取上下文更新信息。
    【解决方案2】:

    之前阅读过您的 cmets,我了解到您想要构建一个场景,以便将您的传感器连接到 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"
           }
       ]
    }
    

    【讨论】:

    • 我已完成上述所有步骤,一切顺利。我的场景是:在我的 dataCollectionUnit(系统)上有一个代理,它从传感器收集数据并存储在 sqliteDB 中。现在我在同一系统上部署了 lwm2m 客户端(wakaama),我想收集 sensorData 并转发到 IDAS(在远程服务器上)以最终交付给 OrionCB。 LWM2M 客户端向 IDAS 注册自身(自动,可以从服务器日志中确认)(运行客户端 -4 -h {serverIP} -p {PORT} 之后。如何让 LWM2M 客户端将数据发送到 Orion?它是自动的(它注册的方式)或者我需要做一些配置。
    • 对于你的问题,你做了 step5 & step6 吗?
    • 嗨费尔南多,是的,我确实做到了。
    • 太好了,你自己回复!从 cmets 之前的步骤开始,(步骤 5)它将数据发送到 Orion。在第 6 步中,您可以得到 Orion 的响应。
    • 哦,谢谢您的反馈。不过上面的Node.js有什么用,这里好像没用过。
    猜你喜欢
    • 2012-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 2011-12-08
    • 2018-02-17
    相关资源
    最近更新 更多