mirror of
https://github.com/teslamate-org/teslamate.git
synced 2026-01-24 21:06:08 +08:00
28 lines
586 B
Elixir
28 lines
586 B
Elixir
defmodule TeslaMate.Mqtt.Handler do
|
|
use Tortoise.Handler
|
|
|
|
require Logger
|
|
|
|
@impl true
|
|
def connection(:up, state) do
|
|
Logger.info("MQTT connection has been established")
|
|
{:ok, state}
|
|
end
|
|
|
|
def connection(:down, state) do
|
|
Logger.warning("MQTT connection has been dropped")
|
|
{:ok, state}
|
|
end
|
|
|
|
def connection(:terminating, state) do
|
|
Logger.warning("MQTT connection is terminating")
|
|
{:ok, state}
|
|
end
|
|
|
|
@impl true
|
|
def terminate(reason, _state) do
|
|
Logger.warning("MQTT Client has been terminated with reason: #{inspect(reason)}")
|
|
:ok
|
|
end
|
|
end
|