mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
refactor: migrate nodeDB to Room database (#717)
This commit is contained in:
parent
99d7147efe
commit
83722159be
14 changed files with 742 additions and 148 deletions
|
|
@ -1,12 +1,20 @@
|
|||
package com.geeksville.mesh
|
||||
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import kotlinx.serialization.Serializable
|
||||
import androidx.room.Entity
|
||||
import androidx.room.PrimaryKey
|
||||
import kotlinx.parcelize.Parcelize
|
||||
|
||||
/**
|
||||
* Room [Entity] and [PrimaryKey] annotations and imports can be removed when only using the API.
|
||||
* For details check the AIDL interface in [com.geeksville.mesh.IMeshService]
|
||||
*/
|
||||
|
||||
// MyNodeInfo sent via special protobuf from radio
|
||||
@Serializable
|
||||
@Parcelize
|
||||
@Entity(tableName = "MyNodeInfo")
|
||||
data class MyNodeInfo(
|
||||
@PrimaryKey(autoGenerate = false)
|
||||
val myNodeNum: Int,
|
||||
val hasGPS: Boolean,
|
||||
val model: String?,
|
||||
|
|
@ -23,52 +31,4 @@ data class MyNodeInfo(
|
|||
) : Parcelable {
|
||||
/** A human readable description of the software/hardware version */
|
||||
val firmwareString: String get() = "$model $firmwareVersion"
|
||||
|
||||
constructor(parcel: Parcel) : this(
|
||||
parcel.readInt(),
|
||||
parcel.readByte() != 0.toByte(),
|
||||
parcel.readString(),
|
||||
parcel.readString(),
|
||||
parcel.readByte() != 0.toByte(),
|
||||
parcel.readByte() != 0.toByte(),
|
||||
parcel.readLong(),
|
||||
parcel.readInt(),
|
||||
parcel.readInt(),
|
||||
parcel.readInt(),
|
||||
parcel.readByte() != 0.toByte(),
|
||||
parcel.readFloat(),
|
||||
parcel.readFloat()
|
||||
)
|
||||
|
||||
override fun writeToParcel(parcel: Parcel, flags: Int) {
|
||||
parcel.writeInt(myNodeNum)
|
||||
parcel.writeByte(if (hasGPS) 1 else 0)
|
||||
parcel.writeString(model)
|
||||
parcel.writeString(firmwareVersion)
|
||||
parcel.writeByte(if (couldUpdate) 1 else 0)
|
||||
parcel.writeByte(if (shouldUpdate) 1 else 0)
|
||||
parcel.writeLong(currentPacketId)
|
||||
parcel.writeInt(messageTimeoutMsec)
|
||||
parcel.writeInt(minAppVersion)
|
||||
parcel.writeInt(maxChannels)
|
||||
parcel.writeByte(if (hasWifi) 1 else 0)
|
||||
parcel.writeFloat(channelUtilization)
|
||||
parcel.writeFloat(airUtilTx)
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
return 0
|
||||
}
|
||||
|
||||
companion object CREATOR : Parcelable.Creator<MyNodeInfo> {
|
||||
override fun createFromParcel(parcel: Parcel): MyNodeInfo {
|
||||
return MyNodeInfo(parcel)
|
||||
}
|
||||
|
||||
override fun newArray(size: Int): Array<MyNodeInfo?> {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue