
How to Create an application to transfer files using Infrared
Communication in Compact FrameworkConnectivity
between smart devices and the personal computers are the necessity in this fast
moving world. This feature is possible using the classes that are provided in
the .Net Compact Framework. These classes that are used for the infrared communication
is added to the namespace System.Net.Sockets. The Infrared Data Association (IrDA)
has set some standards for socket programming and the Infrared communication programming
has to implement these set standards in the IrDA specifications. The
IrDA protocol stack has a layer called the Information Access Service (IAS). This
IAS layer has the Server and the Client component. The server has the services
and the applications that are available for the IR connections that come to it.
The client discovers the connections that are available in the server. To create an application to transfer files using InfraRed communication you need two devices which could be pocket PCs. One of the devices will be sending the data while the other one will receive the data. You will be using the IrDAClient class and its DiscoverDevices method to find the device that is available within the range in which it can access. Information about the devices that are within the range is got using the IrDADeviceInfo objects. To make the device communicate with each other you have to create a send application that is used to send data and a receive application that would receive the data that is sent by the device. The Send application would be in one device and the Receive application would be in the other device. These are the minimum application that is to be created for communication between the two devices. For this purpose you could create a Send and Receive button which could be used to invoke the necessary action. When you use the Send button to send a file to a device, the device to which it is sent should be listening to the devices. To make this possible you have to click the Receive button first so that the device is in the listening mode. Then click the send button to send the file to the other device which has the Receive application and is in the receive mode. The
tasks that are performed when you click the Send button are: The
tasks that are performed when you click the Receive button are: The
steps that are followed to create applications to send and receive are as follows.
First you can create an application for the sending device. The steps involved
in creating the Send application would be, The
steps for the Receive application in the receiving device would be, The
algorithm behind the Send buttons click event should be as follows: The
algorithm behind the Receive buttons click event should be as follows: To run the applications thus created you have to align the InfraRed ports of the devices. Before this you have to install the applications you have created in the respective devices. Click the Receive button in the receiving device. Then click the Send button in the device that will send the data or file. The text file that is sent to the receiving device should be available in the respective folder that is assigned for that purpose. Check whether you have received that file. A walkthrough code is available for this kind of application in the MSDN website. You can download that code and test it. Here we have given the algorithm that is involved in developing that application to give you a clear idea on how to create an application for transferring files through the Infrared Communication port in the smart devices such as Pocket PCs and PDAs.
| ||