Periodidc broadcast announce (#183)

* noise: send nonce

* periodidc broadcast announce
This commit is contained in:
callebtc
2025-07-25 01:38:53 +02:00
committed by GitHub
parent 1c82e4ede8
commit bc14b9f179
2 changed files with 20 additions and 13 deletions
@@ -65,6 +65,7 @@ class BluetoothMeshService(private val context: Context) {
// Wire up PacketProcessor reference for recursive handling in MessageHandler
messageHandler.packetProcessor = packetProcessor
sendPeriodicBroadcastAnnounce()
//startPeriodicDebugLogging()
}
@@ -86,6 +87,22 @@ class BluetoothMeshService(private val context: Context) {
}
}
}
/**
* Send broadcast announcement every 10 seconds
*/
private fun sendPeriodicBroadcastAnnounce() {
serviceScope.launch {
while (isActive) {
try {
delay(10000) // 10 seconds
sendBroadcastAnnounce()
} catch (e: Exception) {
Log.e(TAG, "Error in periodic broadcast announce: ${e.message}")
}
}
}
}
/**
* Setup delegate connections between components
@@ -604,6 +621,7 @@ class BluetoothMeshService(private val context: Context) {
* Send broadcast announce
*/
fun sendBroadcastAnnounce() {
Log.d(TAG, "Sending broadcast announce")
serviceScope.launch {
val nickname = delegate?.getNickname() ?: myPeerID