Commit 84acb663 authored by KangMin An's avatar KangMin An
Browse files

Update: Data Input Process.

parent 656540dc
......@@ -8,8 +8,7 @@
2. String SSPW
3. String EUEIP
4. int EUEPORT
5. String ID
6. String locCode
5. String Email
## PC에 연결하여 동작 (시리얼 모니터 사용 O)
......@@ -149,9 +148,13 @@ void loop() {
String date = ""; // 전송 시점 데이터
date += String(tmYearToCalendar(tm.Year));
date += "-";
date += tm.Month < 10 ? '0' + String(tm.Month) : String(tm.Month);
date += "-";
date += tm.Day < 10 ? '0' + String(tm.Day) : String(tm.Day);
date += " ";
date += tm.Hour < 10 ? '0' + String(tm.Hour): String(tm.Hour);
date += ":"
date += tm.Minute < 10 ? '0' + String(tm.Minute) : String(tm.Minute);
sensors_event_t event; // dht 모듈의 데이터 수집
......@@ -171,12 +174,10 @@ void loop() {
String str_Lights = isnan(lights) != 0 ? "none" : String(lights);
String type_ = "In";
String ID = "eue_tester1";
String locCode = "3124053";
String Email = "eue_tester@example.com";
input += "type=" + type_;
input += "&id=" + ID;
input += "&locCode=" + locCode;
input += "&email=" + Email;
input += "&date=" + date;
input += "&temp=" + str_Temp;
input += "&humi=" + str_Humi;
......@@ -233,7 +234,7 @@ void sendData(String input){
}
// Get 방식을 이용한 전송
String msg = "GET /data/input?";
String msg = "GET /api/data/input?";
msg += input;
msg += " HTTP/1.0\r\n\r\n";
......
......@@ -102,9 +102,13 @@ void loop() {
String date = ""; // 전송 시점 데이터
date += String(tmYearToCalendar(tm.Year));
date += "-";
date += tm.Month < 10 ? '0' + String(tm.Month) : String(tm.Month);
date += "-";
date += tm.Day < 10 ? '0' + String(tm.Day) : String(tm.Day);
date += " ";
date += tm.Hour < 10 ? '0' + String(tm.Hour): String(tm.Hour);
date += ":"
date += tm.Minute < 10 ? '0' + String(tm.Minute) : String(tm.Minute);
String type_ = "Out";
......@@ -171,7 +175,7 @@ void sendData(String input){
}
// Get 방식을 이용한 전송
String msg = "GET /data/input?";
String msg = "GET /api/data/input?";
msg += input;
msg += " HTTP/1.0\r\n\r\n";
......
......@@ -36,7 +36,7 @@ const handleOutData = async (locCode, date, lat, lng) => {
// 내부 수집기로 부터 들어온 정보 처리
const handleInData = async (email, date, temp, humi, lights) => {
db.Weather_in.create(
await db.Weather_in.create(
{
host: email,
collected_at: date,
......@@ -59,16 +59,28 @@ export const getDataInput = (req, res) => {
query: { locCode, date, lat, lng },
} = req;
console.log(locCode, date, lat, lng);
handleOutData(locCode, date, lat, lng);
const trans_date = new Date(date);
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 {
// 내부 데이터 수집기 동작
const {
query: { id, date, temp, humi, lights },
query: { email, date, temp, humi, lights },
} = req;
console.log(id, date, temp, humi, lights);
handleInData(id, date, temp, humi, lights);
const trans_date = new Date(date);
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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment