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.
// start the OBEX server TObexBluetoothProtocolInfo obexProtocolInfo; obexProtocolInfo.iTransport.Copy(KServerTransportName); obexProtocolInfo.iAddr.SetPort(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);
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.
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???
Forum posts: 226
Forum posts: 28
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.....
Forum posts: 226
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
Forum posts: 28
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.....
Forum posts: 226
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
Forum posts: 28
i m not getting in transportupindication. what is problem?
Thank u...
Santosh....
PLZ HElP ME.....
Forum posts: 17
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?
Forum posts: 183
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