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;
} }
+21 -5
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);
} }
@@ -766,10 +765,14 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
) )
} }
{(this.state.hasWifiDevice || this.state.isAndroidHosted) &&
(
<div>
<Divider /> <Divider />
<div > <div >
<Typography className={classes.sectionHead} display="block" variant="caption" color="secondary">CONNECTION</Typography> <Typography className={classes.sectionHead} display="block" variant="caption" color="secondary">CONNECTION</Typography>
{this.state.hasWifiDevice && (
<ButtonBase <ButtonBase
className={classes.setting} disabled={!this.state.wifiConfigSettings.valid} className={classes.setting} disabled={!this.state.wifiConfigSettings.valid}
onClick={() => this.handleShowWifiConfigDialog()} > onClick={() => this.handleShowWifiConfigDialog()} >
@@ -784,6 +787,8 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
</div> </div>
</ButtonBase> </ButtonBase>
)}
{ {
this.state.isAndroidHosted && this.state.isAndroidHosted &&
( (
@@ -803,6 +808,9 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
} }
</div> </div>
</div>
)}
{(!this.props.onboarding) ? ( {(!this.props.onboarding) ? (
<div > <div >
<Divider /> <Divider />
@@ -942,10 +950,15 @@ const SettingsDialog = withStyles(styles, { withTheme: true })(
) )
} }
{
this.state.showWifiDirectConfigDialog && (
<WifiDirectConfigDialog wifiDirectConfigSettings={this.state.wifiDirectConfigSettings} open={this.state.showWifiDirectConfigDialog} <WifiDirectConfigDialog wifiDirectConfigSettings={this.state.wifiDirectConfigSettings} open={this.state.showWifiDirectConfigDialog}
onClose={() => this.setState({ showWifiDirectConfigDialog: false })} onClose={() => this.setState({ showWifiDirectConfigDialog: false })}
onOk={(wifiDirectConfigSettings: WifiDirectConfigSettings) => this.handleApplyWifiDirectConfig(wifiDirectConfigSettings)} 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 }); }}
/> />
{this.state.showSystemMidiBindingsDialog && (
<SystemMidiBindingsDialog <SystemMidiBindingsDialog
open={this.state.showSystemMidiBindingsDialog} open={this.state.showSystemMidiBindingsDialog}
onClose={() => { this.setState({ showSystemMidiBindingsDialog: false }); }} 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.