Connection
The connection features enable you to create a network connection and perform various operations over the connection. The application can access connection details, such as the IP address, proxy information, gateway information, and connection statistics.
Connection Manager
The Connection Manager API (in mobile and wearable applications) provides functions for managing data connections. It allows you to get a state of the connection interface such as Bluetooth, cellular, and Wi-Fi. It also contains functions for getting the IP address, proxy information, and gateway information.
The Connection Manager API is related with libcurl and sockets. After a network connection is established, you can create a socket on the kernel Linux stack to be used directly or by libcurl or any other network library. If you want to create a socket directly without libcurl, you must check whether you are using the IPv4 or IPv6 environment, and create an applicable IP socket.
The Connection Manager provides the following typedefs and enumerators for managing data connections:
-
connection_h
Connection handle for all connection functions. To use the Connection Manager API, first create a connection handle using the connection_create() function. Afterwards, you can obtain network information.
-
connection_profile_h
Profile handle, which provides information according to the connection type.
- Connection state enumerators
One of the following states is returned by the connection_get_[interface]_state() function:
- connection_bt_state_e
- connection_cellular_state_e
- connection_wifi_state_e
The Connection Manager supports getting the connection state for Bluetooth, cellular and Wi-Fi.
-
connection_address_family_e
Enumeration for the address family. It provides IPv4 and IPv6. You can use it as a parameter when you get the IP address of the current connection or proxy.
Connection Profile
The Connection Profile API (in mobile and wearable applications) provides functions for mapping a connection profile. It allows you to use a connection_profile_h handle for getting details about the connection.
Each profile is defined by a set of configuration information defined in the connection_profile_h handle. The profile provides different information according to the connection type (such as Bluetooth, cellular, ethernet, and Wi-Fi).
The following tables define the available profile information, which you can get using the connection_profile_get_*() function.
Information | Description |
---|---|
Profile type | Profile type indicating the network connection type |
Profile ID | Unique profile ID; when you create a new profile, this value is determined |
Profile name | Profile name associated with the profile ID |
Profile state | Profile state, such as disconnected, association, configuration, or connected |
DNS address | DNS address; you can get the first and second DNS address |
Gateway address | Gateway address |
Subnet mask | Subnet mask |
Proxy address | Proxy address |
Proxy type | Proxy method, such as direct or auto |
Network interface name | Name of the network interface, such as eth0 or pdp0 |
IP address | IP address |
IP configuration type | IP address configuration type, such as static, dynamic, auto, or fixed |
Information | Description |
---|---|
Essid | Extended service set identifier |
Bssid | Basic service set identifier |
Encryption type | Type for encryption modes, such as WEP, TKIP, AES or TKIP/AES mixed |
Frequency | Frequency (in MHz) |
Max speed | Maximum speed (in Mbps) |
Passphrase required | Passphrase compulsion |
WPS supported | WPS (Wi-Fi Protected Setup) support |
Security type | Wi-Fi security type; supports WEP, WPA-PSK, WPA2-PSK, and EAP |
Rssi | Received signal strength indication |
Information | Description |
---|---|
APN | Access Point Name |
Cellular authentication info | Authentication information, including user name and password |
Cellular home URL | Home URL |
Service type | Cellular service type |
Connection Statistics
Use the Connection Statistics API (in mobile and wearable applications) to gather and reset statistics on the network usage, such as the amount of sent or received data. The statistics also provide functions for getting the cumulative size of packets sent or received since the last reset based on the operation mode, such as packet switching (PS).
Note |
---|
Only Wi-Fi and cellular connections are supported in the statistics. |
The following table lists the connection type constants.
Constant | Description |
---|---|
CONNECTION_TYPE_WIFI | Wi-Fi type |
CONNECTION_TYPE_CELLULAR | Cellular type |
The following table lists the statistics constants.
Constant | Description |
---|---|
CONNECTION_STATISTICS_TYPE_LAST_RECEIVED_DATA | Last received data |
CONNECTION_STATISTICS_TYPE_LAST_SENT_DATA | Last sent data |
CONNECTION_STATISTICS_TYPE_TOTAL_RECEIVED_DATA | Total received data |
CONNECTION_STATISTICS_TYPE_TOTAL_SENT_DATA | Total sent data |
Use the connection_reset_statistics() function to re-initialize the statistics.