kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
feat: enforce waypoints locked_to
rodzic
a0935a695c
commit
1fc99b8bb4
|
@ -574,27 +574,21 @@ class MeshService : Service(), Logging {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun rememberDataPacket(dataPacket: DataPacket) {
|
private fun rememberDataPacket(dataPacket: DataPacket) {
|
||||||
// Now that we use data packets for more things, we need to be choosier about what we keep. Since (currently - in the future less so)
|
val fromLocal = dataPacket.from == DataPacket.ID_LOCAL
|
||||||
// we only care about old text messages, we just store those...
|
val toBroadcast = dataPacket.to == DataPacket.ID_BROADCAST
|
||||||
if (dataPacket.dataType == Portnums.PortNum.WAYPOINT_APP_VALUE
|
val contactId = if (fromLocal || toBroadcast) dataPacket.to else dataPacket.from
|
||||||
|| dataPacket.dataType == Portnums.PortNum.TEXT_MESSAGE_APP_VALUE
|
|
||||||
) {
|
|
||||||
val fromLocal = dataPacket.from == DataPacket.ID_LOCAL
|
|
||||||
val toBroadcast = dataPacket.to == DataPacket.ID_BROADCAST
|
|
||||||
val contactId = if (fromLocal || toBroadcast) dataPacket.to else dataPacket.from
|
|
||||||
|
|
||||||
// contactKey: unique contact key filter (channel)+(nodeId)
|
// contactKey: unique contact key filter (channel)+(nodeId)
|
||||||
val contactKey = "${dataPacket.channel}$contactId"
|
val contactKey = "${dataPacket.channel}$contactId"
|
||||||
|
|
||||||
val packetToSave = Packet(
|
val packetToSave = Packet(
|
||||||
0L, // autoGenerated
|
0L, // autoGenerated
|
||||||
dataPacket.dataType,
|
dataPacket.dataType,
|
||||||
contactKey,
|
contactKey,
|
||||||
System.currentTimeMillis(),
|
System.currentTimeMillis(),
|
||||||
dataPacket
|
dataPacket
|
||||||
)
|
)
|
||||||
insertPacket(packetToSave)
|
insertPacket(packetToSave)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Update our model and resend as needed for a MeshPacket we just received from the radio
|
/// Update our model and resend as needed for a MeshPacket we just received from the radio
|
||||||
|
@ -613,7 +607,6 @@ class MeshService : Service(), Logging {
|
||||||
debug("Received data from $fromId, portnum=${data.portnum} ${bytes.size} bytes")
|
debug("Received data from $fromId, portnum=${data.portnum} ${bytes.size} bytes")
|
||||||
|
|
||||||
dataPacket.status = MessageStatus.RECEIVED
|
dataPacket.status = MessageStatus.RECEIVED
|
||||||
rememberDataPacket(dataPacket)
|
|
||||||
|
|
||||||
// if (p.hasUser()) handleReceivedUser(fromNum, p.user)
|
// if (p.hasUser()) handleReceivedUser(fromNum, p.user)
|
||||||
|
|
||||||
|
@ -624,9 +617,17 @@ class MeshService : Service(), Logging {
|
||||||
Portnums.PortNum.TEXT_MESSAGE_APP_VALUE ->
|
Portnums.PortNum.TEXT_MESSAGE_APP_VALUE ->
|
||||||
if (!fromUs) {
|
if (!fromUs) {
|
||||||
debug("Received CLEAR_TEXT from $fromId")
|
debug("Received CLEAR_TEXT from $fromId")
|
||||||
|
rememberDataPacket(dataPacket)
|
||||||
updateMessageNotification(dataPacket)
|
updateMessageNotification(dataPacket)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Portnums.PortNum.WAYPOINT_APP_VALUE -> {
|
||||||
|
val u = MeshProtos.Waypoint.parseFrom(data.payload)
|
||||||
|
// Validate locked Waypoints from the original sender
|
||||||
|
if (u.lockedTo != 0 && u.lockedTo != packet.from) return
|
||||||
|
rememberDataPacket(dataPacket)
|
||||||
|
}
|
||||||
|
|
||||||
// Handle new style position info
|
// Handle new style position info
|
||||||
Portnums.PortNum.POSITION_APP_VALUE -> {
|
Portnums.PortNum.POSITION_APP_VALUE -> {
|
||||||
var u = MeshProtos.Position.parseFrom(data.payload)
|
var u = MeshProtos.Position.parseFrom(data.payload)
|
||||||
|
|
Ładowanie…
Reference in New Issue