博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
开源的物联网技术平台thingsboard安装测试及使用步骤
阅读量:6228 次
发布时间:2019-06-21

本文共 4394 字,大约阅读时间需要 14 分钟。

hot3.png

1.安装Java1.8

2.安装Maven

3.安装node js

4.安装git

5.安装npm依赖 以管理员权限运行cmd,然后分别执行如下命令:

npm install -g cross-envnpm install -g webpack

6.安装IDEA

7.安装postgreSQL数据库

下载地址:

Postgresql数据库安装过程,请将用户postgres的密码设置成 postgres。方便后续操作。

Postgresql数据库安装完成后,创建数据库thingsboard,所有者为postgres,然后用数据库工具(我用的是Navicat Premium 12)分别运行D:\thingsboard-develop-1.5\dao\src\main\resources\sql目录下schema-entities.sql、schema-ts.sql、 system-data.sql

8.下载源码

9.编译源码

mvn clean install -DskipTests

如下则代表编译成功:

如果一次不成功则多试几次。

10.导入IDEA,运行 ThingsboardServerApplication

需要安装的插件:IntelliJ Lombok plugin, Protobuf Support

 

11.API测试工具安装及需要的测试文件 (win10下Ubuntu)

ubuntu:win10应用商店 Ubuntu 18.04 LTS

测试coap协议:安装

sudo npm install coap-cli -g

测试脚本:

# Set ThingsBoard host to "demo.thingsboard.io" or "localhost"THINGSBOARD_HOST="localhost"# Replace YOUR_ACCESS_TOKEN with one from Device details panel.ACCESS_TOKEN="i5OqJGOWWV6vWku8v25B"# Publish serial number and firmware version attributescat attributes-data.json | coap post coap://$THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/attributes# Publish timeseries data as an object without timestamp (server-side timestamp will be used)cat telemetry-data.json | coap post coap://$THINGSBOARD_HOST/api/v1/$ACCESS_TOKEN/telemetry

测试http协议:安装cURL

sudo apt-get updatesudo apt install curl

测试脚本:

# Set ThingsBoard host to "demo.thingsboard.io" or "localhost"THINGSBOARD_HOST="localhost"# Set ThingsBoard port to 80 or 8080THINGSBOARD_PORT=8080# Replace YOUR_ACCESS_TOKEN with one from Device details panel.ACCESS_TOKEN="i5OqJGOWWV6vWku8v25B"# Publish serial number and firmware version attributes# replace $THINGSBOARD_PORT with 8080 (in case of local installation) or 80 (in case of live-demo).curl -v -X POST -d @attributes-data.json http://$THINGSBOARD_HOST:$THINGSBOARD_PORT/api/v1/$ACCESS_TOKEN/attributes --header "Content-Type:application/json"# Publish timeseries data as an object without timestamp (server-side timestamp will be used)# replace $THINGSBOARD_PORT with 8080 (in case of local installation) or 80 (in case of live-demo).curl -v -X POST -d @telemetry-data.json http://$THINGSBOARD_HOST:$THINGSBOARD_PORT/api/v1/$ACCESS_TOKEN/telemetry --header "Content-Type:application/json"

测试mqtt协议:安装

npm install mqtt -g

测试脚本:mqtt-js.sh

#!/bin/sh# Set ThingsBoard host to "demo.thingsboard.io" or "localhost"export THINGSBOARD_HOST="localhost"# Replace YOUR_ACCESS_TOKEN with one from Device details panel.export ACCESS_TOKEN="i5OqJGOWWV6vWku8v25B"# Read serial number and firmware version attributesATTRIBUTES=$( cat attributes-data.json )export ATTRIBUTES# Read timeseries data as an object without timestamp (server-side timestamp will be used)TELEMETRY=$( cat telemetry-data.json )export TELEMETRY# publish attributes and telemetry data via mqtt clientnode publish.js

测试mqtt协议:安装

测试脚本:mosquitto.sh

resources/mosquitto.shCopy resources/mosquitto.sh to clipboard#!/bin/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="i5OqJGOWWV6vWku8v25B"# Publish serial number and firmware version attributesmosquitto_pub -d -h "$THINGSBOARD_HOST" -t "v1/devices/me/attributes" -u "$ACCESS_TOKEN" -f "attributes-data.json"# Publish timeseries data as an object without timestamp (server-side timestamp will be used)mosquitto_pub -d -h "$THINGSBOARD_HOST" -t "v1/devices/me/telemetry" -u "$ACCESS_TOKEN" -f "telemetry-data.json"

测试脚本:attributes-data.json

{"firmware_version":"1.0.1", "serial_number":"SN-001"}

测试脚本:telemetry-data.json

{"temperature":21, "humidity":55.0, "active": false}

测试脚本:publish.js

var mqtt = require('mqtt');console.log('Connecting to: %s using access token: %s', process.env.THINGSBOARD_HOST, process.env.ACCESS_TOKEN);var client  = mqtt.connect('mqtt://'+ process.env.THINGSBOARD_HOST,{    username: process.env.ACCESS_TOKEN});client.on('connect', function () {    console.log('Client connected!');    client.publish('v1/devices/me/attributes', process.env.ATTRIBUTES);    console.log('Attributes published!');    client.publish('v1/devices/me/telemetry', process.env.TELEMETRY);    console.log('Telemetry published!');    client.end();});

测试方法:

1.运行ubuntu terminal

2.新建thingsboads文件夹

mkdir thingsboard

3.将上述测试脚本添加到thingsboard文件加下

4.配置.sh文件可执行权限

chmod +x *.sh

5.执行测试,比如测试coap协议上传

./coap-js.sh

返回成功标识 如下:

服务器接收到消息:

详细测试步骤,请参见官方文档:

12.官方文档

 

转载于:https://my.oschina.net/zhenggao/blog/3002230

你可能感兴趣的文章
iPhone应用程序 将图片保存到相册实例
查看>>
给DropDownList添加ToolTip(title)属性
查看>>
IOS新特性详情
查看>>
redis性能测试
查看>>
浅谈mysql的两阶段提交协议
查看>>
《影响力》 一个活生生的例子(转载)
查看>>
程序员有趣的面试智力题(转)
查看>>
分布式监控系统Zabbix-3.0.3-完整安装记录(2)-添加mysql监控
查看>>
phpstorm中完成一键快速注释函数头
查看>>
VMware公司SpringSource部门宣布收购Gemstone Systems公司
查看>>
Linux Start Restart and Stop The Cron or Crond Service
查看>>
2014第12周四开发记
查看>>
[转]Spring MVC之@RequestMapping 详解
查看>>
HttpComponents入门解析
查看>>
nullnull精美的文言文表白,一起体会吧!
查看>>
【ASP.NET】asp,c#命名规则参考
查看>>
jsp小商城
查看>>
推荐12个优秀的 HTML5 网站设计案例欣赏
查看>>
三种主流的WebService实现方案(REST/SOAP/XML-RPC)简述及比较
查看>>
MVPArms MVP快速集成框架
查看>>