Categories
Windows

We Don’t Talk About IrDA

We take for granted that every mobile phone, tablet and laptop has Bluetooth built in, and probably use it all the time for headphones, mice etc without even thinking about developing software for it. There was a time long ago when phones and laptops had IrDA built in and it could be used for exchanging data from contacts to images.

Not all industries move as fast as consumer electronics so you can often still find IrDA in specialist devices in the medical world and beyond. Although it’s no longer ready to run out-of-the-box there is still supported IrDA support in Windows 10 and 11 and an API which is neatly wrapped in InTheHand.Net.IrDA.

Understandably IrDA is now an optional feature in Windows which you can add from Settings > Apps > Optional features > IrDA infrared. You may need to add it as part of your configuration and you can do this programmatically via a Powershell command:-

Add-WindowsCapability -Online -Name "Network.Irda~~~~0.0.1.0"

The IrDA support in Windows includes the Sockets based API and a few sharing features (the ability to send or receive files) but this is more hidden than it used to be and doesn’t integrated with the new Share experience. You can access settings via the classic Control Panel.

The InTheHand.Net.IrDA library provides a simple .NET API over the IrDA specific Socket options and extensions. It’s modelled on the API from the .NET Compact Framework, but that was never implemented by Microsoft for desktop Windows so became part of 32feet.NET. InTheHand.Net.IrDA now only has desktop Win32 support, there didn’t seem any point in including the Window CE implementation (as with Bluetooth there were some differences in the underlying API).

Functionality-wise you can discover remote devices (in practise a single remote device at a time). The device info contains a display name and an address and you can open a Socket to that address and send and receive binary data. Beyond the basics of this you need to know what the remote device expects and luckily there are some standards here.

Sending and receiving files is done using Object Exchange (OBEX) and InTheHand.Net.Obex allows you to send files programmatically over IrDA and Bluetooth. Obex is similar to HTTP but all the commands and headers are passed in a compact binary form to cater for the limited bandwidth of these kind of connections.

By Peter Freeman Foot

Microsoft Windows Development MVP