Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/github_actions/codecov/codecov-ac…
Browse files Browse the repository at this point in the history
…tion-5
  • Loading branch information
handymenny authored Dec 11, 2024
2 parents eec4fb0 + 75d242a commit 1e3e341
Show file tree
Hide file tree
Showing 12 changed files with 11,355 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ object Import0xB826 : ImportCapabilities {
*
* It supports 0xB826 with or without header.
*
* It has been tested with the following 0xB826 versions: 2, 3, 4, 6, 7, 8, 9, 10, 13, 14,
* 17, 21.
* It has been tested with the following 0xB826 versions: 2, 3, 4, 6, 7, 8, 9, 10, 13, 14, 17,
* 21, 22.
*/
override fun parse(input: InputSource): Capabilities {
val capabilities = Capabilities()
Expand Down Expand Up @@ -162,23 +162,22 @@ object Import0xB826 : ImportCapabilities {

/** Parses a combo */
private fun parseCombo(stream: InputStream, version: Int, source: String?): ICombo {
if (version >= 8) {
if (version >= 8 && version < 22) {
stream.skipBytes(3)
}

val numComponents = getNumComponents(stream, version)
val comboFeaturesBits = if (version >= 6) stream.readUShortLE() else stream.readUByte()
val numComponents = getNumComponents(comboFeaturesBits, 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
val ulTxSwitchConfig = parseUlTxSwitch(comboFeaturesBits, version)

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

for (i in 0 until numComponents) {
Expand Down Expand Up @@ -220,19 +219,16 @@ object Import0xB826 : ImportCapabilities {
}

/** Return the num of components of a combo. */
private fun getNumComponents(stream: InputStream, version: Int): Int {
val numBands = stream.readUByte()

private fun getNumComponents(bytes: Int, version: Int): Int {
val offset =
if (version < 3) {
0
} else if (version <= 7) {
1
} else {
3
when (version) {
in 3..7 -> 1
in 8..21 -> 3
in 22..Int.MAX_VALUE -> 6
else -> 0
}

return numBands.readNBits(4, offset)
return bytes.readNBits(4, offset)
}

/**
Expand Down Expand Up @@ -357,12 +353,19 @@ object Import0xB826 : ImportCapabilities {
val byte4 = stream.readUByte()
val byte5 = stream.readUByte()

val scsLeft = byte4.readNBits(2)
val scsRight = byte3.readNBits(1, offset = 7)
val scsIndex = scsRight.insert(scsLeft, 1)
nrBand.scs = getSCSFromIndex(scsIndex)
if (version < 22) {
val scsLeft = byte4.readNBits(2)
val scsRight = byte3.readNBits(1, offset = 7)
val scsIndex = scsRight.insert(scsLeft, 1)
nrBand.scs = getSCSFromIndex(scsIndex)
}

if (version >= 17) {
if (version >= 22) {
val maxBWindex = byte3.readNBits(1, offset = 7).insert(byte4.readNBits(6), 1)
nrBand.maxBandwidthDl = getBWFromIndexV17(maxBWindex)
var maxBwIndexUl = byte4.readNBits(2, offset = 6).insert(byte5.readNBits(5), 2)
nrBand.maxBandwidthUl = getBWFromIndexV17(maxBwIndexUl)
} else if (version >= 17) {
val maxBWindex = byte4.readNBits(6, offset = 2).insert(byte5.readNBits(1), 6)
nrBand.maxBandwidthDl = getBWFromIndexV17(maxBWindex)
val maxBwIndexUl = byte5.readNBits(7, offset = 1)
Expand All @@ -383,7 +386,9 @@ object Import0xB826 : ImportCapabilities {
} else {
stream.skipBytes(3)
}
if (version >= 17) {
if (version >= 22) {
stream.skipBytes(2)
} else if (version >= 17) {
stream.skipBytes(1)
}
return component
Expand Down Expand Up @@ -591,8 +596,12 @@ object Import0xB826 : ImportCapabilities {
return (1 shl shiftAmount) * 15
}

private fun parseUlTxSwitch(stream: InputStream): UplinkTxSwitchConfig? {
val ulTxSwitch = stream.readUByte().readNBits(2, offset = 2)
private fun parseUlTxSwitch(bytes: Int, version: Int): UplinkTxSwitchConfig? {
if (version < 13) return null

val offset = if (version < 22) 10 else 13

val ulTxSwitch = bytes.readNBits(2, offset = offset)
val ulTxSwitchOption =
when (ulTxSwitch) {
1 -> UplinkTxSwitchOption.SWITCHED_UL
Expand Down
17 changes: 15 additions & 2 deletions src/main/java/it/smartphonecombo/uecapabilityparser/model/Mimo.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package it.smartphonecombo.uecapabilityparser.model

import it.smartphonecombo.uecapabilityparser.extension.indexOfMin
import it.smartphonecombo.uecapabilityparser.io.IOUtils.echoSafe
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable

Expand Down Expand Up @@ -47,6 +48,18 @@ sealed interface Mimo : Comparable<Mimo> {
* The sequence generator is guessed, so it can be wrong or incomplete.
*/
fun fromQcIndex(index: Int): Mimo {
// for index > 80 we can't use generator
if (index > 80) {
return when (index) {
81 -> SingleMimo(8)
85 -> SingleMimo(6)
else -> {
echoSafe("Unknown Qc Mimo index $index", err = true)
EmptyMimo
}
}
}

/*
Some examples:
0 -> 0
Expand All @@ -61,10 +74,10 @@ sealed interface Mimo : Comparable<Mimo> {
9 -> 1_1_1
10 -> 2_1_1
...
72 -> 2_2_2_2_2_2_2_2
80 -> 4_4_4_4_4_4_4_4
*/
var result = intArrayOf(0)
for (i in 1..index) {
repeat(index) {
val indexOfMin = result.indexOfMin()
when (result[indexOfMin]) {
4 -> result = IntArray(result.size + 1) { 1 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ object UtilityForTests {
} else {
val aSize = fileA.readBytes().size
val bSize = fileB.readBytes().size
abs(aSize - bSize) < 5 * aSize / 100
abs(aSize - bSize) < maxOf(3 * aSize / 100, 128)
}
}
return result
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ internal class Import0xB826Test :
parse("0xB826-v17-SA-ulTxSwitch.bin", "0xB826-v17-SA-ulTxSwitch.json")
}

@Test
fun parseV17SA6rx8rx() {
parse("0xB826-v17-SA-6rx8rx.bin", "0xB826-v17-SA-6rx8rx.json")
}

@Test
fun parseV17NRDC() {
parse("0xB826-v17-NRDC.bin", "0xB826-v17-NRDC.json")
Expand All @@ -266,4 +271,19 @@ internal class Import0xB826Test :
fun parseV21SAulTxSwitch() {
parse("0xB826-v21-SA-ulTxSwitch.bin", "0xB826-v21-SA-ulTxSwitch.json")
}

@Test
fun parseV22NSA() {
parse("0xB826-v22-NSA.bin", "0xB826-v22-NSA.json")
}

@Test
fun parseV22SA() {
parse("0xB826-v22-SA.bin", "0xB826-v22-SA.json")
}

@Test
fun parseV22SAulTxSwitch() {
parse("0xB826-v22-SA-ulTxSwitch.bin", "0xB826-v22-SA-ulTxSwitch.json")
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added src/test/resources/0xB826/input/0xB826-v22-SA.bin
Binary file not shown.
Loading

0 comments on commit 1e3e341

Please sign in to comment.