Skip to content

Latest commit

 

History

145 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IOT Server Project

Pre Config

Use Docker

git clone https://github.com/Diam2023/IOTServer
cd docker 
docker compose run *
# use -d if need
# docker compose stop

Manual Install

Request

  • MySQL (MariaDB)
  • Redis
  • yaml-cpp

Yaml-Cpp

Arch

yay -S yaml-cpp

Debian

sudo apt install libyaml-cpp-dev

Install QtMqtt

https://github.com/KurtPattyn/QtMqtt

Arch

yay -S qt5-mqtt

Debian

git clone -b 5.12.3 git://code.qt.io/qt/qtmqtt.git qtmqtt

cd qtmqtt

mkdir build

cd build

qmake ..

make

sudo make install

Install Drogon

https://github.com/drogonframework/drogon/wiki/ENG-02-Installation

Arch

yay -S drogon

Debian

git clone https://github.com/drogonframework/drogon

cd drogon

./build

Install Drogon

https://github.com/drogonframework/drogon/wiki/ENG-02-Installation

Arch

yay -S drogon

Debian

git clone https://github.com/drogonframework/drogon

cd drogon

./build

Community API

GoCQHttp

User Interface

All Command: config/config.yaml:240

Or send "help" to Bot

command action
登入{usr} {pwd} LoginAPI
登出 LogoutAPI
添加设备{name} {sn}
删除设备{name}
查看所有设备
订阅设备{name} {topic}
取消订阅{name} {topic}
查看所有订阅消息
查看所有设备别名
设备别名{name}
添加别名{name}
删除别名{name}

Custom Define Action

定义操作 {操作名} {设备名/别名} {subtopic} {JSON数据}

It will publish JSON data to device topic When call {操作名}

command announcement
定义操作{}
删除操作{操作名}

Http

root dir /api/

User Api

base dir user/

Path Request Type Request Body Header Status Response Body
register PUT
{  "user_name": "",  "user_password": ""}
NAN 200 Successful
500
login POST
{  "key": "name/id",  "pwd": "pwd" }
NAN 203 Need Authorize
200 Successful
401
{
"token": ""
}
info GET NAN Authorization: token 203 Need Authorize
200 Successful
401
400
{
"user_id": 2,
"user_name": "testUser10",
"user_password": "",
"user_permission_level": 100
}
logout DELETE NAN Authorization: token 200 Successful
500

Device Api

base dir device/

Path Request Type Request Body Header Status Response Body
new PUT
{  "device_sn": "DTESTSNDATA",  "device_name": "TD",  "device_comment": "TestComment",  "target_permission_level": 1}
Authorization: token 203 Need Authorize
200 Successful
400 Request Body Err
500
delete DELETE
{  "device_sn": "DTESTSNDATA"}
Authorization: token 203 Need Authorize
200 Successful
400 Request Body Err
500
info GET
{  "device_sn": "DTESTSNDATA"}
Authorization: token 203 Need Authorize
200 Successful
400 Request Body Err
500
{
"device_id": 2,
"device_name": "Name",
"device_sn": "",
"target_permission_level": 50
}
all GET NAN Authorization: token 203 Need Authorize
200 Successful
500
[{
"device_id": 2,
"device_name": "Name",
"device_sn": "",
"target_permission_level": 50
}]

Subscribe Api

base dir subscribe/

Path Request Type Request Body Header Status Response Body
new PUT
{  "device_sn": "TESESNDDT",  "topic": "TestTopic"}
Authorization: token 203 Need Authorize
200 Successful
400 Request Body Err
500
delete DELETE
{  "device_sn": "TESESNDDT",  "topic": "TestTopic"}
Authorization: token 203 Need Authorize
200 Successful
400 Request Body Err
500
all GET NAN Authorization: token 203 Need Authorize
200 Successful
500
{
"devices":[],
"aliases":[]
}

Alias Api

base dir alias/

Path Request Type Request Body Header Status Response Body
new PUT
{  "device_sn": "DTESTSNDATA",  "alias": "testAlias"}
Authorization: token 203 Need Authorize
200 Successful
400 Request Body Err
500
delete DELETE
{  "alias": "MyRoom"}
Authorization: token 203 Need Authorize
200 Successful
400 Request Body Err
500
all GET NAN Authorization: token 203 Need Authorize
200 Successful
500
{
"devices":[],
"aliases":[]
}

Action Api

base dir action/

Path Request Type Request Body Header Status Response Body
new PUT
{  "action_name": "TA1",  "device_sn": "TESESNDDT",  "topic_name": "testTopic1",  "action_json": {...}}
Authorization: token 203 Need Authorize
200 Successful
400 Request Body Err
500
delete DELETE
{  "action_name": "TA1"}
Authorization: token 203 Need Authorize
200 Successful
400 Request Body Err
500
all GET NAN Authorization: token 203 Need Authorize
200 Successful
500
{
"devices":[],
"aliases":[],
"actions":[]
}
call PUT
{  "action": "TA1"}
Authorization: token 203 Need Authorize
200 Successful
404
NAN

Gotify

數據庫

  • Mysql
  • Redis

Mqtt

  • mosquitto

About

一個適用於物聯網設備的通訊服務器

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages