Determine the bearer type using RConnectionMonitor API
Article Metadata
Tested with
Devices(s): All (S60)
Compatibility
Platform(s): S60 3rd Edition
S60 5th Edition
S60 5th Edition
Article
Keywords: RConnectionMonitor, GetIntAttribute, KBearer
Created: User:Kbwiki
(23 Apr 2010)
Last edited: hamishwillee
(01 Aug 2012)
Description
The RConnectionMonitor class provides methods for retrieving the bearer type of the current active network connection. The count of all active connections can be retrieved using RConnectionMonitor::GetConnectionCount(). Then, for each active connection, we can retrieve the connection ID and count of subconnections using RConnectionMonitor::GetConnectionInfo(). Once the connection ID is available we can determine the bearer type using RConnectionMonitor::GetIntAttribute () by passing the attribute KBearer for the desired connection.
Note however that the NetworkControl capability is required to retrieve this information.
Solution
Required Headers & Libraries:
#include <rconnmon.h> // Link against connmon.lib
Code:
RConnectionMonitor monitor;
TRequestStatus status1, status2;
TInt bearerType( 0 );
TUint connectionCount( 0 );
TUint subConnectionCount( 0 );
TUint connectionId( 0 );
monitor.ConnectL(); // Open RConnectionMonitor object
// Get connection count
monitor.GetConnectionCount( connectionCount, status1 );
User::WaitForRequest( status1 );
if ( status1.Int() != KErrNone )
{
// Handle errors
}
if ( connectionCount == 0 )
{
// No connection
}
// Get connection info of all the active connections
for ( TUint idx = 1; idx <= iConnectionCount; idx++ )
{
// Get the connection id
TInt error = monitor.GetConnectionInfo( idx, connectionId,
subConnectionCount );
if ( error != KErrNone )
{
// Handle errors
}
// Retrieve the bearer type - on return, bearerType will
// contain one of the values in TConnMonBearerType enumeration
monitor.GetIntAttribute( connectionId, 0, KBearer, bearerType, status2 );
User::WaitForRequest( status2 );
if ( status2.Int() != KErrNone )
{
// Handle errors
}
}
monitor.Close(); // Close RConnectionMonitor object
Required Capabilities: NetworkControl


(no comments yet)