PKConstant - Windows BLE Support

Enables bluetooth low energy support for windows devices.

  • Scan for nearby devices

  • Read/Write characterisitics

  • Subcribe for notifictions or indications

  • Detect disconnections and reconnections

Supports UE 5.5 and comes with a built in example to get you started.

Requires c++20 to be enabled within the project!

Relies on 3rd party windows libs for bluetooth access!

https://www.fab.com/listings/ed920fa6-670f-4e52-ab09-6ae58a6b3f56

Hey! Could you help me out? How do I use your plugin in Blueprints to subscribe and read data from a BLE device, like a heart rate monitor? I guess I need to write to the CCCD to enable notifications — is there a way to do that through Blueprints?

Apologies for the late response only just saw this.

Use the subscribe for notifications node and pass in the related characteristic ID. You will then get data through the event that you pass in as a callback. This will continue until you stop the notifications or disconnect.

Check the manufacturer for how they implement their data, but due to most ID’s being reserved to avoid clashes I expect they will use this one.

00002a37-0000-1000-8000-00805f9b34fb - Heart Rate Measurement ID
Bluetooth GATT Services & Characteristics · GitHub - Handy github with a list of common characertistic id’s

gatt-xml/org.bluetooth.characteristic.heart_rate_measurement.xml at master · oesmith/gatt-xml · GitHub - This repro has the data layouts in a readable xml format, this is the one for that characteristic

They layout bit wise is as follows:
(uint8) 8 bits - Flags
– The first bit is for the heart rate data size, 0 being 8 bit, 1 being 16 bit
– The next 2 bits are for contact status, 3 means its working (Check the xml for what the others mean)
– The next bit is for if energy expenditure
– The next bit is for RR-Interval bit
(uint8) 8 bits or (uint16) 16 bits - Heart rate (Depend on if the flag is 0 or 1)

The following are only available if the flag is set:

(uint16) 16 bits - Energy expended
(uint16) 16 bits - RR-Interval

If your numbers seem off check if its using big endian or little endian.

Hopefully this helps :slight_smile:

Use the subscribe for notifications node and pass in the related characteristic ID. You will then get data through the event that you pass in as a callback. This will continue until you stop the notifications or disconnect.

Is everything here correct?
And this should work?

Yes that should work aslong as that characteristic exists. In the console commands use “log LogBLE verbose” this will get all the logging and should help you debug.

Also if you have an android device I recommend using an app called ‘nrf connect for mobile’ it let’s you scan for devices and will list all data that is being broadcast to it. It helps with trouble shooting things like this.

In Python I managed to get notifications working.
Here’s what I do:

  1. Enable notifications by writing to the Client Characteristic Configuration Descriptor (CCCD):
await characteristic.write_client_characteristic_configuration_descriptor_async(
    GattClientCharacteristicConfigurationDescriptorValue.NOTIFY
)

This sets the CCCD to NOTIFY, so the peripheral device will automatically push updates.

  1. Subscribe to notifications with add_value_changed:
# Subscribe to value changed
characteristic.add_value_changed(
    lambda sender, args: self.on_characteristic_value_changed(sender, args, type_ble_dev)
)

This way I receive data whenever the characteristic value changes.

In Blueprints, using your plugin, I can connect and read characteristics, but I don’t know how to receive notifications.
Could you share a working Blueprint example that actually receives notifications from any BLE device?