Transferring data over an infrared connection

The S60 platform allows you to establish IrDA connections to other devices for sending and receiving data.

Typical use cases include:

Important implementation considerations include:

  • Mobility may cause breaks in infrared connections if an obstacle appears between the two connected devices. Your application must be prepared for unexpected connection breaks and always keep responsive to user actions.

Sending/receiving data over an infrared connection

To establish an infrared connection and transfer data:

  1. Make sure that the mobile device supports infrared technology using the Feature Discovery API.

  2. Search for another device in the range of the technology using the RHostResolver class of the Sockets Client API.

    For detailed information on how to do this, see:

    • Discovery in the Symbian OS Library for a discussion of the classes that are relevant for device discovery in infrared connections

    • How to initiate the discovery procedure in the Symbian OS Library for instructions on how to implement device discovery

  3. Establish a connection to the remote device using the IrDA Sockets API.

    For detailed information on how to do this, see How to make a primary connection in the Symbian OS Library.

  4. Send or receive data over the infrared connection using the methods of the RSocket class of the IrDA Sockets API.

    For detailed information on how to do this, see:

    • Reading and writing data in the Symbian OS Library for a general overview on how to transfer data over an infrared connection

    • How to write data in the Symbian OS Library for instructions on how to implement non-urgent data transfer

  5. Close the infrared connection when you have finished transferring data.

    For detailed information on how to do this, see:

    • Disconnection in the Symbian OS Library for a discussion of how to close infrared connections, depending on the used infrared protocol.

    • How to disconnect in the Symbian OS Library for a code sample of closing the instances of all the components used for the infrared connection

  6. Make sure you have the correct capabilities information set for your application.

  7. Make sure that esock.lib is accessible to your linker when compiling your application by including it in your mmp file or by editing the project properties in your IDE, depending on your build environment.

Additional information on transferring data over infrared

For more information, see:

  • The IrDA Sockets API in the Symbian OS Library for instructions on how to use the IrDA Sockets API to implement infrared connections and transfer data in your application