Over the years several Xojo developers asked for a Bluetooth plugin. As we got two projects this year with need for Bluetooth, the classic one and the LE one, we decided it may be worth starting a Xojo plugin for Bluetooth.
For Bluetooth Low Energy, we got CoreBluetooth classes for MacOS. You can enumerate devices, connect to them and read/write data and get notifications for updates. That works well with a heart monitor here to get the current BPM value to Xojo.
See CBPeripheralMBS class.
Next we got WindowsBlueToothLE classes for Windows. Again, you can see which devices are there, connect and get/set values and get notified for updates. For heart rate monitor, this class works well, too.
See WindowsBlueToothLEMBS class.
For the classic Bluetooth on MacOS, we got the IOBluetooth classes. This is only a subset from the Apple framework, but you can use IOBluetoothDeviceMBS class to control a device. The IOBluetoothRFCOMMChannelMBS class allows you to do a serial port via bluetooth, which is enough for our devices here.
To select a device, you can use the IOBluetoothUI classes. The IOBluetoothDeviceSelectorControllerMBS class provides a dialog or sheet to select a device while IOBluetoothServiceBrowserControllerMBS allows to pick a service on a device.
On Windows, you can use WindowsBlueTooth classes to find devices and configure them. The WindowsBlueToothSelectDeviceDialogMBS class provides a dialog for the user to pick a device.
Once you got the device ID and the port, you can use the WindowsBlueToothSocketMBS class to connect and transfer data. This class work like a normal socket in Xojo, but targets bluetooth. You can get an event for incoming data and even accept connections.
If you come to our Xojo conference, we can present you details on the new plugin and show some examples, maybe even a live demo.
Coming soon in next prerelease.