Skip to content
Shiny.NET

Wi-Fi

NuGet package Shiny.AppDeviceBridge.Wifi

The Wi-Fi bridge gives the page the current network and its changes, scanning, connecting, known networks, the radio and the hotspot, backed by Shiny.Net.Wifi.

Terminal window
dotnet add package Shiny.AppDeviceBridge.Wifi
builder.UseAppDeviceBridge(
bridge => bridge.AddWifiBridge(hotspot: false),
webApp => { /* … */ }
);
Client C# TypeScript
IWifiBridge AddWifiBridgeClient() WifiBridge

What works depends on the platform. iOS can’t scan, and Android can’t toggle the radio. GET /_bridge/wifi lists the platform’s capabilities, and any call it lacks returns 501. Linux uses NetworkManager through Shiny.Net.Wifi.Linux, which the bridge picks automatically. wifi.changed and wifi.hotspot only run while a page listens to them. Permissions come from Shiny.Net.Wifi: location on Android; the Access Wi-Fi Information and Hotspot Configuration entitlements on iOS.

import { WifiBridge } from "@shinyorg/appdevicebridge";
const wifi = new WifiBridge();
await wifi.requestAccess();
const networks = await wifi.scan();
networks.sort((a, b) => b.signalStrengthPercent - a.signalStrengthPercent);
await wifi.onChanged(e => console.log("now on", e.current?.ssid ?? "nothing"));
await wifi.connect({ ssid: "Shop-Floor", passphrase, security: "Wpa2Psk", timeoutMs: 20_000 });
GET/_bridge/wifi#

What this platform can do, the current network, and whether a hotspot is available.

C#IWifiBridge.GetStatusAsyncTSWifiBridge.getStatus
Response
200 WifiStatus
WifiStatus · 3 fields
capabilitiesWifiCapability[]What this platform can do. Calls outside it fail with 501.
currentWifiNetworkInfo | nullThe network the device is on, where the platform can tell.
hotspotSupportedbooleanWhether the app registered the hotspot and the platform supports one.
POST/_bridge/wifi/access#

Requests the permission Wi-Fi needs here — location on Android.

C#IWifiBridge.RequestAccessAsyncTSWifiBridge.requestAccess
Response
200 WifiAccessResult
WifiAccessResult · 1 field
accessAccessState
GET/_bridge/wifi/networks#

Scans for networks in range.

C#IWifiBridge.ScanAsyncTSWifiBridge.scan
Response
200 WifiScanResult[]
WifiScanResult · 10 fields
ssidstring
bssidstring | null
securityWifiSecurity
signalStrengthDbmnumber | null
signalStrengthPercentnumber
frequencyMhznumber | null
bandWifiBand
channelnumber | null
isHiddenboolean
isOpenboolean
GET/_bridge/wifi/current#

The network the device is on. Null when it is not on Wi-Fi.

C#IWifiBridge.GetCurrentNetworkAsyncTSWifiBridge.getCurrentNetwork
Response
200 WifiNetworkInfo · or 204 when there is none
WifiNetworkInfo · 13 fields
interfaceNamestring
ssidstring | null
bssidstring | null
securityWifiSecurity
ipAddressesstring[]
dnsAddressesstring[]
gatewaystring | null
subnetMaskstring | null
signalStrengthDbmnumber | null
signalStrengthPercentnumber | null
frequencyMhznumber | null
bandWifiBand
channelnumber | null
POST/_bridge/wifi/connection#

Joins a network by SSID, or a saved one by id. iOS asks the user first. Fails with 409 when the connection fails, 403 when permission is missing.

C#IWifiBridge.ConnectAsyncTSWifiBridge.connect
Body
application/json · WifiConnectRequest
WifiConnectRequest · 8 fields
ssidstring | null
passphrasestring | null
securityWifiSecurity
bssidstring | nullJoin this access point in particular.
isHiddenboolean
rememberbooleanSave the network on the device.
timeoutMsnumber | nullHow long to wait for the connection, in milliseconds; the platform's default when null.
knownNetworkIdstring | nullA saved network's id, instead of an SSID.
Response
200 WifiNetworkInfo
WifiNetworkInfo · 13 fields
interfaceNamestring
ssidstring | null
bssidstring | null
securityWifiSecurity
ipAddressesstring[]
dnsAddressesstring[]
gatewaystring | null
subnetMaskstring | null
signalStrengthDbmnumber | null
signalStrengthPercentnumber | null
frequencyMhznumber | null
bandWifiBand
channelnumber | null
Errors
403Forbidden409Conflict
DELETE/_bridge/wifi/connection#

Disconnects from the current network.

C#IWifiBridge.DisconnectAsyncTSWifiBridge.disconnect
Response
204 No content
GET/_bridge/wifi/known#

The networks saved on the device that this app can see.

C#IWifiBridge.GetKnownNetworksAsyncTSWifiBridge.getKnownNetworks
Response
200 KnownWifiNetwork[]
KnownWifiNetwork · 5 fields
idstringAn int on Android, a UUID on Linux, the SSID itself on Apple platforms.
ssidstring
securityWifiSecurity
isHiddenboolean
addedByThisAppboolean
DELETE/_bridge/wifi/known#

Forgets a saved network.

C#IWifiBridge.ForgetAsyncTSWifiBridge.forget
ParameterInType
idquerystringrequired
Response
204 No content
GET/_bridge/wifi/radio#

Whether the Wi-Fi radio is on.

C#IWifiBridge.GetRadioAsyncTSWifiBridge.getRadio
Response
200 WifiRadioState
WifiRadioState · 1 field
enabledboolean
PUT/_bridge/wifi/radio#

Turns the Wi-Fi radio on or off.

C#IWifiBridge.SetRadioAsyncTSWifiBridge.setRadio
Body
application/json · WifiRadioState
WifiRadioState · 1 field
enabledboolean
Response
204 No content
GET/_bridge/wifi/hotspot#

Whether a hotspot is supported and running.

C#IWifiBridge.GetHotspotAsyncTSWifiBridge.getHotspot
Response
200 HotspotStatus
HotspotStatus · 3 fields
supportedbooleanWhether the platform supports a hotspot and the app registered it.
runningbooleanWhether one this app started is running.
currentHotspotInfo | nullThe hotspot, when one is running.
POST/_bridge/wifi/hotspot#

Starts a hotspot. Every field of the request is optional; the platform picks what is not given.

C#IWifiBridge.StartHotspotAsyncTSWifiBridge.startHotspot
Body
application/json · HotspotStartRequest
HotspotStartRequest · 4 fields
ssidstring | null
passphrasestring | null
bandWifiBand
isHiddenboolean
Response
200 HotspotInfo
HotspotInfo · 5 fields
ssidstring
passphrasestring | null
securityWifiSecurity
bandWifiBand
addressstring | null
DELETE/_bridge/wifi/hotspot#

Stops the hotspot.

C#IWifiBridge.StopHotspotAsyncTSWifiBridge.stopHotspot
Response
204 No content
GET/_bridge/wifi/hotspot/clients#

The devices connected to a hotspot this app started. Fails with 409 when it is not running.

C#IWifiBridge.GetHotspotClientsAsyncTSWifiBridge.getHotspotClients
Response
200 HotspotClient[]
HotspotClient · 3 fields
macAddressstring
ipAddressstring | null
hostNamestring | null
Errors
409Conflict
EVENTwifi.changed#

The device joined, left or changed networks.

C#IWifiBridge.OnChangedAsyncTSWifiBridge.onChanged
Payload
WifiChangedEvent
currentWifiNetworkInfo | nullThe network now; null when the device left Wi-Fi.
EVENTwifi.hotspot#

The hotspot started, stopped or changed.

C#IWifiBridge.OnHotspotChangedAsyncTSWifiBridge.onHotspotChanged
Payload
HotspotChangedEvent
currentHotspotInfo | nullThe hotspot now; null when it stopped.

JSON property names are camelCase and enums travel as their names. A ? marks a property the payload may omit;| null one that may be null.

WifiStatusobject#

Wi-Fi on this device.

capabilitiesWifiCapability[]What this platform can do. Calls outside it fail with 501.
currentWifiNetworkInfo | nullThe network the device is on, where the platform can tell.
hotspotSupportedbooleanWhether the app registered the hotspot and the platform supports one.
WifiCapabilityenum#

Something a platform's Wi-Fi can do.

"Scan""Connect""Disconnect""CurrentNetwork""RadioState""RadioToggle""Hotspot""HotspotCustomConfiguration""HotspotClients""KnownNetworks""ForgetNetwork""ConnectKnownNetwork"
WifiNetworkInfoobject#

The network the device is on.

interfaceNamestring
ssidstring | null
bssidstring | null
securityWifiSecurity
ipAddressesstring[]
dnsAddressesstring[]
gatewaystring | null
subnetMaskstring | null
signalStrengthDbmnumber | null
signalStrengthPercentnumber | null
frequencyMhznumber | null
bandWifiBand
channelnumber | null
WifiSecurityenum#
"Unknown""Open""Wep""WpaPsk""Wpa2Psk""Wpa3Psk""Enterprise""Owe""Psk"
WifiBandenum#
"Unknown""TwoPointFourGhz""FiveGhz""SixGhz"
AccessStateenum#

Where a permission stands. Reported by every bridge that needs one; the names match Shiny's own.

"Unknown""NotSupported""NotSetup""Disabled""Restricted""Denied""Available"
WifiScanResultobject#

A network in range.

ssidstring
bssidstring | null
securityWifiSecurity
signalStrengthDbmnumber | null
signalStrengthPercentnumber
frequencyMhznumber | null
bandWifiBand
channelnumber | null
isHiddenboolean
isOpenboolean
WifiConnectRequestobject#

A network to join: by ssid, or a saved one by knownNetworkId.

ssid?string | null
passphrase?string | null
security?WifiSecurity
bssid?string | nullJoin this access point in particular.
isHidden?boolean
remember?booleanSave the network on the device.
timeoutMs?number | nullHow long to wait for the connection, in milliseconds; the platform's default when null.
knownNetworkId?string | nullA saved network's id, instead of an SSID.
KnownWifiNetworkobject#

A network saved on the device.

idstringAn int on Android, a UUID on Linux, the SSID itself on Apple platforms.
ssidstring
securityWifiSecurity
isHiddenboolean
addedByThisAppboolean
WifiRadioStateobject#
enabledboolean
HotspotStatusobject#
supportedbooleanWhether the platform supports a hotspot and the app registered it.
runningbooleanWhether one this app started is running.
currentHotspotInfo | nullThe hotspot, when one is running.
HotspotInfoobject#

A running hotspot.

ssidstring
passphrasestring | null
securityWifiSecurity
bandWifiBand
addressstring | null
HotspotStartRequestobject#

A hotspot to start. Every field is optional.

ssid?string | null
passphrase?string | null
band?WifiBand
isHidden?boolean
HotspotClientobject#

A device connected to the hotspot.

macAddressstring
ipAddressstring | null
hostNamestring | null
WifiChangedEventobject#
currentWifiNetworkInfo | nullThe network now; null when the device left Wi-Fi.
HotspotChangedEventobject#
currentHotspotInfo | nullThe hotspot now; null when it stopped.

These routes sit under AppDeviceBridgePolicies.Bridges like every other bridge: callers on this device by default. See Security.