Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

How to create access points

From Wiki
Jump to: navigation, search
Article Metadata
Code ExampleArticle
Created: (27 Jun 2007)
Last edited: hamishwillee (30 May 2013)

Access points are required to establish connection for data transfers. Its always a nice feature to create an access point in code than to go to settings and do.

In this page I will give code snippet for creating a WLAN access point and a sample application for creating a GPRS access point.

Creating a WLAN access point (With WEP security settings)

A wireless access point (WAP or AP) is a device that connects wireless communication devices together to form a wireless network. The WAP usually connects to a wired network, and can relay data between wireless devices and wired devices. Several WAPs can link together to form a larger network that allows "roaming". (In contrast, a network where the client devices manage themselves - without the need for any access points - becomes an ad-hoc network.) WAPs have IP addresses for configuration.

The following headers are required for this

#include <commdb.h>        // link against commdb.lib
#include <apselect.h>      // link against apengine.lib
#include <aplistitem.h>
#include <apdatahandler.h>
#include <apaccesspointitem.h>
#include <wlancdbcols.h>   // for security settings 

A WLAN access point can be created using the following code snippet.

Creating a WLAN access point:

 CApAccessPointItem *wlan = CApAccessPointItem::NewLC();
wlan->WriteTextL(EApWlanNetworkName, _L("WlanAP"));
// security mode 2 refers to WEP.
// network mode refers to whether its AdHoc or Infrastructure mode.

Store it into the CommsDb

 CCommsDatabase *commDb = CCommsDatabase::NewL();
CApDataHandler *handler = CApDataHandler::NewLC(*commDb);
TInt err = commDb ->BeginTransaction();
TUint32 newApId = handler->CreateFromDataL(*wlan);
CleanupStack::PopAndDestroy(3); // handler, commDb, wlan

For Symbian OS v9.1 necessary to use capability 'WriteDeviceData', else CreateFromDataL() generate leave KErrAbort (-39).

Setting the security settings:

 enum TWEPKeyFormat
EAscii, // Ascii format
EHexadecimal // Hex format
enum TWEPKeyInUse
EKeyNumber1, // Key number 1
EKeyNumber2, // Key number 2
EKeyNumber3, // Key number 3
EKeyNumber4 // Key number 4
enum TWEPAuthentication
EAuthOpen, // Open authentication
EAuthShared // Shared authentication
//wlanNew1 is an object of CApAccessPointItem
wlanNew1->ReadUint( EApIapServiceId, newalanid );
// we need to get the IAP id to manupulate the security settings.
//Should be the same value to which the WLAN router is configured
iKeyFormat=EAscii; // TWEPKeyFormat
iAuthentication=EAuthShared; // TWEPAuthentication
iKeyInUse=EKeyNumber3; // TWEPKeyInUse
wLanServiceTable = db->OpenViewMatchingUintLC(
// Give the corresponding IAP ID
errorCode = wLanServiceTable->GotoFirstRecord();
TBool ival =ETrue;
if ( errorCode == KErrNone )
TUint32 dummyUid( KUidNone );
User::LeaveIfError( wLanServiceTable->InsertRecord( dummyUid ) );
// Save link to LAN service
wLanServiceTable->WriteUintL( TPtrC( WLAN_SERVICE_ID ), newApId);
// Save index of key in use (1,2,3 or 4)
( TUint32& ) iKeyInUse )
// Save the authentication type (shared or Open)
( TUint32& )iAuthentication )
// save the correct keydata corresponding to the router configuration
iKeyData )
// Save the format of the key (Hexadecimal or Ascii)
( TUint32& ) iKeyFormat
err = db->CommitTransaction();
// End a transaction.
// Call after `InsertRecord()` or `UpdateRecord()`.

NOTE: The Key In Use, the Key format and the Key data should be the same as the WLAN router or else the connection will not be established.

Creating a GPRS access point

An access point is:

An Internet network to which a mobile can be connected.

A set of settings which are used for that connection.

A particular option in a set of settings in a mobile phone.

Find the sample application from the following link which creates a GPRS access point.

Internal links

This page was last modified on 30 May 2013, at 04:38.
74 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.