Alsa head corruption in error handling.
This commit is contained in:
@@ -682,6 +682,8 @@ const AppThemed = withStyles(appStyles)(class extends ResizeResponsiveComponent<
|
||||
return "Downloading update...";
|
||||
case State.InstallingUpdate:
|
||||
return "Installing update....";
|
||||
case State.HotspotChanging:
|
||||
return "Network connection changing..."
|
||||
default:
|
||||
return "Reconnecting...";
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ const BankDialog = withStyles(styles, { withTheme: true })(
|
||||
|
||||
getSelectedBankName() {
|
||||
try {
|
||||
return this.model.banks.get().getEntry(this.state.selectedItem)!.name;
|
||||
return this.model.banks.get()?.getEntry(this.state.selectedItem)?.name??"";
|
||||
} catch (error) {
|
||||
return "";
|
||||
}
|
||||
|
||||
+106
-2
@@ -52,6 +52,7 @@ export enum State {
|
||||
ReloadingPlugins,
|
||||
DownloadingUpdate,
|
||||
InstallingUpdate,
|
||||
HotspotChanging,
|
||||
};
|
||||
|
||||
class UpdatedError extends Error {
|
||||
@@ -65,6 +66,7 @@ export enum ReconnectReason {
|
||||
LoadingSettings,
|
||||
ReloadingPlugins,
|
||||
Updating,
|
||||
HotspotChanging
|
||||
};
|
||||
|
||||
export type ControlValueChangedHandler = (key: string, value: number) => void;
|
||||
@@ -466,6 +468,10 @@ export class PiPedalModel //implements PiPedalModel
|
||||
case ReconnectReason.Updating:
|
||||
this.setState(State.InstallingUpdate);
|
||||
break;
|
||||
case ReconnectReason.HotspotChanging:
|
||||
this.setState(State.HotspotChanging);
|
||||
this.startHotspotReconnectTimer();
|
||||
break;
|
||||
|
||||
}
|
||||
return true;
|
||||
@@ -643,9 +649,13 @@ export class PiPedalModel //implements PiPedalModel
|
||||
} else if (message === "onUpdateStatusChanged") {
|
||||
let updateStatus = new UpdateStatus().deserialize(body);
|
||||
this.onUpdateStatusChanged(updateStatus);
|
||||
} else if (message === "onNetworkChanging")
|
||||
{
|
||||
this.onNetworkChanging(body as boolean);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private updateLaterTimeout?: NodeJS.Timeout = undefined;
|
||||
|
||||
private clearPromptForUpdateTimer() {
|
||||
@@ -789,7 +799,7 @@ export class PiPedalModel //implements PiPedalModel
|
||||
}
|
||||
}
|
||||
onSocketReconnected() {
|
||||
|
||||
this.cancelOnNetworkChanging();
|
||||
if (this.isAndroidHosted()) {
|
||||
this.androidHost?.setDisconnected(false);
|
||||
}
|
||||
@@ -943,7 +953,7 @@ export class PiPedalModel //implements PiPedalModel
|
||||
return this.webSocket.connect();
|
||||
})
|
||||
.catch((error) => {
|
||||
this.setError("Failed to connect to server. " + this.socketServerUrl);
|
||||
this.setError("Failed to connect to server. (" + this.socketServerUrl + ")");
|
||||
return false;
|
||||
})
|
||||
.then(() => {
|
||||
@@ -2894,6 +2904,100 @@ export class PiPedalModel //implements PiPedalModel
|
||||
window.location.href = url;
|
||||
//window.location.reload();
|
||||
}
|
||||
|
||||
private networkChanging: boolean = false;
|
||||
private networkChanging_expectHotspot = false;
|
||||
private expectNetworkChangeTimeout?: NodeJS.Timeout = undefined;
|
||||
private hotspotReconnectTimer?: NodeJS.Timeout = undefined;
|
||||
|
||||
async detectServer(address: string)
|
||||
{
|
||||
let port = window.location.port;
|
||||
let newUrl = new URL("http://" + address + ":" + port + "/manifest.json");
|
||||
|
||||
try {
|
||||
let response = await fetch(newUrl);
|
||||
if (response.ok)
|
||||
{
|
||||
return "http://" + address +":"+ port;
|
||||
}
|
||||
return "";
|
||||
} catch (error: any)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
async pollForLiveServer() {
|
||||
let wifiConfigSettings = this.wifiConfigSettings.get();
|
||||
if (wifiConfigSettings.mdnsName.length !== 0)
|
||||
{
|
||||
let newUrl = await this.detectServer(wifiConfigSettings.mdnsName);
|
||||
if (newUrl.length !== 0)
|
||||
{
|
||||
return newUrl;
|
||||
}
|
||||
}
|
||||
if (this.networkChanging_expectHotspot)
|
||||
{
|
||||
let newUrl = await this.detectServer("10.40.0.1");
|
||||
if (newUrl.length !== 0)
|
||||
{
|
||||
return newUrl;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
cancelHotspotReconnectTimer()
|
||||
{
|
||||
if (this.hotspotReconnectTimer)
|
||||
{
|
||||
clearTimeout(this.hotspotReconnectTimer);
|
||||
}
|
||||
|
||||
}
|
||||
startHotspotReconnectTimer()
|
||||
{
|
||||
// poll for access to a running pipedal server
|
||||
this.hotspotReconnectTimer = setTimeout(
|
||||
async () => {
|
||||
let newUrl = await this.pollForLiveServer();
|
||||
if (newUrl.length === 0)
|
||||
{
|
||||
this.startHotspotReconnectTimer();
|
||||
} else {
|
||||
this.cancelOnNetworkChanging();
|
||||
window.location.replace(newUrl);
|
||||
}
|
||||
},
|
||||
5*1000);
|
||||
|
||||
}
|
||||
cancelOnNetworkChanging()
|
||||
{
|
||||
this.cancelHotspotReconnectTimer();
|
||||
if (this.expectNetworkChangeTimeout)
|
||||
{
|
||||
clearTimeout(this.expectNetworkChangeTimeout);
|
||||
this.expectNetworkChangeTimeout = undefined;
|
||||
}
|
||||
this.networkChanging = false;
|
||||
this.expectDisconnect(ReconnectReason.Disconnected);
|
||||
}
|
||||
onNetworkChanging(hotspotConnected: boolean)
|
||||
{
|
||||
this.cancelOnNetworkChanging();
|
||||
|
||||
this.networkChanging = true;
|
||||
this.networkChanging_expectHotspot = hotspotConnected;
|
||||
this.expectDisconnect(ReconnectReason.HotspotChanging);
|
||||
|
||||
this.expectNetworkChangeTimeout = setTimeout(
|
||||
() => {
|
||||
this.cancelOnNetworkChanging();
|
||||
},
|
||||
30*1000);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
let instance: PiPedalModel | undefined = undefined;
|
||||
|
||||
@@ -131,7 +131,24 @@ export const SystemMidiBindingDialog =
|
||||
{
|
||||
displayName = "Next Preset";
|
||||
instanceId = 2;
|
||||
} else if (item.symbol === "startHotspot")
|
||||
{
|
||||
displayName = "Enable Hotspot";
|
||||
instanceId = 3;
|
||||
} else if (item.symbol === "stopHotspot")
|
||||
{
|
||||
displayName = "Disable Hotspot";
|
||||
instanceId = 4;
|
||||
} else if (item.symbol === "shutdown")
|
||||
{
|
||||
displayName = "Shutdown";
|
||||
instanceId = 5;
|
||||
} else if (item.symbol === "reboot")
|
||||
{
|
||||
displayName = "Reboot";
|
||||
instanceId = 6;
|
||||
}
|
||||
|
||||
if (instanceId !== -1)
|
||||
{
|
||||
result.push(new BindingEntry(displayName,instanceId,item));
|
||||
|
||||
@@ -28,6 +28,7 @@ export default class WifiConfigSettings {
|
||||
|
||||
this.wifiWarningGiven = input.wifiWarningGiven;
|
||||
this.hotspotName = input.hotspotName;
|
||||
this.mdnsName = input.mdnsName;
|
||||
this.hasPassword = input.hasPassword;
|
||||
this.password = input.password;
|
||||
this.countryCode = input.countryCode;
|
||||
@@ -40,6 +41,7 @@ export default class WifiConfigSettings {
|
||||
autoStartMode: number = 0;
|
||||
hasSavedPassword: boolean = false;
|
||||
homeNetwork: string = "";
|
||||
mdnsName: string = "";
|
||||
wifiWarningGiven: boolean = false;
|
||||
hasPassword: boolean = false;
|
||||
valid: boolean = false;
|
||||
|
||||
Reference in New Issue
Block a user