The sample for working with heart rate devices was tested on Alpha MIO devices.
Based on https://github.com/liquidx/CoreBluetoothPeripheral and https://github.com/timburks/iOSHeartRateMonitor sources.
Add to your project the next source files:
HeartRateMonitor.h HeartRateMonitor.m
You should use the HeartRateMonitorDelegate protocol.
For example:
@interface ViewController : UIViewController <HeartRateMonitorDelegate> @end
And then you should implement the next methods:
// Returns value from device in real time - (void)updateHRM:(NSString *)data; // Called when scanning timeout occured - (void)scanningDidTimeout; // Called when connection timeout occured - (void)connectionDidTimeout; // Called when disconnection occured - (void)disconnection;
Initialization:
HeartRateMonitor *heartRateMonitor = [[HeartRateMonitor alloc] init]; heartRateMonitor.hrmDelegate = self;
For start scanning:
[heartRateMonitor startScan];
For stopping:
[heartRateMonitor stopScan];