This commit is contained in:
Your Name
2025-02-20 15:30:34 +01:00
parent d5f1acc025
commit 725ee971c7
38 changed files with 405 additions and 84 deletions

View File

@@ -7,7 +7,7 @@ header("Pragma: no-cache");
$type=$_GET['type'];
if ($type == "get_npm_sqlite_data") {
$database_path = "/var/www/nebuleair_pro_4g/sqlite/sensors.db";
$database_path = "/var/www/moduleair_pro_4g/sqlite/sensors.db";
//echo "Getting data from sqlite database";
try {
$db = new PDO("sqlite:$database_path");
@@ -45,7 +45,7 @@ if ($type == "update_config") {
}
if ($type == "getModem_busy") {
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/check_running.py';
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/SARA/check_running.py';
$output = shell_exec($command);
echo $output;
}
@@ -56,7 +56,7 @@ if ($type == "RTC_time") {
}
if ($type == "sys_RTC_module_time") {
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/RTC/read.py';
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/RTC/read.py';
$output = shell_exec($command);
echo $output;
}
@@ -68,7 +68,7 @@ if ($type == "git_pull") {
}
if ($type == "set_RTC_withNTP") {
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/RTC/set_with_NTP.py';
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/RTC/set_with_NTP.py';
$output = shell_exec($command);
echo $output;
}
@@ -84,7 +84,7 @@ if ($type == "set_RTC_withBrowser") {
$rtc_time = date('Y-m-d H:i:s', strtotime($time));
// Execute Python script to update the RTC
$command = escapeshellcmd("sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/RTC/set_with_browserTime.py '$rtc_time'");
$command = escapeshellcmd("sudo /usr/bin/python3 /var/www/moduleair_pro_4g/RTC/set_with_browserTime.py '$rtc_time'");
$output = shell_exec($command);
if ($output === null) {
echo json_encode(['success' => false, 'message' => 'Failed to update RTC']);
@@ -95,7 +95,7 @@ if ($type == "set_RTC_withBrowser") {
if ($type == "clear_loopLogs") {
$command = 'truncate -s 0 /var/www/nebuleair_pro_4g/logs/loop.log';
$command = 'truncate -s 0 /var/www/moduleair_pro_4g/logs/loop.log';
$output = shell_exec($command);
echo $output;
}
@@ -103,7 +103,7 @@ if ($type == "clear_loopLogs") {
if ($type == "database_size") {
// Path to the SQLite database file
$databasePath = '/var/www/nebuleair_pro_4g/sqlite/sensors.db';
$databasePath = '/var/www/moduleair_pro_4g/sqlite/sensors.db';
// Check if the file exists
if (file_exists($databasePath)) {
@@ -172,7 +172,7 @@ if ($type == "reboot") {
if ($type == "npm") {
$port=$_GET['port'];
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/NPM/get_data.py ' . $port;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/NPM/get_data.py ' . $port;
$output = shell_exec($command);
echo $output;
}
@@ -180,19 +180,19 @@ if ($type == "npm") {
if ($type == "envea") {
$port=$_GET['port'];
$name=$_GET['name'];
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/envea/read_value.py ' . $port;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/envea/read_value.py ' . $port;
$output = shell_exec($command);
echo $output;
}
if ($type == "noise") {
$command = '/var/www/nebuleair_pro_4g/sound_meter/sound_meter';
$command = '/var/www/moduleair_pro_4g/sound_meter/sound_meter';
$output = shell_exec($command);
echo $output;
}
if ($type == "BME280") {
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/BME280/read.py';
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/BME280/read.py';
$output = shell_exec($command);
echo $output;
}
@@ -204,13 +204,13 @@ if ($type == "table_mesure") {
$download=$_GET['download'];
if ($download==="false") {
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/sqlite/read.py '.$table.' '.$limit;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/sqlite/read.py '.$table.' '.$limit;
$output = shell_exec($command);
echo $output;
} else{
$start_date=$_GET['start_date'];
$end_date=$_GET['end_date'];
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/sqlite/read_select_date.py '.$table.' '.$start_date.' '.$end_date;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/sqlite/read_select_date.py '.$table.' '.$start_date.' '.$end_date;
$output = shell_exec($command);
echo $output;
}
@@ -223,7 +223,7 @@ if ($type == "sara") {
$sara_command=$_GET['command'];
$sara_command = escapeshellcmd($sara_command);
$timeout=$_GET['timeout'];
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara.py ' . $port . ' ' . $sara_command . ' ' . $timeout;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/SARA/sara.py ' . $port . ' ' . $sara_command . ' ' . $timeout;
$output = shell_exec($command);
echo $output;
}
@@ -232,7 +232,7 @@ if ($type == "sara") {
if ($type == "sara_getMQTT_config") {
$port=$_GET['port'];
$timeout=$_GET['timeout'];
$command = '/usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/MQTT/get_config.py ' . $port . ' ' . $timeout;
$command = '/usr/bin/python3 /var/www/moduleair_pro_4g/SARA/MQTT/get_config.py ' . $port . ' ' . $timeout;
$output = shell_exec($command);
echo $output;
}
@@ -242,7 +242,7 @@ if ($type == "sara_getMQTT_login_logout") {
$port=$_GET['port'];
$timeout=$_GET['timeout'];
$login_logout=$_GET['login_logout'];
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/MQTT/login_logout.py ' . $port . ' ' . $login_logout . ' ' . $timeout;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/SARA/MQTT/login_logout.py ' . $port . ' ' . $login_logout . ' ' . $timeout;
$output = shell_exec($command);
echo $output;
}
@@ -252,7 +252,7 @@ if ($type == "sara_MQTT_publish") {
$port=$_GET['port'];
$timeout=$_GET['timeout'];
$message=$_GET['message'];
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/MQTT/publish.py ' . $port . ' ' . $message . ' ' . $timeout;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/SARA/MQTT/publish.py ' . $port . ' ' . $message . ' ' . $timeout;
$output = shell_exec($command);
echo $output;
}
@@ -262,11 +262,11 @@ if ($type == "sara_connectNetwork") {
$port=$_GET['port'];
$timeout=$_GET['timeout'];
$networkID=$_GET['networkID'];
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_connectNetwork.py ' . $port . ' ' . $networkID . ' ' . $timeout;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/SARA/sara_connectNetwork.py ' . $port . ' ' . $networkID . ' ' . $timeout;
$output = shell_exec($command);
echo $output;
#save to config.json
$configFile = '/var/www/nebuleair_pro_4g/config.json';
$configFile = '/var/www/moduleair_pro_4g/config.json';
// Read the JSON file
$jsonData = file_get_contents($configFile);
// Decode JSON data into an associative array
@@ -298,7 +298,7 @@ if ($type == "sara_setURL") {
$port=$_GET['port'];
$url=$_GET['url'];
$profile_id = 2;
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_setURL.py ' . $port . ' ' . $url . ' ' . $profile_id;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/SARA/sara_setURL.py ' . $port . ' ' . $url . ' ' . $profile_id;
$output = shell_exec($command);
echo $output;
}
@@ -308,7 +308,7 @@ if ($type == "sara_APN") {
$port=$_GET['port'];
$timeout=$_GET['timeout'];
$APN_address=$_GET['APN_address'];
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_setAPN.py ' . $port . ' ' . $APN_address . ' ' . $timeout;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/SARA/sara_setAPN.py ' . $port . ' ' . $APN_address . ' ' . $timeout;
$output = shell_exec($command);
echo $output;
}
@@ -321,15 +321,15 @@ if ($type == "sara_writeMessage") {
$type2=$_GET['type2'];
if ($type2 === "write") {
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_writeMessage.py ' . $port . ' ' . $message;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/SARA/sara_writeMessage.py ' . $port . ' ' . $message;
$output = shell_exec($command);
}
if ($type2 === "read") {
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_readMessage.py ' . $port . ' ' . $message;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/SARA/sara_readMessage.py ' . $port . ' ' . $message;
$output = shell_exec($command);
}
if ($type2 === "erase") {
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_eraseMessage.py ' . $port . ' ' . $message;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/SARA/sara_eraseMessage.py ' . $port . ' ' . $message;
$output = shell_exec($command);
}
@@ -342,7 +342,7 @@ if ($type == "sara_sendMessage") {
$endpoint=$_GET['endpoint'];
$endpoint = escapeshellcmd($endpoint);
$profile_id = 2;
$command = 'sudo /usr/bin/python3 /var/www/nebuleair_pro_4g/SARA/sara_sendMessage.py ' . $port . ' ' . $endpoint. ' ' . $profile_id;
$command = 'sudo /usr/bin/python3 /var/www/moduleair_pro_4g/SARA/sara_sendMessage.py ' . $port . ' ' . $endpoint. ' ' . $profile_id;
$output = shell_exec($command);
echo $output;
}
@@ -394,8 +394,8 @@ if ($type == "wifi_connect") {
echo "You will be disconnected. If connection is successfull you can find the device on your local network.";
$script_path = '/var/www/nebuleair_pro_4g/connexion.sh';
$log_file = '/var/www/nebuleair_pro_4g/logs/app.log';
$script_path = '/var/www/moduleair_pro_4g/connexion.sh';
$log_file = '/var/www/moduleair_pro_4g/logs/app.log';
shell_exec("$script_path $SSID $PASS >> $log_file 2>&1 &");
#$output = shell_exec('sudo nmcli connection down Hotspot');
@@ -407,7 +407,7 @@ if ($type == "wifi_connect") {
if ($type == "wifi_scan") {
// Set the path to your CSV file
$csvFile = '/var/www/nebuleair_pro_4g/wifi_list.csv';
$csvFile = '/var/www/moduleair_pro_4g/wifi_list.csv';
// Initialize an array to hold the JSON data
$jsonData = [];