首页 文章

如何在thingsboard iot-gateway中导入原始(不是json格式)mqtt值?

提问于
浏览
0

我在文档和留言板中搜索过,但无法找到以下内容 .

我正在尝试使用IOT网关将数据从mqtt导入到thingboard中 .

该文档概述了如何配置IOT网关以导入json格式的数据 .

{
  "topicFilter": "sensors",
  "converter": {
    "type": "json",
    "filterExpression": "",
    "deviceNameJsonExpression": "${$.serialNumber}",
    "attributes": [
      {
        "type": "string",
        "key": "model",
        "value": "${$.model}"
      }
    ],
    "timeseries": [
      {
        "type": "double",
        "key": "temperature",
        "value": "${$.temperature}"
      }
    ]
  }
}

来自(https://thingsboard.io/docs/iot-gateway/getting-started/#step-81-basic-mapping-example) .

然后该映射用于导入如下发布的数据: mosquitto_pub -h localhost -p 1883 -t "sensors" -m '{"serialNumber":"SN-001", "model":"T1000", "temperature":36.6}'

我希望也可以导入原始数据,即没有json格式,因为我已经有许多数据主题与原始数据有效负载 . 所以,只是原始的ascii编码值 . 所以,像这样: mosquitto_pub -h localhost -p 1883 -t "sensors/livingroom/temperature" -m '36.6'

IOT网关是否可以,如果是这样,配置会是什么样的?

1 回答

  • 0

    这是可能的,但您需要实现新的转换器类型 . 我们拥有的是使用JSON . 您可以实现自己的接受二进制数据的转换器 . 因此,您的配置看起来与此类似:

    {
      "topicFilter": "sensors",
      "converter": {
        "type": "binary",
        /* whatever configuration structure that is applicable to your use case */
      }
    }
    

相关问题