-
- All Implemented Interfaces:
-
android.os.Parcelable,no.nordicsemi.android.ble.callback.DataReceivedCallback,no.nordicsemi.android.ble.callback.profile.ProfileDataCallback,no.nordicsemi.android.ble.common.callback.cgm.CRCSecuredResponse,no.nordicsemi.android.ble.common.profile.cgm.CGMTypes,no.nordicsemi.android.ble.common.profile.cgm.ContinuousGlucoseMeasurementCallback,no.nordicsemi.android.ble.common.profile.glucose.GlucoseTypes
public final class ContinuousGlucoseMeasurementResponse extends ContinuousGlucoseMeasurementDataCallback implements CRCSecuredResponse, Parcelable
Response class that could be used as a result of a synchronous request. The data received are available through getters, instead of a callback.
Usage example:
try { ContinuousGlucoseMeasurementResponse response = waitForNotification(characteristic) .awaitValid(ContinuousGlucoseMeasurementResponse.class); float glucoseConcentration = response.getGlucoseConcentration(); ... } catch (RequestFailedException e) { Log.w(TAG, "Request failed with status " + e.getStatus(), e); } catch (InvalidDataException e) { Log.w(TAG, "Invalid data received: " + e.getResponse().getRawData()); }
-
-
Field Summary
Fields Modifier and Type Field Description private final ArrayList<ContinuousGlucoseMeasurementResponseItem>itemspublic final static Parcelable.Creator<ContinuousGlucoseMeasurementResponse>CREATOR
-
Constructor Summary
Constructors Constructor Description ContinuousGlucoseMeasurementResponse()
-
Method Summary
Modifier and Type Method Description ArrayList<ContinuousGlucoseMeasurementResponseItem>getItems()voidonContinuousGlucoseMeasurementReceived(@NonNull() BluetoothDevice device, float glucoseConcentration, @Nullable() Float cgmTrend, @Nullable() Float cgmQuality, @Nullable() CGMTypes.CGMStatus status, int timeOffset, boolean secured)Callback called when a Continuous Glucose Measurement packet has been received. voidonContinuousGlucoseMeasurementReceivedWithCrcError(@NonNull() BluetoothDevice device, @NonNull() Data data)Callback called when a CGM packet with E2E field was received but the CRC check has failed. voidwriteToParcel(@NonNull() Parcel dest, int flags)booleanisSecured()Returns true if the packet was secured with E2E CRC. booleanisCrcValid()Returns true if the packet was secured with E2E CRC value and the CRC was valid.In all other cases it returns false. -
Methods inherited from class no.nordicsemi.android.ble.common.callback.cgm.ContinuousGlucoseMeasurementDataCallback
onDataReceived -
Methods inherited from class no.nordicsemi.android.ble.callback.profile.ProfileReadResponse
isValid, onInvalidDataReceived, writeToParcel -
Methods inherited from class no.nordicsemi.android.ble.response.ReadResponse
describeContents, getBluetoothDevice, getRawData, onDataReceived -
Methods inherited from class no.nordicsemi.android.ble.common.profile.cgm.ContinuousGlucoseMeasurementCallback
onContinuousGlucoseMeasurementReceived, onContinuousGlucoseMeasurementReceivedWithCrcError, toMgPerDecilitre -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
onContinuousGlucoseMeasurementReceived
void onContinuousGlucoseMeasurementReceived(@NonNull() BluetoothDevice device, float glucoseConcentration, @Nullable() Float cgmTrend, @Nullable() Float cgmQuality, @Nullable() CGMTypes.CGMStatus status, int timeOffset, boolean secured)
Callback called when a Continuous Glucose Measurement packet has been received.
If the E2E CRC field was present in the CGM packet, the data has been verified against it.If CRC check has failed, the onContinuousGlucoseMeasurementReceivedWithCrcError will be called instead.
The Glucose concentration is reported in mg/dL. To convert it to mmol/L use:
or simply call toMgPerDecilitre.value [mg/dL] = 18.02 * value [mmol/L]Note that the conversion factor is compliant to the Continua blood glucose meter specification.
- Parameters:
device- the target device.glucoseConcentration- the glucose concentration in mg/dL.cgmTrend- an optional CGM Trend information, in (mg/dL)/min.cgmQuality- an optional CGM Quality information in percent.status- the status of the measurement.timeOffset- the time offset in minutes since Session Start Time.secured- true if the packet was sent with E2E-CRC value that was verifiedto match the packet, false if the packet didn't contain CRC field.
-
onContinuousGlucoseMeasurementReceivedWithCrcError
void onContinuousGlucoseMeasurementReceivedWithCrcError(@NonNull() BluetoothDevice device, @NonNull() Data data)
Callback called when a CGM packet with E2E field was received but the CRC check has failed.
- Parameters:
device- the target device.data- the CGM packet data that was received, including the CRC field.
-
writeToParcel
void writeToParcel(@NonNull() Parcel dest, int flags)
-
isSecured
boolean isSecured()
Returns true if the packet was secured with E2E CRC.See isCrcValid to check if the CRC was valid.
-
isCrcValid
boolean isCrcValid()
Returns true if the packet was secured with E2E CRC value and the CRC was valid.In all other cases it returns false.
-
-
-
-