ExCEP. Gateway. Client
(ex_cep v0.1.1)
Copy Markdown
Single-channel Edge Gateway TCP/TLS client (:management on 9901 or :business on 9902).
Lifecycle
- Opens TCP/TLS connection to the Cluster server.
- If
require_auth: true, executes the Section 5 three-way SM2 authentication handshake:- Sends
AuthAsdu.Request(0x01) with randomr1 - Receives & verifies
AuthAsdu.Response(0x02) checkingr1and SM2 signature - Sends
AuthAsdu.Confirm(0x03) echoingr2
- Sends
- Enters active framing mode (
{:active, :once}), sendingHealthheartbeat whenever idle forheartbeat_interval_ms(default 60s). - Correlates outgoing requests by
Head/Midand dispatches incoming Cluster requests to the configuredExCEP.Gateway.Handler(defaultExCEP.Gateway.DefaultHandler).
Summary
Functions
Returns a specification to start this module under a supervisor.
Closes the connection.
Connects and authenticates to the Cluster server.
Returns true if connected (and authenticated when require_auth is enabled).
Pulls a binary file from the Cluster using Section 6.2.1 FileGet (e.g. firmware/app package).
Pushes a binary file to the Cluster using Section 6.2.2 chunked transfer.
Reports an app alarm (AppAlarm) on the management channel.
Reports AppInstallResult (Section 7.6.2) on the management channel.
Reports a container alarm (ConAlarm) on the management channel.
Reports DataSpont (spontaneous or periodic) and awaits DataSpontResp.
Reports DevAdd and awaits DevAddResp.
Reports DevDel and awaits DevDelResp.
Reports DevUpdate and awaits DevUpdateResp.
Reports DeviceUpdateResult (Section 7.4.2) on the management channel.
Reports ModelChange and awaits ModelChangeResp.
Reports a system alarm (SysAlarm) on the management channel.
Sends a %DataAsdu{} and awaits the correlated response matching Head/Mid.
Sends a %DataAsdu{} without waiting for a response (one-way upload / alarm).
Sends a Health heartbeat immediately.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec close(GenServer.server()) :: :ok
Closes the connection.
@spec connect(GenServer.server()) :: :ok | {:error, term()}
Connects and authenticates to the Cluster server.
@spec connected?(GenServer.server()) :: boolean()
Returns true if connected (and authenticated when require_auth is enabled).
@spec pull_file(GenServer.server(), String.t(), keyword()) :: {:ok, binary()} | {:error, term()}
Pulls a binary file from the Cluster using Section 6.2.1 FileGet (e.g. firmware/app package).
Pushes a binary file to the Cluster using Section 6.2.2 chunked transfer.
Reports an app alarm (AppAlarm) on the management channel.
Reports AppInstallResult (Section 7.6.2) on the management channel.
Reports a container alarm (ConAlarm) on the management channel.
Reports DataSpont (spontaneous or periodic) and awaits DataSpontResp.
Reports DevAdd and awaits DevAddResp.
Reports DevDel and awaits DevDelResp.
Reports DevUpdate and awaits DevUpdateResp.
Reports DeviceUpdateResult (Section 7.4.2) on the management channel.
Reports ModelChange and awaits ModelChangeResp.
Reports a system alarm (SysAlarm) on the management channel.
@spec request(GenServer.server(), ExCEP.Codec.DataAsdu.t(), keyword()) :: {:ok, ExCEP.Codec.DataAsdu.t()} | {:error, term()}
Sends a %DataAsdu{} and awaits the correlated response matching Head/Mid.
@spec send_asdu(GenServer.server(), ExCEP.Codec.DataAsdu.t(), keyword()) :: :ok | {:error, term()}
Sends a %DataAsdu{} without waiting for a response (one-way upload / alarm).
@spec send_heartbeat(GenServer.server()) :: :ok | {:error, term()}
Sends a Health heartbeat immediately.
@spec start_link(keyword()) :: GenServer.on_start()