|
| 1 | + |
| 2 | +{ |
| 3 | + "id": "http://openinterconnect.org/bleocfmapping/schemas/org.bluetooth.profile.BLP.json#", |
| 4 | + "$schema": "http://json-schema.org/draft-04/schema#", |
| 5 | + "description" : "Copyright (c) 2018 Open Connectivity Foundation, Inc. All rights reserved.", |
| 6 | + "title": "Blood Pressure", |
| 7 | + "definitions": { |
| 8 | + "byte": { |
| 9 | + "type": "integer", |
| 10 | + "minimum": 0, |
| 11 | + "maximum": 255 |
| 12 | + }, |
| 13 | + "byteArray": { |
| 14 | + "type": "array", |
| 15 | + "items": { "$ref": "#/definitions/byte" }, |
| 16 | + "minItems": 1, |
| 17 | + "uniqueItems": false |
| 18 | + }, |
| 19 | + "org.bluetooth.characteristic.blood_pressure_measurement" : { |
| 20 | + "type" : "object", |
| 21 | + "properties": { |
| 22 | + "blood_pressure_measurement[length - 3 : length - 1]": { |
| 23 | + "$ref": "#/definitions/byteArray", |
| 24 | + "description": "Blood Pressure Measurement Compound Value - Systolic", |
| 25 | + "x-ocf-conversion": { |
| 26 | + "x-ocf-alias": "oic.r.blood.pressure", |
| 27 | + "x-to-ocf": [ |
| 28 | + "def ieee11073_Sfloat_2_Float(sfloat_value):", |
| 29 | + "# reserved value for Infinity or NaN (Not a Number)", |
| 30 | + "reserved_float_values = {", |
| 31 | + "0x07FE:math.inf, # +INFINITY", |
| 32 | + "0x07FF:math.nan, # NaN (Not a Number)", |
| 33 | + "0x0800:math.nan, # NRes (Not at this Resolution)", |
| 34 | + "0x0801:math.nan, # Reserved for future", |
| 35 | + "0x0802:-math.inf # -INFINITY", |
| 36 | + "}", |
| 37 | + "mantissa = sfloat_value & 0x0FFF", |
| 38 | + "exponent = sfloat_value >> 12", |
| 39 | + "if (exponent >= 0x0008):", |
| 40 | + "exponent = -((0x000F + 1) - exponent)", |
| 41 | + "output = 0", |
| 42 | + "if (mantissa >= 0x07FE and mantissa <= 0x0802):", |
| 43 | + "output = reserved_float_values[mantissa]", |
| 44 | + "else:", |
| 45 | + "if (mantissa >= 0x0800):", |
| 46 | + "mantissa = -((0x0FFF + 1) - mantissa)", |
| 47 | + "magnitude = pow(10.0, exponent)", |
| 48 | + "output = (mantissa * magnitude)", |
| 49 | + "return output", |
| 50 | + "length = len(blood_pressure_measurement)", |
| 51 | + "flags = blood_pressure_measurement[length - 1]", |
| 52 | + "oic.r.blood.pressure.systolic = ieee11073_Sfloat_2_Float(blood_pressure_measurement[length - 3 : length - 1])", |
| 53 | + "oic.r.blood.pressure.units = \"mmHg\" if (flags & 0x01) else \"kPa\"" |
| 54 | + ], |
| 55 | + "x-from-ocf": [ |
| 56 | + "N/A" |
| 57 | + ] |
| 58 | + } |
| 59 | + }, |
| 60 | + "blood_pressure_measurement[length - 5 : length - 3]": { |
| 61 | + "$ref": "#/definitions/byteArray", |
| 62 | + "description": "Blood Pressure Measurement Compound Value - Diastolic", |
| 63 | + "x-ocf-conversion": { |
| 64 | + "x-ocf-alias": "oic.r.blood.pressure", |
| 65 | + "x-to-ocf": [ |
| 66 | + "def ieee11073_Sfloat_2_Float(sfloat_value):", |
| 67 | + "# reserved value for Infinity or NaN (Not a Number)", |
| 68 | + "reserved_float_values = {", |
| 69 | + "0x07FE:math.inf, # +INFINITY", |
| 70 | + "0x07FF:math.nan, # NaN (Not a Number)", |
| 71 | + "0x0800:math.nan, # NRes (Not at this Resolution)", |
| 72 | + "0x0801:math.nan, # Reserved for future", |
| 73 | + "0x0802:-math.inf # -INFINITY", |
| 74 | + "}", |
| 75 | + "mantissa = sfloat_value & 0x0FFF", |
| 76 | + "exponent = sfloat_value >> 12", |
| 77 | + "if (exponent >= 0x0008):", |
| 78 | + "exponent = -((0x000F + 1) - exponent)", |
| 79 | + "output = 0", |
| 80 | + "if (mantissa >= 0x07FE and mantissa <= 0x0802):", |
| 81 | + "output = reserved_float_values[mantissa]", |
| 82 | + "else:", |
| 83 | + "if (mantissa >= 0x0800):", |
| 84 | + "mantissa = -((0x0FFF + 1) - mantissa)", |
| 85 | + "magnitude = pow(10.0, exponent)", |
| 86 | + "output = (mantissa * magnitude)", |
| 87 | + "return output", |
| 88 | + "length = len(blood_pressure_measurement)", |
| 89 | + "oic.r.blood.pressure.diastolic = ieee11073_Sfloat_2_Float(blood_pressure_measurement[length - 5 : length - 3])" |
| 90 | + ], |
| 91 | + "x-from-ocf": [ |
| 92 | + "N/A" |
| 93 | + ] |
| 94 | + } |
| 95 | + }, |
| 96 | + "blood_pressure_measurement[length - 7 : length - 5]": { |
| 97 | + "$ref": "#/definitions/byteArray", |
| 98 | + "description": "Blood Pressure Measurement Compound Value - Mean Arterial Pressure", |
| 99 | + "x-ocf-conversion": { |
| 100 | + "x-ocf-alias": "oic.r.blood.pressure", |
| 101 | + "x-to-ocf": [ |
| 102 | + "def ieee11073_Sfloat_2_Float(sfloat_value):", |
| 103 | + "# reserved value for Infinity or NaN (Not a Number)", |
| 104 | + "reserved_float_values = {", |
| 105 | + "0x07FE:math.inf, # +INFINITY", |
| 106 | + "0x07FF:math.nan, # NaN (Not a Number)", |
| 107 | + "0x0800:math.nan, # NRes (Not at this Resolution)", |
| 108 | + "0x0801:math.nan, # Reserved for future", |
| 109 | + "0x0802:-math.inf # -INFINITY", |
| 110 | + "}", |
| 111 | + "mantissa = sfloat_value & 0x0FFF", |
| 112 | + "exponent = sfloat_value >> 12", |
| 113 | + "if (exponent >= 0x0008):", |
| 114 | + "exponent = -((0x000F + 1) - exponent)", |
| 115 | + "output = 0", |
| 116 | + "if (mantissa >= 0x07FE and mantissa <= 0x0802):", |
| 117 | + "output = reserved_float_values[mantissa]", |
| 118 | + "else:", |
| 119 | + "if (mantissa >= 0x0800):", |
| 120 | + "mantissa = -((0x0FFF + 1) - mantissa)", |
| 121 | + "magnitude = pow(10.0, exponent)", |
| 122 | + "output = (mantissa * magnitude)", |
| 123 | + "return output", |
| 124 | + "length = len(blood_pressure_measurement)", |
| 125 | + "oic.r.blood.pressure.map = ieee11073_Sfloat_2_Float(blood_pressure_measurement[length - 7 : length - 5])" |
| 126 | + ], |
| 127 | + "x-from-ocf": [ |
| 128 | + "N/A" |
| 129 | + ] |
| 130 | + } |
| 131 | + }, |
| 132 | + "blood_pressure_measurement[length - 7 - timestamp_len - 2 : length - 7 - timestamp_len]": { |
| 133 | + "$ref": "#/definitions/byteArray", |
| 134 | + "description": "Pulse Rate", |
| 135 | + "x-ocf-conversion": { |
| 136 | + "x-ocf-alias": "oic.r.pulserate", |
| 137 | + "x-to-ocf": [ |
| 138 | + "def ieee11073_Sfloat_2_Float(sfloat_value):", |
| 139 | + "# reserved value for Infinity or NaN (Not a Number)", |
| 140 | + "reserved_float_values = {", |
| 141 | + "0x07FE:math.inf, # +INFINITY", |
| 142 | + "0x07FF:math.nan, # NaN (Not a Number)", |
| 143 | + "0x0800:math.nan, # NRes (Not at this Resolution)", |
| 144 | + "0x0801:math.nan, # Reserved for future", |
| 145 | + "0x0802:-math.inf # -INFINITY", |
| 146 | + "}", |
| 147 | + "mantissa = sfloat_value & 0x0FFF", |
| 148 | + "exponent = sfloat_value >> 12", |
| 149 | + "if (exponent >= 0x0008):", |
| 150 | + "exponent = -((0x000F + 1) - exponent)", |
| 151 | + "output = 0", |
| 152 | + "if (mantissa >= 0x07FE and mantissa <= 0x0802):", |
| 153 | + "output = reserved_float_values[mantissa]", |
| 154 | + "else:", |
| 155 | + "if (mantissa >= 0x0800):", |
| 156 | + "mantissa = -((0x0FFF + 1) - mantissa)", |
| 157 | + "magnitude = pow(10.0, exponent)", |
| 158 | + "output = (mantissa * magnitude)", |
| 159 | + "return output", |
| 160 | + "length = len(blood_pressure_measurement)", |
| 161 | + "flags = blood_pressure_measurement[length - 1]", |
| 162 | + "timestamp_len = 7 if (flags & 0x02) else 0", |
| 163 | + "oic.r.pulserate.pulserate = ieee11073_Sfloat_2_Float(blood_pressure_measurement[length - 7 - timestamp_len - 2 : length - 7 - timestamp_len])" |
| 164 | + ], |
| 165 | + "x-from-ocf": [ |
| 166 | + "N/A" |
| 167 | + ] |
| 168 | + } |
| 169 | + } |
| 170 | + } |
| 171 | + } |
| 172 | + }, |
| 173 | + |
| 174 | + "type": "object", |
| 175 | + |
| 176 | + "allOf": [ |
| 177 | + { "$ref": "#/definitions/byte" }, |
| 178 | + { "$ref": "#/definitions/byteArray" }, |
| 179 | + { "$ref": "#/definitions/org.bluetooth.characteristic.blood_pressure_measurement" } |
| 180 | + ], |
| 181 | + |
| 182 | + "required": [ |
| 183 | + "blood_pressure_measurement[length - 3 : length - 1]", |
| 184 | + "blood_pressure_measurement[length - 5 : length - 3]" |
| 185 | + ] |
| 186 | +} |
0 commit comments