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

pull/255/head
Kevin Hester 2021-03-02 11:30:40 +08:00
commit b86e11a8c2
3 zmienionych plików z 15 dodań i 5 usunięć

Wyświetl plik

@ -121,7 +121,7 @@
android:name="com.geeksville.mesh.MainActivity" android:name="com.geeksville.mesh.MainActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:windowSoftInputMode="stateAlwaysHidden|adjustPan" android:windowSoftInputMode="stateAlwaysHidden"
android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar">
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />

Wyświetl plik

@ -26,7 +26,8 @@ data class DataPacket(
var from: String? = ID_LOCAL, // a nodeID string, or ID_LOCAL for localhost var from: String? = ID_LOCAL, // a nodeID string, or ID_LOCAL for localhost
var time: Long = System.currentTimeMillis(), // msecs since 1970 var time: Long = System.currentTimeMillis(), // msecs since 1970
var id: Int = 0, // 0 means unassigned var id: Int = 0, // 0 means unassigned
var status: MessageStatus? = MessageStatus.UNKNOWN var status: MessageStatus? = MessageStatus.UNKNOWN,
var hopLimit: Int = 0
) : Parcelable { ) : Parcelable {
/** /**
@ -60,7 +61,8 @@ data class DataPacket(
parcel.readString(), parcel.readString(),
parcel.readLong(), parcel.readLong(),
parcel.readInt(), parcel.readInt(),
parcel.readParcelable(MessageStatus::class.java.classLoader) parcel.readParcelable(MessageStatus::class.java.classLoader),
parcel.readInt()
) { ) {
} }
@ -77,6 +79,7 @@ data class DataPacket(
if (dataType != other.dataType) return false if (dataType != other.dataType) return false
if (!bytes!!.contentEquals(other.bytes!!)) return false if (!bytes!!.contentEquals(other.bytes!!)) return false
if (status != other.status) return false if (status != other.status) return false
if (hopLimit != other.hopLimit) return false
return true return true
} }
@ -89,6 +92,7 @@ data class DataPacket(
result = 31 * result + dataType result = 31 * result + dataType
result = 31 * result + bytes!!.contentHashCode() result = 31 * result + bytes!!.contentHashCode()
result = 31 * result + status.hashCode() result = 31 * result + status.hashCode()
result = 31 * result + hopLimit
return result return result
} }
@ -100,6 +104,7 @@ data class DataPacket(
parcel.writeLong(time) parcel.writeLong(time)
parcel.writeInt(id) parcel.writeInt(id)
parcel.writeParcelable(status, flags) parcel.writeParcelable(status, flags)
parcel.writeInt(hopLimit)
} }
override fun describeContents(): Int { override fun describeContents(): Int {
@ -115,6 +120,7 @@ data class DataPacket(
time = parcel.readLong() time = parcel.readLong()
id = parcel.readInt() id = parcel.readInt()
status = parcel.readParcelable(MessageStatus::class.java.classLoader) status = parcel.readParcelable(MessageStatus::class.java.classLoader)
hopLimit = parcel.readInt()
} }
companion object CREATOR : Parcelable.Creator<DataPacket> { companion object CREATOR : Parcelable.Creator<DataPacket> {

Wyświetl plik

@ -540,10 +540,12 @@ class MeshService : Service(), Logging {
destId: String, destId: String,
wantAck: Boolean = false, wantAck: Boolean = false,
id: Int = 0, id: Int = 0,
hopLimit: Int = 0,
initFn: MeshProtos.SubPacket.Builder.() -> Unit initFn: MeshProtos.SubPacket.Builder.() -> Unit
): MeshPacket = newMeshPacketTo(destId).apply { ): MeshPacket = newMeshPacketTo(destId).apply {
this.wantAck = wantAck this.wantAck = wantAck
this.id = id this.id = id
this.hopLimit = hopLimit
decoded = MeshProtos.SubPacket.newBuilder().also { decoded = MeshProtos.SubPacket.newBuilder().also {
initFn(it) initFn(it)
}.build() }.build()
@ -564,6 +566,7 @@ class MeshService : Service(), Logging {
val bytes = data.payload.toByteArray() val bytes = data.payload.toByteArray()
val fromId = toNodeID(packet.from) val fromId = toNodeID(packet.from)
val toId = toNodeID(packet.to) val toId = toNodeID(packet.to)
val hopLimit = packet.hopLimit
// If the rxTime was not set by the device (because device software was old), guess at a time // 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()
@ -584,7 +587,8 @@ class MeshService : Service(), Logging {
time = rxTime * 1000L, time = rxTime * 1000L,
id = packet.id, id = packet.id,
dataType = data.portnumValue, dataType = data.portnumValue,
bytes = bytes bytes = bytes,
hopLimit = hopLimit
) )
} }
} }
@ -598,7 +602,7 @@ class MeshService : Service(), Logging {
}.build() }.build()
private fun toMeshPacket(p: DataPacket): MeshPacket { private fun toMeshPacket(p: DataPacket): MeshPacket {
return buildMeshPacket(p.to!!, id = p.id, wantAck = true) { return buildMeshPacket(p.to!!, id = p.id, wantAck = true, hopLimit = p.hopLimit) {
data = makeData(p.dataType, ByteString.copyFrom(p.bytes)) data = makeData(p.dataType, ByteString.copyFrom(p.bytes))
} }
} }