"""Configuration settings for Dangerous Pi backend."""
import os
from pathlib import Path

# Base paths
BASE_DIR = Path(__file__).parent.parent.parent
DATA_DIR = BASE_DIR / "data"
LOGS_DIR = BASE_DIR / "logs"

# Database
DATABASE_PATH = DATA_DIR / "dangerous_pi.db"

# Proxmark3 settings
PM3_DEVICE = os.getenv("PM3_DEVICE", "/dev/ttyACM0")
PM3_TIMEOUT = int(os.getenv("PM3_TIMEOUT", "30"))

# Session settings
SESSION_TIMEOUT = int(os.getenv("SESSION_TIMEOUT", "300"))  # 5 minutes
MAX_SESSIONS = 1

# Server settings
HOST = os.getenv("HOST", "0.0.0.0")
PORT = int(os.getenv("PORT", "8000"))
VERSION = os.getenv("VERSION", "0.1.0")

# Update settings
GITHUB_REPO = os.getenv("GITHUB_REPO", "yourusername/dangerous-pi")  # TODO: Update this
UPDATE_CHECK_INTERVAL = int(os.getenv("UPDATE_CHECK_INTERVAL", "3600"))  # 1 hour

# Wi-Fi settings
WLAN_INTERFACE = os.getenv("WLAN_INTERFACE", "wlan0")
USB_WLAN_INTERFACE = os.getenv("USB_WLAN_INTERFACE", "wlan1")

# UPS settings
UPS_TYPE = os.getenv("UPS_TYPE", "auto")  # Options: "auto", "pisugar", "i2c", "none"
UPS_CHECK_INTERVAL = int(os.getenv("UPS_CHECK_INTERVAL", "60"))  # 1 minute

# I2C UPS settings (for generic fuel gauge HATs)
UPS_I2C_ADDRESS = os.getenv("UPS_I2C_ADDRESS", "0x36")

# PiSugar UPS settings
UPS_PISUGAR_HOST = os.getenv("UPS_PISUGAR_HOST", "127.0.0.1")
UPS_PISUGAR_PORT = int(os.getenv("UPS_PISUGAR_PORT", "8423"))

# BLE settings
BLE_ENABLED = os.getenv("BLE_ENABLED", "true").lower() == "true"
BLE_DEVICE_NAME = os.getenv("BLE_DEVICE_NAME", "DangerousPi")

# Security
AUTH_ENABLED = os.getenv("AUTH_ENABLED", "false").lower() == "true"
AUTH_USERNAME = os.getenv("AUTH_USERNAME", "admin")
AUTH_PASSWORD = os.getenv("AUTH_PASSWORD", "")  # Must be set when AUTH_ENABLED=true
HTTPS_ENABLED = os.getenv("HTTPS_ENABLED", "false").lower() == "true"

# CPU cores settings
# Set to 0 or "auto" to use model-specific defaults
# Pi Zero 2 W defaults to 2 cores (out of 4) for thermal/power management
CPU_CORES = os.getenv("CPU_CORES", "auto")
