To use Samsung Product API, <script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script> Should be loaded in index.html
To use Samsung Product API,
<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>
Should be loaded in index.html
Since : 2.3
Product : TV, AV_BD, B2B (LFD, IWB)
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
DOMString getVersion () bool isConnectedToGateway () unsigned short getIpMode () DOMString getSubnetMask () DOMString getGateway () DOMString getMac () DOMString getDns () DOMString getIp () unsigned short getActiveConnectionType () unsigned long addNetworkStateChangeListener (NetworkStateChangedCallback listener) void removeNetworkStateChangeListener (unsigned long listenerId) DOMString getWiFiSsid () short getWiFiSignalStrengthLevel () unsigned short getWiFiSecurityMode () unsigned short getWiFiEncryptionType () DOMString getSecondaryDns () void setDhcpOption60Field () void removeDhcpOption60Field () DOMString getCurrentDhcpOption60Field () DOMString checkCurrentIpWith60Field ()
[NoInterfaceObject]interface NetworkManagerObject { readonly attribute NetworkManager network; };
WebApi implements NetworkManagerObject;
[NoInterfaceObject]interface NetworkManager { readonly attribute NetworkActiveConnectionType NetworkActiveConnectionType; readonly attribute NetworkIpMode NetworkIpMode; readonly attribute NetworkState NetworkState; readonly attribute NetworkWiFiSecurityMode NetworkWiFiSecurityMode; readonly attribute NetworkWiFiEncryptionType NetworkWiFiEncryptionType; DOMString getVersion(); boolean isConnectedToGateway(); NetworkIpMode getIpMode(); DOMString getSubnetMask(); DOMString getGateway(); DOMString getMac(); DOMString getDns(); DOMString getIp(); NetworkActiveConnectionType getActiveConnectionType(); unsigned long addNetworkStateChangeListener(NetworkStateChangedCallback listener); void removeNetworkStateChangeListener(unsigned long listenerId); DOMString getWiFiSsid(); short getWiFiSignalStrengthLevel(); NetworkWiFiSecurityMode getWiFiSecurityMode(); NetworkWiFiEncryptionType getWiFiEncryptionType(); DOMString getSecondaryDns(); void setDhcpOption60Field(DOMString vendorName); void removeDhcpOption60Field(); DOMString getCurrentDhcpOption60Field(); DOMString checkCurrentIpWith60Field(); };
getVersion
DOMString getVersion>();
Return value:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
var version = null; try { version = webapis.network.getVersion(); } catch (e) { console.log("getVersion exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != version) { console.log("[getVersion] version: " + version); }
isConnectedToGateway
boolean isConnectedToGateway();
with error type InvalidStateError, if a network connection is not available. (Since plugin version 3.0)
var gatewayStatus = null; try { gatewayStatus = webapis.network.isConnectedToGateway(); } catch (e) { console.error("isConnectedToGateway exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != gatewayStatus { console.log("[isConnectedToGateway] gatewayStatus: " + gatewayStatus); }
getIpMode
unsigned short getIpMode();
var ipMode = null; var retVal = null; try { retVal = webapis.network.getIpMode(); } catch (e) { console.log("getIPMode exception [" + e.code + "] message: " + e.message); } if (null != retVal) { switch(retVal) { case webapis.network.NetworkIpMode.STATIC : ipMode = "STATIC"; break; case webapis.network.NetworkIpMode.DYNAMIC; ipMode = "DYNAMIC"; break; case webapis.network.NetworkIpMode.AUTO : ipMode = "AUTO"; break; case webapis.network.NetworkIpMode.FIXED : ipMode = "FIXED"; break; case webapis.network.NetworkIpMode.NONE : ipMode = "NONE"; break; case webapis.network.NetworkIpMode.UNKNOWN : ipMode = "UNKNOWN"; break; default: ipMode = "Error"; } console.log("[getIPMode] ipMode: " + ipMode); }
getSubnetMask
DOMString getSubnetMask();
var netMask = null; try { netMask = webapis.network.getSubnetMask(); } catch (e) { console.log("getSubnetMask exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != netMask) { console.log("[getSubnetMask] netMask: " + netMask); }
getGateway
DOMString getGateway();
var gateway = null; try { gateway = webapis.network.getGateway(); } catch (e) { console.log("getGateway exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != gateway) { console.log("[getGateway] gateway: " + gateway); }
getMac
DOMString getMac();
var mac = null; try { mac = webapis.network.getMac(); } catch (e) { console.log("getMAC exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != mac) { console.log("[getMAC] mac: " + mac); }
getDns
DOMString getDns();
var dns = null; try { dns = webapis.network.getDns(); } catch (e) { console.log("getDNS exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != dns) { console.log("[getDNS] dns: " + dns); }
getIp
DOMString getIp();
var ip = null; try { ip = webapis.network.getIp(); } catch (e) { console.log("getIp exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != ip) { console.log("[getIp] ip: " + ip); } }
getActiveConnectionType
unsigned short getActiveConnectionType();
var connType = null; var retVal = null; try { retVal = webapis.network.getActiveConnectionType(); } catch (e) { console.error("getActiveConnectionType exception [" + e.code + "] message: " + e.message ); } if (null != retVal) { switch(retVal) { case webapis.network.NetworkActiveConnectionType.DISCONNECTED : connType = "DISCONNECTED"; break; case webapis.network.NetworkActiveConnectionType.WIFI : connType = "WIFI"; break; case webapis.network.NetworkActiveConnectionType.CELLULAR : connType = "CELLULAR"; break; case webapis.network.NetworkActiveConnectionType.ETHERNET : connType = "ETHERNET"; break; default: connType = "Error"; } console.log("[getActiveConnectionType] Active Connection Type: " + connType); }
addNetworkStateChangeListener
unsigned long addNetworkStateChangeListener(NetworkStateChangedCallback listener);
Parameters:
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
var onChange = function(data) { console.log("[NetworkStateChangedCallback] data :" + data + " changed"); } try { listenerID = webapis.network.addNetworkStateChangeListener(onChange); } catch (e) { console.log("addNetworkStateChangeListener exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (listenerID > -1) { console.log("addNetworkStateChangeListener success listener ID [" + listenerID + "] "); }
removeNetworkStateChangeListener
void removeNetworkStateChangeListener(unsigned long listenerId);
with error type InvalidValuesError, if the listenerId value is not the same as the value generated by addNetworkStateChangeListener. (Since plugin version 3.0)
try { console.log("begin removeNetworkStateChangeListener listenerID: " + listenerID); webapis.network.removeNetworkStateChangeListener(listenerID); } catch (e) { console.log("removeNetworkStateChangeListener exception [" + e.code + "] name: " + e.name + " message: " + e.message); return; } console.log("removeNetworkStateChangeListener success");
getWiFiSsid
DOMString getWiFiSsid();
WebAPIException with error type InvalidStateError, if a Wi-Fi connection is not available. (Since plugin version 3.0)
code var WiFiSSID = null; try { WiFiSSID = webapis.network.getWiFiSsid(); } catch (e) { console.log("getWiFiSSID exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != WiFiSSID) { console.log("[getWiFiSSID] WiFiSSID: " + WiFiSSID); }
getWiFiSignalStrengthLevel
short getWiFiSignalStrengthLevel();
with error type InvalidStateError, if a Wi-Fi connection is not available. (Since plugin version 3.0)
var WiFiSignalStrengthLevel = null; try { WiFiSignalStrengthLevel = webapis.network.getWiFiSignalStrengthLevel(); } catch (e) { console.log("getWiFiSignalStrengthLevel exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != WiFiSignalStrengthLevel) { console.log("[getWiFiSignalStrengthLevel] WiFiSignalStrengthLevel: " + WiFiSignalStrengthLevel); }
getWiFiSecurityMode
NetworkWiFiSecurityMode getWiFiSecurityMode();
var WiFiSecurityMode = null; try { WiFiSecurityMode = webapis.network.getWiFiSecurityMode(); } catch (e) { console.log("getWiFiSecurityMode exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != WiFiSecurityMode) { console.log("[getWiFiSecurityMode] WiFiSecurityMode: " + WiFiSecurityMode); }
getWiFiEncryptionType
NetworkWiFiEncryptionType getWiFiEncryptionType();
var WiFiEncryptionType = null; try { WiFiEncryptionType = webapis.network.getWiFiEncryptionType(); } catch (e) { console.log("getWiFiEncryptionType exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != WiFiEncryptionType) { console.log("[getWiFiEncryptionType] WiFiEncryptionType: " + WiFiEncryptionType); }
getSecondaryDns
DOMString getSecondaryDns();
with with error type InvalidStateError, if a network connection is not available. (Since plugin version 3.0)
var secondaryDNS = null; try { secondaryDNS = webapis.network.getSecondaryDns(); } catch (e) { console.error("getSecondaryDNS exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != secondaryDNS) { console.log("[getSecondaryDNS] secondaryDNS: " + secondaryDNS); }
setDhcpOption60Field
void setDhcpOption60Field(DOMString vendorName);
Privilege level: partner
Privilege: http://developer.samsung.com/privilege/network.dhcpoption60
with error type InvalidStateError, if the active connection type is Wi-Fi. (Since plugin version 3.0)
with error type TypeMismatchError, if an input parameter is not compatible with its expected type. (Since plugin version 3.0)
try { webapis.network.setDhcpOption60Field("Cisco"); } catch (e) { console.error("setDHCPOption60Field exception [" + e.code + "] message: " + e.message); } console.log("[setDHCPOption60Field] DHCPOption60Field:Success ");
removeDhcpOption60Field
void removeDhcpOption60Field();
try { webapis.network.removeDhcpOption60Field(); } catch (e) { console.error("removeDHCPOption60Field exception [" + e.code + "] message: " + e.message ); } console.log("[removeDHCPOption60Field] DHCPOption60Field:Success ");
getCurrentDhcpOption60Field
DOMString getCurrentDhcpOption60Field();
var DHCPOption60Field = null; try { DHCPOption60Field = webapis.network.getCurrentDhcpOption60Field(); } catch (e) { console.error("getCurrentDHCPOption60Field exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != DHCPOption60Field) { console.log("[getCurrentDHCPOption60Field] DHCPOption60Field: " + DHCPOption60Field); }
checkCurrentIpWith60Field
DOMString checkCurrentIpWith60Field();
var DHCPOption60Field = null; try { DHCPOption60Field = webapis.network.checkCurrentIpWith60Field(); } catch (e) { console.error("checkCurrentIPwith60Field exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != DHCPOption60Field) { console.log("[checkCurrentIPwith60Field] DHCPOption60Field: " + DHCPOption60Field); }
[Callback = FunctionOnly, NoInterfaceObject]interface NetworkStateChangedCallback { void onchange(NetworkState state); };
onchange
void onchange(NetworkState state);
var Gatewaystatus =null; var onChange = function(data) { if(data == webapis.network.NetworkState.GATEWAY_CONNECTED){ Gatewaystatus ="GATEWAY_CONNECTED"; } else if(data == webapis.network.NetworkState.GATEWAY_DISCONNECTED){ Gatewaystatus ="GATEWAY_DISCONNECTED"; } else{ Gatewaystatus ="Status UNKNOWN"; } console.log("[NetworkStateChangedCallback] data :" + data +" "+ Gatewaystatus); }
[NoInterfaceObject] interface NetworkIpMode { const unsigned short NONE = 0; const unsigned short STATIC = 1; const unsigned short DYNAMIC = 2; const unsigned short AUTO = 3; const unsigned short FIXED = 4; const unsigned short UNKNOWN = 5; };
[NoInterfaceObject] interface NetworkActiveConnectionType { const unsigned short DISCONNECTED = 0; const unsigned short WIFI = 1; const unsigned short CELLULAR = 2; const unsigned short ETHERNET = 3; };
[NoInterfaceObject] interface NetworkState { const unsigned short LAN_CABLE_ATTACHED = 1; const unsigned short LAN_CABLE_DETACHED = 2; const unsigned short LAN_CABLE_STATE_UNKNOWN = 3; const unsigned short GATEWAY_CONNECTED = 4; const unsigned short GATEWAY_DISCONNECTED = 5; const unsigned short WIFI_MODULE_STATE_ATTACHED = 6; const unsigned short WIFI_MODULE_STATE_DETACHED = 7; const unsigned short WIFI_MODULE_STATE_UNKNOWN = 8; };
[NoInterfaceObject] interface NetworkWiFiSecurityMode{ const unsigned short WEP= 1; const unsigned short WPA_PSK= 2; const unsigned short WPA2_PSK = 3; const unsigned short EAP = 4; const unsigned short NONE = 5; const unsigned short UNKNOWN = 6; };
[NoInterfaceObject] interface NetworkWiFiEncryptionType{ const unsigned short WEP= 1; const unsigned short TKIP= 2; const unsigned short AES = 3; const unsigned short TKIP_AES_MIXED = 4; const unsigned short NONE = 5; const unsigned short UNKNOWN = 6; };
module Network { [NoInterfaceObject]interface NetworkManagerObject { readonly attribute NetworkManager network; }; WebApi implements NetworkManagerObject; [NoInterfaceObject]interface NetworkManager { readonly attribute NetworkActiveConnectionType NetworkActiveConnectionType; readonly attribute NetworkIpMode NetworkIpMode; readonly attribute NetworkState NetworkState; readonly attribute NetworkWiFiSecurityMode NetworkWiFiSecurityMode; readonly attribute NetworkWiFiEncryptionType NetworkWiFiEncryptionType; DOMString getVersion(); boolean isConnectedToGateway(); NetworkIpMode getIpMode(); DOMString getSubnetMask(); DOMString getGateway(); DOMString getMac(); DOMString getDns(); DOMString getIp(); NetworkActiveConnectionType getActiveConnectionType(); unsigned long addNetworkStateChangeListener(NetworkStateChangedCallback listener); void removeNetworkStateChangeListener(unsigned long listenerId); DOMString getWiFiSsid(); short getWiFiSignalStrengthLevel(); NetworkWiFiSecurityMode getWiFiSecurityMode(); NetworkWiFiEncryptionType getWiFiEncryptionType(); DOMString getSecondaryDns(); void setDhcpOption60Field(DOMString vendorName); void removeDhcpOption60Field(); DOMString getCurrentDhcpOption60Field(); DOMString checkCurrentIpWith60Field(); }; [Callback = FunctionOnly, NoInterfaceObject]interface NetworkStateChangedCallback { void onchange(NetworkState state); }; [NoInterfaceObject] interface NetworkIpMode { const unsigned short NONE = 0; const unsigned short STATIC = 1; const unsigned short DYNAMIC = 2; const unsigned short AUTO = 3; const unsigned short FIXED = 4; const unsigned short UNKNOWN = 5; }; [NoInterfaceObject] interface NetworkActiveConnectionType { const unsigned short DISCONNECTED = 0; const unsigned short WIFI = 1; const unsigned short CELLULAR = 2; const unsigned short ETHERNET = 3; }; [NoInterfaceObject] interface NetworkState { const unsigned short LAN_CABLE_ATTACHED = 1; const unsigned short LAN_CABLE_DETACHED = 2; const unsigned short LAN_CABLE_STATE_UNKNOWN = 3; const unsigned short GATEWAY_CONNECTED = 4; const unsigned short GATEWAY_DISCONNECTED = 5; const unsigned short WIFI_MODULE_STATE_ATTACHED = 6; const unsigned short WIFI_MODULE_STATE_DETACHED = 7; const unsigned short WIFI_MODULE_STATE_UNKNOWN = 8; }; [NoInterfaceObject] interface NetworkWiFiSecurityMode{ const unsigned short WEP= 1; const unsigned short WPA_PSK= 2; const unsigned short WPA2_PSK = 3; const unsigned short EAP = 4; const unsigned short NONE = 5; const unsigned short UNKNOWN = 6; }; [NoInterfaceObject] interface NetworkWiFiEncryptionType{ const unsigned short WEP= 1; const unsigned short TKIP= 2; const unsigned short AES = 3; const unsigned short TKIP_AES_MIXED = 4; const unsigned short NONE = 5; const unsigned short UNKNOWN = 6; }; };