Network Settings
On the RPI, this screen uses the Pi4j library NetworkInfo utility class to show the current IP address to assist with SSH-ing into the device.
Someday, I hope to make a NetworkManager DBus Client here to expose all the same network options as you’d see on a desktop Linux machine.
Implementation
The implementation of this screen shows how succinct the Widget Framework is for putting a screen together:
@ScreenDoc(
screenName = "NetworkInfoScreen",
description = "Shows the current IP Address of the Rpi so the user can SSH in"
)
@ScreenDoc.AllowsGoBack
@AutoDiscover
class NetworkInfoScreen @Inject constructor(
private val navigationNodeTraverser: NavigationNodeTraverser,
private val configurationStorage: ConfigurationStorage
) : NavigationNode<Nothing> {
override val thisClass: Class<out NavigationNode<Nothing>>
get() = NetworkInfoScreen::class.java
override fun provideMainContent(): @Composable (incomingResult: Navigator.IncomingResult?) -> Unit = {
val ipAddress = remember { mutableStateOf("") }
LaunchedEffect(Unit) {
if (configurationStorage.config[E39Config.CarPlatformConfigSpec._isPi]) {
ipAddress.value = NetworkInfo.getIPAddresses()[0]
}
}
Column(Modifier.fillMaxSize()) {
BmwSingleLineHeader("Network Info")
FullScreenMenu.OneColumn(
listOf(
TextMenuItem(
title = "IP Address: ${ipAddress.value}",
isSelectable = false,
onClicked = {}
),
TextMenuItem(
title = "Go Back",
onClicked = {
navigationNodeTraverser.goBack()
}
),
)
)
}
}
}