Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박권수
2021-05-11 04:15:23 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7b4b4e11a6473c4291a122b6c995e67177b83f3f
7b4b4e11
1 parent
f9d89e15
feat. medicine disconnect logic add
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
3 deletions
server/src/api/bottle/bottle.ctrl.js
server/src/api/bottle/index.js
server/src/api/bottle/bottle.ctrl.js
View file @
7b4b4e1
...
...
@@ -5,9 +5,9 @@ const Medicine = require('../../models/medicine');
const
DataProcess
=
require
(
'../../lib/DataProcess'
);
const
Mqtt
=
require
(
'../../lib/MqttModule'
);
exports
.
bottle
Register
=
async
(
ctx
)
=>
{
exports
.
bottle
Connect
=
async
(
ctx
)
=>
{
const
{
bottleId
,
hubId
}
=
ctx
.
request
.
body
;
const
topic
=
'bottle/'
+
String
(
bottleId
)
+
'/bts'
;
const
topic
=
'bottle/'
+
bottleId
+
'/bts'
;
const
newBottle
=
new
Bottle
({
bottleId
,
...
...
@@ -37,6 +37,7 @@ exports.bottleRegister = async(ctx) => {
port
:
hosting
.
port
,
clientId
:
hosting
.
clientId
});
Mqtt
.
mqttSubscribe
(
client
,
topic
,
DataProcess
.
dataPublish
);
await
newBottle
.
save
();
...
...
@@ -44,6 +45,10 @@ exports.bottleRegister = async(ctx) => {
ctx
.
status
=
200
;
};
exports
.
bottleDisconnect
=
async
(
ctx
)
=>
{
const
{
bottleId
}
=
ctx
.
params
;
};
exports
.
lookupInfo
=
async
(
ctx
)
=>
{
const
{
bottleId
}
=
ctx
.
params
;
...
...
@@ -53,6 +58,7 @@ exports.lookupInfo = async(ctx) => {
return
;
}
ctx
.
status
=
200
;
ctx
.
body
=
bottle
;
}
...
...
server/src/api/bottle/index.js
View file @
7b4b4e1
...
...
@@ -3,7 +3,8 @@ const bottleCtrl = require('./bottle.ctrl');
const
bottle
=
new
Router
();
bottle
.
post
(
'/register'
,
bottleCtrl
.
bottleRegister
);
bottle
.
post
(
'/connect'
,
bottleCtrl
.
bottleConnect
);
bottle
.
post
(
'/disconnect/:bottleId'
,
bottleCtrl
.
bottleDisconnect
);
bottle
.
post
(
'/lookupInfo/:bottleId'
,
bottleCtrl
.
lookupInfo
);
bottle
.
post
(
'/setmedicine/:bottleId'
,
bottleCtrl
.
setMedicine
);
...
...
Please
register
or
login
to post a comment