From 52e79da803e9bf02a03976e14daec5c1a5bc30d3 Mon Sep 17 00:00:00 2001 From: andrekir Date: Fri, 13 Sep 2024 18:30:55 -0300 Subject: [PATCH] fix(MeshService): wait for node db initialization with a timeout --- .../main/java/com/geeksville/mesh/service/MeshService.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index 98627a5d..ad62dc1d 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -1463,6 +1463,12 @@ class MeshService : Service(), Logging { radioConfigRepository.installNodeDB(newMyNodeInfo!!, newNodes.map { it.toEntity() }) newNodes.clear() // Just to save RAM ;-) + withTimeoutOrNull(timeMillis = 5000) { + while (myNodeInfo == null) { + delay(100) + } + } ?: errormsg("Timeout: installNodeDB failed!") + haveNodeDB = true // we now have nodes from real hardware sendToRadio(newMeshPacketTo(myNodeNum).buildAdminPacket {