updateSettings method

  1. @mustCallSuper
Future<void> updateSettings(
  1. UpdateSetting settings
)
inherited

Handles an UpdateSetting command and updates the appropriate setting.

Also sends a handshake response to indicate the message was received.

Implementation

@mustCallSuper
Future<void> updateSettings(UpdateSetting settings) async {
  sendMessage(settings);
  if (settings.status == RoverStatus.POWER_OFF) {
    logger.critical("Shutting down...");
    try {
      await onShutdown().timeout(const Duration(seconds: 5));
    } catch (error) {
      logger.critical("Error when shutting down: $error");
    }
    if (!Platform.isLinux) exit(0);
    await Process.run("sudo", ["shutdown", "now"]);
  } else if (settings.status == RoverStatus.RESTART) {
    await restart();
  }
}