mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-06 03:27:01 +03:00
Extend firmware download handler to serve locally built custom firmware, too.
Just save it as `squeezelite-esp32-custom.bin` in the firmware update folder (LMS Cache/updates) and paste http://yourlms:9000/plugins/SqueezeESP32/firmware/custom.bin in the firmware URL box.
This commit is contained in:
@@ -16,6 +16,7 @@ use constant GITHUB_DOWNLOAD_URI => "https://github.com/sle118/squeezelite-esp32
|
||||
use constant ESP32_STATUS_URI => "http://%s/status.json";
|
||||
|
||||
my $FW_DOWNLOAD_REGEX = qr|plugins/SqueezeESP32/firmware/([-a-z0-9-/.]+\.bin)$|i;
|
||||
my $FW_CUSTOM_REGEX = qr/^((?:squeezelite-esp32-)?custom\.bin)$/;
|
||||
my $FW_FILENAME_REGEX = qr/^squeezelite-esp32-.*\.bin(\.tmp)?$/;
|
||||
my $FW_TAG_REGEX = qr/\b(ESP32-A1S|SqueezeAmp|I2S-4MFlash)\.(16|32)\.(\d+)\.([-a-zA-Z0-9]+)\b/;
|
||||
|
||||
@@ -137,6 +138,22 @@ sub handleFirmwareDownload {
|
||||
return Slim::Web::HTTP::closeHTTPSocket($httpClient);
|
||||
}
|
||||
|
||||
if ($path =~ $FW_CUSTOM_REGEX) {
|
||||
my $firmwareFile = catfile(scalar Slim::Utils::OSDetect::dirsFor('updates'), 'squeezelite-esp32-custom.bin');
|
||||
|
||||
if (! -f $firmwareFile) {
|
||||
main::INFOLOG && $log->is_info && $log->info("Failed to find custom firmware build: $firmwareFile");
|
||||
$response->code(404);
|
||||
$httpClient->send_response($response);
|
||||
return Slim::Web::HTTP::closeHTTPSocket($httpClient);
|
||||
}
|
||||
|
||||
main::INFOLOG && $log->is_info && $log->info("Getting custom firmware build");
|
||||
|
||||
$response->code(200);
|
||||
return Slim::Web::HTTP::sendStreamingFile($httpClient, $response, 'application/octet-stream', $firmwareFile, undef, 1);
|
||||
}
|
||||
|
||||
main::INFOLOG && $log->is_info && $log->info("Requesting firmware from: $path");
|
||||
|
||||
downloadFirmwareFile(sub {
|
||||
|
||||
@@ -37,12 +37,13 @@ $prefs->setChange(sub {
|
||||
sub initPlugin {
|
||||
my $class = shift;
|
||||
|
||||
# enable the following to test the firmware downloading code without a SqueezeliteESP32 player
|
||||
# require Plugins::SqueezeESP32::FirmwareHelper;
|
||||
# Plugins::SqueezeESP32::FirmwareHelper::init();
|
||||
|
||||
if ( main::WEBUI ) {
|
||||
require Plugins::SqueezeESP32::PlayerSettings;
|
||||
Plugins::SqueezeESP32::PlayerSettings->new;
|
||||
|
||||
# require Plugins::SqueezeESP32::Settings;
|
||||
# Plugins::SqueezeESP32::Settings->new;
|
||||
}
|
||||
|
||||
$class->SUPER::initPlugin(@_);
|
||||
|
||||
Reference in New Issue
Block a user