Bluetooth 4.0 Support (Bluetooth Low Energy - BLE)?

I haven’t seen this questions asked since about May 2015, so I was hoping the status has changed. I have custom Bluetooth 4.0 hardware that I want to access from an application running the Unreal Engine on Gear VR on Android (Samsung S6). The Bluetooth hardware is not a controller it does not automatically map. Can I access this hardware from the platform-independent Unreal Engine APIs or do I have to drop down into platform-specific native Android to access the Bluetooth peripheral?

Hi CodeJingle,

Right now you would need to use native Android to access Bluetooth hardware which isn’t a controller. The best way to do this is to write an Android plugin to do what this Android guide shows:

http://developer.android.com/guide/topics/connectivity/bluetooth-le.html

Yes I am aware of the correct process for BLE access in native Android. It was my hope that the Unreal Engine was ‘good enough’ that Bluetooth/BLE access was available as a platform-independent API. If I write a separate plugin for each and every platform that I want to support BLE access on, it almost defeats the purpose of writing a VR application in Unreal Engine. In that case it may be easier to write one version of the application that runs on Android for only Gear VR and doesn’t use Unreal Engine.

Are there any examples of Unreal Engine projects that use native Android APIs (preferably in a specific section of the project and not strewn throughout)?

Look at the AndroidJNI.* files and GameActivity.java; this is a good example for the moment. I’m working on an Android plugin example which is a bit better contained.

Thanks very much

Ok I am finally back to the issue of importing platform-specific Java into Unreal Engine (in this case Android for GearVR).

I do see GameActivity.java under ‘/UnrealEngine/Engine/Build/Android/Java/src/com/epicgames/ue4’ but that doesn’t necessarily help me to know the correct process to add more Java.

Will it work to create a high-level plugin that wraps an AAR or JAR, or should I add the Java directly under the path /UnrealEngine/Engine/Build/Android/Java … will it get automatically pulled into the next build?

Like Chris said, you would need to use native Android to access Bluetooth hardware!

Hi jasowole. It is not as fun but let us have a reasonably intelligent conversation here devoid of flaming.

What Chris is actually saying is that there is already native Android functionality wrapped by the Unreal Engine, an example of which is in ‘/UnrealEngine/Engine/Build/Android/Java/src/com/epicgames/ue4/GameActivity.java’. The team and greater community working on the Unreal Engine just haven’t bothered yet to wrap the Bluetooth Low Energy stuff (Bluetooth 4.0+, also known as BLE). At least not out-of-the-box.

Although BLE support doesn’t come out of the box with the Unreal Engine, anyone can add an Unreal Engine wrapper to access any platform-specific functionality, BLE is no exception. This is especially true because the Unreal Engine is open source. Whether by plugin or by a custom build of the source, I can add whatever feature I want to Unreal Engine.

I am asking for feedback, what is the recommended process to add more native Android, either to Unreal Engine directly or to the project. Do I have to throw in more Java files manually under the folder ‘/UnrealEngine/Engine/Build/Android/Java/src/com/’ (seems less desirable), or can I package a JAR or AAR as a plugin (which would be my preference)? Chris claims there is a way to add more native Android to the project through a plugin, please reference his quote above “I’m working on an Android plugin example which is a bit better contained.”

I have a library ready, it is fancy pants native Android that perfectly wraps BLE access across ALL of the handsets currently supported by GearVR. This will make a good Unreal Engine wrapper for BLE, at least on GearVR (since GearVR is currently exclusively Android). I am asking for help to add this in as a plugin, which is what Chis said he was working on, a plugin as an example of how to make an Unreal Engine wrapper for adding more native Android functionality.

So Chris have you gotten around to completing your contained Android plugin example? I would love to see it. Thanks. I built 4.11.0-preview-6 from source successfully on OS X earlier this week and that is the current version I am working with (my custom build of 4.11.0-preview-6). So I am ready to add more native Android support to Unreal Engine by any means necessary, though I would like to start with the company’s or community’s best practices for adding more native Android support. If you guys / gals would kindly point me to them or regurgitate them directly in this thread. Again I would love to see. Double thanks!

Hey so it was ‘Hell on Earth’ but I finally have native Bluetooth Low Energy (BLE) support for GearVR in Unreal Engine. I had to use custom everything. NVPACK 1R4. Apache Ant 1.9.6. Gradle 2.12. android-sdk-macosx ant build script defaults to using Java 1.5 which is ludicrous, I managed to get it to build with Java 1.7. I basically hand-tweaked the entire Java build process to get it to work. The Unreal Engine only supports deprecated build process, you have to support build.gradle to get anything current. No is going to be able to do this except senior developers, this really has to be updated to use build.gradle in order to make it accessible.

Importing our company’s JAR files didn’t work, I had to import the code directly and hand merge the RES folders, hand merge the manifest xml files, add the necessary android support libraries, and tweak the code to reference the correct namespace for BuildConfig and R. I’ve been trying to do this since December, it was my 5th attempt. Finally got it building today. I can’t emphasize enough the barrier of entry for this. All this would have been so much easier with build.gradle support.

Probably at least a few more days before I can post a video demo, I still need to finish up the thunking etc and set up correct consumption on the C++ side. More and more VR peripherals are BLE based so it will quickly become a detriment to the Unreal Engine if you continue lack of native BLE support. I would be able to share my fork if you were using build.gradle because then I could use our company’s public AAR files instead of having to import the private code directly. The goal of GearVR is untethered virtual reality, to get to that goal we need built-in native BLE support.

I go into the steps a little deeper here in a more contextually relevant thread Android Java Libraries in UE4 Game (OUYA SDK, Google Play Game Services, etc.) - Android Development - Unreal Engine Forums

So I am noticing now that Unreal Engine’s built-in support for input devices goes beyond HID. Even ‘input device’ is a lousy way to describe what they have cooked up here. At some point past jerry-rigging a solution for sanity testing I should look into a formal wrapping of my BLE device within this ‘input device’ framework. There are so many layers … Unreal Engine feels like it has the formal organization of an operating system. Auto-generate the code to build the engine that auto-generates the code to build the project. Codeception.

So I have custom-built BLE support now baked into Unreal Engine, and I have a working demo with it using a 9-axis device over BLE. I may post a demo video in a few days.

Any chance for this to become part of stock UE4 ? (or as a plugin people can get/buy)

hey Code, i faced same problem so can you post your great work we will be very thankfull.