thingsboard安装及配置
thingsboard使⽤了
actor模型:akka
⽤作服务调度:zookeeper
远程调⽤:gRPC,thrift
2:sudo rpm -Uvh thingsboard-1.3.rpm,报错:java-1.8.0 is needed by thingsboard-0:1.arch。猜测跟jdk的某些配置有关sudo alternatives --config java
sudo alternatives --install /usr/bin/java java /usr/jdk1.8.0_60/bin/java 1,错误继续.删除配置
sudo alternatives --remove java /usr/jdk1.8.0_60/bin/java
下载rpm版的jdk安装⽂件(jdk-8u144-linux-x64.rpm)。
sudo rpm -Uvh jdk-8u144-linux-x64.rpm.sudo rpm -Uvh thingsboard-1.3.rpm执⾏成功
使⽤postgres数据库
# Install packages
sudo yum install postgresql-server postgresql-contrib
# Initialize your PostgreSQL DB
sudo postgresql-setup initdb
sudo systemctl start postgresql
# Optional: Configure PostgreSQL to start on boot
sudo systemctl enable postgresql
修改/var/lib/pgsql/f
listen_addresses = '*'
修改f
host    all            all            /32        md5。允许某个ip地址登录
host    all            all            127.0.0.1/32            trust.允许本机其他⽤户名登录
修改postgres密码.
修改l为postgres连接.注释掉默认数据库,放开postgres
启动postgres。systemctl start postgresql
sudo /usr/share/thingsboard/bin/install/install.sh --loadDemo
sudo systemctl start thingsboard.service.
git checkout release-1.3
mvn clean package
视个⼈情况安装nodejs,Mosquitto-client,curl。
npm install coap-cli -g
npm install mqtt -g
创建po源
[home_oojah_mqtt]
name=mqtt (CentOS_CentOS-7)
type=rpm-md
baseurl=/repositories/home:/oojah:/mqtt/CentOS_CentOS-7/
gpgcheck=1
gpgkey=/repositories/home:/oojah:/mqtt/CentOS_CentOS-7//l.key
enabled=1
yum search all mosquitto
==== Matched: mosquitto ================================================================ mosquitto-client
s.x86_64 : Mosquitto command line publish/subscribe clients
mosquitto-debuginfo.x86_64 : Debug information for package mosquitto
libmosquitto-devel.x86_64 : MQTT C client library development files
libmosquitto1.x86_64 : MQTT C client library
libmosquittopp-devel.x86_64 : MQTT C++ client library development files
libmosquittopp1.x86_64 : MQTT C++ client library
mosquitto.x86_64 : MQTT version 3.1/3.1.1 compatible message broker
yum install mosquitto-clients
mqtt.js/publish.js:模拟mqtt
#!/bin/sh
# Set ThingsBoard host to "demo.thingsboard.io" or "localhost"
export THINGSBOARD_HOST=demo.thingsboard.io
# Replace YOUR_ACCESS_TOKEN with one from Device credentials window.
export ACCESS_TOKEN=YOUR_ACCESS_TOKEN
# Read serial number and firmware version attributes
ATTRIBUTES=$( 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 client
node publish.js
var mqtt = require('mqtt');
console.log('Connecting to: %s using access token: %s', v.THINGSBOARD_HOST, v.ACCESS_TOKEN);
var client  = t('mqtt://'+ v.THINGSBOARD_HOST,{
username: v.ACCESS_TOKEN
});
<('connect', function () {
console.log('Client connected!');
client.publish('v1/devices/me/attributes', v.ATTRIBUTES);
console.log('Attributes published!');
client.publish('v1/devices/me/telemetry', v.TELEMETRY);
thriftconsole.log('Telemetry published!');
});
Mosquitto-client:模拟mqtt
#!/bin/sh
# Set ThingsBoard host to "demo.thingsboard.io" or "localhost"
THINGSBOARD_HOST="demo.thingsboard.io"
# Replace YOUR_ACCESS_TOKEN with one from Device credentials window.
ACCESS_TOKEN="YOUR_ACCESS_TOKEN"
# Publish serial number and firmware version attributes
mosquitto_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"
coap.js:模拟coap
# Publish serial number and firmware version attributes
cat 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
curl:模拟curl
# 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 $THINGSBOARD_HOST:$THINGSBOARD_PORT/api/v1/$ACCESS_TOKEN/attributes --header "Content-Type:ap # 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 $THINGSBOARD_HOST:$THINGSBOARD_PORT/api/v1/$ACCESS_TOKEN/telemetry --header "Content-Type:ap
模拟数据
attributes-data.json:
{"firmware_version":"1.0.1", "serial_number":"SN-001"}
telemetry-data.json
{"temperature":21, "humidity":55.0, "active": false}
export THINGSBOARD_x.xxx export ACCESS_TOKEN=xxxxxxx
export THINGSBOARD_PORT=xxxx
执⾏./coap-js.sh
或者./curl.sh
或者./mqtt-js.sh
或者./mosquitto.sh
在dashboard上可以看到刚才设备发送的消息及时间

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。