I'm trying to create an access point to connect two devices via an ad hoc connection, but i'm having a problem. The access point my device creates is in the commdb list, but others devices can't locate this access point.
What could be wrong? I'm stuck with this code for weeks and got no solution...Code:CCommsDatabase* db = CCommsDatabase::NewL(); CleanupStack::PushL(db); TInt err = db->BeginTransaction(); // Create a wlan AP and fill its mandatory fields. CApAccessPointItem* wlanAp = CApAccessPointItem::NewLC(); CApAccessPointItem* wlanNewItem = CApAccessPointItem::NewLC(); wlanAp->SetNamesL(_L("WRS_AP1")); wlanAp->SetBearerTypeL(EApBearerTypeWLAN); wlanAp->WriteTextL(EApWlanNetworkName, _L("WRSAP1")); // Give correct Data as per the router configuration //L!nkSys@MdpNok!a //Lan network mode should be 1 for infrastructure, 0 for adhoc wlanAp->WriteUint(EApWlanNetworkMode,1); wlanAp->WriteUint(EApWlanChannelId ,3); // Setting up advanced settings for IP addressing wlanAp->WriteTextL(EApWlanIpAddr ,_L("192.248.16.30")); wlanAp->WriteTextL(EApWlanIpNetMask ,_L("255.255.255.00")); wlanAp->WriteTextL(EApWlanIpGateway ,_L("192.248.16.30")); TBool val =ETrue; TUint32 newalanid; CApDataHandler* handler = CApDataHandler::NewLC(*db); TUint32 apid; apid = handler->CreateFromDataL(*wlanAp); handler->UpdateAccessPointDataL(*wlanAp,val); handler->AccessPointDataL(apid,*wlanNewItem); CApUtils *aputil = CApUtils::NewLC(*db); TUint32 wapuid = wlanAp->WapUid(); TInt Iap = aputil->IapIdFromWapIdL(wapuid); wlanNewItem->ReadUint( EApIapServiceId, newalanid ); TBuf<50> ibuff; wlanNewItem->ReadTextL( EApWlanNetworkName, ibuff ); TUint32 newAPId = wlanNewItem->WapUid(); CCommsDbTableView* wLanServiceTable = db->OpenViewMatchingUintLC( TPtrC( WLAN_SERVICE ), TPtrC( WLAN_SERVICE_ID ), newalanid ); TUint32 errorCode; errorCode = wLanServiceTable->GotoFirstRecord(); TInt leaveError = 0; if ( errorCode == KErrNone ) { wLanServiceTable->UpdateRecord(); } else { TUint32 dummyUid( 10 ); //KUidNone leaveError = User::LeaveIfError( wLanServiceTable->InsertRecord( dummyUid ) ); wLanServiceTable->WriteUintL( TPtrC( WLAN_SERVICE_ID ), apid ); } wLanServiceTable->PutRecordChanges(); err = db->CommitTransaction(); CleanupStack::PopAndDestroy(6); //server is a RConnection object and connection is a RSocketServ TInt error; error = server.Connect(KESockDefaultMessageSlots); error = connection.Open(server, KConnectionTypeDefault); TCommDbConnPref prefs; prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt); prefs.SetDirection(ECommDbConnectionDirectionOutgoing); prefs.SetIapId(Iap); error = connection.Start(prefs);




