An app for the Stages SB20 smart-bike
Indoor cycling has been popular for some time now, and due to widespread lockdowns in 2020 and 2021, more and more people bought a smart bike and a subscription to a service like Zwift. If none of those words make any sense to you, it's basically riding on a static bike (a bike that doesn't go anywhere) while paired to a computer that has a game on it, that responds to your power output and also adjusts the resistance of the bike on which you're riding. So, if you ride up a hill, it gets tougher, and if you ride down one, it gets easier.

I purchased my smart bike, the Stages SB20, and noticed semi-immediately that there were two buttons on the handlebars that were pressable, but didn't do anything. I set about designing my app, called StagePlay, which can connect to the Stages SB20 bike and listen for these button presses, and do something with them.

The app currently runs on Windows, but uses Rust (via Flutter Rust Bridge) to natively find and connect to the Stages bike. The app also lets the user adjust the volume of the computer, or skip to the next track, all of which occurs via invoking the win32 API in Rust.

The app has the following features:

* Searches and connects to a BLE device with a certain service
* Listens for events that have been emitted from the bike (such as gear change events)
* Writes data to the bike for certain functions (like adjusting the resistance for the bike)
* Persists users' choices to an isar database
... and much more!

Using Rust for these functions was far easier and less error-prone than using the native C++ integration that is normally used for Flutter apps on Windows.