Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion accelerator-home-ui/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
"log": true,
"enableAppSuspended": true,
"showVersion": false,
"version": "5.0.24"
"version": "5.0.25"
}
}
47 changes: 30 additions & 17 deletions accelerator-home-ui/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ import PackageManager from './api/PackageManagerApi.js';
import RDKWindowManager from './api/RDKWindowManagerApi.js';
import RuntimeManager from './api/RuntimeManagerApi.js';
import AppController from './AppController.js';
import LEDController, { LEDControlState } from './api/LEDControlApi.js';

var AlexaAudioplayerActive = false;
var thunder = ThunderJS(CONFIG.thunderConfig);
Expand Down Expand Up @@ -257,7 +258,7 @@ export default class App extends Router.App {
GLOBALS.powerState = PowerState.POWER_STATE_ON;
this.LOG("powerState after ===>" + JSON.stringify(GLOBALS.powerState))
this.initializeInactivityEngine();
})
})
.catch(err => {
this.ERR("Error waking device: " + JSON.stringify(err));
})
Expand All @@ -281,7 +282,7 @@ export default class App extends Router.App {
} else if(GLOBALS.MiracastNotificationstatus){
this.jumpToRoute("menu");
miracast.acceptClientConnection("Reject").then(res=>{
if(res.success){Router.focusPage()}
if(res.success){Router.focusPage()}
})
} else {
this.jumpToRoute("menu"); //method to exit the current app(if any) and route to home screen
Expand Down Expand Up @@ -529,6 +530,15 @@ export default class App extends Router.App {
Storage.set("deviceType", ((result.devicetype != null) ? result.devicetype : "IpTv"));
});
UserSettingsApi.get().activate();
LEDController.isSupported().then(isSupported => {
if (isSupported) {
LEDController.activate().then(() => {
LEDController.getSupportedLEDStates();
});
} else {
this.LOG("LEDController is not supported on this device");
}
});
Comment thread
arun-madhavan-013 marked this conversation as resolved.
thunder.Controller.activate({
callsign: 'org.rdk.System'
}).then(result => {
Expand All @@ -537,10 +547,12 @@ export default class App extends Router.App {
//https://github.com/rdkcentral/entservices-apis/blob/1.15.11/docs/apis/PowerManagerPlugin.md#setWakeupSrcConfig
//By the above documentation we passed the Enum value sum to enable all wakeup sources expect WAKEUP_REASON_UNKNOWN
//Enum indicating bit position (bit counting starts at 1)
"wakeupSources": 262143
"wakeupSources": 262143
}
appApi.setWakeupSrcConfiguration(param);
appApi.setPowerState(GLOBALS.powerState).then(res => {});
appApi.setPowerState(GLOBALS.powerState).then(res => {
if (res === false) this.ERR("setPowerState failed: " + JSON.stringify(GLOBALS.powerState));
});
}).catch(err => {
this.ERR("App System plugin activation error: " + JSON.stringify(err));
})
Expand Down Expand Up @@ -839,28 +851,28 @@ export default class App extends Router.App {
this._updateLanguageToDefault()
// Initialize plugins using the abstraction
this._activatePlugin(
"org.rdk.PackageManagerRDKEMS",
"PackageManagerRDKEMS",
"org.rdk.PackageManagerRDKEMS",
"PackageManagerRDKEMS",
() => packagemangerRdkems.activate()
);

this._activatePlugin(
"org.rdk.AppManager",
"AppManager",
"org.rdk.AppManager",
"AppManager",
() => AppManager.get().activate(),
() => this._SubscribeToAppManagerNotifications()
);

this._activatePlugin(
"org.rdk.RDKWindowManager",
"RDKWindowManager",
"org.rdk.RDKWindowManager",
"RDKWindowManager",
() => RDKWindowManager.get().activate(),
() => this._SubscribeToRDKWindowManagerNotifications()
);

this._activatePlugin(
"org.rdk.RuntimeManager",
"RuntimeManager",
"org.rdk.RuntimeManager",
"RuntimeManager",
() => RuntimeManager.get().activate(),
() => this._SubscribeToRuntimeManagerNotifications()
);
Expand Down Expand Up @@ -961,7 +973,7 @@ export default class App extends Router.App {
}
else {
GLOBALS.IsConnectedToInternet = false
}
}
console.warn("onInternetStatusChange:", data);
});
thunder.on('org.rdk.NetworkManager', 'onAvailableSSIDs', data => {
Expand Down Expand Up @@ -2121,6 +2133,7 @@ export default class App extends Router.App {
subscribeToPowerChangeNotifications() {
thunder.on("org.rdk.PowerManager", "onPowerModeChanged", notification => {
this.LOG(new Date().toISOString() + " onPowerModeChanged Notification: " + JSON.stringify(notification));
LEDController.setLEDState(notification.newState === "ON" ? LEDControlState.ACTIVE : LEDControlState.STANDBY);
appApi.getPowerState().then(res => {
GLOBALS.powerState = res ? res.currentState : notification.newState
}).catch(e => GLOBALS.powerState = notification.newState)
Expand Down Expand Up @@ -2852,4 +2865,4 @@ export default class App extends Router.App {
}
}
}
}
}
194 changes: 194 additions & 0 deletions accelerator-home-ui/src/api/LEDControlApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
/**
* If not stated otherwise in this file or this component's LICENSE
* file the following copyright and licenses apply:
*
* Copyright 2026 RDK Management
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
**/

import ThunderJS from 'ThunderJS';
import { CONFIG } from '../Config/Config';
import { Metrics } from '@firebolt-js/sdk';
import { GLOBALS } from '../Config/Config';

export const LEDControlState = {
NONE: 'NONE',
ACTIVE: 'ACTIVE',
STANDBY: 'STANDBY',
WPS_CONNECTING: 'WPS_CONNECTING',
WPS_CONNECTED: 'WPS_CONNECTED',
WPS_ERROR: 'WPS_ERROR',
FACTORY_RESET: 'FACTORY_RESET',
USB_UPGRADE: 'USB_UPGRADE',
DOWNLOAD_ERROR: 'DOWNLOAD_ERROR',
};

class LEDControlApi {
constructor() {
this.thunder = ThunderJS(CONFIG.thunderConfig);
this.callsign = 'org.rdk.LEDControl';
this.INFO = console.info;
this.LOG = console.log;
this.ERR = console.error;
this._isSupportedPromise = this._fetchIsSupported();
this._supportedLEDStatesPromise = null;
}

_fetchIsSupported() {
return this.thunder.call('Controller', `status@${this.callsign}`).then(result => {
const supported = Array.isArray(result) ? result.length > 0 : !!result;
this.LOG(this.callsign + ' isSupported result: ' + supported);
return supported;
}).catch(err => {
this.ERR(this.callsign + ' isSupported error: ' + JSON.stringify(err));
return false;
});
}

isSupported() {
return this._isSupportedPromise;
}

activate() {
return new Promise((resolve, reject) => {
this.thunder.call('Controller', 'activate', { callsign: this.callsign }).then(result => {
this.INFO(this.callsign + ' activate result: ' + JSON.stringify(result));
resolve(true);
}).catch(err => {
this.ERR(this.callsign + ' activate error: ' + JSON.stringify(err));
Metrics.error(Metrics.ErrorType.OTHER, 'LEDControlApiError', 'Error while Thunder Controller LEDControl activate ' + JSON.stringify(err), false, null);
reject(err);
});
});
}

deactivate() {
return new Promise((resolve, reject) => {
this.thunder.call('Controller', 'deactivate', { callsign: this.callsign }).then(result => {
this.INFO(this.callsign + ' deactivate result: ' + JSON.stringify(result));
this._supportedLEDStatesPromise = null;
resolve(true);
}).catch(err => {
this.ERR(this.callsign + ' deactivate error: ' + JSON.stringify(err));
Metrics.error(Metrics.ErrorType.OTHER, 'LEDControlApiError', 'Error while Thunder Controller LEDControl deactivate ' + JSON.stringify(err), false, null);
reject(err);
});
});
}

getLEDState() {
return new Promise((resolve, reject) => {
this.isSupported().then(isSupported => {
if (!isSupported) {
this.LOG(this.callsign + ' getLEDState skipped: plugin not supported on this platform');
resolve(null);
return;
}

this.thunder.call(this.callsign, 'getLEDState').then(result => {
this.LOG(this.callsign + ' getLEDState result: ' + JSON.stringify(result));
resolve(result);
}).catch(err => {
this.ERR(this.callsign + ' getLEDState error: ' + JSON.stringify(err));
Metrics.error(Metrics.ErrorType.OTHER, 'LEDControlApiError', 'Error while Thunder LEDControl getLEDState ' + JSON.stringify(err), false, null);
reject(err);
});
}).catch(err => {
this.ERR(this.callsign + ' getLEDState support check failed: ' + JSON.stringify(err));
resolve(null);
});
});
}

getSupportedLEDStates(forceRefresh = false) {
if (!forceRefresh) {
return this.isSupported().then(isSupported => {
if (!isSupported) {
this.LOG(this.callsign + ' getSupportedLEDStates skipped: plugin not supported on this platform');
return [];
}

if (this._supportedLEDStatesPromise) {
return this._supportedLEDStatesPromise;
}

this._supportedLEDStatesPromise = this.thunder.call(this.callsign, 'getSupportedLEDStates').then(result => {
this.LOG(this.callsign + ' getSupportedLEDStates result: ' + JSON.stringify(result));
if (result.success) {
return result.supportedLEDStates || [];
}
throw result;
}).catch(err => {
this._supportedLEDStatesPromise = null;
this.ERR(this.callsign + ' getSupportedLEDStates error: ' + JSON.stringify(err));
Metrics.error(Metrics.ErrorType.OTHER, 'LEDControlApiError', 'Error while Thunder LEDControl getSupportedLEDStates ' + JSON.stringify(err), false, null);
throw err;
});

return this._supportedLEDStatesPromise;
}).catch(() => {
this.LOG(this.callsign + ' getSupportedLEDStates skipped: support check failed');
return [];
});
}

if (forceRefresh) {
this._supportedLEDStatesPromise = null;
}

return this.getSupportedLEDStates(false);
}

setLEDState(state) {
return new Promise((resolve) => {
this.isSupported().then(isSupported => {
if (!isSupported) {
this.LOG(this.callsign + ' setLEDState skipped: plugin not supported on this platform');
resolve(false);
return;
}

this.getSupportedLEDStates().then(supportedLEDStates => {
if (!Array.isArray(supportedLEDStates) || !supportedLEDStates.includes(state)) {
this.LOG(this.callsign + ' setLEDState skipped: unsupported state requested: ' + state + ', supported: ' + JSON.stringify(supportedLEDStates));
resolve(false);
return;
}

this.thunder.call(this.callsign, 'setLEDState', { state }).then(result => {
this.LOG(this.callsign + ' setLEDState result: ' + JSON.stringify(result));
resolve(result.success === true);
}).catch(err => {
this.ERR(this.callsign + ' setLEDState error: ' + JSON.stringify(err));
Metrics.error(Metrics.ErrorType.OTHER, 'LEDControlApiError', 'Error while Thunder LEDControl setLEDState ' + JSON.stringify(err), false, null);
resolve(false);
});
}).catch(err => {
this.ERR(this.callsign + ' setLEDState failed to fetch supported states: ' + JSON.stringify(err));
resolve(false);
});
}).catch(err => {
this.ERR(this.callsign + ' setLEDState support check failed: ' + JSON.stringify(err));
resolve(false);
});
});
}

matchLEDStateToPowerState() {
return this.setLEDState(GLOBALS.powerState !== 'ON' ? LEDControlState.STANDBY : LEDControlState.ACTIVE);
}
}

const ledControlApi = new LEDControlApi();
export default ledControlApi;
2 changes: 1 addition & 1 deletion accelerator-home-ui/src/routes/otherSettingsRoutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,4 @@ export default {
widgets: ['Menu', 'Volume', "AppCarousel"],
}
]
}
}
5 changes: 4 additions & 1 deletion accelerator-home-ui/src/screens/FailScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
**/
import { Language,Registry, Lightning, Router } from "@lightningjs/sdk";
import { CONFIG } from '../Config/Config'
import LEDController, { LEDControlState } from "../api/LEDControlApi";

const errorTitle = 'Error Title'
const errorMsg = 'Error Message'
Expand Down Expand Up @@ -141,6 +142,7 @@ export default class Failscreen extends Lightning.Component {
if(this.timeout > 0) {
this.initTimer()
}
LEDController.setLEDState(LEDControlState.WPS_ERROR);
}
initTimer() {
this.timeInterval = Registry.setInterval(() => {
Expand All @@ -165,9 +167,10 @@ export default class Failscreen extends Lightning.Component {
if (this.timeInterval) {
Registry.clearInterval(this.timeInterval)
}
LEDController.matchLEDStateToPowerState();
}
_handleBack() {
Router.focusPage()
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { KEYBOARD_FORMATS } from '../ui-components/components/Keyboard'
import PasswordSwitch from './PasswordSwitch';
import NetworkManager from '../api/NetworkManagerAPI';
import PersistentStoreApi from '../api/PersistentStore';
import LEDController, { LEDControlState } from '../api/LEDControlApi'

export default class JoinAnotherNetworkComponent extends Lightning.Component {

Expand All @@ -44,6 +45,10 @@ export default class JoinAnotherNetworkComponent extends Lightning.Component {
this.tag("Keyboard").visible = false
}

_inactive() {
LEDController.matchLEDStateToPowerState();
}

handleDone() {
this.tag("Keyboard").visible = false
let securityCode = this.securityCodes[this.securityCodeIndex].value;
Expand All @@ -69,6 +74,7 @@ export default class JoinAnotherNetworkComponent extends Lightning.Component {
}

async startConnectForAnotherNetwork(device, passphrase) {
LEDController.setLEDState(LEDControlState.WPS_CONNECTING);
await NetworkManager.WiFiConnect(false, { ssid: device.ssid, security: device.security }, passphrase).then(() => {
Comment thread
arun-madhavan-013 marked this conversation as resolved.
NetworkManager.AddToKnownSSIDs(device.ssid, passphrase, device.security).then((response) => {
if (response === true ) {
Comment thread
arun-madhavan-013 marked this conversation as resolved.
Comment thread
arun-madhavan-013 marked this conversation as resolved.
Expand Down
Loading
Loading