1
0

Merge branch 'main' into feature/bmp280

This commit is contained in:
Jose
2025-04-28 10:51:31 +02:00
committed by GitHub
11 changed files with 62 additions and 72 deletions

View File

@@ -85,16 +85,6 @@ public class MainVerticle extends AbstractVerticle {
}
});
vertx.deployVerticle(new WebServerVerticle(), result -> {
if (result.succeeded()) {
Constants.LOGGER.info("🟢 WebServerVerticle desplegado");
Constants.LOGGER.info("\t🔗 WEB SERVER URL: " + configManager.getHost()
+ ":" + configManager.getWebserverPort());
} else {
Constants.LOGGER.error("🔴 Error deploying WebServerVerticle: " + result.cause());
}
});
startPromise.complete();
}

View File

@@ -1,50 +0,0 @@
package net.miarma.contaminus.server;
import java.nio.file.Path;
import java.nio.file.Paths;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Promise;
import io.vertx.ext.web.Router;
import io.vertx.ext.web.handler.StaticHandler;
import net.miarma.contaminus.common.ConfigManager;
import net.miarma.contaminus.common.Constants;
public class WebServerVerticle extends AbstractVerticle {
private ConfigManager configManager;
public WebServerVerticle() {
configManager = ConfigManager.getInstance();
}
@Override
public void start(Promise<Void> startPromise) {
Constants.LOGGER.info("📡 Iniciando WebServerVerticle...");
Router router = Router.router(vertx);
Path webRootPath = Paths.get(configManager.getWebRoot());
if (webRootPath.isAbsolute()) {
Path basePath = Paths.get(System.getProperty("user.dir")); // Directorio actual
webRootPath = basePath.relativize(webRootPath);
}
router.route("/*")
.handler(
StaticHandler.create(webRootPath.toString())
.setCachingEnabled(false)
.setDefaultContentEncoding("UTF-8")
);
router.route("/dashboard/*").handler(ctx -> {
ctx.reroute("/index.html");
});
vertx.createHttpServer()
.requestHandler(router)
.listen(configManager.getWebserverPort(), configManager.getHost());
startPromise.complete();
}
}

View File

@@ -7,8 +7,8 @@
},
"appConfig": {
"endpoints": {
"DATA_URL": "http://localhost:8081/api/v1",
"LOGIC_URL": "http://localhost:8082/api/v1",
"DATA_URL": "https://contaminus.miarma.net/api/raw/v1",
"LOGIC_URL": "https://contaminus.miarma.net/api/v1",
"GET_GROUPS": "/groups",
"GET_GROUP_BY_ID": "/groups/{0}",
"GET_GROUP_DEVICES": "/groups/{0}/devices",

View File

@@ -48,7 +48,7 @@ const HistoryCharts = () => {
const ENDPOINT = config.appConfig.endpoints.sensors;
const reqConfig = {
baseUrl: `${BASE}/${ENDPOINT}`,
baseUrl: `${BASE}${ENDPOINT}`,
params: {}
}

View File

@@ -70,7 +70,7 @@ const PollutionMap = ({ deviceId }) => {
let endp = ENDPOINT.replace('{0}', deviceId);
const reqConfig = {
baseUrl: `${BASE}/${endp}`,
baseUrl: `${BASE}${endp}`,
params: {}
}

View File

@@ -42,7 +42,7 @@ const SideMenu = ({ isOpen, onClose }) => {
const ENDPOINT = config.appConfig.endpoints.GET_DEVICES;
const reqConfig = {
baseUrl: `${BASE}/${ENDPOINT}`,
baseUrl: `${BASE}${ENDPOINT}`,
params: {}
}

View File

@@ -45,7 +45,7 @@ const SummaryCards = ({ deviceId }) => {
const endp = ENDPOINT.replace('{0}', deviceId);
const reqConfig = {
baseUrl: `${BASE}/${endp}`,
baseUrl: `${BASE}${endp}`,
params: {}
}

View File

@@ -1,8 +1,6 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import cleanPlugin from 'vite-plugin-clean'
import path from 'path'
import os from 'os'
// https://vite.dev/config/
export default defineConfig({
@@ -19,10 +17,7 @@ export default defineConfig({
"chartjs": ["chart.js"]
}
}
},
outDir: path.join(
os.platform() === 'win32' ? os.homedir() + '\\.contaminus\\webroot' : os.homedir() + '/.config/contaminus/webroot'
),
}
},
publicDir: 'public',
})

View File

@@ -0,0 +1,8 @@
#include <Wire.h>
#include <BMP280_DEV.h>
#define I2C_BMP280_ADDRESS 0x76
void BMP280_Init();
uint8_t BMP280_DataReady();
void BMP280_Read();

17
hardware/lib/BMP280.cpp Normal file
View File

@@ -0,0 +1,17 @@
#include "BMP280.h"
void BMP280_Init()
{
}
uint8_t BMP280_DataReady()
{
}
void BMP280_Read(float &temperature, float &humidity, float &pressure, float &altitude)
{
}

30
hardware/lib/MQ7.cpp Normal file
View File

@@ -0,0 +1,30 @@
#include "MQ7.h"
void MQ7_Init()
{
pinMode(digitalMQ7, INPUT);
pinMode(analogMQ7, INPUT);
}
void MQ7_Read(float &sensorVolt, float &RSAir, float &R0, float &sensorValue)
{
analogWrite(analogMQ7, 1023);
delay(60000);
analogWrite(analogMQ7, (1023/5)*1.4 );
for(int i = 0; i<100; i++)
{
sensorValue = sensorValue + analogRead(analogMQ7);
delay(90000);
}
sensorValue = sensorValue/100.0;
sensorVolt = sensorValue/1024*5.0;
RSAir = (5.0-sensorVolt)/sensorVolt;
R0 = RSAir/(26+(1/3));
Serial.print("R0 = ");
Serial.println(R0);
delay(1000);
}