# Handover due to maximum TA exceeded
# The MS in the current (best) cell has reached maximum allowed timing
# advance. No handover is performed until the timing advance exceeds
# it. The originating cell is still the best, but no handover is
# performed back to that cell, because the penalty timer (due to
# maximum allowed timing advance) is running.

create-n-bts 2
set-ts-use trx 0 0 states * TCH/F - - - - - -

network
 bts 0
  handover2 maximum distance 5
  handover2 penalty-time max-distance 17

meas-rep lchan 0 0 1 0 rxlev 30 rxqual 0 ta 5 neighbors 20
expect-no-chan
meas-rep lchan 0 0 1 0 rxlev 30 rxqual 0 ta 6 neighbors 20
expect-ho from lchan 0 0 1 0 to lchan 1 0 1 0
expect-ts-use trx 0 0 states * - - - - - - -
expect-ts-use trx 1 0 states * TCH/F - - - - - -

# Penalty timer after TA was exceeded is running, so no handover back to the better cell:
meas-rep lchan 1 0 1 0 rxlev 20 rxqual 0 ta 6 neighbors 30
expect-no-chan

wait 16
# Penalty timer still running
meas-rep lchan 1 0 1 0 rxlev 20 rxqual 0 ta 6 neighbors 30
expect-no-chan

wait 1
# Now 17 seconds have passed, timeout is done, and a handover is performed again.
meas-rep lchan 1 0 1 0 rxlev 20 rxqual 0 ta 6 neighbors 30
expect-ho from lchan 1 0 1 0 to lchan 0 0 1 0
expect-ts-use trx 0 0 states * TCH/F - - - - - -
expect-ts-use trx 1 0 states * - - - - - - -
