mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Traceroute map position snapshots (#4035)
Signed-off-by: Jord <650645+DivineOmega@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
03fd2bf9ba
commit
9833795864
17 changed files with 1195 additions and 44 deletions
|
|
@ -31,6 +31,7 @@ import org.meshtastic.core.database.dao.MeshLogDao
|
|||
import org.meshtastic.core.database.dao.NodeInfoDao
|
||||
import org.meshtastic.core.database.dao.PacketDao
|
||||
import org.meshtastic.core.database.dao.QuickChatActionDao
|
||||
import org.meshtastic.core.database.dao.TracerouteNodePositionDao
|
||||
import org.meshtastic.core.database.entity.ContactSettings
|
||||
import org.meshtastic.core.database.entity.DeviceHardwareEntity
|
||||
import org.meshtastic.core.database.entity.FirmwareReleaseEntity
|
||||
|
|
@ -41,6 +42,7 @@ import org.meshtastic.core.database.entity.NodeEntity
|
|||
import org.meshtastic.core.database.entity.Packet
|
||||
import org.meshtastic.core.database.entity.QuickChatAction
|
||||
import org.meshtastic.core.database.entity.ReactionEntity
|
||||
import org.meshtastic.core.database.entity.TracerouteNodePositionEntity
|
||||
|
||||
@Database(
|
||||
entities =
|
||||
|
|
@ -55,6 +57,7 @@ import org.meshtastic.core.database.entity.ReactionEntity
|
|||
MetadataEntity::class,
|
||||
DeviceHardwareEntity::class,
|
||||
FirmwareReleaseEntity::class,
|
||||
TracerouteNodePositionEntity::class,
|
||||
],
|
||||
autoMigrations =
|
||||
[
|
||||
|
|
@ -79,8 +82,9 @@ import org.meshtastic.core.database.entity.ReactionEntity
|
|||
AutoMigration(from = 21, to = 22),
|
||||
AutoMigration(from = 22, to = 23),
|
||||
AutoMigration(from = 23, to = 24),
|
||||
AutoMigration(from = 24, to = 25),
|
||||
],
|
||||
version = 24,
|
||||
version = 25,
|
||||
exportSchema = true,
|
||||
)
|
||||
@TypeConverters(Converters::class)
|
||||
|
|
@ -97,6 +101,8 @@ abstract class MeshtasticDatabase : RoomDatabase() {
|
|||
|
||||
abstract fun firmwareReleaseDao(): FirmwareReleaseDao
|
||||
|
||||
abstract fun tracerouteNodePositionDao(): TracerouteNodePositionDao
|
||||
|
||||
companion object {
|
||||
fun getDatabase(context: Context): MeshtasticDatabase =
|
||||
Room.databaseBuilder(context.applicationContext, MeshtasticDatabase::class.java, "meshtastic_database")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright (c) 2025 Meshtastic LLC
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.meshtastic.core.database.dao
|
||||
|
||||
import androidx.room.Dao
|
||||
import androidx.room.Insert
|
||||
import androidx.room.OnConflictStrategy
|
||||
import androidx.room.Query
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import org.meshtastic.core.database.entity.TracerouteNodePositionEntity
|
||||
|
||||
@Dao
|
||||
interface TracerouteNodePositionDao {
|
||||
|
||||
@Query("SELECT * FROM traceroute_node_position WHERE log_uuid = :logUuid")
|
||||
fun getByLogUuid(logUuid: String): Flow<List<TracerouteNodePositionEntity>>
|
||||
|
||||
@Query("DELETE FROM traceroute_node_position WHERE log_uuid = :logUuid")
|
||||
suspend fun deleteByLogUuid(logUuid: String)
|
||||
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
suspend fun insertAll(entities: List<TracerouteNodePositionEntity>)
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@ import org.meshtastic.core.database.dao.MeshLogDao
|
|||
import org.meshtastic.core.database.dao.NodeInfoDao
|
||||
import org.meshtastic.core.database.dao.PacketDao
|
||||
import org.meshtastic.core.database.dao.QuickChatActionDao
|
||||
import org.meshtastic.core.database.dao.TracerouteNodePositionDao
|
||||
import javax.inject.Singleton
|
||||
|
||||
@InstallIn(SingletonComponent::class)
|
||||
|
|
@ -51,4 +52,8 @@ class DatabaseModule {
|
|||
|
||||
@Provides
|
||||
fun provideFirmwareReleaseDao(database: MeshtasticDatabase): FirmwareReleaseDao = database.firmwareReleaseDao()
|
||||
|
||||
@Provides
|
||||
fun provideTracerouteNodePositionDao(database: MeshtasticDatabase): TracerouteNodePositionDao =
|
||||
database.tracerouteNodePositionDao()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2025 Meshtastic LLC
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.meshtastic.core.database.entity
|
||||
|
||||
import androidx.room.ColumnInfo
|
||||
import androidx.room.Entity
|
||||
import androidx.room.ForeignKey
|
||||
import androidx.room.Index
|
||||
import org.meshtastic.proto.MeshProtos
|
||||
|
||||
@Entity(
|
||||
tableName = "traceroute_node_position",
|
||||
primaryKeys = ["log_uuid", "node_num"],
|
||||
foreignKeys =
|
||||
[
|
||||
ForeignKey(
|
||||
entity = MeshLog::class,
|
||||
parentColumns = ["uuid"],
|
||||
childColumns = ["log_uuid"],
|
||||
onDelete = ForeignKey.CASCADE,
|
||||
),
|
||||
],
|
||||
indices = [Index(value = ["log_uuid"]), Index(value = ["request_id"])],
|
||||
)
|
||||
data class TracerouteNodePositionEntity(
|
||||
@ColumnInfo(name = "log_uuid") val logUuid: String,
|
||||
@ColumnInfo(name = "request_id") val requestId: Int,
|
||||
@ColumnInfo(name = "node_num") val nodeNum: Int,
|
||||
@ColumnInfo(name = "position", typeAffinity = ColumnInfo.BLOB) val position: MeshProtos.Position,
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue