mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
new play store release
This commit is contained in:
parent
c568b04354
commit
aab062b06f
6 changed files with 67 additions and 60 deletions
|
|
@ -47,5 +47,5 @@ object NodeDB {
|
|||
val nodes = mutableMapOf(* testNodes.map { it.user!!.id to it }.toTypedArray())
|
||||
|
||||
/// Could be null if we haven't received our node DB yet
|
||||
val ourNodeInfo get() = nodes[myId.value!!]
|
||||
val ourNodeInfo get() = nodes[myId.value]
|
||||
}
|
||||
|
|
@ -532,6 +532,51 @@ class MeshService : Service(), Logging {
|
|||
}
|
||||
}
|
||||
|
||||
/// We are reconnecting to a radio, redownload the full state. This operation might take hundreds of milliseconds
|
||||
private fun reinitFromRadio() {
|
||||
// Read the MyNodeInfo object
|
||||
val myInfo = MeshProtos.MyNodeInfo.parseFrom(
|
||||
connectedRadio.readMyNode()
|
||||
)
|
||||
|
||||
val mynodeinfo = MyNodeInfo(myInfo.myNodeNum, myInfo.hasGps)
|
||||
myNodeInfo = mynodeinfo
|
||||
|
||||
// Ask for the current node DB
|
||||
connectedRadio.restartNodeInfo()
|
||||
|
||||
// read all the infos until we get back null
|
||||
var infoBytes = connectedRadio.readNodeInfo()
|
||||
while (infoBytes != null) {
|
||||
val info =
|
||||
MeshProtos.NodeInfo.parseFrom(infoBytes)
|
||||
debug("Received initial nodeinfo $info")
|
||||
|
||||
// Just replace/add any entry
|
||||
updateNodeInfo(info.num) {
|
||||
if (info.hasUser())
|
||||
it.user =
|
||||
MeshUser(
|
||||
info.user.id,
|
||||
info.user.longName,
|
||||
info.user.shortName
|
||||
)
|
||||
|
||||
if (info.hasPosition())
|
||||
it.position = Position(
|
||||
info.position.latitude,
|
||||
info.position.longitude,
|
||||
info.position.altitude
|
||||
)
|
||||
|
||||
it.lastSeen = info.lastSeen
|
||||
}
|
||||
|
||||
// advance to next
|
||||
infoBytes = connectedRadio.readNodeInfo()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Called when we gain/lose connection to our radio
|
||||
private fun onConnectionChanged(c: Boolean) {
|
||||
|
|
@ -540,53 +585,10 @@ class MeshService : Service(), Logging {
|
|||
if (c) {
|
||||
// Do our startup init
|
||||
try {
|
||||
// FIXME - don't do this until after we see that the radio is connected to the phone
|
||||
//val sim = SimRadio(this@MeshService)
|
||||
//sim.start() // Fake up our node id info and some past packets from other nodes
|
||||
|
||||
val myInfo = MeshProtos.MyNodeInfo.parseFrom(
|
||||
connectedRadio.readMyNode()
|
||||
)
|
||||
|
||||
val mynodeinfo = MyNodeInfo(myInfo.myNodeNum, myInfo.hasGps)
|
||||
myNodeInfo = mynodeinfo
|
||||
|
||||
// Ask for the current node DB
|
||||
connectedRadio.restartNodeInfo()
|
||||
|
||||
// read all the infos until we get back null
|
||||
var infoBytes = connectedRadio.readNodeInfo()
|
||||
while (infoBytes != null) {
|
||||
val info =
|
||||
MeshProtos.NodeInfo.parseFrom(infoBytes)
|
||||
debug("Received initial nodeinfo $info")
|
||||
|
||||
// Just replace/add any entry
|
||||
updateNodeInfo(info.num) {
|
||||
if (info.hasUser())
|
||||
it.user =
|
||||
MeshUser(
|
||||
info.user.id,
|
||||
info.user.longName,
|
||||
info.user.shortName
|
||||
)
|
||||
|
||||
if (info.hasPosition())
|
||||
it.position = Position(
|
||||
info.position.latitude,
|
||||
info.position.longitude,
|
||||
info.position.altitude
|
||||
)
|
||||
|
||||
it.lastSeen = info.lastSeen
|
||||
}
|
||||
|
||||
// advance to next
|
||||
infoBytes = connectedRadio.readNodeInfo()
|
||||
}
|
||||
reinitFromRadio()
|
||||
|
||||
// we don't ask for GPS locations from android if our device has a built in GPS
|
||||
if (!mynodeinfo.hasGPS)
|
||||
if (!myNodeInfo!!.hasGPS)
|
||||
startLocationRequests()
|
||||
else
|
||||
debug("Our radio has a built in GPS, so not reading GPS in phone")
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ object SettingsLog : Logging
|
|||
|
||||
@Composable
|
||||
fun SettingsContent() {
|
||||
val typography = MaterialTheme.typography()
|
||||
//val typography = MaterialTheme.typography()
|
||||
|
||||
val context = ambient(ContextAmbient)
|
||||
Column(modifier = LayoutSize.Fill + LayoutPadding(16.dp)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue