Repository navigation
Wire interface mode into reticulum-kt interfaces (Kotlin backend) #1188
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1225120
Wire interface mode into reticulum-kt interfaces on the Kotlin backend
torlando-tech 8e1b1ca
test(rns-backend-kt): cover RNode, BLE, TCPServer mode wiring (PR #11…
torlando-tech c8dbb29
fix(rns-backend-kt): apply saved mode edits to running interfaces (PR…
torlando-tech e8975f5
fix(rns-backend-kt): guard async interface start against supersede (P…
torlando-tech 776eb5f
fix(rns-backend-kt): detach superseded radio interface on rejection (…
torlando-tech 73fa86a
feat(rns-backend-kt): wire INTERNAL mode (reticulum-kt v0.0.24)
torlando-tech File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
rns-backend-kt/src/main/kotlin/network/columba/app/rns/backend/kt/InterfaceModeMapper.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| package network.columba.app.rns.backend.kt | ||
|
|
||
| import android.util.Log | ||
| import network.columba.app.rns.api.model.InterfaceMode as ColumbaMode | ||
| import network.reticulum.common.InterfaceMode as ReticulumMode | ||
|
|
||
| private const val TAG = "InterfaceModeMapper" | ||
|
|
||
| /** | ||
| * Maps a Columba interface-mode string to the reticulum-kt [ReticulumMode] that the | ||
| * constructed interface object should report. | ||
| * | ||
| * Returns `null` for modes that the pinned reticulum-kt enum cannot faithfully | ||
| * represent. A `null` result means "leave the interface at its declared default | ||
| * and log a warning" - the caller must NOT coerce such a mode onto the object, | ||
| * because coercing would silently change runtime behavior to unverified semantics | ||
| * (see issue #1169 and its dependency on reticulum-kt #91). | ||
| * | ||
| * INTERNAL is currently unrepresentable: the pinned reticulum-kt [ReticulumMode] | ||
| * has no INTERNAL value, and its stray [ReticulumMode.POINT_TO_POINT] corresponds | ||
| * to no RNS config mode string. Per #1169 it must stay a no-op until #91 | ||
| * reconciles the enum with the Python reference vocabulary - mapping it to | ||
| * POINT_TO_POINT (or FULL) would change announce re-broadcast behavior without | ||
| * conformance proof. | ||
| */ | ||
| internal fun mapInterfaceMode(configName: String, modeString: String): ReticulumMode? { | ||
| val mapped = | ||
| when (ColumbaMode.fromValue(modeString)) { | ||
| ColumbaMode.FULL -> ReticulumMode.FULL | ||
| ColumbaMode.GATEWAY -> ReticulumMode.GATEWAY | ||
| ColumbaMode.ACCESS_POINT -> ReticulumMode.ACCESS_POINT | ||
| ColumbaMode.ROAMING -> ReticulumMode.ROAMING | ||
| ColumbaMode.BOUNDARY -> ReticulumMode.BOUNDARY | ||
| ColumbaMode.INTERNAL -> null // unrepresentable until reticulum-kt #91 | ||
| null -> { | ||
| Log.w(TAG, "Interface $configName: unknown mode '$modeString', leaving default") | ||
| null | ||
| } | ||
| } | ||
| if (mapped == null && ColumbaMode.fromValue(modeString) == ColumbaMode.INTERNAL) { | ||
| Log.w( | ||
| TAG, | ||
| "Interface $configName: mode '$modeString' not supported by pinned reticulum-kt " + | ||
| "(no INTERNAL in InterfaceMode, pending #91); leaving interface at default mode", | ||
| ) | ||
| } | ||
| return mapped | ||
| } | ||
|
|
||
| /** | ||
| * Returns [iface] with its [network.reticulum.interfaces.Interface.modeOverride] set to the | ||
| * mapped reticulum-kt mode for [mode]. When [mapInterfaceMode] returns `null` | ||
| * (INTERNAL on the pinned enum, or an unknown string) the interface is left at its | ||
| * declared default - the mode is intentionally NOT coerced. | ||
| * | ||
| * A generic extension so every interface-construction site applies the mode as a | ||
| * single `.withMode(config.name, config.mode)` call, keeping | ||
| * [NativeInterfaceFactory.createInterface] within detekt's length/complexity | ||
| * budgets. [name] and [mode] are taken explicitly (not the config object) because | ||
| * [network.columba.app.rns.api.model.InterfaceConfig] declares `mode` only on its | ||
| * concrete subclasses, not the base type. | ||
| */ | ||
| internal fun <T : network.reticulum.interfaces.Interface> T.withMode(name: String, mode: String): T = | ||
| apply { | ||
| mapInterfaceMode(name, mode)?.let { modeOverride = it } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.