mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-04-20 22:23:37 +00:00
Add option to delete single node from nodeDB (#958)
This commit is contained in:
parent
2ebfc05200
commit
828696aca7
8 changed files with 39 additions and 0 deletions
|
|
@ -115,6 +115,9 @@ interface IMeshService {
|
|||
/// Send commitEditSettings admin packet to nodeNum
|
||||
void commitEditSettings();
|
||||
|
||||
/// delete a specific nodeNum from nodeDB
|
||||
void removeByNodenum(in int requestID, in int nodeNum);
|
||||
|
||||
/// Send position packet with wantResponse to nodeNum
|
||||
void requestPosition(in int destNum, in Position position);
|
||||
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@ interface NodeInfoDao {
|
|||
@Query("DELETE FROM NodeInfo")
|
||||
fun clearNodeInfo()
|
||||
|
||||
@Query("DELETE FROM NodeInfo WHERE num=:num")
|
||||
fun delNode(num: Int)
|
||||
|
||||
@Query("SELECT * FROM NodeInfo WHERE num=:num")
|
||||
fun getNodeInfo(num: Int): NodeInfo?
|
||||
|
||||
|
|
|
|||
|
|
@ -60,6 +60,9 @@ class NodeDB @Inject constructor(
|
|||
|
||||
fun myNodeInfoFlow(): Flow<MyNodeInfo?> = nodeInfoDao.getMyNodeInfo()
|
||||
fun nodeInfoFlow(): Flow<List<NodeInfo>> = nodeInfoDao.getNodes()
|
||||
fun delNode(num: Int) {
|
||||
nodeInfoDao.delNode(num)
|
||||
}
|
||||
suspend fun upsert(node: NodeInfo) = withContext(Dispatchers.IO) {
|
||||
nodeInfoDao.upsert(node)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -284,6 +284,17 @@ class UIViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun forgetNode(nodeNum: Int) {
|
||||
try {
|
||||
val packetId = meshService?.packetId ?: return
|
||||
meshService?.removeByNodenum(packetId, nodeNum)
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
nodeDB.delNode(nodeNum)
|
||||
}
|
||||
} catch (ex: RemoteException) {
|
||||
errormsg("Request traceroute error: ${ex.message}")
|
||||
}
|
||||
}
|
||||
fun requestPosition(destNum: Int, position: Position = Position(0.0, 0.0, 0)) {
|
||||
try {
|
||||
meshService?.requestPosition(destNum, position)
|
||||
|
|
|
|||
|
|
@ -1878,7 +1878,13 @@ class MeshService : Service(), Logging {
|
|||
override fun stopProvideLocation() = toRemoteExceptions {
|
||||
stopLocationRequests()
|
||||
}
|
||||
override fun removeByNodenum(requestId: Int, nodeNum: Int) = toRemoteExceptions {
|
||||
sendToRadio(newMeshPacketTo(myNodeNum).buildAdminPacket {
|
||||
removeByNodenum = nodeNum
|
||||
|
||||
})
|
||||
|
||||
}
|
||||
override fun requestPosition(destNum: Int, position: Position) = toRemoteExceptions {
|
||||
if (destNum != myNodeNum) {
|
||||
// request position
|
||||
|
|
|
|||
|
|
@ -139,6 +139,14 @@ class UsersFragment : ScreenFragment("Users"), Logging {
|
|||
R.id.traceroute -> {
|
||||
debug("requesting traceroute for '${user.longName}'")
|
||||
model.requestTraceroute(node.num)
|
||||
}
|
||||
R.id.forget_node -> {
|
||||
debug("Forgetting node '${user.longName}'")
|
||||
|
||||
model.forgetNode(node.num)
|
||||
onNodesChanged(nodes)
|
||||
|
||||
|
||||
}
|
||||
R.id.ignore -> {
|
||||
val message = if (isIgnored) R.string.ignore_remove else R.string.ignore_add
|
||||
|
|
|
|||
|
|
@ -10,6 +10,10 @@
|
|||
android:id="@+id/request_position"
|
||||
android:title="@string/request_position"
|
||||
app:showAsAction="withText" />
|
||||
<item
|
||||
android:id="@+id/forget_node"
|
||||
android:title="@string/forget_node"
|
||||
app:showAsAction="withText" />
|
||||
<item
|
||||
android:id="@+id/traceroute"
|
||||
android:title="@string/traceroute"
|
||||
|
|
|
|||
|
|
@ -187,4 +187,5 @@
|
|||
<string name="waypoint_new">New waypoint</string>
|
||||
<string name="waypoint_received">Received waypoint: %s</string>
|
||||
<string name="error_duty_cycle">Duty Cycle limit reached. Cannot send messages right now, please try again later.</string>
|
||||
<string name="forget_node">Forget Node</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue