ThingsBoard Mac Docker 模拟传递设备数据

    技术2022-07-11  92

    描述该指导文档的场景,比如“员工首次配置打印机”。

    安装

    https://blog.csdn.net/qq_36515349/article/details/107064006

    传递设备数据

    将使用来自本地PC的MQTT、CoAP或HTTP协议来传递数据

    安装brew

    官方步骤

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

    出现问题:

    Failed to connect to raw.githubusercontent.com port 443: Connection refused

    解决方案:

    用浏览器打开

    保存到本地为install.sh,cd到下载目录,并更改权限:

    chmod 777 install.sh

    把install.sh拖入终端,或者在终端直接执行

    install.sh

    输出:

    ==> This script will install: /usr/local/bin/brew /usr/local/share/doc/homebrew /usr/local/share/man/man1/brew.1 /usr/local/share/zsh/site-functions/_brew /usr/local/etc/bash_completion.d/brew /usr/local/Homebrew ...

    出现问题:

    error: RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54 fatal: the remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed Error: Failure while executing; `git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core` exited with 128. Error: Failure while executing; `/usr/local/bin/brew tap homebrew/core` exited with 1.

    解决方案:

    执行如下命令:

    git clone https://github.com/Homebrew/homebrew-core /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core --depth=1

    clone结束后再重新执行:

    install.sh

    安装MQTT

    执行如下命令:

    brew install mosquitto

    创建测试数据

    创建一个文件夹存放需要的数据文件如下:

    attributes-data.json - 包含两个设备属性值:固件版本和序列号。 {"firmware_version":"1.0.1", "serial_number":"SN-001"} telemetry-data.json - 包含三个时间序列值:temperature, humidity and active flag。 {"firmware_version":"1.0.1", "serial_number":"SN-001"}

    下载mosquitto.sh创建的文件夹中,并更改权限

    chmod +x mosquitto.sh

    打开mosquitto.sh并更改内容

    # Set ThingsBoard host to "demo.thingsboard.io" or "localhost" THINGSBOARD_HOST=localhost # Replace YOUR_ACCESS_TOKEN with one from Device details panel. ACCESS_TOKEN=A1_TEST_TOKEN

    ACCESS_TOKEN的值来自于设备中某一设备的设备凭据

    在Web界面观察数据

    Processed: 0.013, SQL: 9