| Reply | « Previous Thread | Next Thread » |
|
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.
|
| marcosmarcos |
| View Public Profile |
| Find all posts by marcosmarcos |
|
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 |
| mahbub_s60 |
| View Public Profile |
| Find all posts by mahbub_s60 |
|
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 |
| marcosmarcos |
| View Public Profile |
| Find all posts by marcosmarcos |
|
Hi, Do you want to send to all devices one by one? If yes then you need to change the code a bit.
-Mahbub |
| mahbub_s60 |
| View Public Profile |
| Find all posts by mahbub_s60 |
|
Quote:
I wish I can help you see the link to comment in an earlier message to see the full encoding please |
| marcosmarcos |
| View Public Profile |
| Find all posts by marcosmarcos |
|
Please ignore this...
Last edited by navediitr : 2009-03-21 at 20:19.
Reason: wrongly put
|
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| 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 |