A code plugin for Unreal Engine that allows developers to access the Bluetooth SDK from Blueprint and C++. This is the source code of "Bluetooth Support" code plugin on https://www.unrealengine.com/marketplace/bluetooth-support
Before adding the plugin to your projects, please take these points into consideration:
- This plugin relies on Android native SDK. Only Android is currently supported.
It won't cause a problem for other platforms. It is safe to call any of the plugin methods on any platform.
You can always wrap platform-specific features by checking the platform name. - Android started supporting Bluetooth Low Energy since Android 4.3 (API level 18).
- Accessing the device's default bluetooth adapter (API level 18)
- Nearby device discovery, connection, characteristic reading (API level 21)
- Getting a nearby device's TXpower, connectablity, advertising intervale (API level 26)
- These permissions and capabilities are required in the manifest file in order to be able to use Bluetooth LE on an Android device.
Don't worry, you can do that easily by following this official guide - Your app should request ACCESS_COARSE_LOCATION & ACCESS_FINE_LOCATION runtime permission in order to be able to discover other BLE devices and for checking if Geolocation is turned on.
Here is how to check/request granted permissions at runtime on UE4. - Be sure that while scanning, the device has Geolocation enabled, otherwise you will not get any scan results. In this plugin there is a special function that you can use to check if Geolocation is enabled.
- Clone/download zip this repository
- Move/unzip the plugin's downloaded folder inside your projects directory/Plugins/
- Restart Unreal Engine (if it is running)
- Find the plugin under the "Mobile" category and enable it.
Make sure that your target platform/device family satisfy the Prerequisites listed above
There is no better way to understand how to integrate the use this plugin than seeing it in action!
You can go ahead and clone this demo project. After opeining it on your UE4, you can naviguate to the project settings and take a look at the Blueprints to learn how to call the different functionnalities.
Basicly, the process is simple.
- Check runtime permissions. If user denyed then you can make sad face :(
- Check that the device supports BLE, that bluetooth & geolocations are enabled. Otherwise ask user to enable geo, also you are able to enable bluetooth yourself via this plugin API.
- Do your work - run scan, obtain discovered devices.
Milestones on the "Release" channel of this repository.
- Added 4.27 support. Added `GetBoundedDevices` function, `lastDiscovery` info is now type of `FDateTime` and added `OnScanFinished` pin to unified node (which will fire even when you call StopScan manually).
- v4.19-4: Unified Scan node with optional filters
- Scan all, and Scan by UUID are now unified an both support Async result callback, no need to call "getDiscoveredDevices" anymore.
- Scan by MAC address added
- v4.19-3: Async scan callback for "filterless" scan.
If you found this project helpful, consider buying me a ☕
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.