Appearance
PPG Device Info
The application can receive info related to the PPG device by implementing PPGDeviceInfoListener
, and then pass it to the session builder when creating a session.
Swift
do {
let licenseDetails = LicenseDetails(licenseKey: "<ENTER_YOUR_LICENSE_KEY>")
let deviceID = "<ENTER_POLAR_DEVICE_ID>"
let session = try PolarSessionBuilder(polarDeviceID: deviceID)
.withSessionInfoListener(self)
.withVitalSignsListener(self)
.withPPGDeviceInfoListener(self)
.build(licenseDetails: licenseDetails)
}
catch {
let e = error as NSError
print("Received Error. Domain: \(e.domain) Code: \(e.code)")
}
do {
let licenseDetails = LicenseDetails(licenseKey: "<ENTER_YOUR_LICENSE_KEY>")
let deviceID = "<ENTER_POLAR_DEVICE_ID>"
let session = try PolarSessionBuilder(polarDeviceID: deviceID)
.withSessionInfoListener(self)
.withVitalSignsListener(self)
.withPPGDeviceInfoListener(self)
.build(licenseDetails: licenseDetails)
}
catch {
let e = error as NSError
print("Received Error. Domain: \(e.domain) Code: \(e.code)")
}
Objective-c
BNHLicenseDetails *licenseDetails = [[BNHLicenseDetails alloc] initWithLicenseKey:@"<ENTER_YOUR_LICENSE_KEY>"];
NSString *deviceID = @"<ENTER_POLAR_DEVICE_ID>";
BNHSessionBuilder *sessionBuilder = [[[[[BNHPolarSessionBuilder alloc] initWithPolarDeviceID:deviceID]
withVitalSignsListener:self]
withSessionInfoListener:self]
withPPGDeviceInfoListener:self];
NSError *error = nil;
id<BNHSession> _Nullable session = [sessionBuilder buildWithLicenseDetails:licenseDetails
error:&error];
if (error != nil) {
NSLog(@"Received Error. Domain: %@ Code: %ld", error.domain, (long)error.code);
}
BNHLicenseDetails *licenseDetails = [[BNHLicenseDetails alloc] initWithLicenseKey:@"<ENTER_YOUR_LICENSE_KEY>"];
NSString *deviceID = @"<ENTER_POLAR_DEVICE_ID>";
BNHSessionBuilder *sessionBuilder = [[[[[BNHPolarSessionBuilder alloc] initWithPolarDeviceID:deviceID]
withVitalSignsListener:self]
withSessionInfoListener:self]
withPPGDeviceInfoListener:self];
NSError *error = nil;
id<BNHSession> _Nullable session = [sessionBuilder buildWithLicenseDetails:licenseDetails
error:&error];
if (error != nil) {
NSLog(@"Received Error. Domain: %@ Code: %ld", error.domain, (long)error.code);
}
Upon successful initialization and connection with a PPG Device, the SDK sends a PPGDeviceInfo
object containing the device type, ID, and version.
- The info of the connected PPG Device.
Swift
func onPPGDeviceInfo(_ info: PPGDeviceInfo) {
DispatchQueue.main.async {
// info.type - The PPGDeviceType
// info.deviceID - The device's ID
// info.version - The firmware version of the device
}
}
func onPPGDeviceBatteryLevel(_ batteryLevel: UInt) {
DispatchQueue.main.async {
// Receive battery level changes
}
}
func onPPGDeviceInfo(_ info: PPGDeviceInfo) {
DispatchQueue.main.async {
// info.type - The PPGDeviceType
// info.deviceID - The device's ID
// info.version - The firmware version of the device
}
}
func onPPGDeviceBatteryLevel(_ batteryLevel: UInt) {
DispatchQueue.main.async {
// Receive battery level changes
}
}
Objective-c
- (void)onPPGDeviceInfo:(BNHPpgDeviceInfo *)info {
dispatch_async(dispatch_get_main_queue(), ^{
// info.type - The PPGDeviceType
// info.deviceID - The device's ID
// info.version - The firmware version of the device
});
}
- (void)onPPGDeviceBatteryLevel:(NSUInteger)batteryLevel {
dispatch_async(dispatch_get_main_queue(), ^{
// Receive battery level changes
});
}
- (void)onPPGDeviceInfo:(BNHPpgDeviceInfo *)info {
dispatch_async(dispatch_get_main_queue(), ^{
// info.type - The PPGDeviceType
// info.deviceID - The device's ID
// info.version - The firmware version of the device
});
}
- (void)onPPGDeviceBatteryLevel:(NSUInteger)batteryLevel {
dispatch_async(dispatch_get_main_queue(), ^{
// Receive battery level changes
});
}
The SDK also provides the initial battery level of the device upon connection, as well as any subsequent changes in the device's battery level while the session is active.
Swift
func onPPGDeviceInfo(_ info: PPGDeviceInfo) {
DispatchQueue.main.async {
// info.type - The PPGDeviceType
// info.deviceID - The device's ID
// info.version - The firmware version of the device
}
}
func onPPGDeviceBatteryLevel(_ batteryLevel: UInt) {
DispatchQueue.main.async {
// Receive battery level changes
}
}
func onPPGDeviceInfo(_ info: PPGDeviceInfo) {
DispatchQueue.main.async {
// info.type - The PPGDeviceType
// info.deviceID - The device's ID
// info.version - The firmware version of the device
}
}
func onPPGDeviceBatteryLevel(_ batteryLevel: UInt) {
DispatchQueue.main.async {
// Receive battery level changes
}
}
Objective-c
- (void)onPPGDeviceInfo:(BNHPpgDeviceInfo *)info {
dispatch_async(dispatch_get_main_queue(), ^{
// info.type - The PPGDeviceType
// info.deviceID - The device's ID
// info.version - The firmware version of the device
});
}
- (void)onPPGDeviceBatteryLevel:(NSUInteger)batteryLevel {
dispatch_async(dispatch_get_main_queue(), ^{
// Receive battery level changes
});
}
- (void)onPPGDeviceInfo:(BNHPpgDeviceInfo *)info {
dispatch_async(dispatch_get_main_queue(), ^{
// info.type - The PPGDeviceType
// info.deviceID - The device's ID
// info.version - The firmware version of the device
});
}
- (void)onPPGDeviceBatteryLevel:(NSUInteger)batteryLevel {
dispatch_async(dispatch_get_main_queue(), ^{
// Receive battery level changes
});
}
Important
Note that info on the PPG Device and battery level changes are sent on a background thread. The application must switch to the UI thread in order to perform UI updates.