No APIs have changed with Grizzly v0.14.0
however the way Grizzly is configured and started has changed.
Grizzly is no longer an application and now exposes a supervisor that the consuming application can add to its supervision tree. In real life firmware, you might not always want to have Grizzly running and staring everything automatically. We overcame this via application configs, but that has led to some awkward configuration and also the application based setup lead to some awkward implementations at the higher application level when making business logic decisions. This gives full control of consuming applications to start and configure Grizzly.
If all the default configuration options work for your application all you need to do is add Grizzly's supervisor to your supervision tree.
defmodule MyAppApplication do
use Application
def start(_type, _args) do
children = [
... other children ...
Grizzly.Supervisor
... other children ...
]
Supervisor.start_link(children, strategy: :one_for_one)
end
end
All mix configuration fields have been removed and moved to be arguments you can pass into the Grizzly supervisor.
For example, a pre-v0.14.0 mix config might look like this:
use Mix.Config
config :grizzly,
serial_port: "/dev/ttyS4",
zipgateway_cfg: %{
manufacturer_id: 0x1234,
product_type: 1,
product_id: 1,
hardware_version: 1
},
runtime: [
on_ready: {MyApp, :zwave_ready, []}
]
That now will look like:
defmodule MyAppApplication do
use Application
def start(_type, _args) do
children = [
... other children ...
{Grizzly.Supervisor, grizzly_args()},
... other children ...
]
Supervisor.start_link(children, strategy: :one_for_one)
end
defp grizzly_args() do
[
serial_port: "/dev/ttyS4",
manufacturer_id: 0x1234,
product_type: 1,
product_id: 1,
hardware_version: 1,
on_ready: {MyApp, :zwave_ready, []}
]
end
end
For more information about Grizzly.Supervisor
please see the hex docs