Skip to content

Commit

Permalink
Merge pull request #538 from handymenny/ulTxSwitch
Browse files Browse the repository at this point in the history
0xb826: initial support for ul tx switch
  • Loading branch information
handymenny authored Nov 10, 2024
2 parents 028e671 + a45c65c commit edece72
Show file tree
Hide file tree
Showing 8 changed files with 10,914 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import it.smartphonecombo.uecapabilityparser.io.InputSource
import it.smartphonecombo.uecapabilityparser.model.BwClass
import it.smartphonecombo.uecapabilityparser.model.Capabilities
import it.smartphonecombo.uecapabilityparser.model.Mimo
import it.smartphonecombo.uecapabilityparser.model.UplinkTxSwitchConfig
import it.smartphonecombo.uecapabilityparser.model.UplinkTxSwitchOption
import it.smartphonecombo.uecapabilityparser.model.UplinkTxSwitchType
import it.smartphonecombo.uecapabilityparser.model.bandwidth.Bandwidth
import it.smartphonecombo.uecapabilityparser.model.bandwidth.InvalidBandwidth
import it.smartphonecombo.uecapabilityparser.model.bandwidth.toBandwidth
Expand Down Expand Up @@ -164,17 +167,22 @@ object Import0xB826 : ImportCapabilities {
if (version >= 8) {
stream.skipBytes(3)
}

val numComponents = getNumComponents(stream, version)
val bands = mutableListWithCapacity<ComponentLte>(numComponents)
var nrBands = mutableListWithCapacity<ComponentNr>(numComponents)
var nrDcBands = mutableListWithCapacity<ComponentNr>(numComponents)
val ulTxSwitchConfig = if (version >= 13) parseUlTxSwitch(stream) else null

when (version) {
6,
8 -> stream.skipBytes(1)
7 -> stream.skipBytes(3)
in 9..13 -> stream.skipBytes(9)
in 14..Int.MAX_VALUE -> stream.skipBytes(25)
in 9..12 -> stream.skipBytes(9)
13 -> stream.skipBytes(8)
in 14..Int.MAX_VALUE -> stream.skipBytes(24)
}

for (i in 0 until numComponents) {
val component = parseComponent(stream, version)
if (component is ComponentNr) {
Expand Down Expand Up @@ -206,6 +214,8 @@ object Import0xB826 : ImportCapabilities {
ComboEnDc(bands, nrBands)
} else if (nrDcBands.isNotEmpty()) {
ComboNrDc(nrBands, nrDcBands)
} else if (ulTxSwitchConfig != null) {
ComboNr(nrBands, uplinkTxSwitch = listOf(ulTxSwitchConfig))
} else {
ComboNr(nrBands)
}
Expand Down Expand Up @@ -582,4 +592,17 @@ object Import0xB826 : ImportCapabilities {
val shiftAmount = index - 1
return (1 shl shiftAmount) * 15
}

private fun parseUlTxSwitch(stream: InputStream): UplinkTxSwitchConfig? {
val ulTxSwitch = stream.readUByte().readNBits(2, offset = 2)
val ulTxSwitchOption =
when (ulTxSwitch) {
1 -> UplinkTxSwitchOption.SWITCHED_UL
2 -> UplinkTxSwitchOption.DUAL_UL
3 -> UplinkTxSwitchOption.BOTH
else -> return null
}

return UplinkTxSwitchConfig(UplinkTxSwitchType.R16, ulTxSwitchOption)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,11 @@ internal class Import0xB826Test :
parse("0xB826-v13-SA2.bin", "0xB826-v13-SA2.json")
}

@Test
fun parseV13SAulTxSwitch() {
parse("0xB826-v13-SA-ulTxSwitch.bin", "0xB826-v13-SA-ulTxSwitch.json")
}

@Test
fun parseV13NRDC() {
parse("0xB826-v13-NRDC.bin", "0xB826-v13-NRDC.json")
Expand All @@ -217,6 +222,11 @@ internal class Import0xB826Test :
parse("0xB826-v14-SA.bin", "0xB826-v14-SA.json")
}

@Test
fun parseV14SAulTxSwitch() {
parse("0xB826-v14-SA-ulTxSwitch.bin", "0xB826-v14-SA-ulTxSwitch.json")
}

@Test
fun parseV17NSA() {
parse("0xB826-v17-NSA.bin", "0xB826-v17-NSA.json")
Expand All @@ -228,8 +238,8 @@ internal class Import0xB826Test :
}

@Test
fun parseV17SA2() {
parse("0xB826-v17-SA2.bin", "0xB826-v17-SA2.json")
fun parseV17SAulTxSwitch() {
parse("0xB826-v17-SA-ulTxSwitch.bin", "0xB826-v17-SA-ulTxSwitch.json")
}

@Test
Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit edece72

Please sign in to comment.