Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
/.idea/runConfigurations.xml
.DS_Store
/build
/captures
Expand Down
10 changes: 10 additions & 0 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added apk-builds/app-debug-androidTest.apk
Binary file not shown.
11 changes: 8 additions & 3 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ android {
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "1.8"
jvmTarget = "11"
}
buildFeatures {
viewBinding = true
Expand Down Expand Up @@ -87,3 +87,8 @@ dependencies {
// netmonster
implementation(libs.netmonster.core)
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ suspend fun getAvailableCells(viewModel: CellDataViewModel): MutableList<CellDat
return localCellList
}

suspend fun getCACells(viewModel: CellDataViewModel): MutableList<CellData> {
val localCellList: MutableList<CellData> = mutableListOf<CellData>()
localCellList.addAll(viewModel.getCACells().toMutableList())
return localCellList
}

fun Route.routeCellData() {
val viewModel: CellDataViewModel = CellDataViewModel.getInstance()

Expand Down Expand Up @@ -75,6 +81,24 @@ fun Route.routeCellData() {
}
}
}

route("/estimate-ca") {
get("/all") {
val cellList = getCACells(viewModel)
call.respond(cellList)
}
get("/cell/{id}") {
val id = call.parameters["id"]?.toIntOrNull()
val cellList = getCACells(viewModel)
if (id != null && id >= 0 && id < cellList.size) {
val someCell: CellData = cellList[id]
call.respond(someCell)
} else {
call.respondText("Cell not found", status = HttpStatusCode.NotFound)
}
}
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import cz.mroczis.netmonster.core.model.cell.CellLte
import cz.mroczis.netmonster.core.model.cell.CellNr
import cz.mroczis.netmonster.core.model.cell.ICell
import cz.mroczis.netmonster.core.model.connection.NoneConnection
import cz.mroczis.netmonster.core.model.connection.PrimaryConnection
import eu.bschmidt.devicepublisher.MainApplication
import eu.bschmidt.devicepublisher.model.DataViewModelInterface
import eu.bschmidt.devicepublisher.util.DevPubUtils
Expand All @@ -43,24 +44,29 @@ data class CellData (
val rssi: Int? = 0,
val rsrq: Double? = 0.0,
val rsrp: Double? = 0.0,
val estimatedDownBandwidth: Int? = 0,
val estimatedUpBandwidth: Int? = 0,
var estimatedDownBandwidth: Int? = 0,
var estimatedUpBandwidth: Int? = 0,
)

class CellDataViewModel : ViewModel(), DataViewModelInterface {

private val _coreConnected: MutableList<CellData> = Collections.synchronizedList(mutableListOf<CellData>())
private val _coreAvailable: MutableList<CellData> = Collections.synchronizedList(mutableListOf<CellData>())
private val _coreCA: MutableList<CellData> = Collections.synchronizedList(mutableListOf<CellData>())

private val _connectedCellDataList = MutableLiveData<List<CellData>>()
val connectedCellDataList: LiveData<List<CellData>> get() = _connectedCellDataList

private val _availableCellDataList = MutableLiveData<List<CellData>>()
val availableCellDataList: LiveData<List<CellData>> get() = _availableCellDataList

private val _caCellDataList = MutableLiveData<List<CellData>>()
val caCellDataList: LiveData<List<CellData>> get() = _availableCellDataList

init {
_connectedCellDataList.value = emptyList()
_availableCellDataList.value = emptyList()
_caCellDataList.value = emptyList()
}

/* connected */
Expand Down Expand Up @@ -91,6 +97,20 @@ class CellDataViewModel : ViewModel(), DataViewModelInterface {
return _coreAvailable.toMutableList()
}

/* Carrier Aggregation (CA) */

private fun setCACellData(newList: List<CellData>) {
_coreCA.clear()
_coreCA.addAll(newList)
DevPubUtils.dispatchToMainThread {
_caCellDataList.value = _coreCA
}
}

fun getCACells(): List<CellData> {
return _coreCA.toMutableList()
}

/* logic */

private fun checkPhonePermission(context: Context): Boolean {
Expand Down Expand Up @@ -142,6 +162,7 @@ class CellDataViewModel : ViewModel(), DataViewModelInterface {

val conList: MutableList<CellData> = mutableListOf<CellData>()
val avaList: MutableList<CellData> = mutableListOf<CellData>()
val caList: MutableList<CellData> = mutableListOf<CellData>()

currentCells.forEach { cell ->
if (cell !is CellLte && cell !is CellNr) {
Expand All @@ -162,8 +183,8 @@ class CellDataViewModel : ViewModel(), DataViewModelInterface {
rssi = lteCell.signal.rssi,
rsrp = lteCell.signal.rsrp,
rsrq = lteCell.signal.rsrq,
estimatedDownBandwidth = if (cell.connectionStatus != NoneConnection()) down else null,
estimatedUpBandwidth = if (cell.connectionStatus != NoneConnection()) up else null,
estimatedDownBandwidth = null,
estimatedUpBandwidth = null,
)
}
is CellNr -> {
Expand All @@ -179,19 +200,34 @@ class CellDataViewModel : ViewModel(), DataViewModelInterface {
rsrp = nrCell.signal.ssRsrp?.toDouble(),
rsrq = nrCell.signal.ssRsrq?.toDouble(),
frequency = nrCell.band!!.downlinkFrequency,
estimatedDownBandwidth = if (cell.connectionStatus != NoneConnection()) down else null,
estimatedUpBandwidth = if (cell.connectionStatus != NoneConnection()) up else null,
estimatedDownBandwidth = null,
estimatedUpBandwidth = null,
)
}
}
if (cell.connectionStatus != NoneConnection()) {
if (cell.connectionStatus is PrimaryConnection) {
cellData.estimatedUpBandwidth = up
cellData.estimatedDownBandwidth = down
conList.add(cellData)
caList.add(cellData)
} else {
avaList.add(cellData)
}
}
/* If there is one connected cell, take the best-RSRQ cell
as an "estimate" to the potential Carrier Aggregation cells
*/
if (caList.size == 1 && avaList.size >= 1) {
val lowestRsrqCell = avaList
.filter { it.rsrq != null }
.maxByOrNull { it.rsrq!! }
if (lowestRsrqCell != null) {
caList.add(lowestRsrqCell)
}
}
setConnectedCellData(conList)
setAvailableCellData(avaList)
setCACellData(caList)
}

companion object {
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
agp = "8.3.2"
agp = "8.7.1"
kotlin = "1.9.22"
coreKtx = "1.10.1"
activityCompose = "1.8.2"
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Apr 04 23:44:22 CEST 2024
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
3 changes: 3 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ pluginManagement {
gradlePluginPortal()
}
}
plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
Expand Down