Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
eue
Commits
84acb663
Commit
84acb663
authored
Jul 26, 2021
by
KangMin An
Browse files
Update: Data Input Process.
parent
656540dc
Changes
3
Show whitespace changes
Inline
Side-by-side
arduino/code/main_inside/main_inside.ino
View file @
84acb663
...
@@ -8,8 +8,7 @@
...
@@ -8,8 +8,7 @@
2. String SSPW
2. String SSPW
3. String EUEIP
3. String EUEIP
4. int EUEPORT
4. int EUEPORT
5. String ID
5. String Email
6. String locCode
## PC에 연결하여 동작 (시리얼 모니터 사용 O)
## PC에 연결하여 동작 (시리얼 모니터 사용 O)
...
@@ -149,9 +148,13 @@ void loop() {
...
@@ -149,9 +148,13 @@ void loop() {
String
date
=
""
;
// 전송 시점 데이터
String
date
=
""
;
// 전송 시점 데이터
date
+=
String
(
tmYearToCalendar
(
tm
.
Year
));
date
+=
String
(
tmYearToCalendar
(
tm
.
Year
));
date
+=
"-"
;
date
+=
tm
.
Month
<
10
?
'0'
+
String
(
tm
.
Month
)
:
String
(
tm
.
Month
);
date
+=
tm
.
Month
<
10
?
'0'
+
String
(
tm
.
Month
)
:
String
(
tm
.
Month
);
date
+=
"-"
;
date
+=
tm
.
Day
<
10
?
'0'
+
String
(
tm
.
Day
)
:
String
(
tm
.
Day
);
date
+=
tm
.
Day
<
10
?
'0'
+
String
(
tm
.
Day
)
:
String
(
tm
.
Day
);
date
+=
" "
;
date
+=
tm
.
Hour
<
10
?
'0'
+
String
(
tm
.
Hour
)
:
String
(
tm
.
Hour
);
date
+=
tm
.
Hour
<
10
?
'0'
+
String
(
tm
.
Hour
)
:
String
(
tm
.
Hour
);
date
+=
":"
date
+=
tm
.
Minute
<
10
?
'0'
+
String
(
tm
.
Minute
)
:
String
(
tm
.
Minute
);
date
+=
tm
.
Minute
<
10
?
'0'
+
String
(
tm
.
Minute
)
:
String
(
tm
.
Minute
);
sensors_event_t
event
;
// dht 모듈의 데이터 수집
sensors_event_t
event
;
// dht 모듈의 데이터 수집
...
@@ -171,12 +174,10 @@ void loop() {
...
@@ -171,12 +174,10 @@ void loop() {
String
str_Lights
=
isnan
(
lights
)
!=
0
?
"none"
:
String
(
lights
);
String
str_Lights
=
isnan
(
lights
)
!=
0
?
"none"
:
String
(
lights
);
String
type_
=
"In"
;
String
type_
=
"In"
;
String
ID
=
"eue_tester1"
;
String
Email
=
"eue_tester@example.com"
;
String
locCode
=
"3124053"
;
input
+=
"type="
+
type_
;
input
+=
"type="
+
type_
;
input
+=
"&id="
+
ID
;
input
+=
"&email="
+
Email
;
input
+=
"&locCode="
+
locCode
;
input
+=
"&date="
+
date
;
input
+=
"&date="
+
date
;
input
+=
"&temp="
+
str_Temp
;
input
+=
"&temp="
+
str_Temp
;
input
+=
"&humi="
+
str_Humi
;
input
+=
"&humi="
+
str_Humi
;
...
@@ -233,7 +234,7 @@ void sendData(String input){
...
@@ -233,7 +234,7 @@ void sendData(String input){
}
}
// Get 방식을 이용한 전송
// Get 방식을 이용한 전송
String
msg
=
"GET /data/input?"
;
String
msg
=
"GET
/api
/data/input?"
;
msg
+=
input
;
msg
+=
input
;
msg
+=
" HTTP/1.0
\r\n\r\n
"
;
msg
+=
" HTTP/1.0
\r\n\r\n
"
;
...
...
arduino/code/main_outside/main_outside.ino
View file @
84acb663
...
@@ -102,9 +102,13 @@ void loop() {
...
@@ -102,9 +102,13 @@ void loop() {
String
date
=
""
;
// 전송 시점 데이터
String
date
=
""
;
// 전송 시점 데이터
date
+=
String
(
tmYearToCalendar
(
tm
.
Year
));
date
+=
String
(
tmYearToCalendar
(
tm
.
Year
));
date
+=
"-"
;
date
+=
tm
.
Month
<
10
?
'0'
+
String
(
tm
.
Month
)
:
String
(
tm
.
Month
);
date
+=
tm
.
Month
<
10
?
'0'
+
String
(
tm
.
Month
)
:
String
(
tm
.
Month
);
date
+=
"-"
;
date
+=
tm
.
Day
<
10
?
'0'
+
String
(
tm
.
Day
)
:
String
(
tm
.
Day
);
date
+=
tm
.
Day
<
10
?
'0'
+
String
(
tm
.
Day
)
:
String
(
tm
.
Day
);
date
+=
" "
;
date
+=
tm
.
Hour
<
10
?
'0'
+
String
(
tm
.
Hour
)
:
String
(
tm
.
Hour
);
date
+=
tm
.
Hour
<
10
?
'0'
+
String
(
tm
.
Hour
)
:
String
(
tm
.
Hour
);
date
+=
":"
date
+=
tm
.
Minute
<
10
?
'0'
+
String
(
tm
.
Minute
)
:
String
(
tm
.
Minute
);
date
+=
tm
.
Minute
<
10
?
'0'
+
String
(
tm
.
Minute
)
:
String
(
tm
.
Minute
);
String
type_
=
"Out"
;
String
type_
=
"Out"
;
...
@@ -171,7 +175,7 @@ void sendData(String input){
...
@@ -171,7 +175,7 @@ void sendData(String input){
}
}
// Get 방식을 이용한 전송
// Get 방식을 이용한 전송
String
msg
=
"GET /data/input?"
;
String
msg
=
"GET
/api
/data/input?"
;
msg
+=
input
;
msg
+=
input
;
msg
+=
" HTTP/1.0
\r\n\r\n
"
;
msg
+=
" HTTP/1.0
\r\n\r\n
"
;
...
...
server/src/controllers/dataController.js
View file @
84acb663
...
@@ -36,7 +36,7 @@ const handleOutData = async (locCode, date, lat, lng) => {
...
@@ -36,7 +36,7 @@ const handleOutData = async (locCode, date, lat, lng) => {
// 내부 수집기로 부터 들어온 정보 처리
// 내부 수집기로 부터 들어온 정보 처리
const
handleInData
=
async
(
email
,
date
,
temp
,
humi
,
lights
)
=>
{
const
handleInData
=
async
(
email
,
date
,
temp
,
humi
,
lights
)
=>
{
db
.
Weather_in
.
create
(
await
db
.
Weather_in
.
create
(
{
{
host
:
email
,
host
:
email
,
collected_at
:
date
,
collected_at
:
date
,
...
@@ -59,16 +59,28 @@ export const getDataInput = (req, res) => {
...
@@ -59,16 +59,28 @@ export const getDataInput = (req, res) => {
query
:
{
locCode
,
date
,
lat
,
lng
},
query
:
{
locCode
,
date
,
lat
,
lng
},
}
=
req
;
}
=
req
;
console
.
log
(
locCode
,
date
,
lat
,
lng
);
const
trans_date
=
new
Date
(
date
);
handleOutData
(
locCode
,
date
,
lat
,
lng
);
console
.
log
(
`Outside[
${
locCode
}
] Data(date:
${
trans_date
}
/ lat:
${
lat
}
/ lng:
${
lng
}
) Input.`
);
handleOutData
(
locCode
,
trans_date
,
lat
,
lng
);
res
.
status
(
statusCode
.
ok
).
send
({
msg
:
serverMSG
.
server_ok
,
content
:
`Outside[
${
locCode
}
] data Input.`
,
});
}
else
{
}
else
{
// 내부 데이터 수집기 동작
// 내부 데이터 수집기 동작
const
{
const
{
query
:
{
id
,
date
,
temp
,
humi
,
lights
},
query
:
{
email
,
date
,
temp
,
humi
,
lights
},
}
=
req
;
}
=
req
;
console
.
log
(
id
,
date
,
temp
,
humi
,
lights
);
const
trans_date
=
new
Date
(
date
);
handleInData
(
id
,
date
,
temp
,
humi
,
lights
);
console
.
log
(
`User[
${
email
}
] Data(date:
${
trans_date
}
/ temp:
${
temp
}
/ humi:
${
humi
}
/ lights:
${
lights
}
) Input.`
);
handleInData
(
email
,
trans_date
,
temp
,
humi
,
lights
);
}
}
res
.
status
(
statusCode
.
ok
).
send
(
serverMSG
.
server_ok
);
res
.
status
(
statusCode
.
ok
).
send
(
serverMSG
.
server_ok
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment