簡體   English   中英

缺少RR間隔的值(BLE / Polar設備)

[英]Missing value for RR-interval (BLE / Polar device)

我擁有一台Polar H10設備,我對使用Android的官方藍牙低功耗API讀出的心率和RR間隔感興趣。 Polar設備每隔一秒發送一個具有心率和RR間隔的包。 現在我已經認識到,在每個這樣的包中都是心率值,但在某些包中沒有RR間隔值(RR間隔的值是-1)。

為什么會這樣? 我的設備壞了或者我在實施中犯了錯誤還是其他人也遇到了這個問題?

編輯:這是代碼。 在方法public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)我從Polar Device接收更改的值。 大約每秒觸發此方法。 然后我解析如下特征:

    public int[] parse(BluetoothGattCharacteristic characteristic) {

        double heartRate = extractHeartRate(c);
        Integer[] interval = extractBeatToBeatInterval(c);

        int[] result = null;
        if (interval != null) {
            result = new int[interval.length + 1];
        } else {
            result = new int[2];
            result[1] = -1;
        }
        result[0] = (int) heartRate;

        if (interval != null) {
            for (int i = 0; i < interval.length; i++) {
                result[i+1] = interval[i];
            }
        }

        return result;
    }


private static double extractHeartRate(
        BluetoothGattCharacteristic characteristic) {

    int flag = characteristic.getProperties();
    Log.d(TAG, "Heart rate flag: " + flag);
    int format = -1;
    // Heart rate bit number format
    if ((flag & 0x01) != 0) {
        format = BluetoothGattCharacteristic.FORMAT_UINT16;
        Log.d(TAG, "Heart rate format UINT16.");
    } else {
        format = BluetoothGattCharacteristic.FORMAT_UINT8;
        Log.d(TAG, "Heart rate format UINT8.");
    }

    final int heartRate = characteristic.getIntValue(format, 1);
    Log.d(TAG, String.format("Received heart rate: %d", heartRate));
    return heartRate;
}

private static Integer[] extractBeatToBeatInterval(
        BluetoothGattCharacteristic characteristic) {

    int flag = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0);
    int format = -1;
    int energy = -1;
    int offset = 1; // This depends on hear rate value format and if there is energy data
    int rr_count = 0;

    if ((flag & 0x01) != 0) {
        format = BluetoothGattCharacteristic.FORMAT_UINT16;
        Log.d(TAG, "Heart rate format UINT16.");
        offset = 3;
    } else {
        format = BluetoothGattCharacteristic.FORMAT_UINT8;
        Log.d(TAG, "Heart rate format UINT8.");
        offset = 2;
    }
    if ((flag & 0x08) != 0) {
        // calories present
        energy = characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT16, offset);
        offset += 2;
        Log.d(TAG, "Received energy: {}"+ energy);
    }
    if ((flag & 0x16) != 0){
        // RR stuff.
        Log.d(TAG, "RR stuff found at offset: "+ offset);
        Log.d(TAG, "RR length: "+ (characteristic.getValue()).length);
        rr_count = ((characteristic.getValue()).length - offset) / 2;
        Log.d(TAG, "RR length: "+ (characteristic.getValue()).length);
        Log.d(TAG, "rr_count: "+ rr_count);
        if (rr_count > 0) {
            Integer[] mRr_values = new Integer[rr_count];
            for (int i = 0; i < rr_count; i++) {
                mRr_values[i] = characteristic.getIntValue(
                        BluetoothGattCharacteristic.FORMAT_UINT16, offset);
                offset += 2;
                Log.d(TAG, "Received RR: " + mRr_values[i]);
            }
            return mRr_values;
        }
    }
    Log.d(TAG, "No RR data on this update: ");
    return null;
}

解析方法返回的第一個元素是心率,第二個元素是RR間隔。 碰巧有時第二個元素是-1(即沒有檢測到RR間隔)。

您的Polar設備或您發布的軟件沒有任何問題。

某些傳輸的數據包中可能缺少RR間隔測量,而if ((flag & 0x16) != 0)說明了這種情況。

例如,假設您的設備每秒發送一次心率測量,並且您有50次/秒:會有一些間隔未測量RR間隔,因為在那一秒內沒有檢測到節拍(這是一個簡化的解釋,只是為了明白這點)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM