Read-only archive of the All About Symbian forum (2001–2013) · About this archive

BTObjectExchange from sdk documentation

0 replies · 1,721 views · Started 24 February 2004

hi there,

anybody here have read the BTObjectExchange example from the sdk documentation? i'm currently use the serverside from the example to receive obex object transfer.

if u had, i want to ask about how to make the bluetooth digital pen connected to the application?

here is the example code

void CObjectExchangeServer::ConstructL()
{
// create OBEX object to receive obex transfer
iObexBufData = CBufFlat::NewL(KBufferSize); iObexBufObject = CObexBufObject::NewL(iObexBufData);

iAdvertiser = CObjectExchangeServiceAdvertiser::NewL();
}

void CObjectExchangeServer::StartL()
{
TRAPD(err,InitialiseServerL());
if (err != KErrNone)
{
iLog.LogL(_L("Failed "😉,err);
DisconnectL();
}
}

void CObjectExchangeServer::InitialiseServerL()
{
if (iObexServer)
{
ASSERT(IsConnected()); // server already running
return;
}

// Get a port to listen on
TInt channel = AvailableServerChannelL();

SetSecurityOnChannelL(EFalse, EFalse, ETrue, channel);

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

//creates a CObexServer session with the OBEX server,
//and calls Start so that it starts listening for incoming connections.
iObexServer = CObexServer::NewL(obexProtocolInfo); iObexServer->Start(this);

// advertise this service
iAdvertiser->StartAdvertisingL(channel); //port nya di advertise
iAdvertiser->UpdateAvailabilityL(ETrue); //adds a Service Availability attribute to the SDP database

iLog.LogL(_L("Server started"😉);
}

TInt CObjectExchangeServer::AvailableServerChannelL()
{
RSocketServ socketServer;
User::LeaveIfError(socketServer.Connect());
//Provides the Connect() function to create an IPC communication channel to the socket server
CleanupClosePushL(socketServer);

RSocket socket;
User::LeaveIfError(socket.Open(socketServer, _L("RFCOMM"😉));
//parameter(server, name of protocol)
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;
}

i also use MObexServerNotify, but why TransportUpIndication() is not working?

void CObjectExchangeServer::TransportUpIndication()
//A OBEX connection is requested over Bluetooth by the sending device
{
iLog.LogL(_L("Connected"😉);
}

anyone can help me? thanks

Rx-