wifi
The sos.management.wifi API groups together methods for managing Wi-Fi setup on the device.
Internal state
The sos.management.wifi API may be in 3 states:
disabled- Wi-Fi is disabled. This state is persistent between reboots.client- Wi-Fi is in the client state, i.e., it is capable of connecting to a network, similarly to a phone or laptop. This state is persistent between reboots with all of its configuration.ap- Wi-Fi is in access point state, i.e., it itself becomes a Wi-Fi network that others can connect to. This state persists between reboots and will be switched to the DISABLED state.
You can use enableClient()/disable() method to enable
or disable the client state, or you can use enableAP()/disableAP() to turn on or off the ap state. It is not possible to go
from client state to ap state directly, the state has to be disabled first.
Wi-Fi Management Capabilities
| Capability | Description |
|---|---|
WIFI | If device supports Wi-Fi setup connection |
WIFI_SCAN | If device supports Wi-Fi scanning |
WIFI_AP | If device supports Wi-Fi Access Point setup |
WIFI_STRENGTH | If device supports Wi-Fi signal strength measurement |
WIFI_COUNTRY | If device supports Wi-Fi country code configuration |
If you want to check if the device supports those capabilities, use sos.management.supports().
Methods
connect()
The connect() method connects the device to a specified Wi-Fi network.
On Tizen, make sure that the connection credentials are correct. If the device fails to connect, it will not retry automatically. Make sure that you have a backup script or a checking mechanism in place, which will allow you to recover from the situation if the connection fails.
- The security type of Wi-Fi is mandatory for Tizen.
- Please note, that Brightsign players use USB drive to read certificates for EAP authentication. For more information check our documentation How to use Wi-Fi Enterprise.
connect(ssid: string, password?: string, options?: IWifiConnectOptions): Promise<void>;
Params
| Name | Type | Required | Description |
|---|---|---|---|
ssid | string | Yes | Name of the network, max. allowed length is 32 characters. |
password | string | No | Password of the device, must be between 8 and 32 characters. |
options | IWifiConnectOptions<IEAPConfig> | No | Additional options for the connection. |
options.hidden | boolean | undefined | No | If the network is hidden, defaults to false. |
options.securityType | WifiEncryptionType | undefined | No | The security type of the network. |
options.eap | IEAPConfig | undefined | No | Authentication details for networks that require EAP. |
options.eap.method | "TLS" | Yes | The type of EAP authentication to use. |
options.eap.identity | string | Yes | Username or identity for authentication. |
options.eap.identityPassword | string | No | Identity password for authentication. |
options.eap.anonymousIdentity | string | No | Anonymous identity for authentication, if required by the EAP method. |
options.eap.phase2Auth | EAPPhase2Auth | No | Secondary authentication method, if required by the EAP method. |
options.eap.useCACert | boolean | Yes | Whether to use a CA certificate for authentication. |
options.eap.caCertificate | string | Yes | The CA certificate to use for authentication, if useCACert is true. |
options.eap.clientCertificate | string | Yes | The client certificate to use for authentication, if required by the EAP method. |
options.eap.privateKey | string | Yes | The private key to use for authentication, if required by the EAP method. |
options.eap.privateKeyPassword | string | No | The password for the private key, if it's encrypted. |
Return value
A promise that resolves when the connection is established or if the connection fails.
Possible errors
- Error If the Wi-Fi state is not in the
clientstate. - Error If the
ssidis not a string or is empty. - Error If the
passwordis not a string - Error If the
optionsis not an object or does not match the expected schema. - Error If the
securityTypeis not one of the allowed values.
Example
// To connect an open Wi-Fi network with an empty password
await sos.management.wifi.connect('MyOpenNetwork', undefined, { securityType: 'OPEN' });
// If the network is hidden
await sos.management.wifi.connect('MyOpenNetwork', undefined, { hidden: true, securityType: 'WPA2' });
// To connect to an encrypted Wi-Fi network with WPA2 security
await sos.management.wifi.connect('MyEncryptedNetwork', 'my-password', { securityType: 'WPA2' });
// To connect to an enterprise Wi-Fi network using EAP
await sos.management.wifi.connect('MyEnterpriseNetwork', 'identity-password', {
securityType: '802.1X_EAP',
eap: {
method: 'PEAP',
identity: 'my-username',
phase2Auth: 'MSCHAPV2',
useCACert: true,
caCertificate: '-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----',
},
});
// To connect to an enterprise Wi-Fi network using EAP-TTLS with a CA certificate
await sos.management.wifi.connect('MyEnterpriseNetwork', 'identity-password', {
securityType: '802.1X_EAP',
eap: {
method: 'TTLS',
identity: 'my-username',
useCACert: true,
caCertificate: '-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----',
},
});
disable()
The disable() method switches the Wi-Fi state to disabled and disconnects from the connected Wi-Fi.
All previously configured networks will be forgotten.
disable(): Promise<void>;
Return value
A promise that resolves when the Wi-Fi is disabled.
Possible errors
Error If the Wi-Fi state is in the client or ap state.
Example
await sos.management.wifi.disable();
disconnect()
The disconnect() method disconnects the device from the Wi-Fi network.
This method will not disable the Wi-Fi client; it will just disconnect from the currently connected network.
disconnect(): Promise<void>;
Return value
A promise that resolves when the device is disconnected from the network.
Possible errors
Error If the Wi-Fi state is not in the client state.
Example
await sos.management.wifi.disconnect();
enableAP()
Sets Wi-Fi to AP state, meaning the device will become a Wi-Fi network that other devices can connect to. It will run in WPA-Personal mode. As such, it requires an SSID (network name) and a password that different devices will use to connect.
- This method is only available on the Linux platform.
- It is not allowed to call this method when in the CLIENT state. You must first switch to the DISABLED state.
- Before calling this method, make sure the device supports Wi-Fi AP via
sos.management.supports("WIFI_AP")
enableAP(ssid: string, password: string): Promise<void>;
Params
| Name | Type | Required | Description |
|---|---|---|---|
ssid | string | Yes | Name of the network, max. allowed length is 32 characters. |
password | string | Yes | Password of the device, must be between 8 and 32 characters. |
Return value
A promise that resolves when the Wi-Fi is enabled in AP mode.
Possible errors
Error If the Wi-Fi state is in the client state.
enableClient()
The enabledClient() method switches the Wi-Fi state from disabled to client state.
enableClient(): Promise<void>;
Return value
A promise that resolves when the Wi-Fi is enabled in client mode.
Possible errors
Error If the Wi-Fi state is in the ap state.
getConnectedTo()
The getConnectedTo() method returns the network the device is currently connected to.
getConnectedTo(): Promise<IWifiDevice | null>;
Return value
An object containing the SSID, whether the network is encrypted, and the signal strength.
If the device is not connected to any network, it returns null.
Possible errors
Error If the Wi-Fi state is not in the client state.
Example
// To get the network the device is currently connected to
const connectedTo = await sos.management.wifi.getConnectedTo();
console.log(`Connected to SSID: ${connectedTo?.ssid}, Strength: ${connectedTo?.strength}`);