nerves_hub_link_http v0.8.2 NervesHubLinkHTTP.Client behaviour

A behaviour module for customizing the tool used for HTTP requests to NervesHub.

Also allows handling FWUP messages and errors

By default, :hackney is used for completing HTTP requests and all FWUP messages are logged to STDOUT. To specify your own module to use, update your config.exs

config :nerves_hub_link_http, client: MyApp.NervesHubLinkHTTP.Client

Link to this section Summary

Types

Firmware update progress, completion or error report

Functions

This function is called internally by NervesHubLinkHTTP to notify clients of fwup errors.

This function is called internally by NervesHubLinkHTTP to notify clients of fwup progress.

Callbacks

Called when downloading a firmware update fails.

Called on firmware update reports.

Performs the HTTP request

Link to this section Types

Link to this type

body()

body() :: binary()
Link to this type

fwup_message()

fwup_message() ::
  {:ok, non_neg_integer(), String.t()}
  | {:warning, non_neg_integer(), String.t()}
  | {:error, non_neg_integer(), String.t()}
  | {:progress, 0..100}

Firmware update progress, completion or error report

Link to this type

header()

header() :: {binary(), binary()}
Link to this type

method()

method() :: :get | :put | :post
Link to this type

opts()

opts() :: keyword()
Link to this type

response()

response() :: {:ok, map()} | {:error, any()}
Link to this type

url()

url() :: binary()

Link to this section Functions

Link to this function

handle_error(data)

handle_error(any()) :: :ok

This function is called internally by NervesHubLinkHTTP to notify clients of fwup errors.

Link to this function

handle_fwup_message(data)

handle_fwup_message(fwup_message()) :: :ok

This function is called internally by NervesHubLinkHTTP to notify clients of fwup progress.

Link to this function

request(method, path, params, opts \\ [])

request(method(), binary(), map() | binary() | list(), Keyword.t()) ::
  response()
Link to this function

update(opts \\ [])

update(Keyword.t()) :: response()
Link to this function

url(path)

url(binary()) :: url()

Link to this section Callbacks

Link to this callback

handle_error(any)

handle_error(any()) :: :ok

Called when downloading a firmware update fails.

The return value of this function is not checked.

Link to this callback

handle_fwup_message(fwup_message)

handle_fwup_message(fwup_message()) :: :ok

Called on firmware update reports.

The return value of this function is not checked.

Link to this callback

request(method, url, list, body, opts)

request(method(), url(), [header()], body(), opts()) :: response()

Performs the HTTP request