CalibrationProtocol extends DistoXProtocol { public static int readDoubleByte(byte[] packet, int lowByteIndex, int highByteIndex) { int low = packet[lowByteIndex] & 0xff; int high = packet[highByteIndex] & 0xff; int combined = (high * 256) + low; if (combined > 32768) combined -= 65536; return combined; } CalibrationProtocol(
            SexyTopoActivity activity, BluetoothDevice bluetoothDevice, SurveyManager dataManager); @Override void go(DataInputStream inStream, DataOutputStream outStream); static int readDoubleByte(byte[] packet, int lowByteIndex, int highByteIndex); static final int ACCELERATION_ADMIN; static final int ACCELERATION_GX_LOW_BYTE; static final int ACCELERATION_GX_HIGH_BYTE; static final int ACCELERATION_GY_LOW_BYTE; static final int ACCELERATION_GY_HIGH_BYTE; static final int ACCELERATION_GZ_LOW_BYTE; static final int ACCELERATION_GZ_HIGH_BYTE; static final int ACCELERATION_NOT_USED; static final int MAGNETIC_ADMIN; static final int MAGNETIC_MX_LOW_BYTE; static final int MAGNETIC_MX_HIGH_BYTE; static final int MAGNETIC_MY_LOW_BYTE; static final int MAGNETIC_MY_HIGH_BYTE; static final int MAGNETIC_MZ_LOW_BYTE; static final int MAGNETIC_MZ_HIGH_BYTE; static final int MAGNETIC_NOT_USED; }
@Test public void testReadDoubleByteGx() { double result = CalibrationProtocol.readDoubleByte( TEST_ACCELERATION_PACKET, CalibrationProtocol.ACCELERATION_GX_LOW_BYTE, CalibrationProtocol.ACCELERATION_GX_HIGH_BYTE); Assert.assertEquals(-79, result, ALLOWED_DELTA); }
@Test public void testReadDoubleByteGy() { double result = CalibrationProtocol.readDoubleByte( TEST_ACCELERATION_PACKET, CalibrationProtocol.ACCELERATION_GY_LOW_BYTE, CalibrationProtocol.ACCELERATION_GY_HIGH_BYTE); Assert.assertEquals(-603, result, ALLOWED_DELTA); }
@Test public void testReadDoubleByteGz() { double result = CalibrationProtocol.readDoubleByte( TEST_ACCELERATION_PACKET, CalibrationProtocol.ACCELERATION_GZ_LOW_BYTE, CalibrationProtocol.ACCELERATION_GZ_HIGH_BYTE); Assert.assertEquals(24785, result, ALLOWED_DELTA); }
@Test public void testReadDoubleByteMx() { double result = CalibrationProtocol.readDoubleByte( TEST_MAGNETIC_PACKET, CalibrationProtocol.MAGNETIC_MX_LOW_BYTE, CalibrationProtocol.MAGNETIC_MX_HIGH_BYTE); Assert.assertEquals(7978, result, ALLOWED_DELTA); }
@Test public void testReadDoubleByteMy() { double result = CalibrationProtocol.readDoubleByte( TEST_MAGNETIC_PACKET, CalibrationProtocol.MAGNETIC_MY_LOW_BYTE, CalibrationProtocol.MAGNETIC_MY_HIGH_BYTE); Assert.assertEquals(-1607, result, ALLOWED_DELTA); }
@Test public void testReadDoubleByteMz() { double result = CalibrationProtocol.readDoubleByte( TEST_MAGNETIC_PACKET, CalibrationProtocol.MAGNETIC_MZ_LOW_BYTE, CalibrationProtocol.MAGNETIC_MZ_HIGH_BYTE); Assert.assertEquals(16090, result, ALLOWED_DELTA); }