### POST /startWps Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/src/js_deviceInfo.js.html Starts Wi-Fi Protected Setup (WPS) using either Push Button Configuration (PBC) or PIN method. ```APIDOC ## POST /startWps ### Description Initiates the WPS process. For PBC, push the button on the router after calling. For PIN, the returned PIN must be entered into the router's settings. ### Method POST ### Endpoint luna://com.webos.service.commercial.signage.storageservice/network/startWps ### Parameters #### Request Body - **method** (String) - Required - 'PBC' or 'PIN' ### Request Example { "method": "PBC" } ### Response #### Success Response (200) - **pin** (String) - The PIN code (only returned if method is 'PIN') #### Response Example { "pin": "12345678" } ``` -------------------------------- ### Start Wi-Fi Protected Setup (WPS) Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/src/js_deviceInfo.js.html Initiates WPS using either PBC or PIN methods. The PBC method requires physical interaction with the router, while the PIN method returns a PIN code via the success callback. ```javascript function startWpsbyPBC () { function successCb() { console.log("successCb"); } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code [" + errorCode + "]: " + errorText); } var deviceInfo = new DeviceInfo(); var options = { method : "PBC" }; deviceInfo.startWps(successCb, failureCb, options); } function startWpsbyPIN () { function successCb(cbObject) { console.log("successCb PIN : " + cbObject.pin); } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code [" + errorCode + "]: " + errorText); } var deviceInfo = new DeviceInfo(); var options = { method : "PIN" }; deviceInfo.startWps(successCb, failureCb, options); } ``` -------------------------------- ### scap_installation.json Example Configuration Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/src/js_configuration.js.html This is an example of a scap_installation.json file, demonstrating the correct format and values for configuring server properties. It includes settings for server IP, port, secure connection, app launch mode, FQDN mode, and FQDN address. ```json { "serverIp":"10.177.211.51", "serverPort":80, "secureConnection":false, "appLaunchMode":"local", "fqdnMode":true, "fqdnAddr":"http://192.168.0.1:2000/lgapp.zip" } ``` -------------------------------- ### Storage#fsync Example - Sync Whole Filesystem Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/Storage This example shows how to synchronize the entire filesystem using Storage#fsync without specifying a particular path. It relies on the default behavior of the fsync method when options are empty. ```javascript function fsync() { // This example will sync whole file system. var failureCb = function(cbObject){ var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log( " Error Code \[" + errorCode + "\]: " + errorText); }; storage.copyFile( function(){ // Copy was success. fsync the device. storage.fsync( function(){ // Success callback for fsync console.log("File synched!!!!!!!!!!"); }, failureCb, // Failure Callback {} // Options - empty options syncs the whole filesystem ); }, failureCb, // Failure Callback for copyFile {source:"file://internal/this.jpg", destination:"file://usb:1/file.jpg"} // Options for copyFile ); } ``` -------------------------------- ### Start WPS by PIN - DeviceInfo JavaScript Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/DeviceInfo Initiates Wi-Fi Protected Setup (WPS) using the PIN method. It requires success and error callback functions. The success callback receives a PIN which should be entered into the router's settings. The options object must specify the method as 'PIN'. ```javascript function startWpsbyPIN () { function successCb(cbObject) { console.log("successCb PIN : " + cbObject.pin); } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code \[" + errorCode + "\]: " + errorText); } var deviceInfo = new DeviceInfo(); var options = { method : "PIN" }; deviceInfo.startWps(successCb, failureCb, options); } ``` -------------------------------- ### Change Input Source Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/src/js_inputSource.js.html Example usage for changing the current input source after the initial setup. It requires an options object containing the new source string. ```javascript function changeInputSource () { var options = { src : "ext://hdmi:1" }; function successCb() { // Do something } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code [" + errorCode + "]: " + errorText); } var inputSource = new InputSource(); inputSource.change(successCb, failureCb, options); } ``` -------------------------------- ### Storage#fsync Example - Copy and Sync File Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/Storage This example demonstrates how to copy a file to USB storage and then synchronize it to the filesystem using Storage#fsync. It includes success and error callback handling. ```javascript function fsync() { // This example will copy a file to USB and sync it. var failureCb = function(cbObject){ var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log( " Error Code \[" + errorCode + "\]: " + errorText); }; var storage = new Storage(); storage.copyFile( function(){ // Copy was success. fsync the file. storage.fsync( function(){ // Success callback for fsync console.log("File synched!!!!!!!!!!"); }, failureCb, {path : "file://usb:1/file.jpg"} // Options specifying the file path ); }, failureCb, {source:"file://internal/this.jpg", destination:"file://usb:1/file.jpg"} // Options for copyFile ); } ``` -------------------------------- ### Get System Settings API Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/src/js_signage.js.html An example of how to call the get system settings API for the commercial signage service. ```APIDOC ## POST /settings/ ### Description Retrieves system settings for a specified category and keys. ### Method POST ### Endpoint luna://com.webos.service.commercial.signage.storageservice/settings/ ### Parameters #### Request Body - **category** (String) - Required - The category of settings to retrieve. - **keys** (Array of Strings) - Required - An array of setting keys to retrieve. ### Request Example ```json { "category": "someCategory", "keys": ["key1", "key2"] } ``` ### Response #### Success Response (200) - **errorCode** (Number) - The error code. - **errorText** (String) - The error text. - **result** (Object) - The retrieved settings. #### Response Example ```json { "errorCode": 0, "errorText": "Success", "result": { "key1": "value1", "key2": "value2" } } ``` ``` -------------------------------- ### DeviceInfo#startWps API Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/DeviceInfo API for starting WPS (Wifi Protected Setup) using either Push Button Configuration (PBC) or a PIN. ```APIDOC ## DeviceInfo#startWps ### Description Starts WPS (Wifi Protected Setup) using PBC (Push Button Configuration) or PIN. ### Method POST (Assumed, as it modifies device state) ### Endpoint /webos-tools/cli/deviceInfo/startWps ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **successCallback** (Function) - Required - Callback function to be executed upon successful WPS initiation. - **errorCallback** (Function) - Required - Callback function to be executed if WPS initiation fails. - **options** (Object) - Required - Configuration options for WPS. - **method** (String) - Required - Specifies the WPS method. Can be 'PBC' (Push Button Configuration) or 'PIN'. ### Request Example ```javascript // Example for starting WPS using PBC function startWpsbyPBC () { function successCb() { console.log("successCb"); } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code [" + errorCode + "]: " + errorText); } var deviceInfo = new DeviceInfo(); var options = { method : "PBC" }; deviceInfo.startWps(successCb, failureCb, options); } // Example for starting WPS using PIN function startWpsbyPIN () { function successCb(cbObject) { console.log("successCb PIN : " + cbObject.pin); } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code [" + errorCode + "]: " + errorText); } var deviceInfo = new DeviceInfo(); var options = { method : "PIN" }; deviceInfo.startWps(successCb, failureCb, options); } ``` ### Response #### Success Response (200) - **pin** (String) - If the 'PIN' method is used, this property contains the generated PIN in the success callback. #### Response Example ```json { "pin": "12345678" } ``` ``` -------------------------------- ### Start WPS by PBC - DeviceInfo JavaScript Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/DeviceInfo Initiates Wi-Fi Protected Setup (WPS) using the Push Button Configuration (PBC) method. It requires a success and error callback function, and an options object specifying the method as 'PBC'. ```javascript function startWpsbyPBC () { function successCb() { console.log("successCb"); } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code \[" + errorCode + "\]: " + errorText); } var deviceInfo = new DeviceInfo(); var options = { method : "PBC" }; deviceInfo.startWps(successCb, failureCb, options); } ``` -------------------------------- ### Start WPS Operation Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/src/js_deviceInfo.js.html Initiates the Wi-Fi Protected Setup (WPS) process on the device using the network storage service. It accepts success and error callbacks along with configuration options. ```javascript DeviceInfo.prototype.startWps = function (successCallback, errorCallback, options) { log("startWps: "); service.Request('luna://com.webos.service.commercial.signage.storageservice/network/', { method: 'startWps', parameters: options, onSuccess: function(result) { log("startWps: onSuccess"); delete result.returnValue; if (typeof successCallback === 'function') { successCallback(result); } }, onFailure: function(error) { log("startWps: onFailure"); delete error.returnValue; if (typeof errorCallback === 'function') { errorCallback(error); } } }); log("DeviceInfo.startWps Done"); }; ``` -------------------------------- ### Set Volume Level Usage Example Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/src/js_sound.js.html Example implementation of calling the setVolumeLevel method. It demonstrates how to define an options object containing the desired volume level and OSD visibility preference, along with success and failure callback handlers. ```javascript function setVolumeLevel () { var options = { level : 15, volOsdEnabled : false }; function successCb() { // Handle success } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code [" + errorCode + "]: " + errorText); } } ``` -------------------------------- ### Get Eddystone Info Usage Example Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/src/js_deviceInfo.js.html Example implementation of the getEddystoneInfo function, demonstrating how to handle the returned object containing beacon status and frame details. ```javascript function getEddystoneInfo () { function successCb(cbObject) { console.log("cbObject : " + JSON.stringify(cbObject)); console.log("enabled : " + cbObject.enabled); console.log("frame : " + cbObject.uuid); } } ``` -------------------------------- ### Manage webOS Devices with SetupDevice Source: https://context7.com/webos-tools/cli/llms.txt Demonstrates how to list, add, modify, remove, and set default webOS devices using the SetupDevice module. These operations return promises and handle device configurations through JSON objects. ```javascript const { SetupDevice } = require('@webos-tools/cli'); // List all registered devices SetupDevice.showDeviceList().then(result => console.log(result.msg)).catch(err => console.error(err)); // Add a new device const addOptions = { add: 'myTV', info: JSON.stringify({ host: '192.168.1.100', port: 22, username: 'root' }) }; SetupDevice.modifyDevice(addOptions).then(() => console.log('Device added')).catch(err => console.error(err)); // Set default device SetupDevice.setDefaultDevice('myTV').then(() => console.log('Default set')).catch(err => console.error(err)); ``` -------------------------------- ### Get Failover Mode Example - JavaScript Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/src/js_signage.js.html This is an example of how to use the 'getFailoverMode' method from the Signage class. It defines success and failure callback functions to handle the retrieved failover mode and priority. It requires an instance of the 'Signage' class. ```javascript function getFailoverMode() { var successCb = function (cbObject){ var mode = cbObject.mode; var priority = cbObject.priority console.log('Failover Mode : ' + mode); console.log('Priority : ' + priority); }; var failureCb = function(cbObject){ var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log( " Error Code [" + errorCode + "]: " + errorText); }; var signage = new Signage(); signage.getFailoverMode(successCb, failureCb); } ``` -------------------------------- ### Download Firmware via Storage API Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/Storage Demonstrates how to initialize the Storage object and invoke the downloadFirmware method with success and failure callbacks. The options object must include the URI of the firmware file. ```javascript function downloadFirmware() { var successCb = function () { console.log("Download firmware is successful"); }; var failureCb = function(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log( " Error Code [" + errorCode + "]: " + errorText); }; var options = { uri : "http://example.org/firmware.10-01.00.10_usb_V3_SECURED.epk" }; var storage = new Storage(); storage.downloadFirmware(successCb, failureCb, options); } ``` -------------------------------- ### Usage Example: Retrieve All Holiday Schedules Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/src/js_time.js.html Demonstrates how to retrieve the holiday schedule list and iterate through the returned objects to access start and end dates. ```javascript function getAllHolidaySchedules () { function successCb(cbObject) { console.log("cbObject : " + JSON.stringify(cbObject)); for (var i = cbObject.holidayScheduleList.length-1; i>=0; i--) { console.log("holidayScheduleList[" + i + "].startMonth : " + cbObject.holidayScheduleList[i].startMonth); console.log("holidayScheduleList[" + i + "].startDay : " + cbObject.holidayScheduleList[i].startDay); console.log("holidayScheduleList[" + i + "].endMonth : " + cbObject.holidayScheduleList[i].endMonth); console.log("holidayScheduleList[" + i + "].endDay : " + cbObject.holidayScheduleList[i].endDay); } } function failureCb(cbObject) { // Handle error } } ``` -------------------------------- ### WebOS CLI System Monitoring Setup Object Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/src/js_signage.js.html This object, `_gSystemMonitoringSetup`, configures and manages the listeners for various system monitoring functionalities. Each property (fan, screen, temperature, signal, lamp) includes flags for event subscription and references to the corresponding listener creation functions. ```javascript var _gSystemMonitoringSetup = { fan: { getEvent: false, listenerObj: null, createListener: monitorFan }, screen: { getEvent: false, listenerObj: null, createListener: monitorScreen }, temperature: { getEvent: false, listenerObj: null, createListener: monitorTemperature }, signal: { getEvent: false, listenerObj: null, createListener: monitorSignal }, lamp: { getEvent: false, listenerObj: null, createListener: monitorLamp } }; ``` -------------------------------- ### Get Video Status (JavaScript Example) Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/src/js_video.js.html Provides a JavaScript example of how to use the getVideoStatus method. It demonstrates success and failure callback functions, logging the video source details or error information. This function is intended for use within a webOS environment where the Video API is available. ```javascript function getVideoStatus () { function successCb(cbObject) { console.log("cbObject : " + JSON.stringify(cbObject.source)); console.log("source.x : " + cbObject.source.x); console.log("source.y : " + cbObject.source.y); console.log("source.width : " + cbObject.source.width); console.log("source.height : " + cbObject.source.height); // Do something ... } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code [" + errorCode + "]: " + errorText); } var video = new Video(); video.getVideoStatus(successCb, failureCb); } ``` -------------------------------- ### POST /startWps Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/src/js_deviceInfo.js.html Initiates the Wi-Fi Protected Setup (WPS) process on the device. ```APIDOC ## POST luna://com.webos.service.commercial.signage.storageservice/network/startWps ### Description Starts the WPS (Wifi Protected Setup) operation to connect the device to a network. ### Method POST ### Endpoint luna://com.webos.service.commercial.signage.storageservice/network/startWps ### Parameters #### Request Body - **options** (Object) - Optional - Configuration parameters for the WPS process. ### Request Example { "options": {} } ### Response #### Success Response (200) - **result** (Object) - The result object returned upon successful initiation. #### Response Example { "returnValue": true } ``` -------------------------------- ### POST /DeviceInfo/startWps Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/DeviceInfo Initiates the Wi-Fi Protected Setup (WPS) process to connect the device to a network. ```APIDOC ## POST /DeviceInfo/startWps ### Description Starts the WPS (Wi-Fi Protected Setup) process to allow the device to connect to a wireless access point. ### Method POST ### Endpoint /DeviceInfo/startWps ### Parameters None ### Request Example { "action": "start" } ### Response #### Success Response (200) - **status** (string) - Indicates the WPS process has started. #### Response Example { "status": "started" } ``` -------------------------------- ### Get Channel List with Pagination Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/src/js_inputSource.js.html Retrieves a paginated list of channels of a specific type. It calculates the start and end indices for the query and specifies the fields to select from the Luna DB service. Dependencies include 'argscheck' and 'service'. ```javascript broadcast.prototype.getChannelList = function (successCallback, failureCallback, options) { argscheck.checkArgs("fFo", "broadcastCordova.getChannelList", arguments); var a = options.startIndex - 1; if (0 > a) a = 0; var c = a + options.count, param = { from: "com.webos.service.tv.channel.dblist:1", select: ["channelId", "channelName", "channelMode", "channelNumber", "channelType", "skipped", "locked", "descrambled", "scrambled"], where: [{ prop: "channelType", op: "=", val: options.type }], filter: [{ prop: "Invisible", op: "=", val: !1 }], limit: c }; service.Request("luna://com.palm.db/", { method: "search", ``` -------------------------------- ### POST luna://com.webos.service.commercial.signage.storageservice/network/startWps Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/src/js_deviceInfo.js.html Initiates the Wi-Fi Protected Setup (WPS) process on the device. ```APIDOC ## POST luna://com.webos.service.commercial.signage.storageservice/network/startWps ### Description Starts the WPS operation to allow the device to connect to a wireless network. ### Method POST ### Endpoint luna://com.webos.service.commercial.signage.storageservice/network/startWps ### Parameters #### Request Body - **options** (Object) - Optional - Configuration parameters for the WPS process. ### Request Example { "options": {} } ### Response #### Success Response (200) - **result** (Object) - The result object returned by the service. #### Response Example { "returnValue": true } ``` -------------------------------- ### Create Directory with Storage#mkdir Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/Storage Demonstrates how to use the Storage#mkdir method to create a directory recursively. It includes success and error callback functions to handle the asynchronous result of the operation. ```javascript function mkdir() { var successCb = function (){ console.log( "directory created successfully"); }; var failureCb = function(cbObject){ var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log( " Error Code [" + errorCode + "]: " + errorText); }; // The directory will be created recursively. var mkdirOption = { path: "file://internal/create/this/directory" }; var storage = new Storage(); storage.mkdir(successCb, failureCb, mkdirOption); } ``` -------------------------------- ### Manage Apps: Install, Remove, List with Installer Source: https://context7.com/webos-tools/cli/llms.txt The Installer module provides methods to manage applications on webOS devices. It allows for installing IPK packages, listing currently installed applications, and removing existing ones. Ensure the correct device is targeted and the IPK path is valid for installation. ```javascript const { Installer } = require('@webos-tools/cli'); const options = { device: 'tv' }; // Target device name const middleCallback = (msg) => console.log(msg); // Install an IPK package const ipkPath = './packages/com.example.myapp_1.0.0_all.ipk'; Installer.install(options, ipkPath) .then(result => { console.log(result.msg); // "Success" }) .catch(err => { console.error('Installation failed:', err); }); // List installed apps on device Installer.list(options) .then(apps => { console.log('Installed apps:'); apps.forEach(app => { console.log(` ${app.id} - ${app.version}`); }); }) .catch(err => { console.error('Failed to list apps:', err); }); // Remove an installed app const appId = 'com.example.myapp'; Installer.remove(options, appId) .then(result => { console.log(result.msg); // "Removed package com.example.myapp" }) .catch(err => { console.error('Removal failed:', err); }); ``` -------------------------------- ### Execute Power Command in JavaScript Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/Power Demonstrates how to initialize the Power class and execute a reboot command. It includes the definition of success and failure callback functions to handle the asynchronous response. ```javascript function executePowerCommand () { var options = { powerCommand : Power.PowerCommand.REBOOT }; function successCb() { // Do something } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code [" + errorCode + "]: " + errorText); } var power = new Power(); power.executePowerCommand(successCb, failureCb, options); } ``` -------------------------------- ### Application Installation with ares-install Source: https://context7.com/webos-tools/cli/llms.txt Commands for installing and removing applications on webOS devices. Supports installing .ipk files to a specific device, listing installed applications, and removing existing ones. ```bash # Install an IPK package ares-install ./com.example.app_1.0.0_all.ipk # Install to specific device ares-install --device myTV ./com.example.app_1.0.0_all.ipk # List installed apps ares-install --list # Remove an installed app ares-install --remove com.example.app ``` -------------------------------- ### Set Display Picture Properties in JavaScript Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/src/js_configuration.js.html Demonstrates how to initialize an options object with various display parameters and invoke the configuration method with success and failure callbacks. ```javascript function setPictureProperty () { var options = { backlight : 50, contrast : 50, brightness : 50, hSharpness : 50, vSharpness : 50, color : 50, tint : 50, colorTemperature : 50, dynamicContrast : "low", superResolution : "low", colorGamut : "wide", dynamicColor : "high", noiseReduction : "medium", mpegNoiseReduction : "low", blackLevel : "low", gamma : "medium" }; function successCb() { // Do something } function failureCb(cbObject) { // Handle error } } ``` -------------------------------- ### List Directory Files Example Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/src/js_storage.js.html Demonstrates how to use the listFiles method to retrieve file information from a specific directory URI. It includes defining success and failure callbacks to process the returned file list. ```javascript function listFiles() { var successCb = function (cbObject){ var files = cbObject.files; for(var i = 0 ; i < files.length; ++i){ var fileInfo = files[i]; console.log("File Name: " + fileInfo.name); console.log("File Type: " + fileInfo.type); console.log("File Size: " + fileInfo.size); } }; var failureCb = function(cbObject){ var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log( " Error Code [" + errorCode + "]: " + errorText); }; var listOption = { path: "file://internal/list/this/dir" }; var storage = new Storage(); storage.listFiles(successCb, failureCb, listOption); } ``` -------------------------------- ### Installer Module API Source: https://context7.com/webos-tools/cli/llms.txt Endpoints for installing, listing, and removing IPK packages on target webOS devices. ```APIDOC ## Installer Operations ### Description Manage application lifecycle by installing, listing, or removing packages on a target device. ### Methods - Installer.install(options, ipkPath) - Installer.list(options) - Installer.remove(options, appId) ### Parameters - **options** (object) - Required - Contains device identifier (e.g., { device: 'tv' }) - **ipkPath** (string) - Required (for install) - Local file path to the .ipk file - **appId** (string) - Required (for remove) - Unique application identifier ### Response - **result** (object) - Contains status message or list of installed applications. ``` -------------------------------- ### GET luna://com.webos.service.commercial.signage.storageservice/settings/ (get) Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/src/js_sound.js.html Retrieves the current sound output configuration from the storage service. This is supported on webOS Signage 3.0 and later. ```APIDOC ## GET luna://com.webos.service.commercial.signage.storageservice/settings/ ### Description Retrieves the current sound output setting for the device. ### Method GET ### Endpoint luna://com.webos.service.commercial.signage.storageservice/settings/ ### Parameters #### Query Parameters - **category** (String) - Required - The setting category, must be "sound". - **keys** (Array) - Required - List of keys to retrieve, e.g., ["soundOutput"]. ### Request Example { "category": "sound", "keys": ["soundOutput"] } ### Response #### Success Response (200) - **returnValue** (Boolean) - Indicates if the operation was successful. - **settings** (Object) - Contains the requested "soundOutput" value. #### Response Example { "returnValue": true, "settings": { "soundOutput": "tv_speaker" } } ``` -------------------------------- ### Set Content Rotation Example Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/src/js_video.js.html Example usage of the setContentRotation method to rotate full-screen video. Requires degree and aspect ratio parameters. ```javascript function setContentRotation () { var options = {degree : "90", aspectRatio : "full"}; function successCb() { /* Do something */ } function failureCb(cbObject) { console.log ("Error Code [" + cbObject.errorCode + "]: " + cbObject.errorText); } var video = new Video(); video.setContentRotation(successCb, failureCb, options); } ``` -------------------------------- ### Initialize InputSource with Video Tag Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/InputSource This snippet demonstrates how to set up an HTML container and initialize the InputSource object using JavaScript. It includes the required callback functions for handling success and failure scenarios. ```html
``` ```javascript function init () {} function onLoad() { var options = { divId : "inputSource", videoId : "inputSourceVid", callback : init, src : "ext://hdmi:1" }; function successCb() { // Do something } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code [" + errorCode + "]: " + errorText); } var inputSource = new InputSource(); inputSource.initialize(successCb, failureCb, options); } ``` -------------------------------- ### DeviceInfo.startWps Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/src/js_deviceInfo.js.html Initiates Wi-Fi Protected Setup (WPS) using either Push Button Configuration (PBC) or a PIN method. ```APIDOC ## POST /startWps ### Description Starts WPS using PBC or PIN. For PIN method, a PIN is returned on success. ### Method POST ### Endpoint /startWps ### Parameters #### Request Body - **method** (String) - Required - WPS method. Use "PBC" for Push Button or "PIN" for PIN entry. ### Request Example (PBC) ```json { "method": "PBC" } ``` ### Request Example (PIN) ```json { "method": "PIN" } ``` ### Response #### Success Response (200) - **pin** (String) - Required if method is "PIN" - The PIN to be entered in the router settings. #### Response Example (PIN) ```json { "pin": "12345678" } ``` ``` -------------------------------- ### Get Input Source Status and Details (JavaScript) Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/src/js_inputSource.js.html This function retrieves the status of all input sources connected to the device. It calls the EIM service to get input status and current input, then uses broadcast to get signal status. The output is formatted differently based on the WebOS platform version. ```javascript InputSource.prototype.getInputSourceStatus = function (successCallback, errorCallback) { log("getInputSourceStatus: "); service.Request("luna://com.webos.service.eim/", { method : "getAllInputStatus", onSuccess : function(result) { log("getInputSourceStatus: On Success"); if (result.returnValue === true) { checkPlatformVersion(function(platformInfo){ var ver = platformInfo.webOSVer; log("convertInputSource: " + JSON.stringify(result.totalCount)); log("convertInputSource: " + JSON.stringify(result.devices)); log("version: " + ver); var cbObj = {}; var inputList = new Array(result.totalCount); var convertList = new Array(result.totalCount); for (var i=0; i{Object}

*/ function getPowerStatus(successCallback, errorCallback) ``` -------------------------------- ### Configure Proxy Settings via DeviceInfo Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/src/js_deviceInfo.js.html Demonstrates how to use the setProxyInfo method to enable or disable a network proxy. It includes an example of the required options object and handling of success and failure callbacks. ```javascript function setProxyInfo () { var options = { enabled : true, ipAddress : "163.231.22.43", port : 5000, userName : "example", password : "35792234" }; function successCb() { console.log("sucess"); } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code [" + errorCode + "]: " + errorText); } var deviceinfo = new DeviceInfo(); deviceinfo.setProxyInfo(successCb, failureCb, options); } ``` -------------------------------- ### Set Device Proxy Configuration Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/DeviceInfo Demonstrates how to initialize the DeviceInfo class and invoke setProxyInfo with a configuration object and callback handlers. The options object includes proxy status, IP, port, and authentication credentials. ```javascript function setProxyInfo () { var options = { enabled : true, ipAddress : "163.231.22.43", port : 5000, userName : "example", password : "35792234", }; function successCb() { console.log("sucess"); } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code [" + errorCode + "]: " + errorText); } var deviceinfo = new DeviceInfo(); deviceinfo.setProxyInfo(successCb, failureCb, options); } ``` -------------------------------- ### Get Current Program Information Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/src/js_inputSource.js.html Fetches information about the currently playing program. It uses the system service to get the effective broadcast time and then calls getSignalChannelId to process the result. Dependencies include 'argscheck', 'service', and 'getSignalChannelId'. ```javascript broadcast.prototype.getCurrentProgram = function (successCallback, failureCallback, options) { argscheck.checkArgs("fFo", "broadcastCordova.getCurrentProgram", arguments), service.Request("luna://com.palm.systemservice/time", { method: "getEffectiveBroadcastTime", parameters: {}, onSuccess: function (cbObject) { var returnObject = {}; returnObject.id = options.id; returnObject.startTime = cbObject.localtime; returnObject.endTime = cbObject.localtime; returnObject.request = "nowInfo"; getSignalChannelId(successCallback, failureCallback, returnObject) }, onFailure: function (e) { delete e.returnValue, failureCallback && failureCallback(e) } }) } ``` -------------------------------- ### POST /deviceInfo/startWps Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.5.0/js/doc/symbols/DeviceInfo Initiates the Wifi Protected Setup (WPS) process on the device using either Push Button Configuration (PBC) or PIN-based authentication. ```APIDOC ## POST /deviceInfo/startWps ### Description Starts the Wifi Protected Setup (WPS) process. This method supports both PBC (Push Button Configuration) and PIN-based methods to connect the device to a wireless network. ### Method POST ### Endpoint DeviceInfo#startWps ### Parameters #### Request Body - **successCallback** (Function) - Required - Callback function executed upon successful initiation. - **errorCallback** (Function) - Required - Callback function executed if an error occurs. - **options** (Object) - Required - Configuration object containing the connection method. - **method** (String) - Required - The WPS method to use: 'PBC' or 'PIN'. ### Request Example { "method": "PBC" } ### Response #### Success Response (200) - **pin** (String) - Returned only if the 'PIN' method is used; contains the generated PIN for router configuration. #### Response Example { "pin": "12345678" } ``` -------------------------------- ### Initialize Webos Tools CLI Modules Source: https://context7.com/webos-tools/cli/llms.txt Demonstrates how to import the primary modules from the @webos-tools/cli package for programmatic access to CLI functionality. ```javascript const { Generator, Inspector, Installer, Launcher, Packager, Puller, Pusher, Server, Shell, SetupDevice } = require('@webos-tools/cli'); ``` -------------------------------- ### Get File Stat using Storage API Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/Storage Demonstrates how to get the statistics of a file using the Storage.statFile method. It includes success and error callback functions to handle the results and potential errors. The function requires a path to the resource as an option. ```javascript function statFile() { var successCb = function (cbObject){ console.log( "Show File Stat: " ); console.log( JSON.stringify(cbObject)); }; var failureCb = function(cbObject){ var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log( " Error Code \[" + errorCode + "\]: " + errorText); }; var options = { path: 'file://internal/myFile.txt', }; var storage = new Storage(); storage.statFile(successCb, failureCb, options); } ``` -------------------------------- ### Retrieve Platform Properties using Configuration#getProperty Source: https://github.com/webos-tools/cli/blob/main/files/templates/signage-sdk-templates/scap_api/1.4.1/js/doc/symbols/Configuration This snippet demonstrates how to initialize the Configuration object and call getProperty with success and failure callbacks. It shows how to pass a JSON string containing the keys to be retrieved and how to parse the resulting JSON object in the success callback. ```javascript function getProperty () { var options = '{"keys":["alias"]}'; function successCb(cbObject) { console.log("cbObject : " + JSON.stringify(cbObject)); var parsedString = JSON.parse(cbObject); for(var key in parsedString) { var value = parsedString[key]; console.log(key + ": " + value); } } function failureCb(cbObject) { var errorCode = cbObject.errorCode; var errorText = cbObject.errorText; console.log ("Error Code [" + errorCode + "]: " + errorText); } var configuration = new Configuration(); configuration.getProperty(successCb, failureCb, options); } ```