{"id":17992600,"url":"https://github.com/timbuchwaldt/exmqttc","last_synced_at":"2025-03-26T01:31:22.252Z","repository":{"id":62429207,"uuid":"90556646","full_name":"timbuchwaldt/exmqttc","owner":"timbuchwaldt","description":"Elixir wrapper for the emqttc library","archived":false,"fork":false,"pushed_at":"2018-11-02T21:11:22.000Z","size":58,"stargazers_count":23,"open_issues_count":3,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-19T20:04:02.023Z","etag":null,"topics":["elixir","emqttc","mqtt","mqtt-client"],"latest_commit_sha":null,"homepage":null,"language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timbuchwaldt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-07T19:32:36.000Z","updated_at":"2023-09-01T11:00:05.000Z","dependencies_parsed_at":"2022-11-01T20:04:09.865Z","dependency_job_id":null,"html_url":"https://github.com/timbuchwaldt/exmqttc","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timbuchwaldt%2Fexmqttc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timbuchwaldt%2Fexmqttc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timbuchwaldt%2Fexmqttc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timbuchwaldt%2Fexmqttc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timbuchwaldt","download_url":"https://codeload.github.com/timbuchwaldt/exmqttc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245571811,"owners_count":20637403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","emqttc","mqtt","mqtt-client"],"created_at":"2024-10-29T20:08:19.128Z","updated_at":"2025-03-26T01:31:21.927Z","avatar_url":"https://github.com/timbuchwaldt.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Exmqttc [![Deps Status](https://beta.hexfaktor.org/badge/all/github/timbuchwaldt/exmqttc.svg)](https://beta.hexfaktor.org/github/timbuchwaldt/exmqttc) [![Build Status](https://travis-ci.org/timbuchwaldt/exmqttc.svg?branch=master)](https://travis-ci.org/timbuchwaldt/exmqttc) [![Inline docs](http://inch-ci.org/github/timbuchwaldt/exmqttc.svg?branch=master)](http://inch-ci.org/github/timbuchwaldt/exmqttc)\n\nElixir wrapper for the emqttc library.\n\nemqttc must currently be installed manually as it is not available on hex (yet).\n\n## Installation\n\nThe package can be installed by adding `exmqttc` and `emqttc` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:exmqttc, \"~\u003e 0.5\"}, {:emqttc, github: \"emqtt/emqttc\"}]\nend\n```\n\n\n## Usage\n\nCreate a callback module:\n```elixir\ndefmodule MyClient do\n  require Logger\n  use Exmqttc.Callback\n\n  def init(_params) do\n    {:ok, []}\n  end\n\n  def handle_connect(state) do\n    Logger.debug \"Connected\"\n    {:ok, state}\n  end\n\n  def handle_disconnect(state) do\n    Logger.debug \"Disconnected\"\n    {:ok, state}\n  end\n\n  def handle_publish(topic, payload, state) do\n    Logger.debug \"Message received on topic #{topic} with payload #{payload}\"\n    {:ok, state}\n  end\nend\n```\n\nYou can keep your own state and return it just like with `:gen_server`.\n\nStart the MQTT connection process by calling `start_link/3`:\n```elixir\n{:ok, pid} = Exmqttc.start_link(MyClient, [], [host: '127.0.0.1'], params)\n```\nThe third argument is a list of emqtt connection options, supporting the following options\n\n- `host`: Connection host, charlist, default: `'localhost'`\n- `port`: Connection port, integer, default 1883\n- `client_id`: Binary ID for client, automatically set to UUID if not specified\n- `clean_sess`: MQTT cleanSession flag. `true` disables persistent sessions on the server\n- `keepalive`: Keepalive timer, integer\n- `username`: Login username, binary\n- `password`: Login password, binary\n- `will`: Last will, keywordlist, sample: `[qos: 1, retain: false, topic: \"WillTopic\", payload: \"I died\"]`\n- `connack_timeout`: Timeout for connack package, integer, default 60\n- `puback_timeout`: Timeout for puback package, integer, default 8\n- `suback_timeout`: Timeout for suback package, integer, default 4\n- `ssl`: List of ssl options\n- `auto_resub`: Automatically resubscribe to topics, boolean, default: `false`\n- `reconnect`: Automatically reconnect on lost connection, integer (),  default `false`\n\nParams are passed to the init function of your callback module.\n\nYou can publish messages to the given PID:\n\n```elixir\nExmqttc.publish(pid, \"test\", \"foo\")\n```\n\n`publish/4` also supports passing in QOS and retain options:\n```elixir\nExmqttc.publish(pid, \"test\", \"foo\", qos: 2, retain: true)\n```\n\nFurther docs can be found at [https://hexdocs.pm/exmqttc](https://hexdocs.pm/exmqttc).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimbuchwaldt%2Fexmqttc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimbuchwaldt%2Fexmqttc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimbuchwaldt%2Fexmqttc/lists"}