Don't show Hotspot config on devices without wifi.

This commit is contained in:
Robin E. R. Davies
2024-11-14 21:05:11 -05:00
parent 04181958a1
commit 301cd6a60a
7 changed files with 106 additions and 74 deletions
+2 -1
View File
@@ -5,5 +5,6 @@
"max_upload_size": 536870912, "max_upload_size": 536870912,
"fakeAndroid": false, "fakeAndroid": false,
"ui_plugins": [], "ui_plugins": [],
"enable_auto_update": true "enable_auto_update": true,
"has_wifi_device": false
} }
+2 -1
View File
@@ -394,7 +394,7 @@ export class PiPedalModel //implements PiPedalModel
webSocket?: PiPedalSocket; webSocket?: PiPedalSocket;
hasWifiDevice: ObservableProperty<boolean> = new ObservableProperty<boolean>(false);
onSnapshotModified: ObservableEvent<SnapshotModifiedEvent> = new ObservableEvent<SnapshotModifiedEvent>(); onSnapshotModified: ObservableEvent<SnapshotModifiedEvent> = new ObservableEvent<SnapshotModifiedEvent>();
ui_plugins: ObservableProperty<UiPlugin[]> ui_plugins: ObservableProperty<UiPlugin[]>
@@ -1036,6 +1036,7 @@ export class PiPedalModel //implements PiPedalModel
) )
.then(data => { .then(data => {
this.enableAutoUpdate = !!data.enable_auto_update; this.enableAutoUpdate = !!data.enable_auto_update;
this.hasWifiDevice.set(!!data.has_wifi_device);
if (data.max_upload_size) { if (data.max_upload_size) {
this.maxPresetUploadSize = data.max_upload_size; this.maxPresetUploadSize = data.max_upload_size;
} }
+66 -50
View File
@@ -92,6 +92,8 @@ interface SettingsDialogState {
showRestartOkDialog: boolean; showRestartOkDialog: boolean;
showShutdownOkDialog: boolean; showShutdownOkDialog: boolean;
showSystemMidiBindingsDialog: boolean; showSystemMidiBindingsDialog: boolean;
hasWifiDevice: boolean;
}; };
@@ -199,10 +201,8 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
showShutdownOkDialog: false, showShutdownOkDialog: false,
showRestartOkDialog: false, showRestartOkDialog: false,
showSystemMidiBindingsDialog: false, showSystemMidiBindingsDialog: false,
isAndroidHosted: this.model.isAndroidHosted() isAndroidHosted: this.model.isAndroidHosted(),
hasWifiDevice: this.model.hasWifiDevice.get()
}; };
this.handleJackConfigurationChanged = this.handleJackConfigurationChanged.bind(this); this.handleJackConfigurationChanged = this.handleJackConfigurationChanged.bind(this);
this.handleJackSettingsChanged = this.handleJackSettingsChanged.bind(this); this.handleJackSettingsChanged = this.handleJackSettingsChanged.bind(this);
@@ -213,7 +213,6 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
this.handleConnectionStateChanged = this.handleConnectionStateChanged.bind(this); this.handleConnectionStateChanged = this.handleConnectionStateChanged.bind(this);
this.handleShowStatusMonitorChanged = this.handleShowStatusMonitorChanged.bind(this); this.handleShowStatusMonitorChanged = this.handleShowStatusMonitorChanged.bind(this);
} }
@@ -542,7 +541,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
<DialogEx tag="settings" fullScreen open={this.props.open} <DialogEx tag="settings" fullScreen open={this.props.open}
onClose={() => { this.props.onClose() }} TransitionComponent={Transition} onClose={() => { this.props.onClose() }} TransitionComponent={Transition}
style={{ userSelect: "none" }} style={{ userSelect: "none" }}
onEnterKey={()=>{}} onEnterKey={() => { }}
> >
<div style={{ display: "flex", flexDirection: "column", flexWrap: "nowrap", width: "100%", height: "100%", overflow: "hidden" }}> <div style={{ display: "flex", flexDirection: "column", flexWrap: "nowrap", width: "100%", height: "100%", overflow: "hidden" }}>
@@ -651,7 +650,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
<ButtonBase className={classes.setting} onClick={() => this.handleInputSelection()} <ButtonBase className={classes.setting} onClick={() => this.handleInputSelection()}
disabled={!isConfigValid || this.state.jackConfiguration.outputAudioPorts.length <= 1} disabled={!isConfigValid || this.state.jackConfiguration.outputAudioPorts.length <= 1}
style={{ opacity: !isConfigValid ? 0.6 : 1.0 }} style={{ opacity: !isConfigValid ? 0.6 : 1.0 }}
@@ -662,7 +661,7 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
<Typography display="block" variant="caption" color="textSecondary" noWrap>{this.state.jackSettings.getAudioInputDisplayValue(this.state.jackConfiguration)}</Typography> <Typography display="block" variant="caption" color="textSecondary" noWrap>{this.state.jackSettings.getAudioInputDisplayValue(this.state.jackConfiguration)}</Typography>
</div> </div>
</ButtonBase> </ButtonBase>
<ButtonBase className={classes.setting} onClick={() => this.handleOutputSelection()} <ButtonBase className={classes.setting} onClick={() => this.handleOutputSelection()}
disabled={!isConfigValid || this.state.jackConfiguration.outputAudioPorts.length <= 1} disabled={!isConfigValid || this.state.jackConfiguration.outputAudioPorts.length <= 1}
style={{ opacity: !isConfigValid ? 0.6 : 1.0 }} style={{ opacity: !isConfigValid ? 0.6 : 1.0 }}
> >
@@ -766,43 +765,52 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
) )
} }
<Divider /> {(this.state.hasWifiDevice || this.state.isAndroidHosted) &&
<div > (
<Typography className={classes.sectionHead} display="block" variant="caption" color="secondary">CONNECTION</Typography> <div>
<Divider />
<div >
<Typography className={classes.sectionHead} display="block" variant="caption" color="secondary">CONNECTION</Typography>
<ButtonBase {this.state.hasWifiDevice && (
className={classes.setting} disabled={!this.state.wifiConfigSettings.valid} <ButtonBase
onClick={() => this.handleShowWifiConfigDialog()} > className={classes.setting} disabled={!this.state.wifiConfigSettings.valid}
<SelectHoverBackground selected={false} showHover={true} /> onClick={() => this.handleShowWifiConfigDialog()} >
<div style={{ width: "100%" }}> <SelectHoverBackground selected={false} showHover={true} />
<Typography className={classes.primaryItem} display="block" variant="body2" color="textPrimary" noWrap> <div style={{ width: "100%" }}>
Wi-Fi auto-hotspot</Typography> <Typography className={classes.primaryItem} display="block" variant="body2" color="textPrimary" noWrap>
<Typography display="block" variant="caption" noWrap color="textSecondary"> Wi-Fi auto-hotspot</Typography>
{this.state.wifiConfigSettings.getSummaryText()} <Typography display="block" variant="caption" noWrap color="textSecondary">
</Typography> {this.state.wifiConfigSettings.getSummaryText()}
</Typography>
</div>
</ButtonBase>
)}
{
this.state.isAndroidHosted &&
(
<ButtonBase className={classes.setting} disabled={!this.state.wifiConfigSettings.valid}
onClick={() => this.model.chooseNewDevice()} >
<SelectHoverBackground selected={false} showHover={true} />
<div style={{ width: "100%" }}>
<Typography className={classes.primaryItem} display="block" variant="body2" color="textPrimary" noWrap>
Connect to a different device</Typography>
<Typography display="block" variant="caption" noWrap color="textSecondary">
</Typography>
</div>
</ButtonBase>
)
}
</div>
</div> </div>
</ButtonBase> )}
{
this.state.isAndroidHosted &&
(
<ButtonBase className={classes.setting} disabled={!this.state.wifiConfigSettings.valid}
onClick={() => this.model.chooseNewDevice()} >
<SelectHoverBackground selected={false} showHover={true} />
<div style={{ width: "100%" }}>
<Typography className={classes.primaryItem} display="block" variant="body2" color="textPrimary" noWrap>
Connect to a different device</Typography>
<Typography display="block" variant="caption" noWrap color="textSecondary">
</Typography>
</div>
</ButtonBase>
)
}
</div>
{(!this.props.onboarding) ? ( {(!this.props.onboarding) ? (
<div > <div >
<Divider /> <Divider />
@@ -942,10 +950,15 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
) )
} }
<WifiDirectConfigDialog wifiDirectConfigSettings={this.state.wifiDirectConfigSettings} open={this.state.showWifiDirectConfigDialog} {
onClose={() => this.setState({ showWifiDirectConfigDialog: false })} this.state.showWifiDirectConfigDialog && (
onOk={(wifiDirectConfigSettings: WifiDirectConfigSettings) => this.handleApplyWifiDirectConfig(wifiDirectConfigSettings)} <WifiDirectConfigDialog wifiDirectConfigSettings={this.state.wifiDirectConfigSettings} open={this.state.showWifiDirectConfigDialog}
/> onClose={() => this.setState({ showWifiDirectConfigDialog: false })}
onOk={(wifiDirectConfigSettings: WifiDirectConfigSettings) => this.handleApplyWifiDirectConfig(wifiDirectConfigSettings)}
/>
)
}
<OkCancelDialog text="Are you sure you want to reboot?" okButtonText='Reboot' <OkCancelDialog text="Are you sure you want to reboot?" okButtonText='Reboot'
open={this.state.showRestartOkDialog} open={this.state.showRestartOkDialog}
onOk={() => { this.setState({ showRestartOkDialog: false }); this.handleRestartOk(); }} onOk={() => { this.setState({ showRestartOkDialog: false }); this.handleRestartOk(); }}
@@ -956,10 +969,13 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
onOk={() => { this.setState({ showShutdownOkDialog: false }); this.handleShutdownOk(); }} onOk={() => { this.setState({ showShutdownOkDialog: false }); this.handleShutdownOk(); }}
onClose={() => { this.setState({ showShutdownOkDialog: false }); }} onClose={() => { this.setState({ showShutdownOkDialog: false }); }}
/> />
<SystemMidiBindingsDialog {this.state.showSystemMidiBindingsDialog && (
open={this.state.showSystemMidiBindingsDialog} <SystemMidiBindingsDialog
onClose={() => { this.setState({ showSystemMidiBindingsDialog: false }); }} open={this.state.showSystemMidiBindingsDialog}
/> onClose={() => { this.setState({ showSystemMidiBindingsDialog: false }); }}
/>
)}
{this.state.showWindowScaleDialog && ( {this.state.showWindowScaleDialog && (
<OptionsDialog open={this.state.showWindowScaleDialog} options={getWindowScaleOptions()} value={getWindowScale()} <OptionsDialog open={this.state.showWindowScaleDialog} options={getWindowScaleOptions()} value={getWindowScale()}
onClose={(() => this.setState({ showWindowScaleDialog: false }))} onClose={(() => this.setState({ showWindowScaleDialog: false }))}
+31
View File
@@ -33,6 +33,7 @@
using namespace pipedal; using namespace pipedal;
using namespace dbus::networkmanager; using namespace dbus::networkmanager;
namespace fs = std::filesystem;
namespace pipedal::impl namespace pipedal::impl
{ {
@@ -1032,3 +1033,33 @@ std::vector<std::string> HotspotManagerImpl::GetKnownWifiNetworks()
std::lock_guard lock(knownWifiNetworksMutex); // pushed off the service thread. std::lock_guard lock(knownWifiNetworksMutex); // pushed off the service thread.
return this->knownWifiNetworks; return this->knownWifiNetworks;
} }
static bool is_wireless_sysfs(const std::string& ifname) {
return fs::exists("/sys/class/net/" + ifname + "/wireless");
}
static std::vector<std::string> get_wireless_interfaces_sysfs() {
std::vector<std::string> wireless_interfaces;
const std::string net_path = "/sys/class/net";
try {
for (const auto& entry : fs::directory_iterator(net_path)) {
std::string ifname = entry.path().filename();
if (is_wireless_sysfs(ifname)) {
wireless_interfaces.push_back(ifname);
}
}
} catch (const fs::filesystem_error& e) {
std::cerr << "Error accessing " << net_path << ": " << e.what() << std::endl;
}
return wireless_interfaces;
}
bool HotspotManager::HasWifiDevice()
{
// use procfs to decide this, as NetworkManager may not be available yet.
return !(get_wireless_interfaces_sysfs().empty());
}
+2
View File
@@ -38,6 +38,8 @@ namespace pipedal {
using ptr = std::unique_ptr<HotspotManager>; using ptr = std::unique_ptr<HotspotManager>;
static bool HasWifiDevice();
static ptr Create(); static ptr Create();
virtual ~HotspotManager() noexcept { } virtual ~HotspotManager() noexcept { }
+2
View File
@@ -33,6 +33,7 @@
#include "TemporaryFile.hpp" #include "TemporaryFile.hpp"
#include "PresetBundle.hpp" #include "PresetBundle.hpp"
#include "json.hpp" #include "json.hpp"
#include "HotspotManager.hpp"
#define OLD_PRESET_EXTENSION ".piPreset" #define OLD_PRESET_EXTENSION ".piPreset"
#define PRESET_EXTENSION ".piPreset" #define PRESET_EXTENSION ".piPreset"
@@ -701,6 +702,7 @@ public:
<< ", \"socket_server_address\": \"" << webSocketAddress << ", \"socket_server_address\": \"" << webSocketAddress
<< "\", \"ui_plugins\": [ ], \"max_upload_size\": " << maxUploadSize << "\", \"ui_plugins\": [ ], \"max_upload_size\": " << maxUploadSize
<< ", \"enable_auto_update\": " << (ENABLE_AUTO_UPDATE ? " true" : "false") << ", \"enable_auto_update\": " << (ENABLE_AUTO_UPDATE ? " true" : "false")
<< ", \"has_wifi_device\": " << (HotspotManager::HasWifiDevice() ? " true": "false")
<< " }"; << " }";
return s.str(); return s.str();
+1 -22
View File
@@ -1,28 +1,7 @@
Loading shields need to be of Modal type. Not all country codes are valid (e.g. Antarctica)
MOD fileTypes
- audioloop: Audio Loops, meant to be used for looper-style plugins
- audiorecording: Audio Recordings, triggered by plugins and stored in the unit
- audiosample: One-shot Audio Samples, meant to be used for sampler-style plugins
- audiotrack: Audio Tracks, meant to be used as full-performance/song or backtrack
- cabsim: Speaker Cabinets, meant as small IR audio files
- h2drumkit: Hydrogen Drumkits, must use h2drumkit file extension
- ir: Impulse Responses
- midiclip: MIDI Clips, to be used in sync with host tempo, must have mid or midi file extension
- midisong: MIDI Songs, meant to be used as full-performance/song or backtrack
- sf2: SF2 Instruments, must have sf2 or sf3 file extension
- sfz: SFZ Instruments, must have sfz file extension
Main menu on Pixel 5 client.
x1 bank menu (landscape pixel 5) should show current bank.
Restart discover on network change?
-verify clean removal of dhcpcd and nm_p2p2d
X Review docs changes once we go live. X Review docs changes once we go live.