top

CUSTOMDEVICE.CUSTOMDEVICE

Gets custom device information, receives a device event connected TV and sends a message from TV to the device.

Add the following line for customdevice.CustomDevice class into a html file your own :

  script type="text/javascript" src="$MANAGER_WIDGET/Common/webapi/1.0/deviceapis.js">/script>

You can declare customdevice.CustomDevice class like this :

  ex) var customdevice = deviceapis.customdevice;


Methods

getDeviceID

Description
get device ID of the customdevice.
Parameters
none
Return■DOMString
  - device ID of customdevice
Emulator SupportYes
SDK ConstraintNone
Example
var custom = window.deviceapis.customdevice || {};
var device1 = null;

Main.keyDown = function()
{
    custom.getCustomDevices(Main.onCustomObtained);
    ....
}

Main.onCustomObtained = function(customs)
{
    device1 = customs[0];
}

string strDeviceID = device1.getDeviceID();

getName

Description
get name of the custom device.
Parameters
none
Return■DOMString
  - name of custom device
Emulator SupportYes
SDK ConstraintNone
Example
var custom = window.deviceapis.customdevice || {};
var device1 = null;

Main.keyDown = function()
{
    custom.getCustomDevices(Main.onCustomObtained);
    ....
}

Main.onCustomObtained = function(customs)
{
    device1 = customs[0];
}

string strName = device1.getName();

getType

Description
get type of the custom device.
Parameters
none
Return■Unsigned short 
  - type of custom device
Emulator SupportYes
SDK ConstraintNone
Example
var custom = window.deviceapis.customdevice || {};
var device1 = null;

Main.keyDown = function()
{
    custom.getCustomDevices(Main.onCustomObtained);
    ....
}

Main.onCustomObtained = function(customs)
{
    device1 = customs[0];
}

unsinged short nType = device1.getType();

getUniqueID

Description
get unique ID of the customdevice.
Parameters
none
Return■DOMString 
  - address/uniqueID of customdevice
Emulator SupportYes
SDK ConstraintNone
Example
var custom = window.deviceapis.customdevice || {};
var device1 = null;

Main.keyDown = function()
{
    custom.getCustomDevices(Main.onCustomObtained);
    ....
}

Main.onCustomObtained = function(customs)
{
    device1 = customs[0];
}

string strUniqueID = device1.getUniqueID();

registerDeviceCallback

Description
This function is used to register a device instance for receiving device event. If null is passed as callback function type, then callback will be unregistered and event will no longer be received by device instance.
Parameters
■callbackFn 
  - Function 
  - callback function that has prototype given as “void callbackFn(CustomDeviceInfo)”
Return■Void
Emulator SupportYes
SDK ConstraintNone
Example
var custom = window.deviceapis.customdevice || {};
var device1 = null;

Main.keyDown = function()
{
    custom.getCustomDevices(Main.onCustomObtained);
    ....
}

Main.onCustomObtained = function(customs)
{
    device1 = customs[0];
}

device1.registerDeviceCallback(deviceCallback);

sendMessage

Description
sends message from DTV widget to custom device.
Parameters
■message
  - DOMString 
  - message buffer
Return■Unsigned short 
  - CUSTOMDEVICE_ERROR_CODE
   * ERROR_CODE_NO_ERR : call is successful
   * ERROR_CODE_ERR : call is not successful
Emulator SupportYes
SDK ConstraintNone
Example
var custom = window.deviceapis.customdevice || {};
var device1 = null;

Main.keyDown = function()
{
    custom.getCustomDevices(Main.onCustomObtained);
    ....
}

Main.onCustomObtained = function(customs)
{
    device1 = customs[0];
}

unsigned short nResult = device1.sendMessage(strMessage);