kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
Merge branch 'dev1.2' of https://github.com/geeksville/Meshtastic-Android into dev1.2
# Conflicts: # app/src/main/java/com/geeksville/mesh/service/MeshService.ktpull/276/head^2
commit
d3556ea9f9
|
@ -182,7 +182,7 @@ class MeshService : Service(), Logging {
|
||||||
val myInfo = localNodeInfo
|
val myInfo = localNodeInfo
|
||||||
val lastSendMsec = (myInfo?.position?.time ?: 0) * 1000L
|
val lastSendMsec = (myInfo?.position?.time ?: 0) * 1000L
|
||||||
val now = System.currentTimeMillis()
|
val now = System.currentTimeMillis()
|
||||||
if(now - lastSendMsec < locationIntervalMsec)
|
if (now - lastSendMsec < locationIntervalMsec)
|
||||||
debug("Not sending position - the local node has sent one recently...")
|
debug("Not sending position - the local node has sent one recently...")
|
||||||
else {
|
else {
|
||||||
sendPosition(lat, lon, alt, destNum, wantResponse)
|
sendPosition(lat, lon, alt, destNum, wantResponse)
|
||||||
|
@ -488,13 +488,13 @@ class MeshService : Service(), Logging {
|
||||||
/**
|
/**
|
||||||
* Return the nodeinfo for the local node, or null if not found
|
* Return the nodeinfo for the local node, or null if not found
|
||||||
*/
|
*/
|
||||||
private val localNodeInfo get(): NodeInfo? =
|
private val localNodeInfo
|
||||||
try {
|
get(): NodeInfo? =
|
||||||
toNodeInfo(myNodeNum)
|
try {
|
||||||
}
|
toNodeInfo(myNodeNum)
|
||||||
catch(ex: Exception) {
|
} catch (ex: Exception) {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Map a nodenum to the nodeid string, or return null if not present
|
/** Map a nodenum to the nodeid string, or return null if not present
|
||||||
If we have a NodeInfo for this ID we prefer to return the string ID inside the user record.
|
If we have a NodeInfo for this ID we prefer to return the string ID inside the user record.
|
||||||
|
@ -542,7 +542,11 @@ class MeshService : Service(), Logging {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A helper function that makes it easy to update node info objects
|
/// A helper function that makes it easy to update node info objects
|
||||||
private fun updateNodeInfo(nodeNum: Int, withBroadcast: Boolean = true, updateFn: (NodeInfo) -> Unit) {
|
private fun updateNodeInfo(
|
||||||
|
nodeNum: Int,
|
||||||
|
withBroadcast: Boolean = true,
|
||||||
|
updateFn: (NodeInfo) -> Unit
|
||||||
|
) {
|
||||||
val info = getOrCreateNodeInfo(nodeNum)
|
val info = getOrCreateNodeInfo(nodeNum)
|
||||||
updateFn(info)
|
updateFn(info)
|
||||||
|
|
||||||
|
@ -552,7 +556,7 @@ class MeshService : Service(), Logging {
|
||||||
nodeDBbyID[userId] = info
|
nodeDBbyID[userId] = info
|
||||||
|
|
||||||
// parcelable is busted
|
// parcelable is busted
|
||||||
if(withBroadcast)
|
if (withBroadcast)
|
||||||
serviceBroadcasts.broadcastNodeChange(info)
|
serviceBroadcasts.broadcastNodeChange(info)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,7 +765,7 @@ class MeshService : Service(), Logging {
|
||||||
Portnums.PortNum.POSITION_APP_VALUE -> {
|
Portnums.PortNum.POSITION_APP_VALUE -> {
|
||||||
var u = MeshProtos.Position.parseFrom(data.payload)
|
var u = MeshProtos.Position.parseFrom(data.payload)
|
||||||
// position updates from mesh usually don't include times. So promote rx time
|
// position updates from mesh usually don't include times. So promote rx time
|
||||||
if(u.time == 0 && packet.rxTime != 0)
|
if (u.time == 0 && packet.rxTime != 0)
|
||||||
u = u.toBuilder().setTime(packet.rxTime).build()
|
u = u.toBuilder().setTime(packet.rxTime).build()
|
||||||
debug("position_app ${packet.from} ${u.toOneLineString()}")
|
debug("position_app ${packet.from} ${u.toOneLineString()}")
|
||||||
handleReceivedPosition(packet.from, u, dataPacket.time)
|
handleReceivedPosition(packet.from, u, dataPacket.time)
|
||||||
|
|
Ładowanie…
Reference in New Issue