使用具有HTTP传输协议的IoT代理JSON

时间:2017-02-21 17:52:14

标签: fiware

我想将IoT Agent JSON(https://github.com/telefonicaid/iotagent-json)与HTTP传输协议而不是MQTT一起使用。可能吗?我该怎么办?

谢谢!

2 个答案:

答案 0 :(得分:0)

是的,你很喜欢它,只需按照新的github README secion来解释HTTP传输选项。

干杯,

答案 1 :(得分:0)

您只需要为所有设备提供一个重复/模板。此类配置必须指定协议为IoTA-JSON且传输为HTTP。请求将发送到Json IoT代理的nothbound接口:

POST http://iota_host:iota_port/iot/services
Fiware-Service: <service>
Fiware-ServicePath: <subservice>

{
   "services": [
      {
         "entity_type": "<default_entity_type>",
         "protocol": "IoTA-JSON",
         "transport": "HTTP",
         "apikey": "<api_key>",
         "attributes": [ "<common_active_attrs_if_any>" ],
         "lazy": [ <common_lazy_attrs_if_any> ],
         "commands": [ <common_commands_if_any> ],
         "static_attributes": [ <common_static_attrs_if_any> ]
      }
   ]
}

之后,您将能够使用Http传输配置基于Json的设备:

POST http://iota_host:iota_port/iot/devices
Fiware-Service: <service>
Fiware-ServicePath: <subservice>

{
   "devices": [
      {
         "device_id": "<device_id>",
         "entity_name": "<entity_name>",
         "entity_type": "<alternative_entity_type>",
         "attributes": [ <additional_active_attrs_if_any> ],
         "lazy": [ <additional_lazy_attrs_if_any> ],
         "commands": [ <additional_commands_if_any> ],
         "static_attributes": [ <additional_static_attrs_if_any> ]
      }
   ]
}

甚至,您可以在不指定传输的情况下创建配置/模板,即配置/模板将仅与所有基于Json的代理相关,而与其传输无关,然后在配置基于Json的设备时,指定运输。