I just started working for a project where I need to implement simple application for custom BLE device. Basically what I would need to do, is to read characteristics values, show them in the UI and store the data in a file.
This sounds pretty easy, however, the BLE device is currently under development, and I would not be getting one for the next couple of weeks.
I’m really eager on getting started with it, and as the task for the app is really simply to find a device, connect to it and to monitor & store values from it, I got thinking that maybe I could make a simple simulator that would fake the device.
And as I do have Android device which is supporting full peripheral mode, I indeed can get it done rather easily. Basically what I need to do, is to check what kind of stuff my Polar H7 is advertising, and then simply doing the same with my own BLE advertiser.
Note that, if you use the examples used with my Using BLE GATT services with Windows 10, you would need to remember that Windows does use caching when pairing Bluetooth devices, thus first do remove any existing paring for the device and then do following:
- Do run the simulator in android device first (and let it run in background while doing pairing)
- Open Bluetooth settings in the android device
- Switch to Windows device, and open Bluetooth settings. Do enable Bluetooth if its disabled
- Start pairing from Windows device, and if there is multiple entries shown for the device, so pair all of them (The right BLE device would be the one that asks you to supply 6 digits ID on the android side, so remember to fill it right)
- After successfull paring, start the Windows application (the one that reads the values from the simulator)
- Search devices, and Select the simulator device to connect to it.
- With first time usage, the Windows device will ask permission to use the BLE simulator device, and you need to accept this.
- After this, the data from the simulator should be updated to the Windows app normally.
With the Foreground Example I made earlier, I did notice that for some reason the call to ReadClientCharacteristicConfigurationDescriptorAsync inside the HeartbeatEngine does harng, thus before I get it fixed, you should simply comment out the line. Anyway, do make sure you call the WriteClientCharacteristicConfigurationDescriptorAsync, since if its not handled, the value changed event’s will not be delivered to your app.