If you wonder if there is a way to run or debug your LG Smart TV application outside of LG IDE, lets say from command line (or Ant), I have some good news for you. It took me some time to discover the necessary requirements but thanks to WMIC and some luck I was able to run and debug the app in emulator with the web inspector.
Requirement for this process is to have LG SDK/IDE including Emulator properly installed. Natively LG IDE (eclipse) handles the process of running or debugging the app in emulator pretty smooth. Once you click run or debug button the eclipse starts local server listening on port 8080 (root is c:/*ECLIPSE-WORKSPACE*/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/*PROJECT*/), starts Safari (installed with LG SDK) within a debug perspective and opens an emulator…
All of these steps can be done manualy from command line:
- lets consider you already have an local server installed, keep in mind that emulator can target your local server at IP 10.0.2.2
- emulator is an executable file that takes some arguments
Run In Emulator
To run the application in emulator use following .bat>
SET "SDK_PATH=C:/Program Files (x86)/LG_Smart_TV_SDK" SET APP_PATH=http://google.com "%SDK_PATH%/Resources/jre64/launch4j-tmp/LG_Smart_TV_Emulator_2013.exe" ^ -classpath "%SDK_PATH%/LG_Smart_TV_Emulator_2013/LG_Smart_TV_Emulator_2013.exe;.;lib/vboxjmscom_4.1.jar;lib/vboxjmscom_4.2.jar;lib/jacob.jar;lib/commons-compress-1.3.jar;lib/log4j-1.2.16.jar" ^ com.dtvsdk.emul.VmEmulatorManager -b ^ %APP_PATH%
If your OS is 32 bit, replace “jre64” by “jre”.
Debug In Emulator
- visit jwebsocket.org and download “Server” version
- unzip somewhere on your drive
- merge default jWebServer/conf/jWebServer.xml config file with the one from LG_Smart_TV_SDK/Resources/jWebSocket-1.0/conf/jWebServer.xml
- run jWebServer
- run web inspector
- run emulator
It seems to be sufficient to merge following things in default jWebServer.xml file:
for each engine:
for user with guest role
for user with user role
Now run the jWebServer with following attributes
SET "SDK_PATH=C:/Program Files (x86)/LG_Smart_TV_SDK" SET "JWEBSOCKET_PATH=c:/Program Files (x86)/jWebSocket/jWebSocket-1.0" java -jar "%JWEBSOCKET_PATH%/libs/jWebSocketServer-1.0.jar" ^ -home "%JWEBSOCKET_PATH%" ^ -bootstrap "%SDK_PATH%\Resources\jWebSocket-1.0\conf\Resources\bootstrap.xml" ^ -config "%JWEBSOCKET_PATH%\conf\jWebSocket.xml"
To debug the application in emulator using web inspector use:
SET "SDK_PATH=C:/Program Files (x86)/LG_Smart_TV_SDK" SET APP_PATH=http://10.0.2.2/your/app/index.html "%SDK_PATH%/Resources/LGInspectorForIDE/NetCast4/inspector.html" "%SDK_PATH%/Resources/jre64/launch4j-tmp/LG_Smart_TV_Emulator_2013.exe" ^ -classpath "%SDK_PATH%/LG_Smart_TV_Emulator_2013/LG_Smart_TV_Emulator_2013.exe;.;lib/vboxjmscom_4.1.jar;lib/vboxjmscom_4.2.jar;lib/jacob.jar;lib/commons-compress-1.3.jar;lib/log4j-1.2.16.jar" ^ com.dtvsdk.emul.VmEmulatorManager -d ^ %APP_PATH%
Both, inspector and the application running in emulator connects to your jWebSocker server. It means you can remotely debug any website (e.g. google.com) running in emulator with web inspetor. For debugging the app on real TV device it may require some different steps but I will cover that in another blog post.
Where to go from here: