Bugmaster
Bugmaster

Reputation: 1080

Aggregate multiple Bluetooth data streams on a PC

I am very new to Bluetooth programming, and thus I apologize if this question seems naive.

That said, a potential client of mine has a custom hardware device that transmits data via Bluetooth to a Windows PC. The PC software connects to the device by opening a virtual COM port, and reading data from it; it then visualizes this data in real time.

What they'd like to do is connect three of these devices (or rather, three very similar devices that are hooked up to different sensors) to the PC at the same time. They want to rewrite the software to aggregate data from all three sources, and to visualize all of it in real time; this means that the delay between each device producing the data, and the data appearing of the screen, can be on the order of tens of milliseconds, at worst.

My question is twofold.

1). Can this be done at all ? Is there a way for software on a PC to connect to three Bluetooth-backed virtual COM ports at the same time ? (I'm guessing that the answer is "yes", but it pays to be sure).

2). What is the best platform for doing this ? The original software is written in C++/MFC, but I personally would prefer something more modern, with access to easier graphics and GUI APIs.

Upvotes: 2

Views: 1679

Answers (1)

alanjmcf
alanjmcf

Reputation: 3440

You could use my library 32feet.NET See e.g. documentation

Firstly do not use virtual COM ports, they are difficult to set-up, opaque in use, and difficult to maintain. Just use our BluetoothClient.Connect operation (or BluetoothListener if the devices make the connection to the PC). Then you will have three Sockets, actually NetworkStreams and you can read from all three, whether asynchronously or synchronously. See e.g. General Bluetooth Data Connections

Your devices will be using the Serial Port Profile so use UUID/Guid BluetoothService.SerialPort. What you need for the three devices is the Device Address for each. Get them via discovery (see the docs) or maybe the Device Address is written on the device's label or circuit board and you can just define them as consts in the code. e.g.

static readonly BluetoothAddress DeviceAddr1
    = BluetoothAddress.Parse("002233445566");

As to the latency it should be ok, and I think other ways of doing it will be slower. .NET is modern and with WinForms, WPF and Silverlight options for the UI.

Upvotes: 1

Related Questions