Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0xB0CDbin: fix MIMO for v32 #455

Merged
merged 3 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ object Import0xB0CDBin : ImportCapabilities {

listCombo = mutableListWithCapacity(numCombos)

for (i in 1..numCombos) {
repeat(numCombos) {
val combo = parseCombo(stream, version)
listCombo.add(combo)
}
Expand Down Expand Up @@ -95,7 +95,7 @@ object Import0xB0CDBin : ImportCapabilities {
private fun parseCombo(stream: InputStream, version: Int): ComboLte {
val numComponents = getNumComponents(stream, version)
val bands = mutableListWithCapacity<ComponentLte>(numComponents)
for (i in 0 until numComponents) {
repeat(numComponents) {
val component = parseComponent(stream, version)
if (component.band != 0) {
bands.add(component)
Expand Down Expand Up @@ -127,12 +127,15 @@ object Import0xB0CDBin : ImportCapabilities {

if (version >= 41) {
component.classUL = BwClass.valueOf(stream.readUByte())
component.mimoDL = Mimo.fromQcIndex(stream.readUByte())
component.mimoUL = Mimo.fromQcIndex(stream.readUByte())
component.mimoDL = parseMimo(stream.readUByte(), true)
component.mimoUL = parseMimo(stream.readUByte(), true)
} else if (version >= 32) {
component.mimoDL = Mimo.fromQcIndex(stream.readUByte())
// versions < 40 don't have an indexed mimo
val mimoIsIndexed = version >= 40

component.mimoDL = parseMimo(stream.readUByte(), mimoIsIndexed)
component.classUL = BwClass.valueOf(stream.readUByte())
component.mimoUL = Mimo.fromQcIndex(stream.readUByte())
component.mimoUL = parseMimo(stream.readUByte(), mimoIsIndexed)
} else {
component.classUL = BwClass.valueOf(stream.readUByte())
}
Expand All @@ -148,12 +151,20 @@ object Import0xB0CDBin : ImportCapabilities {
return component
}

/**
* Convert the given "raw" value to mimo. If indexed is true (version >= 40) calls
* [Mimo.fromQcIndex], otherwise calls [Mimo.from]
*/
private fun parseMimo(value: Int, indexed: Boolean): Mimo {
return if (indexed) Mimo.fromQcIndex(value) else Mimo.from(value)
}

/**
* Return qam from Qualcomm diag index.
*
* The sequence generator is guessed, so it can be wrong or incomplete.
*/
fun getQamFromIndex(index: Int): Modulation {
private fun getQamFromIndex(index: Int): Modulation {
/*
Some examples:
0 -> INVALID
Expand All @@ -169,7 +180,7 @@ object Import0xB0CDBin : ImportCapabilities {
...
*/
var result = arrayOf(ModulationOrder.NONE)
for (i in 1..index) {
repeat(index) {
val indexOfMin = result.indexOfMin()
when (result[indexOfMin]) {
ModulationOrder.QAM256 -> result = Array(result.size + 1) { ModulationOrder.QAM64 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ internal class Import0xB0CDBinTest {
parse("0xB0CD-v32.bin", "0xB0CD-v32.json")
}

@Test
fun parseV324rx() {
parse("0xB0CD-v32-4rx.bin", "0xB0CD-v32-4rx.json")
}

@Test
fun parseV40() {
parse("0xB0CD-v40.bin", "0xB0CD-v40.json")
Expand Down
Binary file not shown.
Loading