made proxmity and bme680 optional

This commit is contained in:
Justin Eckenweber
2026-05-20 11:46:06 +02:00
parent dc442f29bc
commit 8deb6dd274
+15 -6
View File
@@ -13,6 +13,10 @@ from fastapi.middleware.cors import CORSMiddleware
db_user = 'sensor_user'
db_password = 'dein_passwort'
use_bme680 = False
use_proximity = False
use_camera = True
# --- Database connection setup ---
try:
# Connect to local MySQL database
@@ -176,14 +180,19 @@ app = FastAPI()
@app.on_event("startup")
def startup_event():
sensor_thread = threading.Thread(target=sensor_loop, daemon=True)
sensor_thread.start()
if use_bme680:
sensor_thread = threading.Thread(target=sensor_loop, daemon=True)
sensor_thread.start()
if use_proximity:
proxmity_thread = threading.Thread(target=proxmity_loop, daemon=True)
proxmity_thread.start()
if use_bme680:
database_thread = threading.Thread(target=database_loop, daemon=True)
database_thread.start()
proxmity_thread = threading.Thread(target=proxmity_loop, daemon=True)
proxmity_thread.start()
database_thread = threading.Thread(target=database_loop, daemon=True)
database_thread.start()
print("Sensor thread started")
# --- CORS configuration (allows cross-origin requests) ---