mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor(model): Make DataPacket fully mutable and fix Parcel reading (#4431)
Signed-off-by: James Rich <2199651+jamesarich@users.noreply.github.com>
This commit is contained in:
parent
08184aae2d
commit
9dbc8b7fbf
3 changed files with 72 additions and 7 deletions
|
|
@ -48,9 +48,9 @@ enum class MessageStatus : Parcelable {
|
|||
@Serializable
|
||||
data class DataPacket(
|
||||
var to: String? = ID_BROADCAST, // a nodeID string, or ID_BROADCAST for broadcast
|
||||
val bytes: ByteArray?,
|
||||
var bytes: ByteArray?,
|
||||
// A port number for this packet (formerly called DataType, see portnums.proto for new usage instructions)
|
||||
val dataType: Int,
|
||||
var dataType: Int,
|
||||
var from: String? = ID_LOCAL, // a nodeID string, or ID_LOCAL for localhost
|
||||
var time: Long = System.currentTimeMillis(), // msecs since 1970
|
||||
var id: Int = 0, // 0 means unassigned
|
||||
|
|
@ -229,13 +229,11 @@ data class DataPacket(
|
|||
|
||||
override fun describeContents(): Int = 0
|
||||
|
||||
// Update our object from our parcel (used for inout parameters
|
||||
/** Update our object from our parcel (used for inout parameters) */
|
||||
fun readFromParcel(parcel: Parcel) {
|
||||
to = parcel.readString()
|
||||
// parcel.createByteArray() // Wait, this doesn't update bytes! bytes is a VAL.
|
||||
// Actually this method is a bit broken because it can't update val fields.
|
||||
// But it seems only to be used for inout parameters in some places.
|
||||
// I won't touch it unless I have to.
|
||||
bytes = parcel.createByteArray()
|
||||
dataType = parcel.readInt()
|
||||
from = parcel.readString()
|
||||
time = parcel.readLong()
|
||||
id = parcel.readInt()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue