/* package */static String parse(final Data data, final int offset) { final int type = data.getValue()[offset]; switch (type) { case 1: return "Armpit"; case 2: return "Body (general)"; case 3: return "Ear (usually ear lobe)"; case 4: return "Finger"; case 5: return "Gastro-intestinal Tract"; case 6: return "Mouth"; case 7: return "Rectum"; case 8: return "Toe"; case 9: return "Tympanum (ear drum)"; default: return "Unknown"; } } }
public static String parse(final Data data) { // The CGM Measurement characteristic is a variable length structure containing one or more CGM Measurement records int totalSize = data.getValue().length; final StringBuilder builder = new StringBuilder(); int offset = 0; while (offset < totalSize) { offset += parseRecord(builder, data, offset); if (offset < totalSize) builder.append("\n\n"); } return builder.toString(); }
public boolean write(@Nullable final Data data) { return data != null && write(data.getValue()); }
/** * Writes the given data to the characteristic. The write type is taken from the characteristic. * <p> * Use {@link WriteRequest#split() split()} or * {@link WriteRequest#split(DataSplitter) split(DataSplitter)} on the returned * {@link WriteRequest} if data should be automatically split into multiple packets. * If the characteristic is null, the {@link Request#fail(FailCallback) fail(FailCallback)} * callback will be called. * <p> * The returned request must be either enqueued using {@link Request#enqueue()} for * asynchronous use, or awaited using await() in synchronous execution. * * @param characteristic the characteristic to write to. * @param data data to be written to the characteristic. * @return The request. */ @NonNull protected final WriteRequest writeCharacteristic(@Nullable final BluetoothGattCharacteristic characteristic, @Nullable final Data data) { return Request.newWriteRequest(characteristic, data != null ? data.getValue() : null) .setManager(this); }
/** * Writes the given data to the descriptor. * <p> * Use {@link WriteRequest#split() split()} or * {@link WriteRequest#split(DataSplitter) split(ValueSplitter)} on the returned * {@link WriteRequest} if data should be automatically split into multiple packets. * If the descriptor is null, the {@link Request#fail(FailCallback) fail(FailCallback)} * callback will be called. * <p> * The returned request must be either enqueued using {@link Request#enqueue()} for * asynchronous use, or awaited using await() in synchronous execution. * * @param descriptor the descriptor to write to. * @param data data to be written to the descriptor. * @return The request. */ @NonNull protected final WriteRequest writeDescriptor(@Nullable final BluetoothGattDescriptor descriptor, @Nullable final Data data) { return Request.newWriteRequest(descriptor, data != null ? data.getValue() : null) .setManager(this); }
public static String parse(final Data data) { int offset = 0; final int flags = data.getValue()[offset]; // 1 byte offset += 1;
for (int o = offset; o < data.getValue().length; o += 2) { final int units = data.getIntValue(Data.FORMAT_UINT16, o); rrIntervals.add(units * 1000.0f / 1024.0f); // RR interval is in [1/1024s]
assertArrayEquals(text.getBytes(), data.getValue()); }) .done(device -> done = true);