# Test effects of interference levels reported in Resource Indication.
# Note, this is not actually a handover test.

create-bts trx-count 1 timeslots c+s4 TCH/F TCH/F TCH/F TCH/F TCH/F TCH/F PDCH

# By default, the ordering is most-interference-first
network
 bts 0
  channel allocator avoid-interference 1
  interference-meas level-bounds -85 -91 -97 -103 -109 -115
#                                 0   1   2    3    4    5

res-ind trx 0 0 levels           -    1     2     3     4     3     2     -
create-ms bts 0 TCH/F AMR
expect-ts-use trx 0 0 states     *    -     -     -     TCH/F -     -     *

# The ordering may also be configured reversed, still the lowest dBm value should win
network
 bts 0
  interference-meas level-bounds -115 -109 -103 -97 -91 -85
#                                  0    1    2   3   4   5

res-ind trx 0 0 levels           -    5     4     2     -     3     4     -
create-ms bts 0 TCH/F AMR
expect-ts-use trx 0 0 states     *    -     -     TCH/F TCH/F -     -     *

# Favor lchans that have an indicated interference level
res-ind trx 0 0 levels           -    -     -     -     -     4     3     -
create-ms bts 0 TCH/F AMR
expect-ts-use trx 0 0 states     *    -     -     TCH/F TCH/F -     TCH/F *

# For equal levels, pick the first
res-ind trx 0 0 levels           -    2     2     -     -     2     -     -
create-ms bts 0 TCH/F AMR
expect-ts-use trx 0 0 states     *    TCH/F -     TCH/F TCH/F -     TCH/F *

# Test clamping of indexes > 5
res-ind trx 0 0 levels           -    -     6     -     -     4     -     -
create-ms bts 0 TCH/F AMR
expect-ts-use trx 0 0 states     *    TCH/F -     TCH/F TCH/F TCH/F TCH/F *

# Also test for TCH/H
create-bts trx-count 1 timeslots c+s4 TCH/H  TCH/H  TCH/H  TCH/H  TCH/H  TCH/H  PDCH
network
 bts 1
  channel allocator avoid-interference 1
  interference-meas level-bounds -115 -109 -103 -97 -91 -85
#                                  0    1    2   3   4   5

res-ind trx 1 0 levels           -    54     32     21     23     45     54     -
create-ms bts 1 TCH/H AMR
expect-ts-use trx 1 0 states     *    -      -      TCH/-H -      -      -      *

# Favor lchans that have an indicated interference level
res-ind trx 1 0 levels           -    -      -      4-     3-     -      -      -
create-ms bts 1 TCH/H AMR
expect-ts-use trx 1 0 states     *    -      -      TCH/-H TCH/H- -      -      *

# For equal levels, pick the first
res-ind trx 1 0 levels           -    -2     22     2-     -2     22     2-     -
create-ms bts 1 TCH/H AMR
expect-ts-use trx 1 0 states     *    TCH/-H -      TCH/-H TCH/H- -      -      *

# Test clamping of indexes > 5
res-ind trx 1 0 levels           -    7-     67     6-     -7     54     6-     -
create-ms bts 1 TCH/H AMR
expect-ts-use trx 1 0 states     *    TCH/-H -      TCH/-H TCH/H- TCH/-H -      *
