View Source grisp_connect_client (grisp_connect v2.0.0)

Client to interact with grisp.io

This module contains a state machine to ensure connectivity with grisp.io. JsonRPC traffic is managed here.

Summary

Functions

State connecting is used to establish a connection to grisp.io.

State waiting_ip is used to check the device has an IP address. The first time entering this state, the check will be performed right away. If the device do not have an IP address, it will wait a fixed amount of time and check again, without incrementing the retry counter.

Types

data/0

-type data() ::
          #data{domain :: binary(),
                port :: inet:port_number(),
                ws_path :: binary(),
                ws_transport :: tcp | tls,
                conn :: undefined | pid(),
                retry_count :: non_neg_integer(),
                last_error :: term(),
                max_retries :: non_neg_integer() | infinity,
                wait_calls :: [gen_statem:from()]}.

on_error_fun/0

-type on_error_fun() ::
          fun((data(),
               local | remote,
               Code :: atom() | integer(),
               Message :: undefined | binary(),
               Data :: term()) ->
                  data()).

on_result_fun/0

-type on_result_fun() :: fun((data(), Result :: term()) -> data()).

Functions

callback_mode()

code_change(Vsn, State, Data, Extra)

connect()

connected(EventType, OldState, Data)

connecting(EventType, OldState, Data)

State connecting is used to establish a connection to grisp.io.

idle(EventType, OldState, Data)

init(_)

is_connected()

notify(Method, Type, Params)

reboot()

request(Method, Type, Params)

start_link()

terminate(Reason, State, Data)

wait_connected(Timeout)

waiting_ip(EventType, OldState, Data)

State waiting_ip is used to check the device has an IP address. The first time entering this state, the check will be performed right away. If the device do not have an IP address, it will wait a fixed amount of time and check again, without incrementing the retry counter.