mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-01-29 22:00:54 +03:00
Allow firmware installation from LMS' player settings page
This commit is contained in:
@@ -2,6 +2,7 @@ package Plugins::SqueezeESP32::PlayerSettings;
|
||||
|
||||
use strict;
|
||||
use base qw(Slim::Web::Settings);
|
||||
use JSON::XS::VersionOneAndTwo;
|
||||
use List::Util qw(first);
|
||||
|
||||
use Slim::Utils::Log;
|
||||
@@ -36,7 +37,7 @@ sub prefs {
|
||||
}
|
||||
|
||||
sub handler {
|
||||
my ($class, $client, $paramRef) = @_;
|
||||
my ($class, $client, $paramRef, $callback, @args) = @_;
|
||||
|
||||
my ($cprefs, @prefs) = $class->prefs($client);
|
||||
|
||||
@@ -62,7 +63,7 @@ sub handler {
|
||||
x => $paramRef->{'pref_artwork_x'} || 0,
|
||||
y => $paramRef->{'pref_artwork_y'} || 0,
|
||||
};
|
||||
|
||||
|
||||
$cprefs->set('artwork', $artwork);
|
||||
$client->display->modes($client->display->build_modes);
|
||||
# the display update will be done below, after all is completed
|
||||
@@ -76,14 +77,14 @@ sub handler {
|
||||
|
||||
}
|
||||
|
||||
if ($client->depth == 16) {
|
||||
if ($client->can('depth') && $client->depth == 16) {
|
||||
my $equalizer = $cprefs->get('equalizer');
|
||||
for my $i (0 .. $#{$equalizer}) {
|
||||
$equalizer->[$i] = $paramRef->{"pref_equalizer.$i"} || 0;
|
||||
}
|
||||
$cprefs->set('equalizer', $equalizer);
|
||||
$client->update_tones($equalizer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($client->displayWidth) {
|
||||
@@ -93,10 +94,46 @@ sub handler {
|
||||
$paramRef->{'pref_artwork'} = $cprefs->get('artwork');
|
||||
}
|
||||
|
||||
$paramRef->{'pref_equalizer'} = $cprefs->get('equalizer') if $client->depth == 16;
|
||||
$paramRef->{'pref_equalizer'} = $cprefs->get('equalizer') if $client->can('depth') && $client->depth == 16;
|
||||
$paramRef->{'player_ip'} = $client->ip;
|
||||
|
||||
return $class->SUPER::handler($client, $paramRef);
|
||||
Plugins::SqueezeESP32::FirmwareHelper::initFirmwareDownload($client, sub {
|
||||
my ($currentFWInfo, $newFWUrl, $customFwUrl) = @_;
|
||||
|
||||
$currentFWInfo ||= {};
|
||||
my $newFWInfo = Plugins::SqueezeESP32::FirmwareHelper::getFirmwareTag($newFWUrl) || {};
|
||||
|
||||
if ($paramRef->{installUpdate} || $paramRef->{installCustomUpdate}) {
|
||||
my $http = Slim::Networking::SimpleAsyncHTTP->new(sub {
|
||||
main::INFOLOG && $log->is_info && $log->info("Firmware update triggered");
|
||||
}, sub {
|
||||
main::INFOLOG && $log->is_info && $log->info("Failed to trigger firmware update");
|
||||
main::DEBUGLOG && $log->is_debug && $log->debug(Data::Dump::dump(@_));
|
||||
})->post(sprintf('http://%s/config.json', $client->ip), to_json({
|
||||
timestamp => int(Time::HiRes::time() * 1000) * 1,
|
||||
config => {
|
||||
fwurl => {
|
||||
value => $paramRef->{installCustomUpdate} ? $customFwUrl : $newFWUrl,
|
||||
type => 33
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
else {
|
||||
if ($currentFWInfo->{version} && $newFWInfo->{version} && $currentFWInfo->{version} > $newFWInfo->{version}) {
|
||||
main::INFOLOG && $log->is_info && $log->info("There's an update for your SqueezeESP32 player: $newFWUrl");
|
||||
$paramRef->{fwUpdateAvailable} = sprintf($client->string('PLUGIN_SQUEEZEESP32_FIRMWARE_AVAILABLE'), $newFWInfo->{version}, $currentFWInfo->{version});
|
||||
}
|
||||
if ($customFwUrl) {
|
||||
main::INFOLOG && $log->is_info && $log->info("There's a custom firmware for your SqueezeESP32 player: $customFwUrl");
|
||||
$paramRef->{fwCustomUpdateAvailable} = 'PLUGIN_SQUEEZEESP32_CUSTOM_FIRMWARE_AVAILABLE';
|
||||
}
|
||||
}
|
||||
|
||||
$callback->( $client, $paramRef, $class->SUPER::handler($client, $paramRef), @args );
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
1;
|
||||
Reference in New Issue
Block a user