Skip to content

hiroeorz/emqttc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

emqttc Build Status

Erlang mqtt client. Emttc provides parallel connection and auto reconnect to broker.

Build

$ make

Start Application

1> application:start(emqttc).

Subscribe and Publush

Connect to MQTT Broker.

1> {ok, Pid} = emqttc:start_link([{host, "test.mosquitto.org"}]).

%% publish (QoS=0).
2> emqttc:publish(Pid, <<"temp/random">>, <<"0">>).
ok

%% publish (QoS=1).
2> emqttc:publish(Pid, <<"temp/random">>, <<"0">>, [{qos, 1}]).
{ok, 0}

%% publish (QoS=2).
2> emqttc:publish(Pid, <<"temp/random">>, <<"0">>, [{qos, 2}]).
{ok, 1}

%% publish (QoS=2 AND Retain=true).
2> emqttc:publish(Pid, <<"temp/random">>, <<"0">>, [{qos, 2}, {retain, true}]).
{ok, 1}

%% subscribe.
3> Qos = 0.
4> emqttc:subscribe(Pid, [{<<"temp/random">>, Qos}]).
ok

%% add event handler.
5> emqttc_event:add_handler().
ok

%% add event handler.
5> emqttc:add_event_handler(Pid, my_handler).
ok

##Options

Clean Session

Default Clean Session value is true, If you want to set Clean Session = false, add option {clean_session, false}.

1> {ok, Pid} = emqttc:start_link([{host, "test.mosquitto.org"}, {clean_session. false}]).

Keep Alive

Default Keep Alive value is 20(sec), If you want to set KeepAlive, add option {keep_alive, 60}.

1> {ok, Pid} = emqttc:start_link([{host, "test.mosquitto.org"}, {keep_alive. 60}]).

About

erlang mqtt client.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Erlang 98.4%
  • Perl 1.5%
  • Shell 0.1%