Merge remote-tracking branch 'root/master' into dev

pull/129/head
geeksville 2020-08-11 19:33:22 -07:00
commit 72128d1e39
6 zmienionych plików z 62 dodań i 15 usunięć

Wyświetl plik

@ -45,11 +45,16 @@ that environment.
## Analytics setup
* analytics are included but can be disabled by the user on the settings screen
* on dev devices "adb shell setprop debug.firebase.analytics.app com.geeksville.mesh"
* on dev devices
```shell
adb shell setprop debug.firebase.analytics.app com.geeksville.mesh
adb shell setprop log.tag.FirebaseCrashlytics DEBUG
```
for verbose logging:
```aidl
```shell
adb shell setprop log.tag.FA VERBOSE
```

Wyświetl plik

@ -858,7 +858,7 @@ class MainActivity : AppCompatActivity(), Logging,
return true
}
R.id.connectStatusImage -> {
Toast.makeText(this, item.title, Toast.LENGTH_SHORT).show()
Toast.makeText(applicationContext, item.title, Toast.LENGTH_SHORT).show()
return true
}
else -> super.onOptionsItemSelected(item)
@ -869,7 +869,7 @@ class MainActivity : AppCompatActivity(), Logging,
try {
val packageInfo: PackageInfo = packageManager.getPackageInfo(packageName, 0)
val versionName = packageInfo.versionName
Toast.makeText(this, versionName, Toast.LENGTH_LONG).show()
Toast.makeText(applicationContext, versionName, Toast.LENGTH_LONG).show()
} catch (e: PackageManager.NameNotFoundException) {
errormsg("Can not find the version: ${e.message}")
}

Wyświetl plik

@ -20,7 +20,7 @@ data class Channel(
// Note: this string _SHOULD NOT BE LOCALIZED_ because it directly hashes to values used on the device for the default channel name.
val defaultChannelName = "Default"
// These bytes must math the well known and not secret bytes used the default channel AES128 key device code
// These bytes must match the well known and not secret bytes used the default channel AES128 key device code
val channelDefaultKey = byteArrayOfInts(
0xd4, 0xf1, 0xbb, 0x3a, 0x20, 0x29, 0x07, 0x59,
0xf0, 0xbc, 0xff, 0xab, 0xcf, 0x4e, 0x69, 0xbf
@ -32,7 +32,7 @@ data class Channel(
.setModemConfig(MeshProtos.ChannelSettings.ModemConfig.Bw125Cr45Sf128).build()
)
const val prefix = "https://www.meshtastic.org/c/"
const val prefix = "https://www.meshtastic.org/c/#"
private const val base64Flags = Base64.URL_SAFE + Base64.NO_WRAP

Wyświetl plik

@ -866,9 +866,10 @@ class MeshService : Service(), Logging {
}
/// Update our DB of users based on someone sending out a Position subpacket
private fun handleReceivedPosition(fromNum: Int, p: MeshProtos.Position) {
private fun handleReceivedPosition(fromNum: Int, p: MeshProtos.Position, defaultTime: Int = Position.currentTime()) {
updateNodeInfo(fromNum) {
it.position = Position(p, it.position?.time ?: 0)
it.position = Position(p)
updateNodeInfoTime(it, defaultTime)
}
}
@ -942,22 +943,22 @@ class MeshService : Service(), Logging {
val p = packet.decoded
// If the rxTime was not set by the device (because device software was old), guess at a time
val rxTime = if (packet.rxTime == 0) packet.rxTime else currentSecond()
val rxTime = if (packet.rxTime != 0) packet.rxTime else currentSecond()
// Update last seen for the node that sent the packet, but also for _our node_ because anytime a packet passes
// through our node on the way to the phone that means that local node is also alive in the mesh
updateNodeInfo(fromNum) {
// Update our last seen based on any valid timestamps. If the device didn't provide a timestamp make one
val lastSeen = rxTime
it.position = it.position?.copy(time = lastSeen)
}
updateNodeInfo(myNodeNum) {
it.position = it.position?.copy(time = currentSecond())
}
if (p.hasPosition())
handleReceivedPosition(fromNum, p.position)
handleReceivedPosition(fromNum, p.position, rxTime)
else
updateNodeInfo(fromNum) {
// Update our last seen based on any valid timestamps. If the device didn't provide a timestamp make one
updateNodeInfoTime(it, rxTime)
}
if (p.hasData())
handleReceivedData(packet)
@ -1620,3 +1621,8 @@ class MeshService : Service(), Logging {
}
}
}
public fun updateNodeInfoTime(it: NodeInfo, rxTime: Int) {
if (it.position?.time == null || it.position?.time!! < rxTime)
it.position = it.position?.copy(time = rxTime)
}

Wyświetl plik

@ -14,5 +14,10 @@ class PositionTest {
Assert.assertEquals(Position.degD(Position.degI(-89.0)), -89.0, 0.01)
}
@Test
fun givenPositionCreatedWithoutTime_thenTimeIsSet() {
val position = Position(37.1, 121.1, 35)
Assert.assertTrue(position.time != 0)
}
}

Wyświetl plik

@ -0,0 +1,31 @@
package com.geeksville.mesh.service
import com.geeksville.mesh.MeshUser
import com.geeksville.mesh.NodeInfo
import com.geeksville.mesh.Position
import org.junit.Assert
import org.junit.Test
class MeshServiceTest {
val nodeInfo = NodeInfo(4, MeshUser("+one", "User One", "U1"), Position(37.1, 121.1, 35, 10))
@Test
fun givenNodeInfo_whenUpdatingWithNewTime_thenPositionTimeIsUpdated() {
val newerTime = 20
updateNodeInfoTime(nodeInfo, newerTime)
Assert.assertEquals(newerTime, nodeInfo.position?.time)
}
@Test
fun givenNodeInfo_whenUpdatingWithOldTime_thenPositionTimeIsNotUpdated() {
val olderTime = 5
val timeBeforeTryingToUpdate = nodeInfo.position?.time
updateNodeInfoTime(nodeInfo, olderTime)
Assert.assertEquals(timeBeforeTryingToUpdate, nodeInfo.position?.time)
}
}