1 Star 0 Fork 5

jjzhang166 / emqtt

forked from EMQX / emqtt 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

emqtt

MQTT client library and command line tools implemented in Erlang that supports MQTT v5.0/3.1.1/3.1.

Getting started

As a Command Line Tool

Build

$ make

Once you've compiled successfully you will get a script called emqtt in _buile/emqtt/rel/emqtt/bin. We can see what emqtt can do with --help option:

$ ./emqtt --help
Usage: emqtt pub | sub [--help]

emqtt pub is used to publish a single message on a topic and exit. emqtt sub is used to subscribe to a topic and print the messages that it receives.

Command-line Syntax

Options can have both short (single character) and long (string) option names.

A short option can have the following syntax:

-e arg         Single option 'e', argument "arg"

A long option can have the following syntax:

--example=arg  Single option 'example', argument "arg"
--example arg  Single option 'example', argument "arg"

Publish

Synopsis

./emqtt pub [-h [<host>]] [-p <port>] [-I <iface>]
            [-V [<protocol_version>]] [-u <username>]
            [-P <password>] [-C <clientid>] [-k [<keepalive>]]
            [-t <topic>] [-q [<qos>]] [-r [<retain>]]
            [--help <help>] [--will-topic <will_topic>]
            [--will-payload <will_payload>]
            [--will-qos [<will_qos>]]
            [--will-retain [<will_retain>]]
            [--enable-websocket [<enable_websocket>]]
            [--enable-ssl [<enable_ssl>]]
            [--tls-version [<tls_version>]]
            [--CAfile <cafile>] [--cert <cert>]
            [--key <key>] [--payload <payload>]
            [--repeat [<repeat>]]
            [--repeat-delay [<repeat_delay>]]

Options

-h, --host

  Specify the host to connect to, support for domain name and IP address. Defaults to localhost.

-p, --port

  Specify the port to connect to. If not given, the default of 1883 for MQTT or 8883 for MQTT over TLS will be used.

-I, --iface

  Specify the network interface or ip address to use.

-V, --protocol-version

  Specify the MQTT protocol version used by the client. Can be v3.1, v3.1.1 and v5. Defaults to v5.

-u, --username

  Specify the username that can be used by the broker for authentication and authorization.

-P, --password

  Specify the password for the username.

-C, --clientid

  Specify the client identifier. If not given, the client identifier in the format emqtt-<Hostname>-<Random Hexadecimal String> will be automatically generated by emqtt_cli.

-k, --keepalive

  Specify the interval in seconds sending PINGREQ packets to the broker. Defaults to 300 seconds.

-t, --topic

  Specify the MQTT topic you want to publish. If the topic beginning with $, you must use single quote(') to specify the topic rather than double quotes("). This is a required option.

-q, --qos

  Specify the quality of service for the message. Can be 0, 1 and 2. Defaults to 0.

-r, --retain

  Specify whether the message is a retained message. Defaults to false.

--payload

  Specify the application message is to be published. This is a required option.

--repeat

  Specify the number of times the message will be repeatedly published. Defaults to 1.

--repeat-count

  Specify the number of seconds to wait after the previous message was delivered before publishing the next. Defaults to 0, it means to publish repeated messages as soon as the previous message is sent.

--will-topic

  Specify the topic of the will message sent when the client disconnects unexpectedly.

--will-qos

  Specify the quality of service of the will message. Defaults to 0. This must be used in conjunction with --will-topic.

--will-retain

  Specify whether the will message is a retained message. Defaults to false. This must be used in conjunction with --will-topic.

--will-payload

  Specify the application message that will be stored by the broker and sent out if this client disconnects unexpectedly. This must be used in conjunction with --will-topic.

--enable-websocket

  Specify enable WebSocket transport or not. This option can't be used with --enable-ssl currently.

--enable-ssl

  Specify enable SSL/TLS transport or not. This option can't be used with --enable-websocket currently.

--tls-version

  Specify which TLS protocol version to use when communicating with the broker. Valid options are tlsv1.3, tlsv1.2, tlsv1.1 and tlsv1. Defaults to tlsv1.2.

--CAfile

  Specify the path to a file containing PEM encoded CA certificates. This must be used in conjunction with --enable-ssl.

--cert

  Specify the path to a file containing a PEM encoded certificate for this client, if required by the server. This must be used in conjunction with --enable-ssl.

--key

  Specify the path to a file containing a PEM encoded private key for this client, if required by the server. This must be used in conjunction with --enable-ssl.

Examples

Publish a simple message over a TCP connection

$ ./emqtt pub -t "hello" --payload "hello world"
Client emqtt-zhouzibodeMacBook-Pro-4623faa14d8256e9cb95 sent CONNECT
Client emqtt-zhouzibodeMacBook-Pro-4623faa14d8256e9cb95 sent PUBLISH (Q0, R0, D0, Topic=hello, Payload=...(11 bytes))
Client emqtt-zhouzibodeMacBook-Pro-4623faa14d8256e9cb95 sent DISCONNECT

Publish a simple message over a TLS connection

$ ./emqtt pub --enable-ssl=true -t "hello" --payload "hello world" --CAfile=certs/cacert.pem --cert=certs/client-cert.pem --key=certs/client-key.pem
Client emqtt-zhouzibodeMacBook-Pro-cec9489c26e3ed7a38eb sent CONNECT
Client emqtt-zhouzibodeMacBook-Pro-cec9489c26e3ed7a38eb sent PUBLISH (Q0, R0, D0, Topic=hello, Payload=...(11 bytes))
Client emqtt-zhouzibodeMacBook-Pro-cec9489c26e3ed7a38eb sent DISCONNECT

Publish a message repeatedly over a WebSocket connection

$ ./emqtt pub --enable-websocket=true -p 8083 -t "hello" --payload "hello world"
Client emqtt-zhouzibodeMacBook-Pro-1e4677ab46cecf1298ac sent CONNECT
Client emqtt-zhouzibodeMacBook-Pro-1e4677ab46cecf1298ac sent PUBLISH (Q0, R0, D0, Topic=hello, Payload=...(11 bytes))
Client emqtt-zhouzibodeMacBook-Pro-1e4677ab46cecf1298ac sent DISCONNECT

Subscribe

Synopsis

./emqtt sub [-h [<host>]] [-p <port>] [-I <iface>]
            [-V [<protocol_version>]] [-u <username>]
            [-P <password>] [-C <clientid>] [-k [<keepalive>]]
            [-t <topic>] [-q [<qos>]] [--help <help>]
            [--will-topic <will_topic>]
            [--will-payload <will_payload>]
            [--will-qos [<will_qos>]]
            [--will-retain [<will_retain>]]
            [--enable-websocket [<enable_websocket>]]
            [--enable-ssl [<enable_ssl>]]
            [--tls-version [<tls_version>]]
            [--CAfile <cafile>] [--cert <cert>]
            [--key <key>]
            [--retain-as-publish [<retain_as_publish>]]
            [--retain-handling [<retain_handling>]]

Options

-h, --host

  See also --host.

-p, --port

  See also --port.

-I, --iface

  See also --iface.

-V, --protocol-version

  See also --protocol-version.

-u, --username

  See also --username.

-P, --password

  See also --password.

-C, --clientid

  See also --clientid.

-k, --keepalive

  See also --keepalive.

-t, --topic

  Specify the MQTT topic you want to subscribe to. This is a required option.

-q, --qos

  Specify the maximum qos level at which the broker can send application messages to the client. Defaults to 0.

--retain-as-publish

  Specify the Retain As Publish option in subscription options. Defaults to 0.

--retain-handling

  Specify the Retain Handling option in subscription options. Defaults to 0.

--will-topic

  See also --will-topic.

--will-qos

  See also --will-qos.

--will-retain

  See also --will-retain.

--will-payload

  See also --will-payload.

--enable-websocket

  See also --enable-websocket.

--enable-ssl

  See also --enable-ssl.

--tls-version

  See also --tls-version.

--CAfile

  See also --CAfile.

--cert

  See also --cert.

--key

  See also --key.

Examples

Build Non-shared Subscription and Recv "hello world"

$ ./emqtt sub -t "hello"
Client emqtt-zhouzibodeMacBook-Pro-1686fee6fdb99f674f2c sent CONNECT
Client emqtt-zhouzibodeMacBook-Pro-1686fee6fdb99f674f2c subscribed to hello
hello world

Build Shared Subscription and Recv "hello world"

$ ./emqtt sub -t '$share/group/hello'
Client emqtt-zhouzibodeMacBook-Pro-288e65bb3f4013d30249 sent CONNECT
Client emqtt-zhouzibodeMacBook-Pro-288e65bb3f4013d30249 subscribed to $share/group/hello
hello world

As a Dependency Library

Add to rebar3 project

Add to rebar.config

...
{deps, [{emqtt, {git, "https://github.com/emqx/emqtt", {tag, "v1.2.0"}}}]}.
...

Build

$ rebar3 compile

Data Types

option()

option() = {name, atom()} |
           {owner, pid()} |
           {host, host()} |
           {port, inet:port_number()} |
           {tcp_opts, [gen_tcp:option()]} |
           {ssl, boolean()} |
           {ssl_opts, [ssl:ssl_option()]} |
           {ws_path, string()} |
           {connect_timeout, pos_integer()} |
           {bridge_mode, boolean()} |
           {clientid, iodata()} |
           {clean_start, boolean()} |
           {username, iodata()} |
           {password, iodata()} |
           {proto_ver, v3 | v4 | v5} |
           {keepalive, non_neg_integer()} |
           {max_inflight, pos_integer()} |
           {retry_interval, pos_integer()} |
           {will_topic, iodata()} |
           {will_payload, iodate()} |
           {will_retain, boolean()} |
           {will_qos, qos()} |
           {will_props, properties()} |
           {auto_ack, boolean()} |
           {ack_timeout, pos_integer()} |
           {force_ping, boolean()} |
           {properties, properties()}

client()

client() = pid() | atom()

host()

host() = inet:ip_address() | inet:hostname()

properties()

properties() = #{'Payload-Format-Indicator' => 0..1,
                 'Message-Expiry-Interval' => 0..16#FFFFFFFF,
                 'Content-Type' => binary(),
                 'Response-Topic' => binary(),
                 'Correlation-Data' => binary(),
                 'Subscription-Identifier' => 0..16#7FFFFFFF,
                 'Session-Expiry-Interval' => 0..16#FFFFFFFF,
                 'Assigned-Client-Identifier' => binary(),
                 'Server-Keep-Alive' => 0..16#FFFF,
                 'Authentication-Method' => binary(),
                 'Authentication-Data' => binary(),
                 'Request-Problem-Information' => 0..1,
                 'Will-Delay-Interval' => 0..16#FFFFFFFF,
                 'Request-Response-Information' => 0..1,
                 'Response-Information' => binary(),
                 'Server-Reference' => binary(),
                 'Reason-String' => binary(),
                 'Receive-Maximum' => 1..16#FFFF,
                 'Topic-Alias-Maximum' => 0..16#FFFF,
                 'Topic-Alias' => 1..16#FFFF,
                 'Maximum-QoS' => 0..1,
                 'Retain-Available' => 0..1,
                 'User-Property' => [{binary(), binary()}],
                 'Maximum-Packet-Size' => 1..16#FFFFFFFF,
                 'Wildcard-Subscription-Available' => 0..1,
                 'Subscription-Identifier-Available' => 0..1,
                 'Shared-Subscription-Available' => 0..1}

qos()

qos() = 0 | 1 | 2

qos_name()

qos_name() = qos0 | at_most_once |
             qos1 | at_least_once |
             qos2 | exactly_once

topic()

topic() = binary()

payload()

payload() = iodata()

packet_id()

packet_id() = 0..16#FFFF

subopt()

subopt() = {rh, 0 | 1 | 2} |
           {rap, boolean()} |
           {nl, boolean()} |
           {qos, qos() | qos_name()}

pubopt()

pubopt() = {retain, boolean()} |
           {qos, qos() | qos_name()}

reason_code()

reason_code() = 0..16#FF

Exports

emqtt:start_link() -> {ok, Pid} | ignore | {error, Reason}

emqtt:start_link(Options) -> {ok, Pid} | ignore | {error, Reason}

  Types

    Pid = pid()

    Reason = term()

    Options = [option()]

Start MQTT client process with specified options. Options will be used in connecting and running.

The following options are available:

{name, Name}

If a name is provided, the gen_statem will be registered with this name. For details see the documentation for the first argument of gen_statem:start_link/4.

{owner, Pid}

Client process will send messages like {diconnected, ReasonCode, Properties} to the owner process.

{host, Host}

The host of the MQTT server to be connected. Host can be a hostname or an IP address. Defaults to localhost

{port, Port}

The port of the MQTT server to be connected. If not given, the default of 1883 for MQTT or 8883 for MQTT over TLS will be used.

{tcp_opts, Options}

Additional options for gen_tcp:connect/3.

{ssl, boolean()}

Enable SSL/TLS transport or not. Defaults to false.

{ssl_opts, Options}

Additional options for ssl:connect/3.

{ws_path, Path}

Path to the resource. Defaults to /mqtt

{connect_timeout, Timeout}

The maximum time to wait to connect to the server and the server returns a CONNACK. Defaults to 60s.

{bridge_mode, boolean()}

Enable bridge mode or not. Defaults to false.

{clientid, ClientID}

Specify the client identifier. If not given, the client identifier will use the value assigned by the server in MQTT v5 or be automatically generated by internal code in MQTT v3.1/v3.1.1.

{clean_start, CleanStart}

Whether the server should discard any existing session and start a new session. Defaults to true.

{username, Username}

Username used by the server for authentication and authorization.

{password, Password}

Password used by the server for authentication and authorization.

{proto_ver, ProtocolVersion}

MQTT protocol version. Defaults to v4.

{keepalive, Keepalive}

Maximum time interval that is permitted to elapse between the point at which the Client finishes transmitting one MQTT Control Packet and the point it starts sending the next. It will be replaced by server keep alive returned from MQTT server.

{max_inflight, MaxInflight}

Max number of QoS 1 and QoS 2 packets in flight. In other words, the number of packets that were sent but not yet acked. Defaults to infinity, means no limit.

{retry_interval, RetryInterval}

Interval to retry sending packets that have been sent but not received a response. Defaults to 30s.

{will_topic, WillTopic}

Topic of will message.

{will_payload, WillPayload}

Payload of will message.

{will_retain, WillRetain}

Whether the server should publish the will message as a retained message. Defaults to false.

{will_qos, WillQoS}

QoS of will message. Defaults to 0.

{will_props, WillProperties}

Properties of will message.

{auto_ack, boolean()}

If true (the default), cliean process will automatically send ack packet like PUBACK when it receives a packet from the server. If false, application decides what to do.

{ack_timeout, AckTimeout}

Maximum time to wait for a reply message. Defaults to 30s.

{force_ping, boolean()}

If false (the default), if any other packet is sent during keep alive interval, the ping packet will not be sent this time. If true, the ping packet will be sent every time.

{properties, Properties}

Properties of CONNECT packet.

emqtt:connect(Client) -> {ok, Properties} | {error, Reason}

  Types

    Client = client()

    Properties = properties()

    Reason = timeout | inet:posix() | any()

Connect to the MQTT server over TCP or TLS and send a CONNECT packet with the options specified in start_link/1, 2. Client must be a pid returned from start_link/1, 2 or a name specified in start_link/1, 2.

Returns:

  • {ok, Properties} if a MQTT connection is established. Properties is propterties in CONNACK packet returned from MQTT server.

  • {error, timeout} if connection can't be established within the specified time

  • {error, inet:posix()} A POSIX error value if something else goes wrong.

emqtt:ws_connect(Client) -> {ok, Properties} | {error, Reason}

  Types

    Same as emqtt:connect/1

Connect to the MQTT server over Websocket and send a CONNECT packet with the options specified in start_link/1, 2. Client must be a pid returned from start_link/1, 2 or a name specified in start_link/1, 2.

emqtt:disconnect(Client) -> ok | {error, Reason}

emqtt:disconnect(Client, ReasonCode) -> ok | {error, Reason}

emqtt:disconnect(Client, ReasonCode, Properties) -> ok | {error, Reason}

  Types

    Client = client()

    ReasonCode = reason_code()

    Properties = properties()

    Reason = closed | inet:posix()

Send a DISCONNECT packet to the MQTT server. ReasonCode specifies a MQTT reason code for DISCONNECT packet, defaults to 0 meaning normal disconnection. Properties specifies properties for DISCONNECT packet, defaults to #{} meaning no properties are attached.

emqtt:ping(Client) -> pong | {error, Reason}

  Types

    Client = client()

    Reason = ack_timeout

Send a PINGREQ packet to the MQTT server. If PINGRESP packet is received from the server within the timeout period, pong is returned. If not, {error, ack_timeout} is returned.

emqtt:subscribe(Client, Properties, Subscriptions) -> {ok, Properties, ReasonCodes} | {error, Reason})

  Types

    Client = client()

    Properties = properties()

    Subscriptions = [{topic(), [subopt()]}]

    ReasonCodes = [reason_code()]

    Reason = term()

Send a SUBSCRIBE packet to the MQTT server. Properties specifies properties for SUBSCRIBE packet, defaults to #{} meaning no properties are attached. Subscriptions specifies pairs of topic filter and subscription options. The topic filter is requried, the subscription options can be [], equivalent to [{rh, 0}, {rap, 0}, {nl, 0}, {qos, 0}].

emqtt:unsubscribe(Client, Properties, Topics) -> {ok, Properties, ReasonCodes} | {error, Reason})

  Types

    Client = client()

    Properties = properties()

    Topics = [topic()]

    ReasonCodes = [reason_code()]

    Reason = term()

Send a UNSUBSCRIBE packet to the MQTT server. Properties specifies properties for SUBSCRIBE packet, defaults to #{} meaning no properties are attached. Topics specifies a list of topic filter with at least one topic filter.

emqtt:publish(Client, Topic, Properties, Payload, PubOpts) -> ok | {ok, PacketId} | {error, Reason})

  Types

    Client = client()

    Topic = topic()

    Properties = properties()

    Payload = payload()

    PubOpts = [pubopt()]

    PacketId = packet_id()

    Reason = term()

Send a PUBLISH packet to the MQTT server. Topic, Properties and Payload specify topic, properties and payload for PUBLISH packet. PubOpts specifies qos and retain flag for PUBLISH packet, defaults to [], equivalent to [{qos, 0}, {retain, false}].

Returns:

  • ok Ii a QoS 0 packet is sent.

  • {ok, PacketId} if a QoS 1/2 packet is sent, the packet identifier will be returned.

  • {error, Reason} if something goes wrong.

emqtt:puback(Client, PacketId) -> ok

emqtt:puback(Client, PacketId, ReasonCode) -> ok

emqtt:puback(Client, PacketId, ReasonCode, Properties) -> ok

  Types

    Client = client()

    PacketId = packet_id()

    ReasonCode = reason_code()

    Properties = properties()

Send a PUBACK packet to the MQTT server. PacketId, ReasonCode and Properties specify packet identifier, reason code and properties for PUBACK packet.

emqtt:pubrec(Client, PacketId) -> ok

emqtt:pubrec(Client, PacketId, ReasonCode) -> ok

emqtt:pubrec(Client, PacketId, ReasonCode, Properties) -> ok

  Types

    Same as emqtt:puback/2, 3, 4.

Send a PUBREC packet to the MQTT server. PacketId, ReasonCode and Properties specify packet identifier, reason code and properties for PUBREC packet.

emqtt:pubrel(Client, PacketId) -> ok

emqtt:pubrel(Client, PacketId, ReasonCode) -> ok

emqtt:pubrel(Client, PacketId, ReasonCode, Properties) -> ok

  Types

    Same as emqtt:puback/2, 3, 4.

Send a PUBREL packet to the MQTT server. PacketId, ReasonCode and Properties specify packet identifier, reason code and properties for PUBREL packet.

emqtt:pubcomp(Client, PacketId) -> ok

emqtt:pubcomp(Client, PacketId, ReasonCode) -> ok

emqtt:pubcomp(Client, PacketId, ReasonCode, Properties) -> ok

  Types

    Same as emqtt:puback/2, 3, 4.

Send a PUBCOMP packet to the MQTT server. PacketId, ReasonCode and Properties specify packet identifier, reason code and properties for PUBCOMP packet.

emqtt:subscriptions(Client) -> Subscriptions

  Types

    Client = client()

    Subscriptions = [{topic(), [subopt()]}]

Return all subscriptions.

emqtt:stop(Client) -> ok

  Types

    Client = client()

Stop a client process.

emqtt:pause(Client) -> ok

  Types

    Client = client()

Pause the client process. The paused client process will ignore all PUBLISH packets received and not send PINGREQ packet if force_ping is set to false.

emqtt:resume(Client) -> ok

  Types

    Client = client()

Resume a client process from a paused state.

Examples

{ok, ConnPid} = emqtt:start_link([{clientid, ClientId}]).
{ok, _Props} = emqtt:connect(ConnPid).

SubOpts = [{qos, 1}].
{ok, _Props, _ReasonCodes} = emqtt:subscribe(ConnPid, #{}, [{<<"hello">>, SubOpts}]).

ok = emqtt:publish(ConnPid, <<"hello">>, #{}, <<"Hello World!">>, [{qos, 0}]).
{ok, _PktId} = emqtt:publish(ConnPid, <<"hello">>, #{}, <<"Hello World!">>, [{qos, 1}]).

receive
    {disconnect, ReasonCode, Properties} ->
        io:format("Recv a DISONNECT packet - ReasonCode: ~p, Properties: ~p~n", [ReasonCode, Properties]);
    {publish, PUBLISH} ->
        io:format("Recv a PUBLISH packet: ~p~n", [PUBLISH]);
    {puback, {PacketId, ReasonCode, Properties}} ->
        io:format("Recv a PUBACK packet - PacketId: ~p, ReasonCode: ~p, Properties: ~p~n", [PacketId, ReasonCode, Properties])
end.

{ok, _Props, _ReasonCode} = emqtt:unsubscribe(ConnPid, #{}, <<"hello">]).

ok = emqtt:disconnect(ConnPid).
ok = emqtt:stop(ConnPid).

License

Apache License Version 2.0

Author

EMQ X Team.

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS Copyright 2019, Anonymous <anonymous@example.org>. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

简介

Erlang MQTT v5.0 Client 展开 收起
Erlang
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Erlang
1
https://gitee.com/jjzhang166/emqtt.git
git@gitee.com:jjzhang166/emqtt.git
jjzhang166
emqtt
emqtt
master

搜索帮助