@Override
	public void onDataReceived(@NonNull final BluetoothDevice device, @NonNull final Data data) {
		super.onDataReceived(device, data);

		if (data.size() < 3) {
			onInvalidDataReceived(device, data);
			return;
		}

		final int opCode = data.getIntValue(Data.FORMAT_UINT8, 0);
		if (opCode != OP_CODE_NUMBER_OF_STORED_RECORDS_RESPONSE && opCode != OP_CODE_RESPONSE_CODE) {
			onInvalidDataReceived(device, data);
			return;
		}

		final int operator = data.getIntValue(Data.FORMAT_UINT8, 1);
		if (operator != OPERATOR_NULL) {
			onInvalidDataReceived(device, data);
			return;
		}

		switch (opCode) {
			case OP_CODE_NUMBER_OF_STORED_RECORDS_RESPONSE -> {
				// Field size is defined per service
				int numberOfRecords;

				switch (data.size() - 2) {
					case 1 -> numberOfRecords = data.getIntValue(Data.FORMAT_UINT8, 2);
					case 2 -> numberOfRecords = data.getIntValue(Data.FORMAT_UINT16_LE, 2);
					case 4 -> numberOfRecords = data.getIntValue(Data.FORMAT_UINT32_LE, 2);
					default -> {
						// Other field sizes are not supported
						onInvalidDataReceived(device, data);
						return;
					}
				}
				onNumberOfRecordsReceived(device, numberOfRecords);
			}
			case OP_CODE_RESPONSE_CODE -> {
				if (data.size() != 4) {
					onInvalidDataReceived(device, data);
					return;
				}

				final int requestCode = data.getIntValue(Data.FORMAT_UINT8, 2);
				final int responseCode = data.getIntValue(Data.FORMAT_UINT8, 3);
				if (responseCode == RACP_RESPONSE_SUCCESS) {
					onRecordAccessOperationCompleted(device, requestCode);
				} else if (responseCode == RACP_ERROR_NO_RECORDS_FOUND) {
					onRecordAccessOperationCompletedWithNoRecordsFound(device, requestCode);
				} else {
					onRecordAccessOperationError(device, requestCode, responseCode);
				}
			}
		}
	}
@Test
	public void onNumberOfRecordsReceived_uint8() {
		final Data data = new Data(new byte[] { 5, 0, 1 });
		callback.onDataReceived(null, data);
		assertEquals(numberOfRecords, 1);
	}