From: Vincent Date: Mon, 14 Dec 2020 09:32:37 +0000 (+0100) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=d91f756a2b6b47bfb7568679f6fc58493ce4dc0f;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5752476..00a1b33 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,8 +3,12 @@ - - + + + + + + diff --git a/config/global.php b/config/global.php index 1549b8f..2bc3162 100644 --- a/config/global.php +++ b/config/global.php @@ -24,7 +24,8 @@ $squeezeboxPlayers = array( 'Lit Jérôme' => 'b8:27:eb:62:d3:ce', 'Lit Vincent' => 'b8:27:eb:40:0e:e9', //'Bureau' => 'b8:27:eb:f6:1d:30', - 'Bureau' => 'cc:cc:2d:2a:b5:35', + //'Bureau' => 'cc:cc:2d:2a:b5:35', + 'Bureau' => '7e:23:f6:33:1d:3b', ); $phones = array('vincent' => array( diff --git a/scripts/cron/cron.php b/scripts/cron/cron.php index 7e7a35c..b5b96ce 100644 --- a/scripts/cron/cron.php +++ b/scripts/cron/cron.php @@ -21,6 +21,9 @@ function cronOneLoop($cronmin) if ($cronmin % 10 == 0) { cronSqueezeFavorites($cronmin); } + if ($cronmin % 20 == 0) { + cronSqueezeCheckPlayers($cronmin); + } if ($cronmin % 2 == 0) { cronPing($cronmin); @@ -189,6 +192,18 @@ function cronSqueezeFavorites($cronmin) } } +function cronSqueezeCheckPlayers($cronmin) +{ + _logSection('Check squeezebox players'); + $players = ['Salon' => 'salon', 'Bureau' => 'bureau']; + foreach ($players as $player => $device) { + if (getSqueezePlayerStatus($player) === -1) { + shieldRunAppAndBackHome('sbplayer', $device, 1, true); + sleep(5); + } + } +} + function cronWeather($cronmin) { _logSection('Weather'); diff --git a/scripts/lib/shield.php b/scripts/lib/shield.php index 70277b5..60751fd 100644 --- a/scripts/lib/shield.php +++ b/scripts/lib/shield.php @@ -147,10 +147,20 @@ function shieldFranceTv($device = null) shieldLaunchApp('fr.francetv.pluzz/fr.francetv.androidtv.main.MainActivity', $device); } -function shieldLaunchApp($activity, $device) +function shieldLaunchApp($activity, $device=null) { shieldHome($device); - shieldCommand('shell am start', '-n ' . $activity, $device); + + echo $activity; + + if (strpos($activity, '/') === false) { + if (strpos($activity, '.') === false) { + $activity = shieldGetAppId($activity); + } + shieldCommand('shell monkey', '-p ' . $activity.' 1', $device); + } else { + shieldCommand('shell am start', '-n ' . $activity, $device); + } } function shieldMyCanal($channel = false, $type = 'live', $device = null) @@ -202,7 +212,7 @@ function shieldVLC($file, $device = null) function shieldListApps($device = null) { - shieldCommand('shell pm list', 'packages -f', $device); + echo shieldCommand('shell pm list', 'packages -f', $device); } function shieldFindIntents($app, $device) @@ -240,9 +250,35 @@ function shieldGetApps() 'dailymotion' => 'com.dailymotion.dailymotion', 'vimeo' => 'com.vimeo.android.videoapp', 'plex' => 'com.plexapp.android', + 'sbplayer' => 'com.angrygoat.android.sbplayer', + 'spotify' => 'com.spotify.tv.android', + 'steamlink' => 'com.valvesoftware.steamlink', ]; } +function shieldRunAppAndBackHome($app, $device = null, $waitBeforeBack = 1, $backToSleep = true) +{ + + if (shieldIsAwake($device)) { + $backToSleep = false; + } + if ($backToSleep) { + $d = getDevice($device); + $s = 'maskShield' . ucfirst($d['id']) . 'Wakeup'; + setState($s, '1'); + } + echo 'shieldLaunchApp :: '.$app."\n"; + shieldLaunchApp($app, $device); + sleep($waitBeforeBack); + echo 'shieldHome'."\n"; + shieldHome($device); + if ($backToSleep) { + shieldSleep($device); + sleep(1); + setState($s, '0'); + } +} + function shieldHome($device = null) { shieldWakeup($device); @@ -298,11 +334,12 @@ function shieldGetCurrentApp($device = null) } + function _adb($command, $params = '', $device = null) { $c = _adbcmd($command, $params, $device); $output = `$c`; - // echo $c . ' :: ' . $output . "\n"; + echo $c . ' :: ' . $output . "\n"; return $output; } diff --git a/scripts/lib/squeezebox.php b/scripts/lib/squeezebox.php index 63efbaa..47378cd 100644 --- a/scripts/lib/squeezebox.php +++ b/scripts/lib/squeezebox.php @@ -24,10 +24,14 @@ function stopAllSqueezebox() function getSqueezePlayerStatus($player = '') { $res = _squeezeRequest('mode ?', $player); + if (null === $res) { + return -1; + } + if (!isset($res['result']) || !isset($res['result']['_mode'])) { return false; } - return $res['result']['_mode'] == 'play'; + return $res['result']['_mode'] == 'play' ? 1 : 0; } function stopSqueezebox($player) diff --git a/scripts/shield.php b/scripts/shield.php index c33f624..4c5d366 100644 --- a/scripts/shield.php +++ b/scripts/shield.php @@ -30,5 +30,7 @@ if (isset($_GET['key'])) { } else if (isset($_GET['mycanal'])) { $e = explode(':', $_GET['mycanal']); shieldMyCanal($e[1], $e[0]); +} else if (isset($_GET['runappback'])) { + shieldRunAppAndBackHome($_GET['runappback']); } echo ''; \ No newline at end of file diff --git a/servers/logcat.php b/servers/logcat.php index 7ec1334..90344a0 100644 --- a/servers/logcat.php +++ b/servers/logcat.php @@ -26,7 +26,7 @@ $cases = [ if (getState($state, '0') == '1') { setState($state, '0'); } else { - if (!getSqueezePlayerStatus($squeezePlayer)) { + if (getSqueezePlayerStatus($squeezePlayer) === 0) { shieldRunActivity($device); } else { execScene('bureau/sound/on');