mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Save messages in CSV and fix position broadcast
This commit is contained in:
parent
b4d562d15f
commit
78a08898fe
7 changed files with 126 additions and 27 deletions
|
|
@ -9,7 +9,7 @@ import com.geeksville.mesh.database.entity.Packet
|
|||
@Dao
|
||||
interface PacketDao {
|
||||
|
||||
@Query("Select * from packet order by rowid desc limit 0,:maxItem")
|
||||
@Query("Select * from packet order by received_date desc limit 0,:maxItem")
|
||||
fun getAllPacket(maxItem: Int): LiveData<List<Packet>>
|
||||
|
||||
@Insert
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@ package com.geeksville.mesh.database.entity
|
|||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import com.geeksville.mesh.MeshProtos
|
||||
import com.geeksville.mesh.Portnums
|
||||
import com.google.protobuf.TextFormat
|
||||
import java.io.IOException
|
||||
|
||||
|
||||
@Entity(tableName = "packet")
|
||||
|
|
@ -12,6 +16,25 @@ data class Packet(@PrimaryKey val uuid: String,
|
|||
@ColumnInfo(name = "message") val raw_message: String
|
||||
) {
|
||||
|
||||
|
||||
|
||||
val proto: MeshProtos.MeshPacket?
|
||||
get() {
|
||||
if (message_type == "packet") {
|
||||
val builder = MeshProtos.MeshPacket.newBuilder()
|
||||
try {
|
||||
TextFormat.getParser().merge(raw_message, builder)
|
||||
return builder.build()
|
||||
} catch (e: IOException) {
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
val position: MeshProtos.Position?
|
||||
get() {
|
||||
return proto?.run {
|
||||
if (hasDecoded() && decoded.portnumValue == Portnums.PortNum.POSITION_APP_VALUE) {
|
||||
return MeshProtos.Position.parseFrom(decoded.payload)
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue