Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A Bluetooth-enabled oximeter, which is a device used to measure the oxygen level

ID: 1840615 • Letter: A

Question

A Bluetooth-enabled oximeter, which is a device used to measure the oxygen level (SpO2) in the blood and Heart Rate (HR), transmits the SpO2 and HR measurements through three bytes of data once per second to a Bluetooth-enabled microcontroller (See Figure 1). The three bytes contain the 7 bits of SpO2 (SP_0 to SP_6) and the 9 bits of HR (HR_0 to HR_8) as shown in Figure 2. Bits 'X' are used for something else. Assuming that a 'C' code has three variables B1, B2 and B3 declared as unsigned char in a main function and are used to hold the three bytes, byte 1, byte 2 and byte 3 received by the microcontroller respectively. Write the code that can be used to extract the measurements SpO2 and HR from the three received bytes.

Explanation / Answer

public byte[] readBytes(InputStream inputStream, int length) throws IOException { byte[] data = new byte[length]; int len = inputStream.read(data); if (len != length) { throw new IOException("Read the end of stream."); } byte[] headerData = readBytes(inputStream, 9); public class ByteWriter { private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); public void writeBytes(byte[] data) { try { outputStream.write(data); } catch (IOException ex) { ex.printStackTrace(); } } public byte[] getBytes() { return outputStream.toByteArray(); } } return data; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote