Implementing Remote Device Reboot via Mobile App
Remote reboot of an IoT device is one of the first requested features when operating a distributed network of sensors or gateways. Device stopped responding, but power is on—classic scenario for industrial ESP32 gateways, Raspberry Pi, routers with OpenWRT.
Implementation: Command via MQTT or REST
If device is connected to MQTT broker—publish to control topic:
suspend fun rebootDevice(deviceId: String) {
val topic = "devices/$deviceId/commands/reboot"
val payload = MqttMessage(
jsonOf("action" to "reboot", "timestamp" to System.currentTimeMillis(),
"requestedBy" to currentUser.id).toByteArray()
).apply { qos = 1 } // QoS 1 — guarantee delivery at least once
mqttClient.publish(topic, payload)
// Wait for device confirmation in response topic
withTimeout(30_000) {
deviceStateFlow.first { it.deviceId == deviceId && it.event == "rebooting" }
}
}
QoS 1 instead of 0—device may have temporarily disconnected from broker; on reconnection, it retrieves command from retained queue.
Confirmation and Timeout
After sending reboot command, device should respond "received, rebooting", then appear online again. In app—status indicator: "sent → confirmed → offline → online". If device doesn't return within 60 seconds—notification about possible power or firmware issue.
Implementing remote device reboot with confirmation and recovery monitoring: 1–2 weeks. Cost individually quoted.







