Skip to content

How to use WITs as APIs

sejoong_de_jang edited this page Oct 27, 2020 · 16 revisions

APIs

setWitsconfigInfo()

setWitsconfigInfo() is for setting WITs environment, It should be called before start function or watch function.

// async
    void setWitsconfigInfo(WitsInfoData data)
    dictionary WitsInfoData {
        DOMString? width;
        DOMString deviceIp;
        DOMString hostIp;
        DOMString baseAppPath;
        boolean isDebugMode;
        DOMString profilePath;
    }

code

const wits = require('@tizentv/wits');

const data = {
    deviceIp: '123.123.123.123',
    hostIp: '456.456.456.456',
    isDebugMode: true,
    baseAppPath: 'e:/dev/tizenworkspace/export', //The application path which you want to live-reload.
    profilePath: 'e:/dev/Wits/resource/profiles.xml' //Profile path for packaging your application.
};

await wits.setWitsconfigInfo(data);

start()

start() is a sequence for building and installing your application, connecting PC and Target TV, pushing files, supporting live-reload feature.

// async
    void start()

code

const wits = require('@tizentv/wits');

const data = {
    deviceIp: '123.123.123.123',
    hostIp: '456.456.456.456',
    isDebugMode: true,
    baseAppPath: 'e:/dev/tizenworkspace/export', //The application path which you want to live-reload.
    profilePath: 'e:/dev/Wits/resource/profiles.xml' //Profile path for packaging your application.
};

await wits.setWitsconfigInfo(data);
await wits.start();

watch()

watch() is a sequence for connecting PC and Target TV, pushing files, supporting live-reload feature. (Except for re-building and re-installing your application.)

// async
    void watch()

code

const wits = require('@tizentv/wits');

const data = {
    deviceIp: '123.123.123.123',
    hostIp: '456.456.456.456',
    isDebugMode: true,
    baseAppPath: 'e:/dev/tizenworkspace/export', //The application path which you want to live-reload.
    profilePath: 'e:/dev/Wits/resource/profiles.xml' //Profile path for packaging your application.
};

await wits.setWitsconfigInfo(data);
await wits.watch();

disconnect()

disconnect() is for disconnecting communications between PC and Target TV.

// async
    void disconnect()

code

const wits = require('@tizentv/wits');
await wits.disconnect();

setOutputChannel()

setOutputChannel() is for getting WITs' log information. The return value is integer value between 1000 and 9999, and this value will be used to unsetOutputChannel(). You can integrate the WITs' log on your application.

    long setOutputChannel(OutputCallback callback)
    interface OutputCallback {
        void online();
    };
// integrate to VS Code output
const wits = require('@tizentv/wits');
const vscode = require('vscode');

const output = vscode.window.createOutputChannel('WITs output');
const id = wits.setOutputChannel(output.appendLine);

unsetOutputChannel()

unsetOutputChannel() is for unregistering the output callback. Call the unsetOutputChannel() with the return value of the setOutputChannel().

    void unsetOutputChannel(long requestId)
const wits = require('@tizentv/wits');

wits.unsetOutputChannel(id);