Я запускаю образец BLE с github (Windows) и пытаюсь получить вариабельность сердечного ритма от Polar H10.
Однако единственные услуги и характеристики, которые он мне показывает, следующие:
// first layer keys are serviceUuid's
// second layer keys are characteristicUuid's
// with their respective name/description as values
{
"1800" /* Generic Access */ : {
"2a00": "Device Name",
"2a01": "Appearance",
"2a02": "Peripheral Privacy Flag",
"2a03": "Reconnection Address",
"2a04": "Peripheral Preferred Connection Parameters"
},
"1801" /* Generic Attribute */ : {
"2a05": "Service Changed"
},
"180d" /* Heart Rate */ : {
"2a37": "Heart Rate Measurement",
"2a38": "Body Sensor Location"
},
"180a" /* Device Information */ : {
"2a23": "System ID",
"2a24": "Model Number String",
"2a25": "Serial Number String",
"2a26": "Firmware Revision String",
"2a27": "Hardware Revision String",
"2a28": "Software Revision String",
"2a29": "Manufacturer Name String"
},
"180f" /* Battery Service */ : {
"2a19": "Battery Level"
},
"6217ff4b-fb31-1140-ad5a-a45545d7ecf3" /* unknown */: {
"6217ff4c-c8ec-b1fb-1380-3ad986708e2d": "unknown", /* read:true */ // value =
uInt16Array [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
"6217ff4d-91bb-91d0-7e2a-7cd3bda8a1f3": "unknown" /* write:true,
indicate:true, descriptors:{ descriptorUuid: "2902" }*/
{
/* 6172 */
this service has all the numbers which I have no idea about.
Example: 10905, 10906, and etc.
}
}
Теперь я знаю, что Polar H10 дает вам вариабельность сердечного ритма.Так почему это не показывает мне?
У кого-нибудь есть идеи?
РЕДАКТИРОВАТЬ ::
private static ushort ParseHeartRateValue(byte[] data)
{
//ushort offset = 1;
// Heart Rate profile defined flag values
const byte heartRateValueFormat = 0x04;
byte flags = data[0];
ushort offset = 1;
bool HRC2 = (flags & 1) == 1;
if (HRC2) //this means the BPM is un uint16
{
short hr = BitConverter.ToInt16(data, offset);
offset += 2;
}
else //BPM is uint8
{
byte hr = data[offset];
offset += 1;
}
//see if EE is available
//if so, pull 2 bytes
bool ee = (flags & (1 << 3)) != 0;
if (ee)
offset += 2;
// see if RR is present
// if so, the number of RR values is total bytes left / 2(size of uInt 16)
bool rr = ((flags & 1 << 4) != 0);
if (rr)
{
int count = (data.Length - offset) / 2;
for (int i = 0; i < count; i++)
{
//each existence of these values means an R-Wave was already detected
//the ushort means the time (1/1024 seconds) since last r-wave
ushort value = BitConverter.ToUInt16(data, offset);
double intervalLengthInSeconds = value / 1024.0;
offset += 2;
}
}
bool isHeartRateValueSizeLong = ((flags & heartRateValueFormat) != 0);
if (isHeartRateValueSizeLong)
{
return BitConverter.ToUInt16(data, 1);
}
else
{
return data[1];
}
}
}
}