You Are Here:

Community: Developer Discussion Boards

#1 Old change Bluetooth OBEX example - 2008-11-10, 05:16

Join Date: Nov 2008
Posts: 27
marcosmarcos
Offline
Registered User
Interestingly, the application of bluetooth OBEX and especially the method of transport file.

But I like to have someone help me improve this application doing this:

Once the search is for all the devices to select the first of automatic form and send a file and thus end up with all devices in the list of found devices. That means that autoimaticamente send a selected file to all devices that are in search of devices.

Here is the code where I think we can make this change:
bjectExchangeClient.cpp
#include <StringLoader.h>
#include <BtObjectExchange.rsg>
#include "ObjectExchangeClient.h"
#include "ObjectExchangeServiceSearcher.h"
#include "BTObjectExchange.pan"
#include "Log.h"

// CObjectExchangeClient::NewL()
// Symbian en dos etapas constructor.

CObjectExchangeClient* CObjectExchangeClient::NewL( MLog& aLog )
{
CObjectExchangeClient* self = NewLC( aLog );
CleanupStack::Pop( self );
return self;
}

// CObjectExchangeClient::NewLC()

CObjectExchangeClient* CObjectExchangeClient::NewLC( MLog& aLog )
{
CObjectExchangeClient* self = new ( ELeave ) CObjectExchangeClient( aLog );
CleanupStack::PushL( self );
self->ConstructL();
return self;
}

// CObjectExchangeClient::CObjectExchangeClient()

CObjectExchangeClient::CObjectExchangeClient( MLog& aLog )
: CActive( CActive::EPriorityStandard ),
iState( EWaitingToGetDevice ),
iLog( aLog )
{
CActiveScheduler::Add( this );
}

// CObjectExchangeClient::~CObjectExchangeClient()

CObjectExchangeClient::~CObjectExchangeClient()
{
if ( iState != EWaitingToGetDevice && iClient )
{
iClient->Abort();
iStatus = KErrNone;
}
Cancel();

delete iCurrObject;
iCurrObject = NULL;

delete iServiceSearcher;
iServiceSearcher = NULL;

delete iClient;
iClient = NULL;
}

// CObjectExchangeClient::ConstructL()

void CObjectExchangeClient::ConstructL()
{
iServiceSearcher = CObjectExchangeServiceSearcher::NewL( iLog );
}

// CObjectExchangeClient:oCancel()

void CObjectExchangeClient:oCancel()
{
}

// CObjectExchangeClient::RunL()

void CObjectExchangeClient::RunL()
{
HBufC* textResource = NULL;

if ( iStatus != KErrNone )
{
switch ( iState )
{
case EGettingDevice:
if ( iStatus == KErrCancel )
{
textResource = StringLoader::LoadLC ( R_BTOB_NO_DEVICE );
iLog.LogL( *textResource );
CleanupStack::PopAndDestroy ( textResource );
}
iState = EWaitingToGetDevice;
break;
case EGettingService:
case EGettingConnection:
case EDisconnecting:
textResource = StringLoader::LoadLC ( R_BTOB_CONNECTION_ERROR );
iLog.LogL( *textResource, iStatus.Int() );
CleanupStack::PopAndDestroy ( textResource );
iState = EWaitingToGetDevice;
break;
case EWaitingToSend:
textResource = StringLoader::LoadLC ( R_BTOB_SEND_ERROR );
iLog.LogL( *textResource, iStatus.Int() );
CleanupStack::PopAndDestroy ( textResource );
iState = EWaitingToGetDevice;
iState = EDisconnecting;
iClient->Disconnect( iStatus );
SetActive();
break;
default:
Panic( EBTObjectExchangeUnexpectedLogicState );
break;
}
}
else
{
switch ( iState )
{
case EGettingDevice:
iLog.LogL( iServiceSearcher->ResponseParams().DeviceName() );
iState = EGettingService;
iStatus = KRequestPending;
// Esto significa que el RunL no puede ser llamado hasta que
// Este programa hace algo para iStatus
iServiceSearcher->FindServiceL( iStatus );
SetActive();
break;

case EGettingService:
textResource = StringLoader::LoadLC ( R_BTOB_FOUND_SERVICE );
iLog.LogL( *textResource );
CleanupStack::PopAndDestroy ( textResource );
iState = EGettingConnection;
ConnectToServerL();
break;

case EGettingConnection:
textResource = StringLoader::LoadLC ( R_BTOB_CONNECTED );
iLog.LogL( *textResource );
CleanupStack::PopAndDestroy ( textResource );
iState = EWaitingToSend;
break;

case EWaitingToSend:
textResource = StringLoader::LoadLC ( R_BTOB_SENT_OBJECT );
iLog.LogL( *textResource );
CleanupStack::PopAndDestroy ( textResource );
iState = EDisconnecting;
iClient->Disconnect( iStatus );
SetActive();
break;

case EDisconnecting:
textResource = StringLoader::LoadLC ( R_BTOB_DISCONNECTED );
iLog.LogL( *textResource);
CleanupStack::PopAndDestroy ( textResource );
iState = EWaitingToGetDevice;
break;

default:
Panic( EBTObjectExchangeSdpRecordDelete );
break;
};
}
}

// CObjectExchangeClient::ConnectL()

void CObjectExchangeClient::ConnectL()
{
if ( iState == EWaitingToGetDevice && !IsActive() )
{
iServiceSearcher->SelectDeviceByDiscoveryL( iStatus );
iState = EGettingDevice;
SetActive();
}
else
{
HBufC* strClientBusy = StringLoader::LoadLC( R_BTOB_CLIENT_BUSY );
iLog.LogL( *strClientBusy );
CleanupStack::PopAndDestroy ( strClientBusy );
User::Leave( KErrInUse );
}
}

// CObjectExchangeClient::ConnectToServerL()

void CObjectExchangeClient::ConnectToServerL()
{
TObexBluetoothProtocolInfo protocolInfo;
protocolInfo.iTransport.Copy( KServerTransportName );
protocolInfo.iAddr.SetBTAddr( iServiceSearcher->BTDevAddr() );
protocolInfo.iAddr.SetPort( iServiceSearcher->Port() );

if ( iClient )
{
delete iClient;
iClient = NULL;
}
iClient = CObexClient::NewL( protocolInfo );

iClient->Connect( iStatus );
SetActive();
}

// CObjectExchangeClient::SendObjectL()

void CObjectExchangeClient::SendObjectL(TFileName& aName)
{
if ( iState != EWaitingToSend )
{
User::Leave( KErrDisconnected );
}
else if ( IsActive() )
{
User::Leave( KErrInUse );
}

delete iCurrObject;
iCurrObject = NULL;
iCurrObject = CObexFileObject::NewL(aName);

TParsePtr parsePtr (aName);
TPtrC ptr = parsePtr.NameAndExt();

iCurrObject->SetNameL( ptr );

iClient->Put( *iCurrObject, iStatus );
SetActive();
}

// CObjectExchangeClient::StopL()

void CObjectExchangeClient::StopL()
{
if ( iClient && iClient->IsConnected() )
{
iClient->Abort();
iState = EWaitingToGetDevice;
}
}

// CObjectExchangeClient:isconnectL()

void CObjectExchangeClient:isconnectL()
{
if ( iState == EWaitingToGetDevice )
{
return;
}
if ( iState == EWaitingToSend )
{
HBufC* strDisconnecting = StringLoader::LoadLC( R_BTOB_DISCONNECTING );
iLog.LogL( *strDisconnecting );
CleanupStack::PopAndDestroy ( strDisconnecting );
iState = EDisconnecting;
iClient->Disconnect( iStatus );
SetActive();
}
else
{
User::Leave( KErrInUse );
}
}

// CObjectExchangeClient::IsBusy()

TBool CObjectExchangeClient::IsBusy()
{
return IsActive();
}

// CObjectExchangeClient::IsConnected()

TBool CObjectExchangeClient::IsConnected()
{
return iState == EWaitingToSend;
}
//end

if you want to download the application can be downloaded here:
http://http://www.forum.nokia.com/in..._0_en.zip.html


Help also is a great idea if someone has a question or I could help send a response and I thank you answer or what we discussed.
Last edited by marcosmarcos : 2008-11-10 at 05:22.
Reply With Quote

#2 Old Re: change Bluetooth OBEX example - 2008-11-11, 13:52

Join Date: Mar 2008
Posts: 577
mahbub_s60's Avatar
mahbub_s60
Offline
Forum Nokia Expert
Hi,

Could you explain a bit more about the problem you see with this example? It looks it works OK as it should be.


-Mahbub
Reply With Quote

#3 Old Re: change Bluetooth OBEX example - 2008-11-12, 07:55

Join Date: Nov 2008
Posts: 27
marcosmarcos
Offline
Registered User
Okay I will explain better because I am not very good with the English in fact I am using a translator.

The example that I was part of a code of the link that I put this application is the Bluetooth OBEX and is to send a file to a single device at a time, to send him to a second device must be re-connect
Back to select the file and resubmitting.
So here we go well.
What I want to do is just that once made the search and selection of file. So when choosing the file and the search I found 8 devices, then I want the file you want to be sent automatically to the first sending off and was automatically disconnects the second and third automatically and so on until you are finished with all phones.

Not if you understand me, then I put that code because I think there is this part that I want to do or change.

They also want to make a txt file. Where I recorded the shipments that are performed for example device name and the date and time.
As a register of sending.

thanks you mahbub_s60 I´m have need you help
Reply With Quote

#4 Old Re: change Bluetooth OBEX example - 2008-11-14, 13:19

Join Date: Mar 2008
Posts: 577
mahbub_s60's Avatar
mahbub_s60
Offline
Forum Nokia Expert
Hi, Do you want to send to all devices one by one? If yes then you need to change the code a bit.


-Mahbub
Reply With Quote

#5 Old Re: change Bluetooth OBEX example - 2008-11-21, 05:23

Join Date: Nov 2008
Posts: 27
marcosmarcos
Offline
Registered User
Quote:
Originally Posted by mahbub_s60 View Post
Hi, Do you want to send to all devices one by one? If yes then you need to change the code a bit.
If that's right mahbub_s60


I wish I can help you see the link to comment in an earlier message to see the full encoding

please
Reply With Quote

#6 Old Re: change Bluetooth OBEX example - 2009-03-21, 20:14

Join Date: Sep 2007
Posts: 3
navediitr
Offline
Registered User
Please ignore this...
Last edited by navediitr : 2009-03-21 at 20:19. Reason: wrongly put
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
SyncML , OBEX over Bluetooth pvsasidhar OMA DM/DS/CP 174 2009-09-12 11:03
Change the bluetooth name Dipakbaviskar Bluetooth Technology 0 2007-05-28 14:31
Bluetooth OBEX operations, help me pls siddhartha84 Symbian Networking & Messaging 0 2007-04-12 07:12
Bluetooth Obex gatakut Python 0 2007-04-01 12:10
Bluetooth Profiles over Symbian OBEX jimdeal General Symbian C++ 2 2006-09-15 09:30

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia