2

I´m trying to configure a RFCOMM server with Symbian.

Looking to my code, seems that i´m not missing nothing, but other devices just can´t see my service.

I listed all bluetooth services available on my phone using my notebook, but the service wasn´t there.

Can someone help me please?

Here is the code:

void BtServer::StartServicoL()
{

   TProtocolDesc pdesc;
   User::LeaveIfError(iSocketServer.FindProtocol(NOMERFCOMM(), pdesc)); 

   iState = EFindingAvailablePort;
   User::LeaveIfError(iListeningSocket.Open(iSocketServer, NOMERFCOMM));

   User::LeaveIfError(iListeningSocket.GetOpt(KRFCOMMGetAvailableServerChannel, KSolBtRFCOMM, iPort));

   iState = EBinding;
   iBtSocketAddr.SetPort(iPort);
   User::LeaveIfError(iListeningSocket.Bind(iBtSocketAddr));
   User::LeaveIfError(iListeningSocket.Listen(1));  

   iServiceAdvertiser->StartL(iPort);

   iBtSocketAddr.SetSecurity(iBtSecurity);

   iAcceptingSocket.Close();

   User::LeaveIfError(iAcceptingSocket.Open(iSocketServer));

   iListeningSocket.Accept(iAcceptingSocket, iStatus);   

   SetActive();

}

void CBluetoothServiceAdvertiser::StartL(const TInt aPort)
{

   iPort = aPort; 

   iState = EConnecting;
   User::LeaveIfError(iSdpServ.Connect());
   User::LeaveIfError(iSdpDatabase.Open(iSdpServ));

   TUUID serviceUUID(UUID_SERVICE);

   iSdpDatabase.CreateServiceRecordL(serviceUUID, iRecordHandle);

   CSdpAttrValueDES* protocolDescriptorList = CSdpAttrValueDES::NewDESL(NULL);
   CleanupStack::PushL(protocolDescriptorList);

   TBuf8<TAM_MAX_NRO_PORTA> port; 
   port.Append((TChar)iPort);

   protocolDescriptorList
         ->StartListL()
            ->BuildDESL()
               ->StartListL()               
                  ->BuildUUIDL(KRFCOMM) 
                  ->BuildUintL(port)    
               ->EndListL()             
         ->EndListL();              


   iSdpDatabase.UpdateAttributeL(iRecordHandle, KSdpAttrIdProtocolDescriptorList, *protocolDescriptorList);
   CleanupStack::PopAndDestroy(protocolDescriptorList);

   iSdpDatabase.UpdateAttributeL(iRecordHandle, KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceName, NOME_SERV);

   iSdpDatabase.UpdateAttributeL(iRecordHandle, KSdpAttrIdBasePrimaryLanguage + KSdpAttrIdOffsetServiceDescription, DESC_SERV);

   CSdpAttrValue* attrVal = NULL;

   TBuf8<TAM_MAX_SERV_DISP> avail;

   avail.FillZ(1); 

   avail[0]=0xff;  

   attrVal = CSdpAttrValueUint::NewUintL(avail);

   CleanupStack::PushL(attrVal);
   iSdpDatabase.UpdateAttributeL(iRecordHandle, KSdpAttrIdServiceAvailability, *attrVal);
   CleanupStack::PopAndDestroy(attrVal);

}
Mizu
  • 31
  • 4

0 Answers0