Skip to content

Commit ddefa85

Browse files
v15.0.0
2 parents f967e9b + 598cfbf commit ddefa85

17 files changed

Lines changed: 175 additions & 34 deletions

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
# 15.0.0
4+
5+
* hotfix for uptime bug
6+
* rpc() Lua helper
7+
* sequence() Lua helper
8+
* Dependency upgrades (including wifi scan edge case bugfix)
9+
310
# 14.9.0
411

512
* Ability to manage `resource` variables from Lua.

FEATURE_MIN_VERSIONS.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"api_ota_releases": "11.1.0",
3232
"ota_update_hour": "8.2.3",
3333
"quiet_motors": "14.0.0",
34+
"resource_variables": "14.9.0",
3435
"rpi_led_control": "6.4.4",
3536
"safe_height_input": "12.1.0",
3637
"sensors": "6.3.0",

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
15.0.0
1+
15.0.0

lib/core/bot_state.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,7 @@ defmodule FarmbotOS.BotState do
353353
end
354354

355355
def handle_call({:report_uptime, seconds}, _form, state) do
356+
FarmbotOS.SysCalls.CheckUpdate.uptime_hotfix(seconds)
356357
change = %{informational_settings: %{uptime: seconds}}
357358

358359
{reply, state} = get_reply_from_change(state, change)

lib/os/lua.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ defmodule FarmbotOS.Lua do
145145
photo_grid: &DataManipulation.photo_grid/2,
146146
read_pin: &Firmware.read_pin/2,
147147
read_status: &Info.read_status/2,
148+
rpc: &DataManipulation.rpc/2,
149+
sequence: &DataManipulation.sequence/2,
148150
send_message: &Info.send_message/2,
149151
set_job_progress: &Info.set_job_progress/2,
150152
set_pin_io_mode: &Firmware.set_pin_io_mode/2,

lib/os/lua/data_manipulation.ex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ defmodule FarmbotOS.Lua.DataManipulation do
218218

219219
def photo_grid(args, lua), do: lua_extension(args, lua, "photo_grid")
220220
def api(args, lua), do: lua_extension(args, lua, "api")
221+
def rpc(args, lua), do: lua_extension(args, lua, "rpc")
222+
def sequence(args, lua), do: lua_extension(args, lua, "sequence")
221223

222224
def lua_extension(args, lua, filename) do
223225
lua_code = File.read!("#{:code.priv_dir(:farmbot)}/lua/#{filename}.lua")

lib/os/sys_calls/check_update.ex

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,22 @@ defmodule FarmbotOS.SysCalls.CheckUpdate do
4848
UpdateProgress.set(progress_pid, 100)
4949
{:error, error}
5050
end
51+
52+
def max_uptime, do: 31
53+
# Rebooting allows the bot to refresh its API token.
54+
def uptime_hotfix(uptime_seconds) do
55+
days = uptime_seconds / 86400
56+
57+
if days > max_uptime() do
58+
{tz, ota_hour} = FarmbotOS.UpdateSupport.get_hotfix_info()
59+
60+
if tz && ota_hour do
61+
if Timex.now(tz).hour == ota_hour do
62+
FarmbotOS.UpdateSupport.do_hotfix()
63+
end
64+
else
65+
FarmbotOS.UpdateSupport.do_hotfix()
66+
end
67+
end
68+
end
5169
end

lib/os/update_support.ex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,17 @@ defmodule FarmbotOS.UpdateSupport do
121121
string = "#{server}/api/releases?platform=#{target}"
122122
to_charlist(string)
123123
end
124+
125+
def get_hotfix_info() do
126+
device = FarmbotOS.Asset.device()
127+
tz = device.timezone
128+
ota_hour = device.ota_hour
129+
{tz, ota_hour}
130+
end
131+
132+
def do_hotfix() do
133+
uptime = FarmbotOS.SysCalls.CheckUpdate.max_uptime()
134+
FarmbotOS.Logger.debug(3, "Rebooting after #{uptime} days of uptime.")
135+
FarmbotOS.SysCalls.reboot()
136+
end
124137
end

mix.exs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,17 @@ defmodule FarmbotOS.MixProject do
9595
# Run "mix help deps" to learn about dependencies.
9696
defp deps do
9797
[
98-
{:busybox, "~> 0.1.5", targets: @all_targets},
98+
{:busybox, "~> 0.1", targets: @all_targets},
9999
{:certifi, "~> 2.8"},
100100
{:circuits_gpio, "~> 1.0", targets: @all_targets},
101101
{:circuits_i2c, "~> 1.0", targets: @all_targets},
102102
{:circuits_uart, "~> 1.4"},
103-
{:cors_plug, "~> 2.0.3", targets: @all_targets},
103+
{:cors_plug, "~> 2.0", targets: @all_targets},
104104
{:dns, "~> 2.3"},
105-
{:ecto_sqlite3, "~> 0.7.2"},
105+
{:ecto_sqlite3, "~> 0.7"},
106106
{:ecto, "~> 3.7"},
107-
{:ex_doc, "~> 0.25", only: [:dev], targets: [:host], runtime: false},
107+
{:ex_doc, "~> 0.28", only: [:dev], targets: [:host], runtime: false},
108108
{:excoveralls, "~> 0.14", only: [:test], targets: [:host]},
109-
{:extty, "~> 0.2.1"},
110109
{:farmbot_system_rpi,
111110
git: "git@github.com:FarmBot/farmbot_system_rpi.git",
112111
tag: "v1.18.1-farmbot.1",
@@ -122,29 +121,30 @@ defmodule FarmbotOS.MixProject do
122121
tag: "v1.18.1-farmbot.1",
123122
runtime: false,
124123
targets: :rpi4},
124+
{:extty, "~> 0.2"},
125125
{:hackney, "~> 1.18"},
126-
{:jason, "~> 1.2"},
127-
{:luerl, github: "rvirding/luerl", tag: "1.0"},
126+
{:jason, "~> 1.3"},
127+
{:luerl, "~> 1.0"},
128128
{:mdns_lite, "~> 0.8", targets: @all_targets},
129129
{:mimic, "~> 1.5", only: :test},
130-
{:mix_unused, "~> 0.3.0", only: :dev},
130+
{:mix_unused, "~> 0.4", only: :dev},
131131
{:muontrap, "~> 1.0"},
132-
{:nerves_runtime, "~> 0.11.6", targets: @all_targets},
132+
{:nerves_runtime, "~> 0.11", targets: @all_targets},
133133
{:nerves_time, "~> 0.4", targets: @all_targets},
134-
{:nerves, "~> 1.7.11", runtime: false},
134+
{:nerves, "~> 1.7", runtime: false},
135135
{:phoenix_html, "~> 3.2"},
136-
{:plug_cowboy, "~> 2.5.2"},
137-
{:ring_logger, "~> 0.8.3"},
138-
{:rollbax, ">= 0.0.0"},
136+
{:plug_cowboy, "~> 2.5"},
137+
{:ring_logger, "~> 0.8"},
138+
{:rollbax, "~> 0.11"},
139139
{:shoehorn, "~> 0.8"},
140-
{:telemetry, "~> 1.0.0"},
141-
{:tesla, "~> 1.4.3"},
140+
{:telemetry, "~> 1.0"},
141+
{:tesla, "~> 1.4"},
142142
{:timex, "~> 3.7"},
143-
{:toolshed, "~> 0.2.22", targets: @all_targets},
143+
{:toolshed, "~> 0.2", targets: @all_targets},
144144
{:tortoise, "~> 0.10"},
145-
{:uuid, "~> 1.1.8"},
146-
{:vintage_net_ethernet, "~> 0.10.1", targets: @all_targets},
147-
{:vintage_net_wifi, "~> 0.10.1", targets: @all_targets},
145+
{:uuid, "~> 1.1"},
146+
{:vintage_net_ethernet, "~> 0.10", targets: @all_targets},
147+
{:vintage_net_wifi, "~> 0.10", targets: @all_targets},
148148
{:vintage_net, "~> 0.11", targets: @all_targets}
149149
]
150150
end

0 commit comments

Comments
 (0)