Skip to content

Commit

Permalink
Merge branch 'beta' of https://github.com/jeedom/plugin-luna into beta
Browse files Browse the repository at this point in the history
  • Loading branch information
Sekiro-kost committed Jul 11, 2024
2 parents 072b9dc + d7cc5ba commit 1dd7046
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 53 deletions.
38 changes: 38 additions & 0 deletions core/class/luna.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1093,6 +1093,36 @@ public static function waitLuna($_method, $_params = null) {
return $result;
}

public static function checkLunaLte() {
$waitFileExist = false;
$result = shell_exec('sudo test -f /boot/jeedomLTE && echo "exists" || echo "not exists"');
if (trim($result) != "exists") {
$maxWaitTime = 180;
$startTime = time();
$isLte = null;
while (time() - $startTime < $maxWaitTime) {
$result = shell_exec('sudo test -f /boot/jeedomLTE && echo "exists" || echo "not exists"');
if(trim($result) == "exists"){
log::add('luna', 'debug', 'Wait for jeedomLTE file');
$waitFileExist = true;
break;
}else{
usleep(500000);
}
}
} else {
$waitFileExist = true;
}
if($waitFileExist){
$isLte = shell_exec('sudo cat /boot/jeedomLTE');
if(trim($isLte) == "2"){
config::save('isLte', 'NOLTE', 'luna');
} else {
config::save('isLte', 'LTE', 'luna');
}
}
}

//Todo a supprimer dans l'avenir
// public static function cronHourly() {
// // executer LTE si pas de ppp0 dans un ifconfig
Expand Down Expand Up @@ -1184,6 +1214,14 @@ public static function sendSMS($number, $text) {
}

/* ----- FIN SMS ----- */
/* ----- Outils d'aministration ----- */
public static function reloadConfig() {
shell_exec('sudo rm /boot/jeedomLTE');
shell_exec('sudo systemctl daemon-reload');
shell_exec('sudo systemctl enable jeedomLTE.service');
shell_exec('sudo systemctl start jeedomLTE.service');
self::checkLunaLte();
}

public static function switchHost($activated = true) {
//exec("sudo apt remove -y dnsmasq");
Expand Down
55 changes: 2 additions & 53 deletions plugin_info/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,7 @@ function luna_install() {
luna::switchHost();
luna::installLora();
luna::onBattery();
$waitFileExist = false;
$result = shell_exec('sudo test -f /boot/jeedomLTE && echo "exists" || echo "not exists"');
if (trim($result) != "exists") {
$maxWaitTime = 180;
$startTime = time();
$isLte = null;
while (time() - $startTime < $maxWaitTime) {
$result = shell_exec('sudo test -f /boot/jeedomLTE && echo "exists" || echo "not exists"');
if(trim($result) == "exists"){
$waitFileExist = true;
break;
}else{
usleep(500000);
}
}
} else {
$waitFileExist = true;
}
if($waitFileExist){
$isLte = shell_exec('sudo cat /boot/jeedomLTE');
if(trim($isLte) == "2"){
config::save('isLte', 'NOLTE', 'luna');
} else {
config::save('isLte', 'LTE', 'luna');
}
}
luna::checkLunaLte();
}

function luna_update() {
Expand Down Expand Up @@ -122,31 +97,5 @@ function luna_update() {
luna::switchHost();
luna::installLora();
luna::onBattery();
$waitFileExist = false;
$result = shell_exec('sudo test -f /boot/jeedomLTE && echo "exists" || echo "not exists"');
if (trim($result) != "exists") {
$maxWaitTime = 180;
$startTime = time();
$isLte = null;
while (time() - $startTime < $maxWaitTime) {
$result = shell_exec('sudo test -f /boot/jeedomLTE && echo "exists" || echo "not exists"');
if(trim($result) == "exists"){
log::add('luna', 'debug', 'Wait for jeedomLTE file');
$waitFileExist = true;
break;
}else{
usleep(500000);
}
}
} else {
$waitFileExist = true;
}
if($waitFileExist){
$isLte = shell_exec('sudo cat /boot/jeedomLTE');
if(trim($isLte) == "2"){
config::save('isLte', 'NOLTE', 'luna');
} else {
config::save('isLte', 'LTE', 'luna');
}
}
luna::checkLunaLte();
}

0 comments on commit 1dd7046

Please sign in to comment.