@signageos/front-applet 8.2.1 → 8.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +1 -1
- package/dist/bundle.js.map +1 -1
- package/docs/index.md +9 -9
- package/docs/sos/browser.md +11 -3
- package/docs/sos/display.md +13 -20
- package/docs/sos/fileSystem.md +31 -6
- package/docs/sos/hardware/barcodeScanner.md +9 -0
- package/docs/sos/hardware/index.md +9 -0
- package/docs/sos/native/mdc.md +8 -3
- package/docs/sos/osd.md +9 -0
- package/docs/sos/video.md +9 -0
- package/docs/sos_management/app.md +97 -18
- package/docs/sos_management/audio.md +43 -2
- package/docs/sos_management/autoRecovery.md +101 -0
- package/docs/sos_management/debug.md +84 -1
- package/docs/sos_management/firmware.md +64 -1
- package/docs/sos_management/index.md +217 -19
- package/docs/sos_management/network.md +84 -29
- package/docs/sos_management/os.md +59 -4
- package/docs/sos_management/package.md +25 -3
- package/docs/sos_management/power.md +142 -18
- package/docs/sos_management/proxy.md +54 -3
- package/docs/sos_management/remoteControl.md +55 -4
- package/docs/sos_management/screen.md +140 -29
- package/docs/sos_management/security.md +48 -5
- package/docs/sos_management/time.md +76 -9
- package/docs/sos_management/wifi.md +207 -45
- package/es6/FrontApplet/Browser/Browser.d.ts +11 -3
- package/es6/FrontApplet/Browser/Browser.js +11 -3
- package/es6/FrontApplet/Browser/Browser.js.map +1 -1
- package/es6/FrontApplet/Command/Command.js +1 -0
- package/es6/FrontApplet/Command/Command.js.map +1 -1
- package/es6/FrontApplet/Display/Display.d.ts +14 -19
- package/es6/FrontApplet/Display/Display.js +14 -19
- package/es6/FrontApplet/Display/Display.js.map +1 -1
- package/es6/FrontApplet/FileSystem/FileSystem.d.ts +27 -5
- package/es6/FrontApplet/FileSystem/FileSystem.js +27 -5
- package/es6/FrontApplet/FileSystem/FileSystem.js.map +1 -1
- package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.d.ts +9 -0
- package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.js +9 -0
- package/es6/FrontApplet/Hardware/BarcodeScanner/BarcodeScanner.js.map +1 -1
- package/es6/FrontApplet/Hardware/Hardware.d.ts +9 -0
- package/es6/FrontApplet/Hardware/Hardware.js +9 -0
- package/es6/FrontApplet/Hardware/Hardware.js.map +1 -1
- package/es6/FrontApplet/Management/App/App.d.ts +53 -17
- package/es6/FrontApplet/Management/App/App.js +23 -12
- package/es6/FrontApplet/Management/App/App.js.map +1 -1
- package/es6/FrontApplet/Management/App/IApp.d.ts +3 -0
- package/es6/FrontApplet/Management/Audio/Audio.d.ts +24 -3
- package/es6/FrontApplet/Management/Audio/Audio.js +24 -3
- package/es6/FrontApplet/Management/Audio/Audio.js.map +1 -1
- package/es6/FrontApplet/Management/AutoRecovery/AutoRecovery.d.ts +49 -3
- package/es6/FrontApplet/Management/AutoRecovery/AutoRecovery.js +49 -3
- package/es6/FrontApplet/Management/AutoRecovery/AutoRecovery.js.map +1 -1
- package/es6/FrontApplet/Management/Debug/Debug.d.ts +44 -2
- package/es6/FrontApplet/Management/Debug/Debug.js +43 -1
- package/es6/FrontApplet/Management/Debug/Debug.js.map +1 -1
- package/es6/FrontApplet/Management/Firmware/Firmware.d.ts +41 -4
- package/es6/FrontApplet/Management/Firmware/Firmware.js +33 -0
- package/es6/FrontApplet/Management/Firmware/Firmware.js.map +1 -1
- package/es6/FrontApplet/Management/Management.d.ts +119 -21
- package/es6/FrontApplet/Management/Management.js +119 -22
- package/es6/FrontApplet/Management/Management.js.map +1 -1
- package/es6/FrontApplet/Management/Network/Network.d.ts +44 -25
- package/es6/FrontApplet/Management/Network/Network.js +28 -14
- package/es6/FrontApplet/Management/Network/Network.js.map +1 -1
- package/es6/FrontApplet/Management/OS/IOS.d.ts +3 -0
- package/es6/FrontApplet/Management/OS/OS.d.ts +32 -4
- package/es6/FrontApplet/Management/OS/OS.js +32 -4
- package/es6/FrontApplet/Management/OS/OS.js.map +1 -1
- package/es6/FrontApplet/Management/Package/Package.d.ts +18 -3
- package/es6/FrontApplet/Management/Package/Package.js +18 -4
- package/es6/FrontApplet/Management/Package/Package.js.map +1 -1
- package/es6/FrontApplet/Management/Power/IPower.d.ts +3 -0
- package/es6/FrontApplet/Management/Power/IPower.js.map +1 -1
- package/es6/FrontApplet/Management/Power/Power.d.ts +67 -20
- package/es6/FrontApplet/Management/Power/Power.js +70 -24
- package/es6/FrontApplet/Management/Power/Power.js.map +1 -1
- package/es6/FrontApplet/Management/Proxy/Proxy.d.ts +28 -3
- package/es6/FrontApplet/Management/Proxy/Proxy.js +28 -3
- package/es6/FrontApplet/Management/Proxy/Proxy.js.map +1 -1
- package/es6/FrontApplet/Management/RemoteControl/RemoteControl.d.ts +23 -5
- package/es6/FrontApplet/Management/RemoteControl/RemoteControl.js +23 -5
- package/es6/FrontApplet/Management/RemoteControl/RemoteControl.js.map +1 -1
- package/es6/FrontApplet/Management/Screen/Screen.d.ts +77 -32
- package/es6/FrontApplet/Management/Screen/Screen.js +65 -26
- package/es6/FrontApplet/Management/Screen/Screen.js.map +1 -1
- package/es6/FrontApplet/Management/Security/Security.d.ts +25 -7
- package/es6/FrontApplet/Management/Security/Security.js +25 -7
- package/es6/FrontApplet/Management/Security/Security.js.map +1 -1
- package/es6/FrontApplet/Management/Time/Time.d.ts +47 -11
- package/es6/FrontApplet/Management/Time/Time.js +29 -7
- package/es6/FrontApplet/Management/Time/Time.js.map +1 -1
- package/es6/FrontApplet/Management/Wifi/IWifi.d.ts +3 -0
- package/es6/FrontApplet/Management/Wifi/IWifi.js.map +1 -1
- package/es6/FrontApplet/Management/Wifi/Wifi.d.ts +137 -42
- package/es6/FrontApplet/Management/Wifi/Wifi.js +137 -42
- package/es6/FrontApplet/Management/Wifi/Wifi.js.map +1 -1
- package/es6/FrontApplet/NativeCommands/MDC/Mdc.d.ts +8 -3
- package/es6/FrontApplet/NativeCommands/MDC/Mdc.js +8 -3
- package/es6/FrontApplet/NativeCommands/MDC/Mdc.js.map +1 -1
- package/es6/FrontApplet/OSD/OSD.d.ts +9 -0
- package/es6/FrontApplet/OSD/OSD.js +9 -0
- package/es6/FrontApplet/OSD/OSD.js.map +1 -1
- package/es6/FrontApplet/Video/Video.d.ts +9 -0
- package/es6/FrontApplet/Video/Video.js +9 -0
- package/es6/FrontApplet/Video/Video.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,6 +2,18 @@ import IPostMessage from '../../IPostMessage';
|
|
|
2
2
|
import ITime, { DateTime, IGetTime } from './ITime';
|
|
3
3
|
/**
|
|
4
4
|
* The `sos.management.time` API groups together methods for working with the system time.
|
|
5
|
+
*
|
|
6
|
+
* <details>
|
|
7
|
+
* <summary>Time Management Capabilities</summary>
|
|
8
|
+
* | Capability | Description |
|
|
9
|
+
* |:------------|:-------------|
|
|
10
|
+
* | `SET_TIME` | If the device can set the system time. |
|
|
11
|
+
* | `SET_TIMEZONE` | If the device can set the system timezone. |
|
|
12
|
+
* | `GET_TIMEZONE` | If the device can get the system timezone. |
|
|
13
|
+
* | `NTP_TIME` | If the device can set the NTP server and system timezone. |
|
|
14
|
+
*
|
|
15
|
+
* If you want to check if the device supports those capabilities, use [`sos.management.supports()`](https://developers.signageos.io/sdk/sos_management/#supports).
|
|
16
|
+
* </details>
|
|
5
17
|
*/
|
|
6
18
|
export default class Time implements ITime {
|
|
7
19
|
private messagePrefix;
|
|
@@ -9,9 +21,15 @@ export default class Time implements ITime {
|
|
|
9
21
|
/** @internal */
|
|
10
22
|
constructor(messagePrefix: string, postMessage: IPostMessage<any>);
|
|
11
23
|
/**
|
|
12
|
-
* The `get()` method returns currently set time
|
|
24
|
+
* The `get()` method returns the currently set time from the device.
|
|
13
25
|
*
|
|
26
|
+
* @returns {Promise<IGetTime>} A promise that resolves to the current time with timezone.
|
|
27
|
+
* @throws {Error} If the time cannot be retrieved.
|
|
14
28
|
* @since 4.0.0
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const currentTime = await sos.management.time.get();
|
|
32
|
+
* console.log(`Current time is: ${currentTime.currentDate} in timezone ${currentTime.timezone}`);
|
|
15
33
|
*/
|
|
16
34
|
get(): Promise<IGetTime>;
|
|
17
35
|
/** @deprecated Use `setManual(dateTime, timezone)` instead. */
|
|
@@ -22,36 +40,54 @@ export default class Time implements ITime {
|
|
|
22
40
|
* The `setManual()` method sets the system time and the system timezone and disables NTP server settings.
|
|
23
41
|
*
|
|
24
42
|
* :::warning Setting NTP server and timezone has side effects
|
|
25
|
-
*
|
|
26
43
|
* - **Tizen**: After calling this API, display Reboots!
|
|
27
|
-
* Tizen has limited set of available timezones. Read more here.
|
|
28
|
-
* - **RaspberryPi**: After calling this API, RPi Reboots backend server which can take up to 60 seconds! During the reboot no JS API is
|
|
44
|
+
* Tizen has a limited set of available timezones. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405381271314-Tizen-Timezones-Limited-List-for-NTP).
|
|
45
|
+
* - **RaspberryPi**: After calling this API, RPi Reboots the backend server, which can take up to 60 seconds! During the reboot, no JS API is
|
|
29
46
|
* available. **Always wait for Promise resolution.**
|
|
30
|
-
*
|
|
31
47
|
* :::
|
|
32
48
|
*
|
|
33
49
|
* @param dateTime The date and time to set.
|
|
34
50
|
* @param timezone The timezone to set.
|
|
35
|
-
*
|
|
51
|
+
* @returns {Promise<void>} A promise that resolves when the time is successfully set.
|
|
52
|
+
* @throws {Error} If `dateTime` is not a valid Date or DateTime object.
|
|
53
|
+
* @throws {Error} If `timezone` is not a valid string.
|
|
54
|
+
* @throws {Error} If the time cannot be set.
|
|
36
55
|
* @since 4.0.0
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* // Set the system time to 2023-10-01T12:00:00 in Europe/Prague timezone
|
|
59
|
+
* const dateTime = {
|
|
60
|
+
* year: 2023,
|
|
61
|
+
* month: 10,
|
|
62
|
+
* day: 1,
|
|
63
|
+
* hour: 12,
|
|
64
|
+
* minute: 0,
|
|
65
|
+
* second: 0,
|
|
66
|
+
* }
|
|
67
|
+
* await sos.management.time.setManual(dateTime, 'Europe/Prague');
|
|
37
68
|
*/
|
|
38
69
|
setManual(dateTime: DateTime, timezone: string): Promise<void>;
|
|
39
70
|
/**
|
|
40
71
|
* The `setNTP()` method sets the NTP server and the system timezone.
|
|
41
72
|
*
|
|
42
73
|
* :::warning Setting NTP server and timezone has side effects
|
|
43
|
-
*
|
|
44
74
|
* - **Tizen / WebOS**: After calling this API, display Reboots!
|
|
45
|
-
* Tizen has limited set of available timezones. Read more here.
|
|
46
|
-
* - **RaspberryPi**: After calling this API, RPi Reboots backend server which can take up to 60 seconds! During the reboot no JS API is
|
|
75
|
+
* Tizen has a limited set of available timezones. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405381271314-Tizen-Timezones-Limited-List-for-NTP).
|
|
76
|
+
* - **RaspberryPi**: After calling this API, RPi Reboots the backend server, which can take up to 60 seconds! During the reboot, no JS API is
|
|
47
77
|
* available. **Always wait for Promise resolution.**
|
|
48
|
-
*
|
|
49
78
|
* :::
|
|
50
79
|
*
|
|
51
80
|
* @param ntpServer The NTP server to set.
|
|
52
81
|
* @param timezone The timezone to set.
|
|
53
|
-
*
|
|
82
|
+
* @return {Promise<void>} A promise that resolves when the NTP server and timezone are successfully set.
|
|
83
|
+
* @throws {Error} If `ntpServer` is not a valid string.
|
|
84
|
+
* @throws {Error} If `timezone` is not a valid string.
|
|
85
|
+
* @throws {Error} If the NTP server and timezone cannot be set.
|
|
54
86
|
* @since 4.0.0
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* // Set the NTP server to `pool.ntp.org` and timezone to `Europe/Prague`
|
|
90
|
+
* await sos.management.time.setNTP('pool.ntp.org', 'Europe/Prague');
|
|
55
91
|
*/
|
|
56
92
|
setNTP(ntpServer: string, timezone: string): Promise<void>;
|
|
57
93
|
private getMessage;
|
|
@@ -5,9 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Validate_1 = __importDefault(require("../../Validate/Validate"));
|
|
7
7
|
const ITime_1 = require("./ITime");
|
|
8
|
-
// TODO: add warnings from the old docs, but AFAIK it's not possible to change time in the JS runtime, so the applet has to be always rebooted.
|
|
9
8
|
/**
|
|
10
9
|
* The `sos.management.time` API groups together methods for working with the system time.
|
|
10
|
+
*
|
|
11
|
+
* <details>
|
|
12
|
+
* <summary>Time Management Capabilities</summary>
|
|
13
|
+
* | Capability | Description |
|
|
14
|
+
* |:------------|:-------------|
|
|
15
|
+
* | `SET_TIME` | If the device can set the system time. |
|
|
16
|
+
* | `SET_TIMEZONE` | If the device can set the system timezone. |
|
|
17
|
+
* | `GET_TIMEZONE` | If the device can get the system timezone. |
|
|
18
|
+
* | `NTP_TIME` | If the device can set the NTP server and system timezone. |
|
|
19
|
+
*
|
|
20
|
+
* If you want to check if the device supports those capabilities, use [`sos.management.supports()`](https://developers.signageos.io/sdk/sos_management/#supports).
|
|
21
|
+
* </details>
|
|
11
22
|
*/
|
|
12
23
|
class Time {
|
|
13
24
|
messagePrefix;
|
|
@@ -18,9 +29,15 @@ class Time {
|
|
|
18
29
|
this.postMessage = postMessage;
|
|
19
30
|
}
|
|
20
31
|
/**
|
|
21
|
-
* The `get()` method returns currently set time
|
|
32
|
+
* The `get()` method returns the currently set time from the device.
|
|
22
33
|
*
|
|
34
|
+
* @returns {Promise<IGetTime>} A promise that resolves to the current time with timezone.
|
|
35
|
+
* @throws {Error} If the time cannot be retrieved.
|
|
23
36
|
* @since 4.0.0
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const currentTime = await sos.management.time.get();
|
|
40
|
+
* console.log(`Current time is: ${currentTime.currentDate} in timezone ${currentTime.timezone}`);
|
|
24
41
|
*/
|
|
25
42
|
async get() {
|
|
26
43
|
const { currentTimeWithTimezone } = await this.postMessage({
|
|
@@ -52,18 +69,23 @@ class Time {
|
|
|
52
69
|
* The `setNTP()` method sets the NTP server and the system timezone.
|
|
53
70
|
*
|
|
54
71
|
* :::warning Setting NTP server and timezone has side effects
|
|
55
|
-
*
|
|
56
72
|
* - **Tizen / WebOS**: After calling this API, display Reboots!
|
|
57
|
-
* Tizen has limited set of available timezones. Read more here.
|
|
58
|
-
* - **RaspberryPi**: After calling this API, RPi Reboots backend server which can take up to 60 seconds! During the reboot no JS API is
|
|
73
|
+
* Tizen has a limited set of available timezones. [Read more here](https://docs.signageos.io/hc/en-us/articles/4405381271314-Tizen-Timezones-Limited-List-for-NTP).
|
|
74
|
+
* - **RaspberryPi**: After calling this API, RPi Reboots the backend server, which can take up to 60 seconds! During the reboot, no JS API is
|
|
59
75
|
* available. **Always wait for Promise resolution.**
|
|
60
|
-
*
|
|
61
76
|
* :::
|
|
62
77
|
*
|
|
63
78
|
* @param ntpServer The NTP server to set.
|
|
64
79
|
* @param timezone The timezone to set.
|
|
65
|
-
*
|
|
80
|
+
* @return {Promise<void>} A promise that resolves when the NTP server and timezone are successfully set.
|
|
81
|
+
* @throws {Error} If `ntpServer` is not a valid string.
|
|
82
|
+
* @throws {Error} If `timezone` is not a valid string.
|
|
83
|
+
* @throws {Error} If the NTP server and timezone cannot be set.
|
|
66
84
|
* @since 4.0.0
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* // Set the NTP server to `pool.ntp.org` and timezone to `Europe/Prague`
|
|
88
|
+
* await sos.management.time.setNTP('pool.ntp.org', 'Europe/Prague');
|
|
67
89
|
*/
|
|
68
90
|
async setNTP(ntpServer, timezone) {
|
|
69
91
|
(0, Validate_1.default)({ ntpServer }).required().string();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Time.js","sourceRoot":"","sources":["../../../../src/FrontApplet/Management/Time/Time.ts"],"names":[],"mappings":";;;;;AACA,uEAA+C;AAC/C,mCAA+D;AAE/D
|
|
1
|
+
{"version":3,"file":"Time.js","sourceRoot":"","sources":["../../../../src/FrontApplet/Management/Time/Time.ts"],"names":[],"mappings":";;;;;AACA,uEAA+C;AAC/C,mCAA+D;AAE/D;;;;;;;;;;;;;;GAcG;AACH,MAAqB,IAAI;IAGf;IACA;IAHT,gBAAgB;IAChB,YACS,aAAqB,EACrB,WAA8B;QAD9B,kBAAa,GAAb,aAAa,CAAQ;QACrB,gBAAW,GAAX,WAAW,CAAmB;IACpC,CAAC;IAEJ;;;;;;;;;;OAUG;IACI,KAAK,CAAC,GAAG;QACf,MAAM,EAAE,uBAAuB,EAAE,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC;YAC1D,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,gCAAgC,CAAC;SACvD,CAAC,CAAC;QAEH,OAAO,uBAAuB,CAAC;IAChC,CAAC;IAED,+DAA+D;IACxD,GAAG,CAAC,WAAiB,EAAE,QAAgB;QAC7C,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IAC9C,CAAC;IAqCD,gBAAgB;IACT,KAAK,CAAC,SAAS,CAAC,GAAG,IAA+B;QACxD,MAAM,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;QAErC,IAAI,WAAW,YAAY,IAAI,EAAE,CAAC;YACjC,IAAA,kBAAQ,EAAC,EAAE,WAAW,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC;QAC7C,CAAC;aAAM,CAAC;YACP,IAAA,kBAAQ,EAAC,EAAE,WAAW,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,CAAC,iBAAS,CAAC,CAAC;QACxD,CAAC;QACD,IAAA,kBAAQ,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC;QAE3C,MAAM,IAAI,CAAC,WAAW,CAAC;YACtB,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,gCAAgC,CAAC;YACvD,WAAW;YACX,QAAQ;SACR,CAAC,CAAC;IACJ,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACI,KAAK,CAAC,MAAM,CAAC,SAAiB,EAAE,QAAgB;QACtD,IAAA,kBAAQ,EAAC,EAAE,SAAS,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC;QAC5C,IAAA,kBAAQ,EAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,CAAC;QAC3C,MAAM,IAAI,CAAC,WAAW,CAAC;YACtB,IAAI,EAAE,IAAI,CAAC,UAAU,CAAC,4BAA4B,CAAC;YACnD,SAAS;YACT,QAAQ;SACR,CAAC,CAAC;IACJ,CAAC;IAEO,UAAU,CAAC,IAAY;QAC9B,OAAO,IAAI,CAAC,aAAa,GAAG,GAAG,GAAG,IAAI,CAAC;IACxC,CAAC;CACD;AAvHD,uBAuHC"}
|
|
@@ -17,6 +17,9 @@ export default interface IWifi {
|
|
|
17
17
|
removeListener(event: WifiEvent, listener: (...args: []) => void): void;
|
|
18
18
|
removeAllListeners(event?: WifiEvent): void;
|
|
19
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Interface representing a scanned Wi-Fi device.
|
|
22
|
+
*/
|
|
20
23
|
export interface IScannedDevice {
|
|
21
24
|
ssid: string;
|
|
22
25
|
encrypted: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IWifi.js","sourceRoot":"","sources":["../../../../src/FrontApplet/Management/Wifi/IWifi.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"IWifi.js","sourceRoot":"","sources":["../../../../src/FrontApplet/Management/Wifi/IWifi.ts"],"names":[],"mappings":";;;AAsCa,QAAA,oBAAoB,GAAG;IACnC,MAAM,EAAE,UAAU;IAClB,YAAY,EAAE,SAAS;CACvB,CAAC"}
|
|
@@ -3,25 +3,32 @@ import IWifiMessage, { WifiEvent } from './IWifiEvent';
|
|
|
3
3
|
import { IWifiDevice } from '../Network/INetworkInfo';
|
|
4
4
|
import IWifi, { IScannedDevice, IWifiConnectOptions } from './IWifi';
|
|
5
5
|
/**
|
|
6
|
-
* The `sos.management.wifi` API groups together methods for managing Wi-Fi.
|
|
7
|
-
*
|
|
8
|
-
* :::info
|
|
9
|
-
*
|
|
10
|
-
* Use `sos.management.supports('WIFI')` to check if the device supports managing Wi-Fi setup.
|
|
11
|
-
*
|
|
12
|
-
* :::
|
|
6
|
+
* The `sos.management.wifi` API groups together methods for managing Wi-Fi setup on the device.
|
|
13
7
|
*
|
|
14
8
|
* #### Internal state
|
|
15
9
|
*
|
|
16
10
|
* The `sos.management.wifi` API may be in 3 states:
|
|
17
11
|
*
|
|
18
12
|
* - `disabled` - Wi-Fi is disabled. This state is persistent between reboots.
|
|
19
|
-
* - `client` - Wi-Fi is in the client state, i.e
|
|
20
|
-
* - `ap` - Wi-Fi is in access point state, i.e
|
|
13
|
+
* - `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.
|
|
14
|
+
* - `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.
|
|
21
15
|
*
|
|
22
|
-
* You can use `enableClient()`/`
|
|
23
|
-
* or disable the `client` state or you can use `enableAP()`/`disableAP()` to
|
|
16
|
+
* You can use `enableClient()`/`disable()` method to enable
|
|
17
|
+
* 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
|
|
24
18
|
* from `client` state to `ap` state directly, the state has to be `disabled` first.
|
|
19
|
+
*
|
|
20
|
+
* <details>
|
|
21
|
+
* <summary>Wi-Fi Management Capabilities</summary>
|
|
22
|
+
* | Capability | Description |
|
|
23
|
+
* |:------------|:-------------|
|
|
24
|
+
* | `WIFI` | If device supports Wi-Fi setup connection |
|
|
25
|
+
* | `WIFI_SCAN` | If device supports Wi-Fi scanning |
|
|
26
|
+
* | `WIFI_AP` | If device supports Wi-Fi Access Point setup |
|
|
27
|
+
* | `WIFI_STRENGTH` | If device supports Wi-Fi signal strength measurement |
|
|
28
|
+
* | `WIFI_COUNTRY` | If device supports Wi-Fi country code configuration |
|
|
29
|
+
*
|
|
30
|
+
* If you want to check if the device supports those capabilities, use [`sos.management.supports()`](https://developers.signageos.io/sdk/sos_management/#supports).
|
|
31
|
+
* </details>
|
|
25
32
|
*/
|
|
26
33
|
export default class Wifi implements IWifi {
|
|
27
34
|
private messagePrefix;
|
|
@@ -35,46 +42,68 @@ export default class Wifi implements IWifi {
|
|
|
35
42
|
*
|
|
36
43
|
* @throws Error If the Wi-Fi state is in the `ap` state.
|
|
37
44
|
* @returns {Boolean} if client mode is enabled.
|
|
45
|
+
* @since 4.3.0
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* const isClientEnabled = await sos.management.wifi.isClientEnabled();
|
|
49
|
+
* if (!isClientEnabled) {
|
|
50
|
+
* await sos.management.wifi.enableClient();
|
|
51
|
+
* }
|
|
38
52
|
*/
|
|
39
53
|
isClientEnabled(): Promise<boolean>;
|
|
40
54
|
/**
|
|
41
55
|
* The `enabledClient()` method switches the Wi-Fi state from `disabled` to `client` state.
|
|
42
56
|
*
|
|
57
|
+
* @returns {Promise<void>} A promise that resolves when the Wi-Fi is enabled in client mode.
|
|
43
58
|
* @throws Error If the Wi-Fi state is in the `ap` state.
|
|
59
|
+
* @since 4.3.0
|
|
44
60
|
*/
|
|
45
61
|
enableClient(): Promise<void>;
|
|
46
62
|
/**
|
|
47
63
|
* The `isAPEnabled()` method checks whether the Wi-Fi is in `ap` state.
|
|
48
64
|
*
|
|
49
|
-
* @returns {Boolean}
|
|
65
|
+
* @returns {Boolean} If AP mode is enabled.
|
|
66
|
+
* @since 4.3.0
|
|
50
67
|
*/
|
|
51
68
|
isAPEnabled(): Promise<boolean>;
|
|
52
69
|
/**
|
|
53
|
-
*
|
|
70
|
+
* 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.
|
|
54
71
|
*
|
|
55
|
-
* :::
|
|
56
|
-
*
|
|
72
|
+
* :::note
|
|
73
|
+
* - This method is only available on the Linux platform.
|
|
74
|
+
* - It is not allowed to call this method when in the CLIENT state. You must first switch to the **DISABLED** state.
|
|
75
|
+
* - Before calling this method, make sure the device supports Wi-Fi AP via `sos.management.supports("WIFI_AP")`
|
|
57
76
|
* :::
|
|
58
77
|
*
|
|
78
|
+
* @example // {@link https://github.com/signageos/applet-examples/tree/master/examples/management-js-api/wifi-access-point | Example applet with Wi-Fi access point}
|
|
79
|
+
*
|
|
59
80
|
* @param ssid Name of the network, max. allowed length is 32 characters.
|
|
60
81
|
* @param password Password of the device, must be between 8 and 32 characters.
|
|
61
|
-
*
|
|
82
|
+
* @returns {Promise<void>} A promise that resolves when the Wi-Fi is enabled in AP mode.
|
|
62
83
|
* @throws Error If the Wi-Fi state is in the `client` state.
|
|
84
|
+
* @since 4.3.0
|
|
63
85
|
*/
|
|
64
86
|
enableAP(ssid: string, password: string): Promise<void>;
|
|
65
87
|
/**
|
|
66
|
-
* The `disable()` method switches the Wi-Fi state to `disabled` and
|
|
88
|
+
* The `disable()` method switches the Wi-Fi state to `disabled` and disconnects from the connected Wi-Fi.
|
|
67
89
|
*
|
|
68
90
|
* All previously configured networks will be forgotten.
|
|
91
|
+
*
|
|
92
|
+
* @returns {Promise<void>} A promise that resolves when the Wi-Fi is disabled.
|
|
93
|
+
* @throws Error If the Wi-Fi state is in the `client` or `ap` state.
|
|
94
|
+
* @since 4.3.0
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* await sos.management.wifi.disable();
|
|
69
98
|
*/
|
|
70
99
|
disable(): Promise<void>;
|
|
71
100
|
/**
|
|
72
|
-
* The `getConnectedTo()` method returns
|
|
73
|
-
*
|
|
74
|
-
* @throws Error If the Wi-Fi state is not in the `client` state.
|
|
101
|
+
* The `getConnectedTo()` method returns the network the device is currently connected to.
|
|
75
102
|
*
|
|
76
103
|
* @returns An object containing the SSID, whether the network is encrypted, and the signal strength.
|
|
77
104
|
* If the device is not connected to any network, it returns `null`.
|
|
105
|
+
* @throws Error If the Wi-Fi state is not in the `client` state.
|
|
106
|
+
* @since 4.3.0
|
|
78
107
|
*
|
|
79
108
|
* @example
|
|
80
109
|
* // To get the network the device is currently connected to
|
|
@@ -83,87 +112,153 @@ export default class Wifi implements IWifi {
|
|
|
83
112
|
*/
|
|
84
113
|
getConnectedTo(): Promise<IWifiDevice | null>;
|
|
85
114
|
/**
|
|
86
|
-
* The `connect()` method connects the device to a specified network.
|
|
115
|
+
* The `connect()` method connects the device to a specified Wi-Fi network.
|
|
116
|
+
*
|
|
117
|
+
* :::danger
|
|
118
|
+
* On Tizen, make sure that the connection credentials are correct. If the device fails to connect, it will not retry automatically.
|
|
119
|
+
* 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.
|
|
120
|
+
* :::
|
|
87
121
|
*
|
|
88
122
|
* :::warning
|
|
89
|
-
* Connecting to
|
|
90
|
-
* - For Tizen, make sure that the `password` is an empty string (`''`) and in options you have selected `OPEN` as encryption type.
|
|
123
|
+
* Connecting to an OPEN Wi-Fi network for Tizen and WebOS is different.
|
|
124
|
+
* - For Tizen, make sure that the `password` is an empty string (`''`) and in the options you have selected `OPEN` as encryption type.
|
|
91
125
|
* - For WebOS, you can pass `undefined` as the `password` parameter.
|
|
92
126
|
* :::
|
|
93
127
|
*
|
|
94
128
|
* :::info
|
|
95
|
-
*
|
|
129
|
+
* The security type of Wi-Fi is mandatory for Tizen.
|
|
96
130
|
* :::
|
|
97
131
|
*
|
|
98
132
|
* @param ssid Name of the network, max. allowed length is 32 characters.
|
|
99
133
|
* @param password Password of the device, must be between 8 and 32 characters.
|
|
100
|
-
* @param options Additional options for the connection
|
|
134
|
+
* @param options Additional options for the connection.
|
|
135
|
+
* @param options.hidden If the network is hidden, defaults to `false`.
|
|
136
|
+
* @param options.securityType The security type of the network.
|
|
101
137
|
*
|
|
102
138
|
* @throws Error If the Wi-Fi state is not in the `client` state.
|
|
103
|
-
* @
|
|
139
|
+
* @throws Error If the `ssid` is not a string or is empty.
|
|
140
|
+
* @throws Error If the `password` is not a string or is empty (if required).
|
|
141
|
+
* @throws Error If the `options` is not an object or does not match the expected schema.
|
|
142
|
+
* @throws Error If the `securityType` is not one of the allowed values.
|
|
143
|
+
* @returns {Promise<void>} A promise that resolves when the connection is established or if the connection fails.
|
|
144
|
+
* @since 4.3.0
|
|
104
145
|
*
|
|
105
146
|
* @example
|
|
106
|
-
* // To connect
|
|
147
|
+
* // To connect to an open Wi-Fi network, e.g., WebOS
|
|
107
148
|
* await sos.management.wifi.connect('MyOpenNetwork');
|
|
108
149
|
*
|
|
109
|
-
* // To connect
|
|
150
|
+
* // To connect an open Wi-Fi network with an empty password (Tizen)
|
|
110
151
|
* await sos.management.wifi.connect('MyOpenNetwork', '', { securityType: 'OPEN' });
|
|
111
152
|
*
|
|
112
153
|
* // If the network is hidden
|
|
113
154
|
* await sos.management.wifi.connect('MyOpenNetwork', undefined, { hidden: true });
|
|
114
155
|
*
|
|
115
|
-
* // To connect
|
|
156
|
+
* // To connect to an encrypted Wi-Fi network with WPA2 security
|
|
116
157
|
* await sos.management.wifi.connect('MyEncryptedNetwork', 'my-password', { securityType: 'WPA2' });
|
|
117
158
|
*/
|
|
118
159
|
connect(ssid: string, password?: string, options?: IWifiConnectOptions): Promise<void>;
|
|
119
160
|
/**
|
|
120
|
-
* The `disconnect()` method disconnects the device from Wi-Fi network.
|
|
161
|
+
* The `disconnect()` method disconnects the device from the Wi-Fi network.
|
|
162
|
+
* This method will not disable the Wi-Fi client; it will just disconnect from the currently connected network.
|
|
121
163
|
*
|
|
164
|
+
* @returns {Promise<void>} A promise that resolves when the device is disconnected from the network.
|
|
122
165
|
* @throws Error If the Wi-Fi state is not in the `client` state.
|
|
166
|
+
* @since 4.3.0
|
|
167
|
+
*
|
|
168
|
+
* @example
|
|
169
|
+
* await sos.management.wifi.disconnect();
|
|
123
170
|
*/
|
|
124
171
|
disconnect(): Promise<void>;
|
|
125
172
|
/**
|
|
126
|
-
* The `getCountry()` method returns the 2-letter country code to which Wi-Fi regulations the device adheres
|
|
127
|
-
* have different regulations
|
|
128
|
-
* settings. However, if you experience any problems, you might want to try changing Wi-Fi country configuration to your country.
|
|
173
|
+
* The `getCountry()` method returns the 2-letter country code to which Wi-Fi regulations the device adheres. Different countries may
|
|
174
|
+
* have different regulations when it comes to the Wi-Fi networks. Under normal circumstances, everything should work with the default
|
|
175
|
+
* settings. However, if you experience any problems, you might want to try changing the Wi-Fi country configuration to your country.
|
|
129
176
|
*
|
|
130
177
|
* @throws Error If the Wi-Fi state is not in the `client` state.
|
|
131
|
-
* @returns
|
|
178
|
+
* @returns {Promise<string | null>} A promise that resolves to the 2-letter country code from the ISO 3166 standard, or `null` if not set.
|
|
179
|
+
* @since 4.3.0
|
|
180
|
+
*
|
|
181
|
+
* @example
|
|
182
|
+
* const countryCode = await sos.management.wifi.getCountry();
|
|
183
|
+
* console.log(`Current Wi-Fi country code is: ${countryCode}`); // e.g. 'US', 'CZ', etc.
|
|
132
184
|
*/
|
|
133
185
|
getCountry(): Promise<string | null>;
|
|
134
186
|
/**
|
|
135
|
-
* The `
|
|
136
|
-
* have different regulations
|
|
137
|
-
* settings. However, if you experience any problems, you might want to try changing Wi-Fi country configuration to your country.
|
|
187
|
+
* The `setCountry()` method sets the 2-letter country code for the Wi-Fi settings. Different countries may
|
|
188
|
+
* have different regulations when it comes to the Wi-Fi networks. Under normal circumstances, everything should work with the default
|
|
189
|
+
* settings. However, if you experience any problems, you might want to try changing the Wi-Fi country configuration to your country.
|
|
190
|
+
*
|
|
191
|
+
* :::note
|
|
192
|
+
* This method is only available on the Linux platform.
|
|
193
|
+
* :::
|
|
138
194
|
*
|
|
139
195
|
* @param countryCode 2-letter country code from the ISO 3166 standard.
|
|
196
|
+
* @returns {Promise<void>} A promise that resolves when the country code is set.
|
|
140
197
|
* @throws Error If the Wi-Fi state is not in the `client` state.
|
|
198
|
+
* @since 4.3.0
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* // To set the country code to the United States
|
|
202
|
+
* await sos.management.wifi.setCountry('US');
|
|
141
203
|
*/
|
|
142
204
|
setCountry(countryCode: string): Promise<void>;
|
|
143
205
|
/**
|
|
144
206
|
* The `scanDevices()` method initializes a new network scan and available networks.
|
|
145
207
|
*
|
|
146
|
-
*
|
|
147
|
-
* Use `sos.management.supports('WIFI_SCAN')` to check if the device supports scanning for devices.
|
|
148
|
-
* :::
|
|
149
|
-
*
|
|
208
|
+
* @returns {Promise<IScannedDevice[]>} A promise that resolves to an array of scanned devices.
|
|
150
209
|
* @throws Error If the Wi-Fi state is not in the `client` state.
|
|
210
|
+
* @since 4.3.0
|
|
211
|
+
*
|
|
212
|
+
* @example
|
|
213
|
+
* const scannedDevices = await sos.management.wifi.scanDevices();
|
|
214
|
+
* scannedDevices.forEach(device => {
|
|
215
|
+
* console.log(`Found Wi-Fi network: ${device.ssid}, Encrypted: ${device.encrypted}`);
|
|
216
|
+
* });
|
|
151
217
|
*/
|
|
152
218
|
scanDevices(): Promise<IScannedDevice[]>;
|
|
153
219
|
/**
|
|
154
220
|
* The `on()` method sets up a listener, which is called whenever the specified event occurs.
|
|
221
|
+
*
|
|
222
|
+
* @param event The event for which to set up the listener.
|
|
223
|
+
* @param listener The listener function to call when the event occurs.
|
|
224
|
+
* @returns {void} Resolves when the listener is set up.
|
|
225
|
+
* @since 4.3.0
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* sos.management.wifi.on(WifiEvent.CLIENT_ENABLED, () => {
|
|
229
|
+
* console.log('Wi-Fi client is enabled');
|
|
230
|
+
* });
|
|
155
231
|
*/
|
|
156
232
|
on(event: WifiEvent, listener: () => void): void;
|
|
157
233
|
/**
|
|
158
234
|
* The `on()` method sets up a **one-time** listener, which is called whenever the specified event occurs.
|
|
235
|
+
*
|
|
236
|
+
* @param event The event for which to set up the listener.
|
|
237
|
+
* @param listener The listener function to call when the event occurs.
|
|
238
|
+
* @returns {void} Resolves when the listener is set up.
|
|
239
|
+
* @since 4.3.0
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* sos.management.wifi.once(WifiEvent.CLIENT_CONNECTED, () => {
|
|
243
|
+
* console.log('Wi-Fi client is connected');
|
|
244
|
+
* });
|
|
159
245
|
*/
|
|
160
246
|
once(event: WifiEvent, listener: () => void): void;
|
|
161
247
|
/**
|
|
162
248
|
* The `removeListener()` method removes a listener previously set up by `on()` or `once()` methods.
|
|
249
|
+
*
|
|
250
|
+
* @param event The event for which to remove the listener.
|
|
251
|
+
* @param listener The listener function to remove.
|
|
252
|
+
* @returns {void} Resolves when the listener is removed.
|
|
253
|
+
* @since 4.3.0
|
|
163
254
|
*/
|
|
164
255
|
removeListener(event: WifiEvent, listener: () => void): void;
|
|
165
256
|
/**
|
|
166
|
-
* The `removeAllListeners()` method removes all listeners for a specified event or
|
|
257
|
+
* The `removeAllListeners()` method removes all listeners for a specified event or all events.
|
|
258
|
+
*
|
|
259
|
+
* @param event The event for which to remove all listeners. If not specified, all listeners for all events will be removed.
|
|
260
|
+
* @returns {void} Resolves when all listeners are removed.
|
|
261
|
+
* @since 4.3.0
|
|
167
262
|
*/
|
|
168
263
|
removeAllListeners(event?: WifiEvent): void;
|
|
169
264
|
/** @internal */
|