Click here to Skip to main content
13,664,631 members
Click here to Skip to main content
Add your own
alternative version


43 bookmarked
Posted 1 Feb 2004
Licenced CPOL

Pocket PC 2003 File transfer - The OBEX way

, 1 Feb 2004
Rate this:
Please Sign up or sign in to vote.
A sample application that pulls files from an OBEX server.


OBEX is standard for infrared or Bluetooth communication, best suited for small devices, and it is supported on the PocketPC platforms. Why not use it for simple data synchronization tasks?

This sample application connects to the Obex-FTP service on a desktop (or server), retrieves the file list of a special folder in the servers Obex-FTP root, and then pulls the modified files to merge them with its own database.

In this way the server application can simply write new information into this dedicated folder, and the clients (our PocketPC app) can connect and synchronize from time to time. The server may be any device with a Obex-FTP server (a desktop with a bluetooth stick, another PocketPC, a Palm, or even a SmartPhone).


An OBEX server publishes a list of "services" clients can connect to. The default and most basic of this services is the OBEX Inbox (or OBEX Object Push). This service, however, does normally not allow to pull (or GET) data other than some predefined default objects (like a vCard) from the server; and because of this it is not approriate for the purpose of this sample.

The OBEX FTP service however has all the functionally we need: get a list of files and folders, get, store, and delete files, and much more. All devices with an OBEX server that supports this services - whether they use infrared or Bluetooth communication - can act as a synchronization server for our client.

There are other OBEX services like IrMCSync or SYNCML or even custom OBEX extensions which could be used for synchronization (you can download the OBEX specification here) but none of them is as simple and versatile as the FTP approach.

Using the code

The class CObexFTP is a wrapper for the system supplied IObex object; use it detect appropriate devices in range and spawn instances of CObexFTPConnection which in turn encapsulates the IObexDevice interface and adds some useful methods for file transfer applications.

Typically you will derive your own class from CObexFTP and override the virtual function OnDeviceArrived to connect to this device and perform file transfer operations. Likewise you could override the functions OnDeviceRemoved and OnDeviceChanged, which will only be called if you have an active connection and will probably better be overridden in the corresponding CObexFTPConnection objects.

Once you have successfully initialized your instance (see CObexFTP::Initialize()) you can call the functions StartDeviceEnumeration() and StopDeviceEnumeration() to start/stop getting asynchrounous notifications through the above mentioned virtual functions.

Typically in your override of OnDeviceArrived you will create a CObexFTPConnection object (or a derived class) and call the Connect method. Since this methods keeps a pointer in a linked list you should not delete this object without calling Disconnect first!

The argument of OnDeviceArrived is a pointer to a standard IPropertyBag object; if you need more information about the device before accepting the connecting, the helper class CObexDeviceProperties may be of interest.

// Sample override of OnDevicedArrived
void CMyObex::OnDeviceArrived(IPropertyBag *Props)
  CObexDeviceProperties DevProps(Props);
  if (0==wcsicmp(DevProps.GetName(),L"ServerName"))
    CMyObexConnection *pConn=new CMyObexConnection;
    if (pConn->Connect(this,Props))
      // ... work with it
      delete pConn;

The sample application

The sample application uses WTL7.1 which has built-in CE-support (you can download it for free directly from Microsoft) because the OBEX classes use ATL anyway.

It simply connects to the first arriving FTP-server, changes to the folder "SampleFolder" and shows the name of all files that have changed since the last synchronization in a listbox.

If you want to play with it (e.g. with a desktop server running the WIDCOMM bluetooth stack), you have to create this folder in your servers FTP directory and put some files in it.

You will need embedded Visual C 4.2 and the PocketPC Platform SDK to compile the source; for the sample project file (PocketObex.vcp) you further need WTL7.1 installed and integrated into eVC.

A word of caution

I developed and tested this classes and the sample application on a T-Mobile MDA-II (which is also known as O2-XDA-II or similar). This seems to be the first device with a built-in Microsoft Bluetooth stack, most other vendors seem to use the WIDCOMM stack. I doubt that the Microsoft OBEX support properly integrates with the WIDCOMM stack, but I'd love to hear otherwise (:.

BTW: If you have a MDA-II (which is a great device!) and have wondered why there is no OBEX-FTP server on your device even after the latest firmware upgrade: There is no reason other than somebody (Microsoft?, HCT?, T-Mobile?,O2?) decided not to install it. If you simply compile the sample in the Microsoft WINCE-420 and put some registry values in, it works.

Open Issues

These classes currently do not care for authentication; if you have problems connecting to your server, make sure you switch off the "Secure connection" or similar for the FTP service on the server side.

If you would have to transfer larger amounts of data, some kind of progress indicator and a CANCEL button would be nice to have.


  • Jan 2004: First release.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
Germany Germany
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionHow do i use the Demo Application? Pin
saravanababu6-Oct-09 22:58
membersaravanababu6-Oct-09 22:58 
GeneralNot able to find obex.h included in obexutil.h Pin
kashdk16-Dec-08 18:23
memberkashdk16-Dec-08 18:23 
Questionhow to trasfer image file (*jpg,*.bmp....)? Pin
Harish Sharma12-May-08 7:17
memberHarish Sharma12-May-08 7:17 
QuestionBluetooth Communication Pin
kathalora7-Nov-07 15:22
memberkathalora7-Nov-07 15:22 
QuestionHelp: It Cannot find any server on device Pin
binguo2-Aug-07 0:59
memberbinguo2-Aug-07 0:59 
GeneralUsing Broadcom GetFile :confused: Pin
samyharris15-Jun-07 8:58
membersamyharris15-Jun-07 8:58 
GeneralError message :( Pin
Dali Hammadi19-Mar-07 5:39
memberDali Hammadi19-Mar-07 5:39 
GeneralRe: Error message :( Pin
MBuehrer19-Mar-07 5:45
memberMBuehrer19-Mar-07 5:45 
GeneralRe: Error message :( Pin
Dali Hammadi21-Mar-07 6:36
memberDali Hammadi21-Mar-07 6:36 
GeneralSmartphone , Discovery Prolem Pin
Member #37832911-Feb-07 20:01
memberMember #37832911-Feb-07 20:01 
GeneralInfo in PropertyBag Pin
tm0594610-Jan-07 22:20
membertm0594610-Jan-07 22:20 
QuestionCan I use this source code for smartphone (with changes) Pin
sfj39-Dec-06 11:08
membersfj39-Dec-06 11:08 
GeneralSmartphone Comaptibility Pin
babiqescobar28-Oct-06 6:40
memberbabiqescobar28-Oct-06 6:40 
QuestionTransfer contact from PDA? Pin
viettho4-Aug-06 5:57
memberviettho4-Aug-06 5:57 
GeneralSame thing for XP Pin
kazak_dev2-Apr-06 23:04
memberkazak_dev2-Apr-06 23:04 
QuestionHow to use PutFile? Pin
Goutam Das8-Mar-06 18:56
memberGoutam Das8-Mar-06 18:56 
Generalobex object push. Pin
gdx990321-Dec-05 10:54
membergdx990321-Dec-05 10:54 
GeneralCan't find atlresce.h? everybody help me ! thanks Pin
falasnow31-Jul-05 15:33
memberfalasnow31-Jul-05 15:33 
GeneralRe: Can't find atlresce.h? everybody help me ! thanks Pin
MBuehrer31-Jul-05 19:56
memberMBuehrer31-Jul-05 19:56 
Questionwhat about Windows XP? Pin
matro21-Jul-05 13:35
membermatro21-Jul-05 13:35 
GeneralThanks + Large File Issue Pin
JustinWF23-Jun-05 11:02
memberJustinWF23-Jun-05 11:02 
GeneralRe: Thanks + Large File Issue Pin
MBuehrer24-Jun-05 3:34
memberMBuehrer24-Jun-05 3:34 
GeneralRe: Thanks + Large File Issue Pin
parama_chakra4-Dec-05 17:33
memberparama_chakra4-Dec-05 17:33 
GeneralCan't find ObexStrings.h Pin
BakaOnigiri11-May-05 3:22
memberBakaOnigiri11-May-05 3:22 
GeneralRe: Can't find ObexStrings.h Pin
MBuehrer16-May-05 4:58
memberMBuehrer16-May-05 4:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01-2016 | 2.8.180810.1 | Last Updated 2 Feb 2004
Article Copyright 2004 by MBuehrer
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid