diff --git a/CHANGELOG.md b/CHANGELOG.md index 501d3efff..7cc14c01a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,7 @@ # Changelog +# 6.4.5 +* Fix Firmware syncing applying _every_ setting. + # 6.4.4 * Optimize AMQP connection. * Sync PinBindings with the API. diff --git a/VERSION b/VERSION index 49df80bfe..7d765dabd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.4.4 +6.4.5 diff --git a/lib/farmbot/bootstrap/settings_sync.ex b/lib/farmbot/bootstrap/settings_sync.ex index f0808567d..f2e8e09ff 100644 --- a/lib/farmbot/bootstrap/settings_sync.ex +++ b/lib/farmbot/bootstrap/settings_sync.ex @@ -151,8 +151,8 @@ defmodule Farmbot.Bootstrap.SettingsSync do run(tries_left - 1) else try do - do_sync_fbos_configs() do_sync_fw_configs() + do_sync_fbos_configs() Logger.debug 1, "Synced Farmbot OS and Firmware settings with API" :ok rescue @@ -182,8 +182,8 @@ defmodule Farmbot.Bootstrap.SettingsSync do old_map = take_valid_fw(old_map) new_map = take_valid_fw(new_map) new_stuff = Map.new(new_map, fn({key, new_value}) -> - if old_map[key] !== new_value do - IO.puts "1 #{key} #{old_map[key]} !== #{new_value}" + if old_map[key] != new_value do + IO.puts "1 #{key} #{old_map[key]} != #{new_value}" apply_to_config_storage key, new_value {key, new_value} else @@ -193,8 +193,8 @@ defmodule Farmbot.Bootstrap.SettingsSync do if Process.whereis(Farmbot.Firmware) do Map.new(new_map, fn({param, new_value}) -> - if old_map[param] !== new_value do - IO.puts "2 #{param} #{old_map[param]} !== #{new_value}" + if old_map[param] != new_value do + IO.puts "2 #{param} #{old_map[param]} != #{new_value}" Farmbot.Firmware.update_param(String.to_atom(param), new_value) end {param, get_config_value(:float, "hardware_params", param)} @@ -219,7 +219,7 @@ defmodule Farmbot.Bootstrap.SettingsSync do defp apply_to_config_storage(key, val) when key in @firmware_keys do if val do - Logger.success 2, "Updating FW param: #{key}: #{get_config_value(:float, "hardware_params", key)} => #{val / 1 || "null"}" + Logger.success 2, "Updating FW param: #{key}: #{get_config_value(:float, "hardware_params", key)} => #{val}" update_config_value(:float, "hardware_params", key, val / 1) else Logger.warn 2, "Not allowing #{key} to be set to null" diff --git a/lib/farmbot/firmware/uart_handler/uart_handler.ex b/lib/farmbot/firmware/uart_handler/uart_handler.ex index b86e6d3dd..058cd1076 100644 --- a/lib/farmbot/firmware/uart_handler/uart_handler.ex +++ b/lib/farmbot/firmware/uart_handler/uart_handler.ex @@ -87,6 +87,7 @@ defmodule Farmbot.Firmware.UartHandler do defmodule State do @moduledoc false defstruct [ + config_busy: false, nerves: nil, current_cmd: nil, tty: nil, @@ -125,6 +126,8 @@ defmodule Farmbot.Firmware.UartHandler do end) case state do + %State{config_busy: true} = state -> + {:noreply, [:busy], state} %State{} = state -> {:noreply, [], state} _ -> state @@ -137,7 +140,7 @@ defmodule Farmbot.Firmware.UartHandler do # Restart the framing to pick up new changes. UART.configure state.nerves, [framing: UART.Framing.None, active: false] configure_uart(state.nerves, true) - state + %{state | config_busy: true} end defp handle_config({:config, "settings", "firmware_hardware", val}, state) do @@ -147,8 +150,8 @@ defmodule Farmbot.Firmware.UartHandler do UART.close(state.nerves) UartHandler.Update.force_update_firmware(val) open_tty(state.tty, state.nerves) - Farmbot.BotState.reset_sync_status - %{state | hw: val} + Farmbot.BotState.reset_sync_status() + %{state | hw: val, config_busy: true} else state end @@ -273,7 +276,7 @@ defmodule Farmbot.Firmware.UartHandler do end def handle_info({:nerves_uart, _, {_q, :done}}, state) do - {:noreply, [:done], %{state | current_cmd: nil}} + {:noreply, [:done], %{state | current_cmd: nil, config_busy: false}} end def handle_info({:nerves_uart, _, {_q, gcode}}, state) do