Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect unit for blood pressure #114

Open
Walter0697 opened this issue Aug 5, 2021 · 2 comments
Open

Incorrect unit for blood pressure #114

Walter0697 opened this issue Aug 5, 2021 · 2 comments

Comments

@Walter0697
Copy link

It seems like for the official GATT specification, bit 0 will have a value of 0 if the unit is mmHg, and a value of 1 if the unit is kPa. However, the logic in the code seems to be reserved.

private extension Flag {
    static let unitFlag: Flag = 0x01
    static let timeStamp: Flag = 0x02
    static let pulseRate: Flag = 0x04
}

struct BloodPressureCharacteristic {
    
    let systolicPressure: Measurement<UnitPressure>
    let diastolicPressure: Measurement<UnitPressure>
    let meanArterialPressure: Measurement<UnitPressure>
    let date: Date?
    let pulseRate: Int?
    
    init(data: Data) throws {
        let flags: UInt8 = try data.read()
        let unit: UnitPressure = Flag.isAvailable(bits: flags, flag: .unitFlag) ? .millimetersOfMercury : .kilopascals

The incorrect logic cant be found in BloodPressureCharacteristic.swift and BloodPressureCharacteristic.swift

If I am correct, the correct code should be
let unit: UnitPressure = Flag.isAvailable(bits: flags, flag: .unitFlag) ? .kilopascals : .millimetersOfMercury

@philips77
Copy link
Member

On the other hand, after testing the whole app, you have found only one bit wrong! Look how many bits we got right!

@NickKibish
Copy link
Collaborator

Ok, I'll check that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants