This commit is contained in:
PaulVua
2025-02-05 10:51:20 +01:00
parent 7de382a43d
commit 268a0586b8
11 changed files with 290 additions and 23 deletions

View File

@@ -6,6 +6,23 @@ header("Pragma: no-cache");
$type=$_GET['type'];
if ($type == "get_npm_sqlite_data") {
$database_path = "/var/www/nebuleair_pro_4g/sqlite/sensors.db";
//echo "Getting data from sqlite database";
try {
$db = new PDO("sqlite:$database_path");
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
// Fetch the last 10 records
$stmt = $db->query("SELECT timestamp, PM1, PM25, PM10 FROM data ORDER BY timestamp DESC LIMIT 10");
$data = $stmt->fetchAll(PDO::FETCH_ASSOC);
echo json_encode($data);
} catch (PDOException $e) {
echo json_encode(["error" => $e->getMessage()]);
}
}
if ($type == "update_config") {
echo "updating....";
$param=$_GET['param'];