Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 00:57, 15 July 2008.

How to create access points

From Forum Nokia Wiki

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->SetNamesL(_L("NewAP"));
 wlan->SetBearerTypeL(EApBearerTypeWLAN);
 wlan->WriteTextL(EApWlanNetworkName, _L("WlanAP"));
 wlan->WriteUint(EApWlanSecurityMode,2); 
           // security mode 2 refers to WEP. 
 wlan->WriteUint(EApWlanNetworkMode,1); 
           // network mode refers to whether its AdHoc or Infrastructure mode.

Store it into the CommsDb

CCommsDatabase *commDb = CCommsDatabase::NewL();
 CleanupStack::PushL(db);
 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
    };
 
 handler->AccessPointDataL(newApId,*wlanNew1); 
 //wlanNew1 is an object of CApAccessPointItem 
			
 wlanNew1->ReadUint( EApIapServiceId, newalanid );
 
 // we need to get the IAP id to manupulate the security settings.
					
			
 iKeyData.Copy(_L("626ABB616A"));
 //Should be the same value to which the WLAN router is configured
 
 iKeyFormat=EAscii;           // TWEPKeyFormat
 iAuthentication=EAuthShared; // TWEPAuthentication
 iKeyInUse=EKeyNumber3;       // TWEPKeyInUse
 
 wLanServiceTable = db->OpenViewMatchingUintLC(
                                               TPtrC(  WLAN_SERVICE ),
                                               TPtrC( WLAN_SERVICE_ID ),
                                                      newalanid 
                                               ); 
 // Give the corresponding IAP ID
        
 errorCode = wLanServiceTable->GotoFirstRecord();
 
 TBool ival =ETrue;
 if ( errorCode == KErrNone )
 {
 wLanServiceTable->UpdateRecord();
 }
 else
 {
 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)
 TRAP(error,wLanServiceTable->WriteUintL( 
                                        TPtrC( WLAN_WEP_INDEX ),
                                        ( TUint32& ) iKeyInUse )
                                         );
					 
// Save the authentication type (shared or Open)
 TRAP(error,wLanServiceTable->WriteUintL( 
                                         TPtrC( WLAN_AUTHENTICATION_MODE ),
                                         ( TUint32& )iAuthentication )
                                         );
					 
// save the correct keydata corresponding to the router configuration
 TRAP(error,wLanServiceTable->WriteTextL( 
                                         TPtrC( WLAN_WEP_KEY3 ),
                                         iKeyData )
                                         );
					 
// Save the format of the key (Hexadecimal or Ascii)
 wLanServiceTable->WriteUintL( 
                               TPtrC( LAN_WEP_KEY3_FORMAT ),
                               ( TUint32& ) iKeyFormat
                              );
 wLanServiceTable->PutRecordChanges();
 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.

http://wiki.forum.nokia.com/index.php/Image:IAPSampleEx.zip

Related Discussions
Thread Thread Starter Forum Replies Last Post
How to change font size for Edwin? strike_noir Symbian User Interface 6 2007-08-14 11:37
GPRS not Working on 6600? imifsd General Discussion 7 2003-11-27 14:14
Which Access Point is used on the 6680 for http? phi_ste Mobile Java Networking & Messaging & Security 3 2006-08-17 21:48
Default Connection Access rkuppala Symbian Networking & Messaging 1 2003-07-08 18:44
how to disconnect on 7650 gerodol Mobile Java Networking & Messaging & Security 1 2003-05-30 14:33
 
Powered by MediaWiki
     
     RDF Facets:
     
     
     qfnZtopicQUqfnTopicZseriesE5f60Q
     qfnZtypeQUqfnTypeZCommunityContentQ
     qfnZtypeQUqfnTypeZWebpageQ
     qfnZtypeQUqfnTypeZWikiContentQ
     qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX