The Missing Wheel Companion App is a React Native application that subscribes to data from Bluetooth Low Energy (BLE) bike trainers and heart rate monitors. This data is transmitted to the Missing Wheel project in Unreal Engine. Within the project, the data controls the speed of an in-game playable bike avatar. Resistance calculations—based on the avatar's incline, decline, and momentum—are performed in real-time. This calculated resistance is then sent back to the companion app, which adjusts the bike trainer accordingly.
Bike trainers and heart rate monitors typically conform to the BLE GATT standard, which allows Bluetooth devices, such as phones, to easily capture their data without needing to pair. One advantage of BLE is that applications can listen to BLE signals, filter the relevant ones, and capture the data emitted by them. It's important to note that there is no privacy protection inherent to BLE.
There were two options when starting this project:
Create a direct connection between the PC and Bluetooth devices via Bluetooth dongles and have that drive the game developed in Unreal Engine.
Develop a bridge for mobile phones that reads Bluetooth data and then sends it to Unreal over a network (details regarding online or LAN connectivity to be determined).
I chose to develop a mobile application because it's almost guaranteed that anyone with a smart trainer will have a smartphone, and mobile devices offer robust support for Bluetooth connectivity. I attempted to create an Unreal Plugin using Windows Runtime libraries and to develop my own Dynamic Linked Libraries (DLLs) to retrieve Bluetooth data. Although I was somewhat successful, Unreal Engine has many protected variables and functions that were constantly getting in the way, for these reasons, I opted for the mobile application approach.
There is an extensive list of unique UUIDs and their categories: Here is a PDF listing all the device categories and their UUIDs.
For the purpose of this project I will be focusing on:
Heart Rate Monitor
Heart Rate Service (0x180d)
Heart Rate Measurement Characteristic (0x2A37)
Bike Trainer
Fitness Machine Service (0x1826)
Indoor Bike Data characteristic (0x2AD2)
Resistance Profile TBD