×
Namespaces

Variants
Actions

How to change mobile device's Network Mode programmatically in Symbian^3

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata
Tested with
Devices(s): Nokia N8
Compatibility
Platform(s): Symbian^3
Platform Security
Signing Required: DevCert
Capabilities: NetworkControl
Article
Keywords: RMobilePhone, RMmCustomAPI
Created: User:Kbwiki (01 Nov 2010)
Last edited: hamishwillee (03 Jul 2012)

Description

This article describes how to change the global network mode (UMTS/GSM/DualMode) programmatically.

Note.pngNote: RMmCustomAPI is not part of the Symbian^3 public SDK. See the RMmCustomAPI Class Reference at symlab.org (a small archive/mirror site of symbian.org).

Solution

The following Capabilities and libraries are required:

CAPABILITY NetworkControl 

LIBRARY etel.lib etelmm.lib customapi.lib         


 #include <etelmm.h>
#include <e32property.h>
#include <RMmCustomAPI.h>
 
// Class member variables
RMobilePhone iMobilePhone;
RTelServer iTelServer;
TFileName iTsyName;
RMmCustomAPI iCustomAPI;

Initialisation

 // In ConstructL()
User::LeaveIfError(iTelServer.Connect());
User::LeaveIfError(iTelServer.RTelServer::GetTsyName(0,iTsyName));
User::LeaveIfError(iTelServer.LoadPhoneModule(iTsyName));
TInt numPhones;
User::LeaveIfError(iTelServer.EnumeratePhones(numPhones));
 
if (numPhones < 1)
User::Leave(KErrNotFound);
 
// Get info about the first available phone
RTelServer::TPhoneInfo info;
User::LeaveIfError(iTelServer.GetPhoneInfo(0, info));
 
//Use this info to open a connection to the phone
iMobilePhone.Open(iTelServer, info.iName);
User::LeaveIfError(iCustomAPI.Open(iMobilePhone));

Changing the network mode

 TInt error = KErrNone;
 
// To get the current network mode
TUint32 currentNetworkModes;
error = iCustomAPI.GetCurrentSystemNetworkModes(currentNetworkModes);
 
// To set the Network Mode as GSM
error = iCustomAPI.SetSystemNetworkMode(RMmCustomAPI::KCapsNetworkModeGsm);
 
// To set the Network Mode as UMTS/3G
error = iCustomAPI.SetSystemNetworkMode(RMmCustomAPI::KCapsNetworkModeUmts);

Releasing resources

 iMobilePhone.Close();
iTelServer.Close();
This page was last modified on 3 July 2012, at 03:14.
61 page views in the last 30 days.
×