Configure hotspot credentials from dashboard
This commit is contained in:
@@ -42,6 +42,14 @@ async function field(device: string, name: string): Promise<string | null> {
|
||||
}
|
||||
}
|
||||
|
||||
async function connectionField(connection: string, name: string): Promise<string | null> {
|
||||
try {
|
||||
return (await nmcli(["--get-values", name, "connection", "show", connection])).split("\n")[0]?.trim() || null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function inspectAdapter(device: string): Promise<Adapter> {
|
||||
const type = await field(device, "GENERAL.TYPE");
|
||||
if (type !== "wifi") return { interface: device, available: false, connected: false, connection: null, address: null };
|
||||
@@ -90,10 +98,11 @@ class NetworkController {
|
||||
}
|
||||
|
||||
private async publish(): Promise<{ hotspot: Adapter; upstream: Adapter }> {
|
||||
const [hotspot, upstream, internet] = await Promise.all([
|
||||
const [hotspot, upstream, internet, hotspotSsid] = await Promise.all([
|
||||
inspectAdapter(this.config.NETWORK_HOTSPOT_INTERFACE),
|
||||
inspectAdapter(this.config.NETWORK_UPSTREAM_INTERFACE),
|
||||
connectivity()
|
||||
connectivity(),
|
||||
connectionField(this.config.NETWORK_HOTSPOT_CONNECTION, "802-11-wireless.ssid")
|
||||
]);
|
||||
await writeNetworkStatus(this.config.NETWORK_STATUS_PATH, {
|
||||
enabled: true,
|
||||
@@ -104,6 +113,7 @@ class NetworkController {
|
||||
probeDeadline: this.probeDeadline,
|
||||
lastFailure: this.lastFailure,
|
||||
connectivity: internet,
|
||||
hotspotSsid,
|
||||
hotspot,
|
||||
upstream
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user