defining new WLAN APN

Login to reply to this topic.
Mon, 2007-07-23 12:23
Joined: 2007-07-23
Forum posts: 4

Hi all,
I am trying to create a new Access Point with WLAn setting through c++ code.
I am able to create the database entery successfully but the new entery (created by me) is not getting displayed in the device UI when I am trying to see it through Tool\\settings\\connection\\Access Points.
device I m using is Nokia E61

here goes my code:

        TBuf<128> connName;
        connName.Copy(_L("wlanName"));
        TBuf<128> apn;
        apn.Copy(_L("wlanName"));
        TBuf<128> login;
        login.Copy(_L(""));
        TBuf<128> password;
        password.Copy(_L(""));
        TBuf<128> apnProxyAddress;
        apnProxyAddress.Copy(_L(""));
        TInt apnProxyPort;
        apnProxyPort= 0;
        TInt er2 = 0;       
        TUint32 serviceId=0;

        CCommsDatabase *cdb = CCommsDatabase::NewL();
               
        CCommsDbTableView *view = cdb->OpenViewMatchingTextLC(TPtrC( _S("WLANServiceTable") ),TPtrC(COMMDB_NAME), connName);

        if(view && view->GotoFirstRecord()==KErrNone)
        {                       
                view->ReadUintL(TPtrC(COMMDB_ID),serviceId);
                User::LeaveIfError(view->UpdateRecord());                       
        }
        else
        {
                User::LeaveIfError(view->InsertRecord(serviceId));
        }
        CleanupStack::PopAndDestroy();//view

        view = cdb->OpenViewMatchingUintLC(TPtrC( WLAN_SERVICE_EXTENSION_TABLE),
                                                                TPtrC(COMMDB_ID), serviceId);   
               
        if(view && view->GotoFirstRecord()==KErrNone)
        {                       
                view->ReadUintL(TPtrC(COMMDB_ID),serviceId);                        User::LeaveIfError(view->UpdateRecord());                       
        }
        else
        {
                User::LeaveIfError(view->InsertRecord(serviceId));
        }
       
        view->WriteTextL(TPtrC(COMMDB_NAME), newconnName);                view->WriteTextL(TPtrC(WLAN_SERVICE_SSID), _L("network")); // WLAN Network Name
        view->WriteUintL(TPtrC(WLAN_SERVICE_CONNECTION_MODE),EAdhoc);
        view->WriteUintL(TPtrC(WLAN_SERVICE_SECURITY_MODE), EOpen);
        view->WriteTextL(TPtrC(WLAN_SERVICE_WEPKEY1),_L("1eer2d1a2d1d4"));
        view->WriteTextL(TPtrC(WLAN_SERVICE_WEPKEY2),_L(""));
        view->WriteTextL(TPtrC(WLAN_SERVICE_WEPKEY3),_L(""));
        view->WriteTextL(TPtrC(WLAN_SERVICE_WEPKEY4),_L(""));
        view->PutRecordChanges();
        CleanupStack::PopAndDestroy();//view

        view = cdb->OpenViewMatchingTextLC(TPtrC(WAP_ACCESS_POINT),TPtrC(COMMDB_NAME), connName);
        TUint32 wapAccessPointId=0;
        if(view && view->GotoFirstRecord()==KErrNone)
        {
                view->ReadUintL(TPtrC(COMMDB_ID),wapAccessPointId);                User::LeaveIfError(view->UpdateRecord());
        }
        else
        {                       
                User::LeaveIfError(view->InsertRecord(wapAccessPointId));
        }               
        view->WriteTextL(TPtrC(COMMDB_NAME), connName);
        view->WriteTextL(TPtrC(WAP_CURRENT_BEARER),TPtrC(WAP_IP_BEARER));
        view->PutRecordChanges();
        CleanupStack::PopAndDestroy();//view
       
        TUint32 locationId = 1;
        view = cdb->OpenViewMatchingTextLC(TPtrC(LOCATION), TPtrC(COMMDB_NAME), _L("Mobile"));
        if (view->GotoFirstRecord() == KErrNone)
        {
                TRAP( er2, view->ReadUintL(TPtrC(COMMDB_ID), locationId); );
        }
        CleanupStack::PopAndDestroy();//view

        //if (!IAP)
        //        create IAP service, network
        view = cdb->OpenViewMatchingTextLC(TPtrC(IAP),
                TPtrC(COMMDB_NAME), connName);
        TUint32 iapId=0;
        if(view && view->GotoFirstRecord()==KErrNone)
        {
                view->ReadUintL(TPtrC(COMMDB_ID),iapId);                        User::LeaveIfError(view->UpdateRecord());
        }
        else
        {                       
                User::LeaveIfError(view->InsertRecord(iapId));
        }               
        view->WriteTextL(TPtrC(COMMDB_NAME), connName);
        view->WriteUintL(TPtrC(IAP_SERVICE), serviceId);
        view->WriteTextL(TPtrC(IAP_SERVICE_TYPE),TPtrC(OUTGOING_GPRS));               
        view->WriteUintL(TPtrC(IAP_BEARER),KCommDbBearerWLAN);               
        view->WriteTextL(TPtrC(IAP_BEARER_TYPE),_L(""));
        view->WriteUintL(TPtrC(IAP_NETWORK),0);
        view->WriteUintL(TPtrC(IAP_NETWORK_WEIGHTING),(TUint32)0);
        view->WriteUintL(TPtrC(IAP_LOCATION),(TUint32) 0);               
        view->PutRecordChanges();               
        CleanupStack::PopAndDestroy();//view
        //if (!WAP_IP_BEARER)
        //        create WAP_IP_BEARER wapaccesspoint, iap
        view = cdb->OpenViewMatchingUintLC(TPtrC(WAP_IP_BEARER),
                TPtrC(WAP_ACCESS_POINT_ID), wapAccessPointId);
        TUint32 wapIpBearer=0;
        if(view && view->GotoFirstRecord()==KErrNone)
        {
                view->ReadUintL(TPtrC(COMMDB_ID),wapIpBearer);               
                User::LeaveIfError(view->UpdateRecord());
        }
        else
        {                       
                User::LeaveIfError(view->InsertRecord(wapIpBearer));
        }

        view->WriteUintL(TPtrC(WAP_ACCESS_POINT_ID), wapAccessPointId);
        view->WriteTextL(TPtrC(WAP_GATEWAY_ADDRESS), _L("0.0.0.0"));
        view->WriteUintL(TPtrC(WAP_IAP),iapId);
        view->WriteUintL(TPtrC(WAP_WSP_OPTION),EWapWspOptionConnectionOriented);
        view->WriteUintL(TPtrC(WAP_SECURITY),FALSE);
        view->WriteUintL(TPtrC(WAP_PROXY_PORT),(TUint32)0);
        view->PutRecordChanges();
        CleanupStack::PopAndDestroy();//view

If there is any mistake in my code then please suggest me the write way to do so.
thnking u all.


Tue, 2007-07-24 06:07
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
Re: defining new WLAN APN
Tue, 2007-07-24 07:33
Joined: 2007-07-23
Forum posts: 4
Re: defining new WLAN APN

Thnks a lot Vin. I tried with that also but its not able to create the security wep key . There are lots of pre defined macros that ar enot available any where.
can u please suggest how to mention the WEP key values.
have u tried with that values ??? are u able to create it successfully ?

Tue, 2007-07-24 10:09
Forum Nokia Champion
Joined: 2004-05-26
Forum posts: 732
Re: defining new WLAN APN

Did you see these line of code on that page?

    // Remove the comments below to run the AP settings dialog,
    // in case the AP needs to have WEP setting etc. entered
    /*
    CApSettingsHandler *settings =
    CApSettingsHandler::NewLC(
            EFalse,
            EApSettingsSelListIsListPane,
            EApSettingsSelMenuNormal, 0, 0, 0);
    settings->RunSettingsL(apId, apId);
    */   


Tue, 2007-07-24 10:17
Joined: 2007-07-23
Forum posts: 4
Re: defining new WLAN APN

Yes, this code will bring up the ui in which we need to give the WEP key.
I am asking whether there is nay way by which we can supply the WEP key through the code itself (hardcoded) ???
so that while updating the WLAN setting to the database itself the WEP key will also be stored there for future connection

  • Login to reply to this topic.