-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add device extensions support #228
Conversation
@@ -481,7 +506,7 @@ defmodule NervesHubLink.Socket do | |||
_ = Client.handle_error(reason) | |||
end | |||
|
|||
rejoin(socket, topic, socket.assigns.params) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are the params removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I meant to comment. The slipstream default is to reuse the params that were sent in the initial join. With the addition of features
channel, this was sending the generic firmware metadata params in the event of the features channel closing and rejoining.
I could have pattern matched on the channel name to selectively choose, or just let slipstream send the default original params (which are already static anyway, so no need to forcefully send)
e91b8a9
to
1736c14
Compare
name = opts[:name] || raise "Missing required feature arg: name" | ||
version = opts[:version] || raise "Missing required feature arg: version" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to being arguments to the use
macro rather than callbacks so that it can be enforced at compile time vs just a warning (not everyone has --warnings-as-errors
flag by default)
These need some typing and docs that will come later as I'm out of time for a bit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken almost verbatim from https://github.com/nervescloud/nerves_hub_link_geo
Honestly, this code is looking solid to me! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing to add. Should work well :)
Is there anything that needs to be rounded out or added?
@@ -0,0 +1,22 @@ | |||
defmodule NervesHubLink.Features.Geo.Resolver do | |||
@typedoc "Supported location sources" | |||
@type sources() :: :gps | :geoip | :custom |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since users can add their own this should probably be a string :)
(was this lifted from geo, if so, kind of irrelevant to the PR)
Or {:custom, "where_i_put_it"}
style. Give us something to display in UI about how it gets it's data.
9675d62
to
d4f8a3a
Compare
Rebasing but should be good to review @joshk This has had geo and health integrated into it. I like the new abstraction. Nice and friendly. |
c3ec7c5
to
9ccb710
Compare
9ccb710
to
dff5731
Compare
Link won't load the Feature modules if run I tried changing it to not just run |
I suppose since we plan on controlling this from nerves_hub_link we could provide a default discoverability for health and geo and then let people configure if they have more or other sets they want. I'll move this to config. |
Running this and nerves_hub_web locally, catching a bunch of trickiness :) |
It's because of how modules are loaded (i.e. iex(8)> NervesHubLink.Features.find_features
%{}
# This first call forces the module to load
iex(9)> NervesHubLink.Features.Geo.module_info :attributes
[
vsn: [11907264823846348490321455620962448498],
behaviour: [GenServer],
behaviour: [NervesHubLink.Features]
]
iex(10)> NervesHubLink.Features.find_features
%{
"geo" => %{
module: NervesHubLink.Features.Geo,
version: "0.0.1",
attached?: false
}
} |
Yeah, I know. I switched it to config. Argue if you disagree :D |
5e2ca0b
to
b044770
Compare
@jjcarstens @joshk please review this now, kindly, I think it is done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This generally LGTM, just some small nits, nothing blocking.
|
||
## Configure Geo | ||
|
||
It is intended to be easy to replace the default Geo Resolver with your own. Maybe you have a GPS module or can resolve a reasonably precise location via LTE. Just change config: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is intended to be easy to replace the default Geo Resolver with your own. Maybe you have a GPS module or can resolve a reasonably precise location via LTE. Just change config: | |
It is intended to be easy to replace the default Geo Resolver with your own. Maybe you have a GPS module or can resolve a reasonably precise location via LTE. Just change the config: |
This adds the mechanism to handle extensions on a device for custom data and/or reporting outside the firmware update mechanism. Extensions are isolated from the socket as to not get in the way of potential firmware updates and can be defined in external libs as well as this one by implementing the `NervesHubLink.Extensions` behavior - Implements Geo and Health modules as examples of Extensions - All Extensions currently report only on request from NervesHub - Add optional vintage_net dependency to allow fetching interfaces
f08f78a
to
ff6b16a
Compare
Good nit-hunt @nshoes, much appreciated :) |
Next idea of the previously defined "extensions"
This adds the mechanism to handle features on a device for custom data and/or reporting outside the update mechanism. Features are isolated from the socket as to not get in the way of potential updates and can be defined in external libs as well as this one by implementing the
NervesHubLink.Extensions
behavior.