To use Samsung Product API,
<script type="text/javascript" src="$WEBAPIS/webapis/webapis.js"></script>
Should be loaded in index.html
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Interface | Method |
---|---|
NetworkManagerObject | |
NetworkManager |
DOMString getVersion () |
NetworkStateChangedCallback | void onchange (unsigned short state) |
NetworkIpMode | |
NetworkActiveConnectionType | |
NetworkState | |
NetworkWiFiSecurityMode | |
NetworkWiFiEncryptionType |
[NoInterfaceObject]interface NetworkManagerObject {
readonly attribute NetworkManager network;
};
WebApi implements NetworkManagerObject;
Since : 2.3
[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>();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
DOMString Network plugin module versionExceptions:
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();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
Boolean value:Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if a network connection is not available. (Since plugin version 3.0)
Code example:
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();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
unsigned short Network IP modeExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
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();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
DOMString Subnet mask address for the currently-configured networkExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if a network connection is not available. (Since plugin version 3.0)
Code example:
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();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
DOMString Gateway address for the currently-configured networkExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if a network connection is not available. (Since plugin version 3.0)
Code example:
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();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
DOMString MAC address for the currently-configured networkExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if a network connection is not available. (Since plugin version 3.0)
Code example:
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();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
DOMString DNS address for the currently-configured networkExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if a network connection is not available. (Since plugin version 3.0)
Code example:
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();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
DOMString IP address for the currently-configured networkExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if a network connection is not available. (Since plugin version 3.0)
Code example:
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();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
unsigned short Currently-active network connection type:Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
Code example:
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);
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Parameters:
Return value:
unsigned long Application async listener IDExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
Code example:
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);
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type TypeMismatchError, if an input parameter is not compatible with its expected type.
with error type InvalidValuesError, if the listenerId value is not the same as the value generated by addNetworkStateChangeListener. (Since plugin version 3.0)
Code example:
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();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
DOMString Wi-Fi network SSIDExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
WebAPIException with error type InvalidStateError, if a Wi-Fi connection is not available. (Since plugin version 3.0)
Code example:
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();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
short Signal strength level. Valid values are 1 to 5. Signal strength is strongest when the value is 5.Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if a Wi-Fi connection is not available. (Since plugin version 3.0)
Code example:
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();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
unsigned short Wi-Fi security modeExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if a Wi-Fi connection is not available. (Since plugin version 3.0)
Code example:
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();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
unsigned short Wi-Fi encryption typeExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if a Wi-Fi connection is not available. (Since plugin version 3.0)
Code example:
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();
Since : 2.4
Product : SSSP
Privilege level: public
Privilege: http://developer.samsung.com/privilege/network.public
Return value:
DOMString Secondary DNS addressExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with with error type InvalidStateError, if a network connection is not available. (Since plugin version 3.0)
Code example:
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);
Since : 2.4
Product : SSSP
Privilege level: partner
Privilege: http://developer.samsung.com/privilege/network.dhcpoption60
Parameters:
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if a network connection is not available. (Since plugin version 3.0)
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)
Code example:
try {
webapis.network.setDhcpOption60Field("Cisco");
} catch (e) {
console.error("setDHCPOption60Field exception [" + e.code + "] message: " + e.message);
}
console.log("[setDHCPOption60Field] DHCPOption60Field:Success ");
removeDhcpOption60Field
void removeDhcpOption60Field();
Since : 2.4
Product : SSSP
Privilege level: partner
Privilege: http://developer.samsung.com/privilege/network.dhcpoption60
Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if a network connection is not available. (Since plugin version 3.0)
with error type InvalidStateError, if the active connection type is Wi-Fi. (Since plugin version 3.0)
Code example:
try {
webapis.network.removeDhcpOption60Field();
} catch (e) {
console.error("removeDHCPOption60Field exception [" + e.code + "] message: " + e.message );
}
console.log("[removeDHCPOption60Field] DHCPOption60Field:Success ");
getCurrentDhcpOption60Field
DOMString getCurrentDhcpOption60Field();
Since : 2.4
Product : SSSP
Privilege level: partner
Privilege: http://developer.samsung.com/privilege/network.dhcpoption60
Return value:
DOMString Vendor-specific string. Default value is "default".Exceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if a network connection is not available. (Since plugin version 3.0)
with error type InvalidStateError, if the active connection type is Wi-Fi. (Since plugin version 3.0)
Code example:
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();
Since : 2.4
Product : SSSP
Privilege level: partner
Privilege: http://developer.samsung.com/privilege/network.dhcpoption60
Return value:
DOMString Vendor stringExceptions:
with error type SecurityError, if the application does not have the privilege to call this method.
with error type InvalidStateError, if a network connection is not available. (Since plugin version 3.0)
with error type InvalidStateError, if the active connection type is Wi-Fi. (Since plugin version 3.0)
Code example:
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);
Parameters:
Code example:
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;
};
Since : 2.3
[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;
};
Since : 2.3
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;
};
};