Work in progress Rust library for handling Polar bluetooth heart rate monitors. Currently only targetting support for H10 due to lack of other devices.
```rust,ignore use arctic::{async_trait};
struct Handler;
impl arctic::EventHandler for Handler { async fn batteryupdate(&self, batterylevel: u8) { println!("Battery: {}", battery_level); }
async fn heartrate_update(&self, _ctx: &arctic::PolarSensor, heartrate: u16) {
println!("Heart rate: {}", heartrate);
}
}
async fn main() -> Result<(), Box
while !polar.is_connected().await {
match polar.connect().await {
Err(arctic::Error::NoBleAdaptor) => {
println!("No bluetooth adapter found");
return Ok(());
},
Err(why) => println!("Could not connect: {:?}", why),
_ => {},
}
}
if let Err(why) = polar.subscribe(arctic::NotifyStream::Battery).await {
println!("Could not subscribe to battery notifications: {:?}", why)
}
if let Err(why) = polar.subscribe(arctic::NotifyStream::HeartRate).await {
println!("Could not subscribe to heart rate notifications: {:?}", why)
}
polar.event_handler(Handler);
let result = polar.event_loop().await;
println!("No more data: {:?}", result);
Ok(())
} ```