Click here to Skip to main content
15,355,133 members
Articles / Mobile Apps / Windows Mobile
Posted 21 Jan 2003


218 bookmarked

Infrared Communication with your Mobile Phone

Rate me:
Please Sign up or sign in to vote.
4.89/5 (88 votes)
17 Dec 2003CPOL7 min read
Learn how to make your Pocket PC speak with your mobile phone.

Sample Image


My English is not very well and so I hope everyone can understand this article. Still if questions should exist, I will gladly answer those. And if someone should find some errors, please send me the correct version of the wrong text - thanks for the help in improving my English knowledge ;-).

For data exchange, most of the new mobile phones and Pocket PCs possess an infrared (IRDA) port. So, why not use this infrared connection to communicate between these two devices?

This simple Pocket PC 2002 application shows how to communicate with your mobile phone, it will read the manufacturer, the model identification and the Phone Book of your mobile phone to your Pocket PC.

I have tried this Pocket PC application (running on my HP jornada 565) only with a Nokia 5210, my new Siemens S55 and a very old Siemens S25 mobile phone. So, I hope the application will also work with other mobile phones.

How can I speak with the mobile phone?

To speak with your mobile phone you have to use some special commands, called AT commands. You have to send these commands via the IRDA port of your Pocket PC to the mobile phone and the mobile phone will respond to you. If the mobile phone supports the received AT command, it will send you a valid response, otherwise it will send you an error response.

The AT commands have a general structure, for example take a look at the figure below:

AT command

<CR> ... Carriage return

This command is to request the manufacturer identification of the mobile phone. For example a Nokia 5210 will send you the following response:

AT response

<CR> ... Carriage return
<LF> ... Line feed

If the mobile phone doesn't support the received AT command, it will send you an error response:

AT error

<CR> ... Carriage return
<LF> ... Line feed

You can find some detailed documentation about the AT commands at the following sites:

The Code

The application is a simple dialog based MFC application including some simple API calls.

For the infrared communication, I have written a simple class called CIrdaPort. The class supports some functions to open and close the IRDA port and some functions for the read and write operations.

UML class diagram

To open the IRDA port use the following function:

BOOL CIrdaPort::Open(UINT uiPort);

This function will open the IRDA port, the uiPort parameter defines the index of the IRDA port (1 for COM1, 2 for COM2, 3 for COM3). The return value TRUE indicates success, the value FALSE failure.

You can use the following function to take a look in the registry for the index of the IRDA port:

UINT CIrdaPort::FindPortIndex();

If the function finds some index of the IRDA port in the registry this index will be returned, otherwise the return value is 0.

If you want to write some characters to the IRDA port you can use the following function:

BOOL CIrdaPort::Send(const CString& strSend) const;

This function will send the string strSend to the mobile phone. The return value FALSE indicates failure, the value TRUE success.

To wait for a response you can use the following function:

BOOL CIrdaPort::WaitForResponse(CString& strResponse, DWORD dwTimeout) const;

This function waits for a response strResponse of the mobile phone or returns with FALSE if the timeout dwTimeout occurred.

If you are finished with all read and write operations you have to close the port with the following function:

void CIrdaPort::Close();

This function will close the IRDA port.

When you click on the "Read ..." button of the dialog, the application tries to connect to the mobile phone and read some information about the phone, like the manufacturer and the model identification (for example: Nokia Mobile Phones, Nokia 5210 or SIEMENS, S55). After that it tries to read all Phone Book entries of your mobile phone and display it in a list box on the dialog.

Don't forget to activate the infrared port of your mobile phone!

Before you can test the communication between your Pocket PC and your mobile phone, you have to activate the infrared (IRDA) port of your mobile phone. Most of the mobile phones have their own menu item to activate the infrared port. For example, for a Nokia mobile phone you have to choose Menu -> Infrared. After activating the infrared port, you will see the following symbol IR symbol at the top left corner on the display of your Nokia mobile phone and you will know that the infrared port is enabled.

Some mobile phones, like the Nokia phones, disable the infrared port after some minutes if there is no data exchange on the infrared connection. So, before you start a communication take a look on your mobile phone and reactivate the infrared port if necessary. Look also that there is a straight connection between the infrared sensor of your Pocket PC and your mobile phone and that there is nothing between the two devices which can block the communication.

Bluetooth connection between Pocket PC and mobile phone

After I published this article, I received many questions about how to connect your Pocket PC with your mobile phone via Bluetooth. I couldn't try it because I have no Bluetooth mobile phone or Bluetooth Pocket PC at the moment, but João Paulo Figueira tried it out and found the answer:

Change the name of the communications port from COMx: to BTC1: and comment out the following line:

VERIFY(SetupComm(m_hPort, 2048, 2048));

It's also possible to increase the port speed up to 115200.

João Paulo Figueira also found the registry key that holds the port's name, but he didn't know if this is standard. So, it would be great if you have some information about that and send it to me or João Paulo Figueira.

The registry key that he found that holds the port's name is HKEY_LOCAL_MACHINE\ExtModems\BtDialupModem.

Related links

If you have some problems with the sample application or you need some more information about RAW Infrared Communication on Pocket PC, take a look at Ruud en Frida Vermeij's homepage at In this site you can find many useful tips and tricks about the RAW Infrared Communication on Pocket PC.

If you are interested in Infrared Winsock Communication (IrSock) on Pocket PC and Desktop PC devices, take a look at my IRDA article at the Pocket PC Developer Network. This article is going to demonstrate, how simply you can implement the infrared support into your Windows applications. It provides a small Server/Client example, with the help of which you can send messages from your Pocket PC application to a desktop Windows application. You can use this example as a base for your own applications, which will provide ability to exchange data between different devices right from your application.

IrdaMobile under the normal Windows operating system (Windows 2000 or XP)

Since I have published this article in January this year, one of the most asked questions in the forum and the mails was, how the implement the sample application under the normal Windows operating system, like Windows 2000 or XP.

Sample Image

So, now I took the time to implement the sample application of this article under the normal Windows operating system, like Windows 2000 or XP.

Now, you can download a working executable of the IrdaMobile application for the normal Windows operating system and the hole source code at the top of this article.

The only thing you need to run the sample application under your normal Windows operating system (Windows 2000 or XP) is a virtual COM port driver like IrCOMM2k (Virtual Infrared COM Port for Windows 2000/XP). IrCOMM2k is a driver for Windows 2000 and XP, it emulates a serial port which can be used to exchange data via IrDA with mobile devices. For more information about this topic take a look at the "Technical Details" of this driver at

Bugs and comments

If you have any comments or find some bugs, I would love to hear about it and make the code better.

Release history

  • 18.12.2003

    Added the IrdaMobile sample for the normal Windows operating system (Windows 2000 or XP).

  • 31.10.2003

    Some changes in the CIrdaPort::FindPortIndex() function.

  • 14.09.2003

    Added the "Bluetooth Connection between Pocket PC and Mobile Phone" part to the article (thanks to João Paulo Figueira).

  • 09.09.2003

    Correction of the wrong implementation of the CIrdaPort::FindPortIndex() function (thanks to Ruud en Frida Vermeij).

  • 24.01.2003

    Removed the APS file from the source code archive (thanks to Johann Gerell).

  • 22.01.2003

    First release in CodeProject.


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


About the Author

Daniel Strigl
Austria Austria
No Biography provided

Comments and Discussions

QuestionHelp to sending SMS in PDU mode? Pin
Le@rner10-Mar-10 23:56
MemberLe@rner10-Mar-10 23:56 
Generalthing required for thiss application.. Pin
santosh d10-Mar-10 20:07
Membersantosh d10-Mar-10 20:07 
GeneralDial number from pc on mobile and answer that call from pc microphone Pin
suashpatil1-Jul-09 2:55
Membersuashpatil1-Jul-09 2:55 
GeneralDial number from pc on mobile and answer that call from pc microphone Pin
suashpatil1-Jul-09 2:55
Membersuashpatil1-Jul-09 2:55 
General[Message Deleted] Pin
it.ragester28-Mar-09 5:46
Memberit.ragester28-Mar-09 5:46 
Generalinformation for unlocking Pin
evhy23-Feb-09 20:46
Memberevhy23-Feb-09 20:46 
Questionhow to receive sms from mobile through gateway using javaprogram Pin
hafij1411-Dec-08 20:24
Memberhafij1411-Dec-08 20:24 
Generalproject on infrared communication Pin
vishu patel24-Sep-08 21:00
Membervishu patel24-Sep-08 21:00 
Generalcodes Pin
sivakarthiki2-Sep-08 20:46
Membersivakarthiki2-Sep-08 20:46 
Question不能在EVC下运行 Pin
hardices200814-Jul-08 16:14
Memberhardices200814-Jul-08 16:14 
Generalhelp me Pin
yanql6-Jun-08 0:05
Memberyanql6-Jun-08 0:05 
Generalhelp me for mobile Pin
amirul_slm28-May-08 5:39
Memberamirul_slm28-May-08 5:39 
QuestionHow to receive phone call and Record the conversation as Audio Pin
pankaj motiyar29-Apr-08 18:47
Memberpankaj motiyar29-Apr-08 18:47 
Questionretrieve contacts of window mobile in application Pin
kk_upadhyay25-Dec-07 1:24
Memberkk_upadhyay25-Dec-07 1:24 
Generalir communication Pin
macar2028-Sep-07 3:08
Membermacar2028-Sep-07 3:08 
GeneralRe: ir communication Pin
Daniel Strigl28-Sep-07 5:14
MemberDaniel Strigl28-Sep-07 5:14 
Generalhelp Pin
sanalp_sp24-Apr-07 20:37
Membersanalp_sp24-Apr-07 20:37 
QuestionHow can I send a .jar file from my desktop to a phone Pin
gonzalo_mateos29-Mar-07 9:23
Membergonzalo_mateos29-Mar-07 9:23 
Questionhow to connect the irDA in packet pc. Pin
shilpabellary7-Mar-07 22:27
Membershilpabellary7-Mar-07 22:27 
Generalhelp with pocket bluesnarfer Pin
madmaxedcn7-Jan-07 9:40
Membermadmaxedcn7-Jan-07 9:40 
QuestionHow in Java Pin
Jose Cruz13-Dec-06 11:34
MemberJose Cruz13-Dec-06 11:34 
AnswerRe: How in Java Pin
Daniel Strigl13-Dec-06 19:38
MemberDaniel Strigl13-Dec-06 19:38 
Questioncreating cdb file while using emulation Pin
Astitva17-Oct-06 18:45
MemberAstitva17-Oct-06 18:45 
GeneralHelp in communication b/w mobile n PC Pin
Nauman Rahim26-Jul-06 20:07
MemberNauman Rahim26-Jul-06 20:07 
GeneralHigh port numbers problem solved Pin
Peter Kullmann10-May-06 5:49
MemberPeter Kullmann10-May-06 5:49 

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.