Skip to content

Commit

Permalink
최종
Browse files Browse the repository at this point in the history
  • Loading branch information
annkwon1123 committed Jun 2, 2024
1 parent 735a684 commit 590a947
Show file tree
Hide file tree
Showing 4 changed files with 2,331 additions and 2,305 deletions.
2 changes: 1 addition & 1 deletion src/pages/api/data_result.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default async function handler(req, res) {
} else if (req.method === 'POST') {

// POST 요청: 클라이언트로부터 받은 목표온도 정보를 데이터베이스에 추가
const { level, area, temp_goal, date } = req.body;
const { level, area, temp_goal, cur_date, goal_date } = req.body;
await axios.post('http://localhost:8089/api/data_result',
{
level: level,
Expand Down
17 changes: 6 additions & 11 deletions src/pages/api/sensing.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,15 @@ import axios from 'axios';
export default async function handler(req, res) {
try {

if (req.method === 'GET') {
// GET 요청: 센서 데이터를 조회하여 클라이언트에 응답
const response = await axios.get('http://localhost:8089/api/sensing');
const sensing_t = response.data;
res.status(200).json({ sensing_t });
} else if (req.method === 'POST') {
if (req.method === 'POST') {
// POST 요청: 클라이언트로부터 받은 센서 정보를 데이터베이스에 추가
const { sensor_mac, sensor_temp, sensor_humi, sensor_time } = req.body;
const { sensing_mac, sensing_temp, sensing_humi, sensing_time } = req.body;
await axios.post('http://localhost:8089/api/sensing',
{
sensor_mac: sensor_mac,
sensor_temp: sensor_temp,
sensor_humi: sensor_humi,
sensor_time: sensor_time,
sensing_mac: sensing_mac,
sensing_temp: sensing_temp,
sensing_humi: sensing_humi,
sensing_time: sensing_time,
});
console.log('데이터가 성공적으로 전송되었습니다.');
} else {
Expand Down
3 changes: 1 addition & 2 deletions src/pages/mornitoring/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,7 @@ return updatedLevels;
const calculateAverage = () => {
if (batteryLevels.length === 0) return 0;
const total = batteryLevels.reduce((sum, level) => sum + level.level, 0);

return total / batteryLevels.length;
return total / batteryLevels.length;
};

// 4. 센싱 값 평균 전송 하기
Expand Down
Loading

0 comments on commit 590a947

Please sign in to comment.