How to notify incoming bluetooth connection request?

Login to reply to this topic.
Tue, 2005-05-17 10:51
Joined: 2004-12-03
Forum posts: 28
Hi,
  I am developing bluetooth application, in this i need to know the incoming connection from devices, to accept/reject the connection.
 
  I m not able know the connection. how to solve this problem?

                 Thanks for UR HELP...
Santosh...

PLZ HElP ME.....


Tue, 2005-05-17 11:03
Joined: 2005-01-04
Forum posts: 226
How to notify incoming bluetooth connection request?
Have a look at any of the BT applications ported along with the S60 SDK
Fri, 2005-05-20 13:02
Joined: 2004-12-03
Forum posts: 28
Re: How to notify incoming bluetooth connection request?
Thanks for reply


I searched in s60 examples, no example is there to get solve this problem.
i saw in examples, they gave about searching and selecting the device.

i actually want, i dont want to search, i want  to know,when the remote device trying to connect my device.


plz help its urgent for me


Santosh

PLZ HElP ME.....

Fri, 2005-05-20 13:40
Joined: 2005-01-04
Forum posts: 226
Re: How to notify incoming bluetooth connection request?
Hi,

Basically, there are two ways where u can connect two devices using Bluetooth.

1)Using OBEX protocol
2)Using Sockets

After verifying the service record in the database corresponding to the required service class,the connection establishment procedure starts as ......

In the former one,u get to know the connection establishment when the callback function TransportUpIndication() of MObexServerNotify gets called.You can verify the same in the BT OBEX example in SDK.

In the latter one,U make use of an Active object to listen for the incoming connections on a certain port. The connection establishment completes when the RunL() of corresponding active object completes.You can verify the same in BTPointToPoint example in SDK.

Hope this helps,

BR,
Sunil
Mon, 2005-05-23 08:03
Joined: 2004-12-03
Forum posts: 28
Re: How to notify incoming bluetooth connection request?
hi sunil,
          i m using the following code, its not working


BConnCall::BConnCall()
{
   
};


BConnCall* BConnCall::NewLC()
{
   BConnCall* self = new (ELeave) BConnCall();
   CleanupStack::PushL(self);
   self->ConstructL();
   return self;
}
BConnCall* BConnCall::NewL()
{
   BConnCall* self = BConnCall::NewLC();
    CleanupStack::Pop(self);
    return self;
}

void BConnCall::ConstructL()
{
   iObexBufData = CBufFlat::NewL(1008);
   iObexBufObject = CObexBufObject::NewL(iObexBufData);
   iCoeEnv = CEikonEnv::Static();
   
}


BConnCall::~BConnCall()
{
    if (iObexServer && iObexServer->IsStarted())
        {
        iObexServer->Stop();
        }

    delete iObexServer;
    iObexServer = NULL;

}

void BConnCall::DisconnectL()
{
    if (iObexServer && iObexServer->IsStarted())
        {
        iObexServer->Stop();
        }

    delete iObexServer;
    iObexServer = NULL;
}

void BConnCall::StartL()
{
    TRAPD(err,InitialiseServerL());
    if (err != KErrNone)
        {
       
        DisconnectL();
        }
}
void BConnCall::InitialiseServerL()
{

    if (iObexServer)
        {
       iEikonEnv->InfoMsg(_L("if (iObexShand"));
        ASSERT(IsConnected()); // server already running
      return;
        }

    //  Get a port to listen on
    TInt channel = AvailableServerChannelL();
   
    SetSecurityOnChannelL(EFalse, EFalse, ETrue, channel);
   
   TApaTaskList taskList(iCoeEnv->WsSession());

   TApaTask currentTask = taskList.FindByPos(0);

   TApaTask ourAppTask = taskList.FindApp(_L("0x101f6163"));

   if(currentTask.ThreadId() != ourAppTask.ThreadId())
      ourAppTask.BringToForeground();

    // start the OBEX server   
    TObexBluetoothProtocolInfo obexProtocolInfo;
    obexProtocolInfo.iTransport.Copy(KServerTransportName);
    obexProtocolInfo.iAddr.SetPort(channel);

    iObexServer = CObexServer::NewL(obexProtocolInfo);
    iObexServer->Start(this);
         
}

TBool BConnCall::IsConnected()
{
    return iObexServer != NULL;
}


TInt BConnCall::AvailableServerChannelL()
{
    RSocketServ socketServer;
   
    User::LeaveIfError(socketServer.Connect());
    CleanupClosePushL(socketServer);

    RSocket socket;TProtocolDesc pInfo;
   
   User::LeaveIfError(socketServer.FindProtocol(_L("RFCOMM"), pInfo));

   User::LeaveIfError(socket.Open(socketServer,pInfo.iAddrFamily,pInfo.iSockType,KRFCOMM));

    CleanupClosePushL(socket);

    TInt channel;
    User::LeaveIfError(socket.GetOpt(KRFCOMMGetAvailableServerChannel,KSolBtRFCOMM,channel));

    // found the port can now close the socket and the socket server
    CleanupStack::PopAndDestroy();  //  socket
    CleanupStack::PopAndDestroy();  //  socketServer

   return channel;   
}

void BConnCall::SetSecurityOnChannelL(TBool aAuthentication,TBool aEncryption,TBool aAuthorisation,TInt aChannel)
{
    // a connection to the security manager
    RBTMan secManager;

    // a security session
    RBTSecuritySettings secSettingsSession;

    // define the security on this port
    User::LeaveIfError(secManager.Connect());
    CleanupClosePushL(secManager);
    User::LeaveIfError(secSettingsSession.Open(secManager));
    CleanupClosePushL(secSettingsSession);

    // the security settings
   TUid settingsUID;settingsUID.iUid = 0x101f6163;
    TBTServiceSecurity serviceSecurity(settingsUID, KSolBtRFCOMM, 0);

    //Define security requirements
    serviceSecurity.SetAuthentication(aAuthentication);
    serviceSecurity.SetEncryption(aEncryption);
    serviceSecurity.SetAuthorisation(aAuthorisation);

    serviceSecurity.SetChannelID(aChannel);
    TRequestStatus status;
    secSettingsSession.RegisterService(serviceSecurity, status);
   
    User::WaitForRequest(status); // wait until the security settings are set
    User::LeaveIfError(status.Int());
   
    CleanupStack::PopAndDestroy();  //  secManager
    CleanupStack::PopAndDestroy();  //  secSettingsSession
}


void BConnCall::ErrorIndication(TInt aError)
{

}

void BConnCall::TransportUpIndication()
{

}

void BConnCall::TransportDownIndication()
{

}

TInt BConnCall::ObexConnectIndication(const TObexConnectInfo&,const TDesC8&)
{
    return KErrNone;
}

void BConnCall::ObexDisconnectIndication(const TDesC8& )
{

}

CObexBufObject* BConnCall::PutRequestIndication()
{
  return iObexBufObject;
}

TInt BConnCall::PutPacketIndication()
{
    return KErrNone;
}

TInt BConnCall::PutCompleteIndication()
{
   return KErrNone;
}

CObexBufObject* BConnCall::GetRequestIndication(CObexBaseObject* )
{
   return NULL;
}

TInt BConnCall::GetPacketIndication()
{
   return KErrNone;
}

TInt BConnCall::GetCompleteIndication()
{
   return KErrNone;
}

TInt BConnCall::SetPathIndication(const CObex::TSetPathInfo&,const TDesC8& )
{
   return KErrNone;
}

void BConnCall::AbortIndication()
{

}

thank u.........

Santosh...

PLZ HElP ME.....

Wed, 2005-05-25 08:08
Joined: 2005-01-04
Forum posts: 226
Re: How to notify incoming bluetooth connection request?
Hi,


void BConnCall::TransportUpIndication()
{

}


The above function gets called when any remote device is trying to connect your device.So,you can use any of the dialogs to display the "Connecting" message in your device.

For example,

void BConnCall::TransportUpIndication()
{
        CAknInformationNote* message =new (ELeave)  CAknInformationNote;
        message->ExecuteLD(_L("Connected"));

}

Also,include the header file aknnotewrappers.h

BR,
Sunil
Wed, 2005-05-25 11:46
Joined: 2004-12-03
Forum posts: 28
Re: How to notify incoming bluetooth connection request?
Hi
  i m not getting in transportupindication. what is problem?

Thank u...


Santosh....

PLZ HElP ME.....

Tue, 2005-12-06 05:11
Joined: 2005-06-24
Forum posts: 17
Re: How to notify incoming bluetooth connection request?
Hi ,

i have seen that u have used   
TApaTask ourAppTask = taskList.FindApp(_L("0x101f6163"));

can i know the process equivalent to the process ID of
0x101f6163?







Thu, 2005-12-22 10:02
Joined: 2005-03-06
Forum posts: 183
Re: How to notify incoming bluetooth connection request?
what I want to do is alert me of ANY bluetooth connection attempts from ANY service.. ie. I want to know when anyone or anything tries to connect to my phone using bluetooth, so that I can remove the "ABC is trying to connectto you. Allow Connection (Y/N) ?" message from the phone.

I want to prevent this message appearing EVER and automatically deny any connection requests.

The reason I want to do this is because these annoying little idiots wrote these so called "bluetooth viruses" eg Cabir which keep trying to connect to peoples phones if your bluetooth is switched on. This has the effect that everyone is now forced to switch bluetooth off or use stealth mode to avoid continuos bletooth connection requests.

Anyone who how to refuse all connections from any source???

Regards,
Isseyp
  • Login to reply to this topic.