Skip to content

Commit

Permalink
feat: implement AdminMessage session_passkey handling
Browse files Browse the repository at this point in the history
  • Loading branch information
andrekir committed Sep 4, 2024
1 parent 3182fad commit 716b75c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions app/src/main/java/com/geeksville/mesh/service/MeshService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ class MeshService : Service(), Logging {

private val configTotal by lazy { ConfigProtos.Config.getDescriptor().fields.size }
private val moduleTotal by lazy { ModuleConfigProtos.ModuleConfig.getDescriptor().fields.size }
private var sessionPasskey: ByteString = ByteString.EMPTY

private var localConfig: LocalConfig = LocalConfig.getDefaultInstance()
private var moduleConfig: LocalModuleConfig = LocalModuleConfig.getDefaultInstance()
Expand Down Expand Up @@ -559,6 +560,7 @@ class MeshService : Service(), Logging {
portnumValue = Portnums.PortNum.ADMIN_APP_VALUE
payload = AdminProtos.AdminMessage.newBuilder().also {
initFn(it)
it.sessionPasskey = sessionPasskey
}.build().toByteString()
}

Expand Down Expand Up @@ -768,7 +770,6 @@ class MeshService : Service(), Logging {
}

private fun handleReceivedAdmin(fromNodeNum: Int, a: AdminProtos.AdminMessage) {
// For the time being we only care about admin messages from our local node
if (fromNodeNum == myNodeNum) {
when (a.payloadVariantCase) {
AdminProtos.AdminMessage.PayloadVariantCase.GET_CONFIG_RESPONSE -> {
Expand All @@ -792,6 +793,9 @@ class MeshService : Service(), Logging {
warn("No special processing needed for ${a.payloadVariantCase}")

}
} else {
debug("Admin: Received session_passkey from $fromNodeNum")
sessionPasskey = a.sessionPasskey
}
}

Expand Down Expand Up @@ -1373,7 +1377,6 @@ class MeshService : Service(), Logging {
radioConfigRepository.setStatusMessage("Nodes (${newNodes.size} / 100)")
}


private var rawMyNodeInfo: MeshProtos.MyNodeInfo? = null
private var rawDeviceMetadata: MeshProtos.DeviceMetadata? = null

Expand Down

0 comments on commit 716b75c

Please sign in to comment.