mirror of
https://github.com/meshtastic/Meshtastic-Android.git
synced 2026-02-07 06:12:56 -05:00
@@ -334,6 +334,7 @@ class MainActivity : AppCompatActivity(), Logging {
|
||||
// val messageStr = getText(messageText)
|
||||
|
||||
val builder = MaterialAlertDialogBuilder(this)
|
||||
.setCancelable(false)
|
||||
.setTitle(titleText)
|
||||
.setMessage(messageText)
|
||||
.setPositiveButton(R.string.okay) { _, _ ->
|
||||
|
||||
@@ -34,6 +34,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.filterNotNull
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.flatMapLatest
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
@@ -143,6 +144,11 @@ class UIViewModel @Inject constructor(
|
||||
private val requestIds = MutableStateFlow<HashMap<Int, Boolean>>(hashMapOf())
|
||||
|
||||
init {
|
||||
radioInterfaceService.errorMessage.filterNotNull().onEach {
|
||||
_snackbarText.value = it
|
||||
radioInterfaceService.clearErrorMessage()
|
||||
}.launchIn(viewModelScope)
|
||||
|
||||
radioConfigRepository.nodeInfoFlow().onEach(nodeDB::setNodes)
|
||||
.launchIn(viewModelScope)
|
||||
|
||||
|
||||
@@ -55,6 +55,18 @@ class RadioInterfaceService @Inject constructor(
|
||||
private val _receivedData = MutableSharedFlow<ByteArray>()
|
||||
val receivedData: SharedFlow<ByteArray> = _receivedData
|
||||
|
||||
private val _errorMessage = MutableStateFlow<String?>(null)
|
||||
val errorMessage: SharedFlow<String?> = _errorMessage
|
||||
|
||||
fun setErrorMessage(text: String) {
|
||||
errormsg(text)
|
||||
_errorMessage.value = text
|
||||
}
|
||||
|
||||
fun clearErrorMessage() {
|
||||
_errorMessage.value = null
|
||||
}
|
||||
|
||||
private val logSends = false
|
||||
private val logReceives = false
|
||||
private lateinit var sentPacketsLog: BinaryLogFile // inited in onCreate
|
||||
|
||||
@@ -664,12 +664,16 @@ class MeshService : Service(), Logging {
|
||||
handleReceivedTelemetry(packet.from, u, dataPacket.time)
|
||||
}
|
||||
|
||||
// Handle new style routing info
|
||||
Portnums.PortNum.ROUTING_APP_VALUE -> {
|
||||
shouldBroadcast =
|
||||
true // We always send acks to other apps, because they might care about the messages they sent
|
||||
// We always send ACKs to other apps, because they might care about the messages they sent
|
||||
shouldBroadcast = true
|
||||
val u = MeshProtos.Routing.parseFrom(data.payload)
|
||||
val isAck = u.errorReasonValue == MeshProtos.Routing.Error.NONE_VALUE
|
||||
|
||||
if (u.errorReason == MeshProtos.Routing.Error.DUTY_CYCLE_LIMIT) {
|
||||
radioInterfaceService.setErrorMessage(getString(R.string.error_duty_cycle))
|
||||
}
|
||||
|
||||
handleAckNak(isAck, fromId, data.requestId)
|
||||
queueResponse.remove(data.requestId)?.complete(true)
|
||||
}
|
||||
|
||||
@@ -181,4 +181,5 @@
|
||||
<string name="waypoint_delete">Delete waypoint?</string>
|
||||
<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>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user