Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to access Cell Phone (ie: Nokia) via Irda from PC ?

How to access Cell Phone (ie: Nokia) via Irda from PC ?

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Ivan Budiono
    wrote on last edited by
    #1

    Can you give me an information about how to use af_irda.h in C++ ? I think that I could access my cell phone via Irda connected to my PC using af_irda.h. Isn't it correct ? I've downloaded some examples and articles, but they are for Windows.CE not Windows XP. Can you give me a sample code to do that ? I've tried to include af_irda.h but there were few errors when I run the application. Can I use af_irda.h in Visual C++ 6.0 ? Or there any other way to access my cell phone in simple and direct way ? Thanks a lot.

    P 1 Reply Last reply
    0
    • I Ivan Budiono

      Can you give me an information about how to use af_irda.h in C++ ? I think that I could access my cell phone via Irda connected to my PC using af_irda.h. Isn't it correct ? I've downloaded some examples and articles, but they are for Windows.CE not Windows XP. Can you give me a sample code to do that ? I've tried to include af_irda.h but there were few errors when I run the application. Can I use af_irda.h in Visual C++ 6.0 ? Or there any other way to access my cell phone in simple and direct way ? Thanks a lot.

      P Offline
      P Offline
      Peter Molnar
      wrote on last edited by
      #2

      Communication between the phone and the PC can be established in the following ways: 1.RS232 serial port 2.IrDA 3.Bluetooth Whether you believe or not all three ways work the same way, namely by sending so called AT commands to the phone and receiving an answer. I would recommend you to look up Device I/O in the PlatformSDK, especially functions like ReadFile and CreateFile,WriteFile, and ReadFile (yes, they are called file!). they will tell you have to communicate over the serial port. You can use the same functions for communicating over IrDa and Bluetooth, because both implement an RS232 serial interface. From the point of view of your code, the only difference is that you use the device's name when opening them with CreateFile (e.g. IRDAx or BTHx instead of COMx). Peter Molnar

      C 2 Replies Last reply
      0
      • P Peter Molnar

        Communication between the phone and the PC can be established in the following ways: 1.RS232 serial port 2.IrDA 3.Bluetooth Whether you believe or not all three ways work the same way, namely by sending so called AT commands to the phone and receiving an answer. I would recommend you to look up Device I/O in the PlatformSDK, especially functions like ReadFile and CreateFile,WriteFile, and ReadFile (yes, they are called file!). they will tell you have to communicate over the serial port. You can use the same functions for communicating over IrDa and Bluetooth, because both implement an RS232 serial interface. From the point of view of your code, the only difference is that you use the device's name when opening them with CreateFile (e.g. IRDAx or BTHx instead of COMx). Peter Molnar

        C Offline
        C Offline
        cofst
        wrote on last edited by
        #3

        Hi Peter, I'm a begginer in this, i know that this section is For C++ only, but I have the same problem to comunicate to my cell phone, and I'm very confused now. I have already try CreateFile,ReadFile,and WriteFile Function as you tell us on this message board. I try those using Visual Basic by declaring CreateFile Function with kernel32.dll as the library. the problem is there is no file created when the programm's running, even on my drive C:\. this is my code. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' CF=CreteFile("C:\tester.txt",GENERIC_WRITE, _ FILE_SHARE_READ,0,CREATE_NEW,FILE_ATTRIBUTE_ARCHIVE,0) if CF<>-1 then 'write file function else msgbox "Error Message" end if CloseHandle(CF) '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' I have try to change the first parameter with "\\.\c:\tester.txt" or "\\.\irda1\tester.txt" but the result is same, there's nothing happen. I hope you can give me a sugestion or maybe you can tell me where i can find the example programm in VB or VB.NET Thank you Very Much!!! and im sory, my english is not very good;P

        1 Reply Last reply
        0
        • P Peter Molnar

          Communication between the phone and the PC can be established in the following ways: 1.RS232 serial port 2.IrDA 3.Bluetooth Whether you believe or not all three ways work the same way, namely by sending so called AT commands to the phone and receiving an answer. I would recommend you to look up Device I/O in the PlatformSDK, especially functions like ReadFile and CreateFile,WriteFile, and ReadFile (yes, they are called file!). they will tell you have to communicate over the serial port. You can use the same functions for communicating over IrDa and Bluetooth, because both implement an RS232 serial interface. From the point of view of your code, the only difference is that you use the device's name when opening them with CreateFile (e.g. IRDAx or BTHx instead of COMx). Peter Molnar

          C Offline
          C Offline
          cofst
          wrote on last edited by
          #4

          hi peter, i have try again and it works,the programm can detect my irda device on com3. but when i start to send the AT Command to the phone by using WriteFile function, there's no reaction. and then i want to translate the working code into VB.net, but the result will not correctly why???:confused: can you help me????please:(

          P 1 Reply Last reply
          0
          • C cofst

            hi peter, i have try again and it works,the programm can detect my irda device on com3. but when i start to send the AT Command to the phone by using WriteFile function, there's no reaction. and then i want to translate the working code into VB.net, but the result will not correctly why???:confused: can you help me????please:(

            P Offline
            P Offline
            Peter Molnar
            wrote on last edited by
            #5

            Hi Ivan, sorry for not answering for a long time but I was away from my desk. As for porting C++ code to VB.NET, I am not familiar it but I definetaly know -just as you write- that it is possible to call Win32 API functions from VB.NET code. Comments on your code: 1.The first param of CreateFile is a string like "COM1" or any other string describing the communication device's name. Inspite of the function name NO file is actually created. Use GENERIC_READ | GENERIC_WRITE access flags. 2.CreateFile returns a handle which identifies the opened communication port. Using this handle you can call WriteFile to send AT commands to the device and later on ReadFile to check for response. 3.In order to not block your channel forever, and receive your info you should poll the port for answer (of course only after you have successfully sent to it an AT command) in a loop with ReadFile for a pre-defined, device specific period of time. You should collect the returned info in a buffer. 4.A successfully opened device that you communicate with ALWAYS returns a response regardless of whether the given AT command is understood by the device or not. Possible responses are "\r\nERROR\r\n" if the AT command is not known to the device, or "\r\nSOME INFORMATION\r\n\r\nOK\r\n" if the sent AT command is supported, where \r\n is 0x0d and 0x0a. Peter Molnar

            C 1 Reply Last reply
            0
            • P Peter Molnar

              Hi Ivan, sorry for not answering for a long time but I was away from my desk. As for porting C++ code to VB.NET, I am not familiar it but I definetaly know -just as you write- that it is possible to call Win32 API functions from VB.NET code. Comments on your code: 1.The first param of CreateFile is a string like "COM1" or any other string describing the communication device's name. Inspite of the function name NO file is actually created. Use GENERIC_READ | GENERIC_WRITE access flags. 2.CreateFile returns a handle which identifies the opened communication port. Using this handle you can call WriteFile to send AT commands to the device and later on ReadFile to check for response. 3.In order to not block your channel forever, and receive your info you should poll the port for answer (of course only after you have successfully sent to it an AT command) in a loop with ReadFile for a pre-defined, device specific period of time. You should collect the returned info in a buffer. 4.A successfully opened device that you communicate with ALWAYS returns a response regardless of whether the given AT command is understood by the device or not. Possible responses are "\r\nERROR\r\n" if the AT command is not known to the device, or "\r\nSOME INFORMATION\r\n\r\nOK\r\n" if the sent AT command is supported, where \r\n is 0x0d and 0x0a. Peter Molnar

              C Offline
              C Offline
              cofst
              wrote on last edited by
              #6

              hi peter, finally i've made it with visual c++ 6.0 but, this is will only success if i use windows XP as the operating system, and failed when i try those in win2000pro or win 2000 server. maybe i should told you that my irda device can only be attached to the usb, not to the serial port. so i can't use my code to send or recieve any information. and maybe you can told me for the suitable path that i can use for accesing this usb irda device, instead of com3 that will only automatically show up (added to the com port list) when i beam my cellphone's irda in windows XP OS not to win 2000. i have try what you told to write IRDAx as the path but this's failed please help me :( thank's very much! note: i also email you this post.;)

              P 1 Reply Last reply
              0
              • C cofst

                hi peter, finally i've made it with visual c++ 6.0 but, this is will only success if i use windows XP as the operating system, and failed when i try those in win2000pro or win 2000 server. maybe i should told you that my irda device can only be attached to the usb, not to the serial port. so i can't use my code to send or recieve any information. and maybe you can told me for the suitable path that i can use for accesing this usb irda device, instead of com3 that will only automatically show up (added to the com port list) when i beam my cellphone's irda in windows XP OS not to win 2000. i have try what you told to write IRDAx as the path but this's failed please help me :( thank's very much! note: i also email you this post.;)

                P Offline
                P Offline
                Peter Molnar
                wrote on last edited by
                #7

                HI, IrDA really implements a VIRTUAL serial port by means of its device driver, and it is also the device driver which is responsible for the device to be recognized by the OS, and XP has definitely more built-in drivers than previous OSs. Virtual means that an IrDA device can really be manipulated like a real COM port although it is not. Since I dont have any real experience specifically with IrDA I suggest you to consult the device manufacturer's documentation. Peter Molnar

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups