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
This module defines the network information retrieval functionalities provided by the Tizen Samsung Product API.
Since : 2.3
Product : TV, AV, B2B
Privilege Level : Public
Privilege : http://developer.samsung.com/privilege/network.public
Defines a WebApi object instance of the Tizen Samsung Product API. The webapis.network object enables access to Network API functionality.
[NoInterfaceObject] interface NetworkManagerObject { readonly attribute NetworkManager network; };
WebApi implements NetworkManagerObject;
Provides methods for network functionalities.
[NoInterfaceObject] interface NetworkManager { attribute NetworkActiveConnectionType NetworkActiveConnectionType; attribute NetworkIpMode NetworkIpMode; attribute NetworkState NetworkState; attribute NetworkWiFiSecurityMode NetworkWiFiSecurityMode; attribute NetworkWiFiEncryptionType NetworkWiFiEncryptionType; DOMString getVersion(); boolean isConnectedToGateway(); NetworkIpMode getIpMode(); DOMString getSubnetMask(); DOMString getGateway(); DOMString getMac(); DOMString getDns(); DOMString getIp(); DOMString getTVName(); NetworkActiveConnectionType getActiveConnectionType(); unsigned long addNetworkStateChangeListener(NetworkStateChangedCallback listener); void removeNetworkStateChangeListener(unsigned long listenerId); DOMString getWiFiSsid(); long getWiFiSignalStrengthLevel(); NetworkWiFiSecurityMode getWiFiSecurityMode(); NetworkWiFiEncryptionType getWiFiEncryptionType(); DOMString getSecondaryDns(); void setDhcpOption60Field(DOMString vendorName); void removeDhcpOption60Field(); DOMString getCurrentDhcpOption60Field(); DOMString checkCurrentIpWith60Field(); void setEAPCAfilePath(DOMString path); void setEAPPassphrase(DOMString name, DOMString password); long getWiFiFrequency(); };
Retrieves the device network module version.
DOMString getVersion();
Return Value :
Exceptions :
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); }
Checks whether the device is connected to a network gateway.
boolean isConnectedToGateway();
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); }
Retrieves the device's IP configuration mode.
NetworkIpMode 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); }
Retrieves the device's configured subnet mask address.
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); }
Retrieves the device's configured gateway address.
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); }
Retrieves the network device's MAC address.
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); }
Retrieves the device's configured DNS address.
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); }
Retrieves the device's configured IP address.
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); }
Retrieves the device's configured name when device is connected to a network.
DOMString getTVName();
Since : 4.0
var tvname = null; try { tvname = webapis.network.getTVName(); } catch (e) { console.log("getTVName exception [" + e.code + "] mname: " + e.name + " message: " + e.message); } if (null != tvname) { console.log("[getTVName] tvname : " + tvname); }
Retrieves the device's currently-active connection type.
NetworkActiveConnectionType 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); }
Registers an asynchronous event listener.
unsigned long addNetworkStateChangeListener(NetworkStateChangedCallback listener);
Parameters :
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 + "] "); }
Unregisters an asynchronous event listener.
void removeNetworkStateChangeListener(unsigned long listenerId);
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");
Retrieves the Wi-Fi network SSID. Works only when the active connection type is Wi-Fi.
DOMString getWiFiSsid();
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); }
Retrieves the Wi-Fi signal strength. Works only when the active connection type is Wi-Fi.
long getWiFiSignalStrengthLevel();
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); }
Retrieves the Wi-Fi security mode. Works only when the active connection type is Wi-Fi.
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); }
Retrieves the Wi-Fi encryption type. Works only when the active connection type is Wi-Fi.
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); }
Retrieves the device's configured secondary DNS address.
DOMString getSecondaryDns();
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); }
Sets the DHCP option 60 vendor string. Works only when the active connection type is wired. The vendor string is updated when Udhcpc is restarted or relaunched.
void setDhcpOption60Field(DOMString vendorName);
Privilege Level : Partner
Privilege : http://developer.samsung.com/privilege/network.dhcpoption60
try { webapis.network.setDhcpOption60Field("Cisco"); } catch (e) { console.error("setDHCPOption60Field exception [" + e.code + "] message: " + e.message); } console.log("[setDHCPOption60Field] DHCPOption60Field:Success ");
Sets the DHCP option 60 vendor string to the default value, "udhcpc1.21.1". Works only when the active connection type is wired. The vendor string is updated when Udhcpc is restarted or relaunched.
void removeDhcpOption60Field();
try { webapis.network.removeDhcpOption60Field(); } catch (e) { console.error("removeDHCPOption60Field exception [" + e.code + "] message: " + e.message ); } console.log("[removeDHCPOption60Field] DHCPOption60Field:Success ");
Retrieves the DHCP option 60 vendor string. Works only when the active connection type is wired.
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); }
Retrieves the DHCP option 60 vendor string currently used by Udhcp. Works only when the active connection type is wired.
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); }
Set the PEAP certification file path for PEAP base AP connection.
void setEAPCAfilePath(DOMString path);
Product : B2B
Since : 6.5
var err = false; try { webapis.network.setEAPCAfilePath("/opt/usr/home/owner/share/Root_test/ca.der"); } catch (e) { console.error("setEAPCAfilePath exception [" + e.code + "] name: " + e.name + " message: " + e.message); err = true; } if (err != true) { console.log("[setEAPCAfilePath] SUCCESS"); }
sets the username and password.
void setEAPPassphrase(DOMString name, DOMString password);
var err = false; try { webapis.network.setEAPPassphrase("testing11", "password11"); } catch (e) { console.error("setEAPPassphrase exception [" + e.code + "] name: " + e.name + " message: " + e.message); err = true; } if (err != true) { console.log("[setEAPPassphrase] SUCCESS"); }
Retrieves the Wi-Fi network Frequency. Works only when the active connection type is Wi-Fi.
long getWiFiFrequency();
Since : 6.0
var WiFiFrequency = null; try { WiFiFrequency = webapis.network.getWiFiFrequency(); } catch (e) { console.log("getWiFiFrequency exception [" + e.code + "] name: " + e.name + " message: " + e.message); } if (null != WiFiFrequency) { console.log("[getWiFiFrequency] WiFiFrequency: " + WiFiFrequency); }
Defines a listener for gateway connection state change notifications.
[Callback = FunctionOnly, NoInterfaceObject] interface NetworkStateChangedCallback { void onchange(NetworkState state); };
Callback method for gateway connection state change notifications.
void onchange(NetworkState state);
Since : 3.0
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); }
Defines constants for network IP modes.
[NoInterfaceObject] interface NetworkIpMode { const unsigned long NONE = 0; const unsigned long STATIC = 1; const unsigned long DYNAMIC = 2; const unsigned long AUTO = 3; const unsigned long FIXED = 4; const unsigned long UNKNOWN = 5; };
Defines constants for network connection types.
[NoInterfaceObject] interface NetworkActiveConnectionType { const unsigned long DISCONNECTED = 0; const unsigned long WIFI = 1; const unsigned long CELLULAR = 2; const unsigned long ETHERNET = 3; };
Defines constants for network states.
[NoInterfaceObject] interface NetworkState { const unsigned long INTERNET_CONNECTED = 0; const unsigned long LAN_CABLE_ATTACHED = 1; const unsigned long LAN_CABLE_DETACHED = 2; const unsigned long LAN_CABLE_STATE_UNKNOWN = 3; const unsigned long GATEWAY_CONNECTED = 4; const unsigned long GATEWAY_DISCONNECTED = 5; const unsigned long WIFI_MODULE_STATE_ATTACHED = 6; const unsigned long WIFI_MODULE_STATE_DETACHED = 7; const unsigned long WIFI_MODULE_STATE_UNKNOWN = 8; const unsigned long INTERNET_DISCONNECTED = 9; };
Defines constants for Wi-Fi network security modes.
[NoInterfaceObject] interface NetworkWiFiSecurityMode { const unsigned long WEP = 1; const unsigned long WPA_PSK = 2; const unsigned long WPA2_PSK = 3; const unsigned long EAP = 4; const unsigned long NONE = 5; const unsigned long UNKNOWN = 6; };
Defines constants for Wi-fi network encryption types.
[NoInterfaceObject] interface NetworkWiFiEncryptionType { const unsigned long WEP = 1; const unsigned long TKIP = 2; const unsigned long AES = 3; const unsigned long TKIP_AES_MIXED = 4; const unsigned long NONE = 5; const unsigned long UNKNOWN = 6; };
module Network { [NoInterfaceObject] interface NetworkManagerObject { readonly attribute NetworkManager network; }; WebApi implements NetworkManagerObject; [NoInterfaceObject] interface NetworkManager { attribute NetworkActiveConnectionType NetworkActiveConnectionType; attribute NetworkIpMode NetworkIpMode; attribute NetworkState NetworkState; attribute NetworkWiFiSecurityMode NetworkWiFiSecurityMode; attribute NetworkWiFiEncryptionType NetworkWiFiEncryptionType; DOMString getVersion(); boolean isConnectedToGateway(); NetworkIpMode getIpMode(); DOMString getSubnetMask(); DOMString getGateway(); DOMString getMac(); DOMString getDns(); DOMString getIp(); DOMString getTVName(); NetworkActiveConnectionType getActiveConnectionType(); unsigned long addNetworkStateChangeListener(NetworkStateChangedCallback listener); void removeNetworkStateChangeListener(unsigned long listenerId); DOMString getWiFiSsid(); long getWiFiSignalStrengthLevel(); NetworkWiFiSecurityMode getWiFiSecurityMode(); NetworkWiFiEncryptionType getWiFiEncryptionType(); DOMString getSecondaryDns(); void setDhcpOption60Field(DOMString vendorName); void removeDhcpOption60Field(); DOMString getCurrentDhcpOption60Field(); DOMString checkCurrentIpWith60Field(); void setEAPCAfilePath(DOMString path); void setEAPPassphrase(DOMString name, DOMString password); long getWiFiFrequency(); }; [Callback = FunctionOnly, NoInterfaceObject] interface NetworkStateChangedCallback { void onchange(NetworkState state); }; [NoInterfaceObject] interface NetworkIpMode { const unsigned long NONE = 0; const unsigned long STATIC = 1; const unsigned long DYNAMIC = 2; const unsigned long AUTO = 3; const unsigned long FIXED = 4; const unsigned long UNKNOWN = 5; }; [NoInterfaceObject] interface NetworkActiveConnectionType { const unsigned long DISCONNECTED = 0; const unsigned long WIFI = 1; const unsigned long CELLULAR = 2; const unsigned long ETHERNET = 3; }; [NoInterfaceObject] interface NetworkState { const unsigned long INTERNET_CONNECTED = 0; const unsigned long LAN_CABLE_ATTACHED = 1; const unsigned long LAN_CABLE_DETACHED = 2; const unsigned long LAN_CABLE_STATE_UNKNOWN = 3; const unsigned long GATEWAY_CONNECTED = 4; const unsigned long GATEWAY_DISCONNECTED = 5; const unsigned long WIFI_MODULE_STATE_ATTACHED = 6; const unsigned long WIFI_MODULE_STATE_DETACHED = 7; const unsigned long WIFI_MODULE_STATE_UNKNOWN = 8; const unsigned long INTERNET_DISCONNECTED = 9; }; [NoInterfaceObject] interface NetworkWiFiSecurityMode { const unsigned long WEP = 1; const unsigned long WPA_PSK = 2; const unsigned long WPA2_PSK = 3; const unsigned long EAP = 4; const unsigned long NONE = 5; const unsigned long UNKNOWN = 6; }; [NoInterfaceObject] interface NetworkWiFiEncryptionType { const unsigned long WEP = 1; const unsigned long TKIP = 2; const unsigned long AES = 3; const unsigned long TKIP_AES_MIXED = 4; const unsigned long NONE = 5; const unsigned long UNKNOWN = 6; }; };