mirror of
https://github.com/netfun2000/hipudding-teslamate.git
synced 2026-02-27 09:44:28 +08:00
28 lines
589 B
Elixir
28 lines
589 B
Elixir
defmodule TeslaMate.Mqtt.Handler do
|
|
use Tortoise311.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
|