Crates.io | iot_center |
lib.rs | iot_center |
version | 0.0.1 |
source | src |
created_at | 2018-06-28 02:28:22.935931 |
updated_at | 2018-06-28 02:28:22.935931 |
description | simple iot center to receive from mqtt and save to sqlite |
homepage | |
repository | https://github.com/babydragon/iot_center |
max_upload_size | |
id | 72036 |
size | 11,056 |
通过订阅mqtt topic,将数据写入数据库。目前仅支持sqlite。mqtt数据体:
{
"device_id": "DEVICE_ID",
"message_type": "TYPE",
"timestamp": 1529907482,
"data": {
"key": "value"
}
}
其中timestamp是消息时间戳,既UNIX时间戳;data字段包含每种类型自定义数据,以json格式直接存入sqlite的text字段。 读取时可以通过sqlite的json函数进行解析。
数据库结构:
CREATE TABLE IF NOT EXISTS iot_data(
id INTEGER PRIMARY KEY AUTOINCREMENT,
device TEXT NOT NULL,
type TEXT NOT NULL,
time INTEGER NOT NULL,
data TEXT NOT NULL
)
(待续。。。)