Connection Manager

Service URI - luna://com.palm.connectionmanager

Provides the status of available Internet connections.

Connection manager provides methods for managing Internet connections. It enables apps to get the status of connections.

Methods

Method

Description

Supported in Emulator

getStatus

Gets the current status of network connections (both WiFi and wired) on the system.

Partially

(Only Wired)

getStatus

Description

Gets the current status of network connections (both Wi-Fi and wired) on the system. Apps can subscribe to it so that they are notified whenever the network status changes.

Parameters

NameRequiredTypeDescription
subscribe
No
Boolean
Flag that decides whether to subscribe or not.
  • true : Subscribe.
  • false : Do not subscribe. Call the method only once. (Default)

Call returns

NameRequiredTypeDescription
returnValue
Yes
Boolean
Flag that indicates success/failure of the request.
  • true: Success
  • false: Failure
errorText
No
String
`errorText` contains the error text if the method fails. The method will return `errorText` only if it fails.
See the Error code reference of this method for more details.
subscribed
No
Boolean
Flag that indicates whether the subscription is enabled or not.
  • true: Enabled
  • false: Not enabled.
isInternetConnectionAvailable
Yes
Boolean
Flag that indicates whether internet connection is available or not.
  • true: Any internet connection is available.
  • false: No internet connections are available.
Yes
Object
Object that contains information about the state of the wired connection.
Yes
Object
Object that contains information about the state of the Wi-Fi connection.
Yes
Object
Object that contains information about the state of the Wi-Fi direct connection.

Subscription returns

NameRequiredTypeDescription
isInternetConnectionAvailable
Yes
Boolean
Flag that indicates whether internet connection is available or not.
  • true: Any internet connection is available.
  • false: No internet connections are available.
Yes
Object
Object that contains information about the state of the wired connection.
Yes
Object
Object that contains information about the state of the Wi-Fi connection.
Yes
Object
Object that contains information about the state of the Wi-Fi direct connection.
Note

  • In webOS TV 3.X, the subscription feature of `getStatus()` is not working correctly. In this case, use the following service URI for subscription:

    luna://com.webos.service.connectionmanager

  • Regardless of the webOS TV version, you can easily monitor the network status using the following method in webOSTV.js: connection.getStatus

Error code reference

Error Message

Error Description

Connman manager is not available

The Connection Manager(connman) process is not running, and the network status is not available at this time.

Example

// One-time call
var request = webOS.service.request('luna://com.palm.connectionmanager', {
  method: 'getStatus',
  onSuccess: function (inResponse) {
    console.log('Result: ' + JSON.stringify(inResponse));
    // To-Do something
  },
  onFailure: function (inError) {
    console.log('Failed to get network state');
    console.log('[' + inError.errorCode + ']: ' + inError.errorText);
    // To-Do something
    return;
  },
});

// Subscription
var subscriptionHandle;

subscriptionHandle = webOS.service.request(
  'luna://com.palm.connectionmanager',
  {
    method: 'getStatus',
    parameters: { subscribe: true },
    onSuccess: function (inResponse) {
      if (typeof inResponse.subscribed != 'undefined') {
        if (!inResponse.subscribed) {
          console.log('Failed to subscribe network state');
          return;
        }
      }

      console.log('Result: ' + JSON.stringify(inResponse));
      // To-Do something
    },
    onFailure: function (inError) {
      console.log('Failed to get network state');
      console.log('[' + inError.errorCode + ']: ' + inError.errorText);
      // To-Do something
      return;
    },
  }
);
...
// If you need to unsubscribe the data, use cancel() method as below
subscriptionHandle.cancel();

Return example

{
  "wired": {
      "netmask": "255.255.254.0",
      "dns1": "123.456.789.180",
      "ipAddress": "123.456.789.12",
      "onInternet": "yes",
      "method": "manual",
      "state": "connected",
      "gateway": "123.456.789.1",
      "interfaceName": "eth0"
  },
  "isInternetConnectionAvailable": true,
  "wifi": {
      "state": "disconnected"
  },
  "returnValue": true,
  "wifiDirect": {
      "state": "disconnected"
  }
}

See also

None

Object

wired object

The `wired` object provides details on the status of the wired connections.

Only if the `wired` connection is available will all the fields of this object contain the relevant information. If the wired connection is not available, the `state` field of this object will be set to `disconnected` and is the only value that is returned to the calling app.

{
  "state": String,
  "interfaceName": String,
  "ipAddress": String,
  "netmaks": String,
  "gateway": String,
  "dns1": String,
  "dns2": String,
  "dns2": String,
  "method": String,
  "onInternet": String
}
NameRequiredTypeDescription
state
Yes
String
If the wired connection is available it will be set to `connected`. If the wired connection is not available, it will be set to `disconnected`.
interfaceName
No
String
Name of the wired interface in use. For example, `ppp0`.
ipAddress
No
String
The IP address associated with the wired connection.
netmask
No
String
The netmask value for the wired connection.
gateway
No
String
The IP address of the network gateway.
dns1
No
String
Primary DNS address for the wired connection.
dns2
No
String
Secondary DNS address for the wired connection.
dns3
No
String
Tertiary DNS address for the wired connection.
method
No
String
If the IP address was assigned using manual mode, `method` will contain manual. If the IP address was assigned through DHCP, `method` will contain `dhcp`.
onInternet
No
String
The captive portal technique forces an HTTP client on a network to see a special web page (usually for authentication purposes) before using the Internet normally. Captive portals are used at most Wi-Fi hotspots. The `onInternet` will contain one of the following values:
  • yes : Indicating the WiFi connection is connected to the Internet.
  • no : Indicating the WiFi connection is not connected to the Internet.

wifi object

The `wifi` object provides details on the status of the WiFi connection. Only if the WiFi connection is available all the fields of this object will contain the relevant information. If the WiFi connection is not available, only the `state` field of this object will be set to `disconnected`, and is the only value that is returned to the calling app.

{
  "state": String,
  "interfaceName": String,
  "ipAddress": String,
  "netmask": String,
  "gateway": String,
  "dns1": String,
  "dns2": String,
  "dns3": String,
  "method": String,
  "ssid": String,
  "isWakeOnWiFiEnabled": String,
  "onInternet": String
} 
NameRequiredTypeDescription
state
Yes
String
If the Wi-Fi connection is available it will be set to `connected`. If the Wi-Fi connection is not available, it will be set to `disconnected`.
interfaceName
No
String
Name of the Wi-Fi Interface name in use. For example, `eth0`.
ipAddress
No
String
The IP address associated with the Wi-Fi connection.
netmask
No
String
The netmask value for the Wi-Fi connection.
gateway
No
String
The IP address of the network gateway.
dns1
No
String
Primary DNS address for the Wi-Fi connection.
dns2
No
String
Secondary DNS address for the Wi-Fi connection.
dns3
No
String
Tertiary DNS address for the Wi-Fi connection.
method
No
String
If the IP address was assigned using the manual mode, `method` will contain manual. If the IP Address was assigned through DHCP, `method` will contain `dhcp`.
ssid
No
String
The SSID of the connected service (if known).
isWakeOnWiFiEnabled
No
Boolean
If the Wi‑Fi interface was set to stay up even when suspended, `isWakeOnWiFiEnabled` will contain `true`. If the Wi‑Fi interface was not set to stay up when suspended, `isWakeOnWiFiEnabled` will contain `false`.
onInternet
No
String
The captive portal technique forces an HTTP client on a network to see a special web page (usually for authentication purposes) before using the Internet normally. Captive portals are used at most Wi‑Fi hotspots. The `onInternet` will contain one of the following values:
  • yes : Indicating the Wi‑Fi connection is connected to the Internet.
  • no : Indicating the Wi‑Fi connection is not connected to the Internet.

wifiDirect object

The `wifiDirect` object provides details on the status of the Wi-Fi direct connection. Only if the Wi-Fi direct connection is available all the fields of this object will contain the relevant information. If the Wi-Fi direct connection is not available, only the `state` field of this object will be set to `disconnected`, and is the only value that is returned to the calling app.

{
  "state": String,
  "connectedPeers": WifiPeerInfo Object,
  "localIp": String,
} 

Name

Required

Type

Description

state

Yes

String

If the Wi-Fi connection is available it will be set to `connected`. If the Wi-Fi connection is not available, it will be set to `disconnected`.

connectedPeers

No

Object Array

A list of objects that provides information about connected peers.

localIp

No

String

The IP address of the local connection endpoint.

WifiPeerInfo object

This object contains information on a peer-to-peer client.

{
  "deviceName": String,
  "deviceAddress": String,
  "groupOwner": Boolean,
  "configMethod": Number,
  "signalLevel": Number,
  "wfdInfo": WifiWfdInfo Object,
  "connected": Boolean,
  "peerIp": String,
  "invited": String,
  "serviceDiscoveryResponse": String
} 

Name

Required

Type

Description

deviceName

Yes

String

Device name

deviceAddress

No

String

Device address

groupOwner

Yes

Boolean

Group owner

configMethod

No

Number

Configuration method

signalLevel

Yes

Number

Signal level

wfdInfo

No

Object

WFD information

connected

Yes

Boolean

Connection status

peerIp

No

String

IPv4 address

invited

No

String

If the connection is available, this property will be set to `true`. If the connection is not available, this property will be set to `false`.

serviceDiscoveryResponse

No

String

Service discovery response. Only sent on the first inquiry and never again.

WifiWfdInfo object (Wi-Fi Direct Info object)

This object contains information on the Wi-Fi Direct settings of a Wi-Fi Peer connection. It is used in Wi-Fi Peer Info and is only present when the connection uses Wi-Fi Direct.

{
  "wfdCpSupport": Boolean,
  "wfdDeviceType": String,
  "wfdRtspPort": Number,
  "wfdSessionAvail": Boolean,
} 
NameRequiredTypeDescription
wfdCpSupport
Yes
Boolean
The flag that indicates whether the Wi-Fi Direct content protection is supported:
  • true: Supported
  • false: Not supported.
wfdDeviceType
Yes
String
Wi-Fi Direct device type, one of:
  • source
  • primary-sink
  • secondary-sink
wfdRtspPort
Yes
Number
Control port for Wi-Fi Direct session management.
wfdSessionAvail
Yes
Boolean
The flag that indicates whether the session is available:
  • true: Available
  • false: Not available

No Headings