Skip to content

Commit

Permalink
Merge pull request #455 from handymenny/0xb0cd-v32-mimo
Browse files Browse the repository at this point in the history
0xB0CDbin: fix MIMO for v32
  • Loading branch information
handymenny authored Jul 29, 2024
2 parents 40028d7 + d4bedfc commit b42a83b
Show file tree
Hide file tree
Showing 4 changed files with 3,017 additions and 8 deletions.
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

0 comments on commit b42a83b

Please sign in to comment.