refactor: split out emqx_coap application

This commit is contained in:
JianBo He 2023-03-30 15:21:42 +08:00
parent 786f030958
commit 0b6c5c4c91
34 changed files with 448 additions and 195 deletions

19
apps/emqx_coap/.gitignore vendored Normal file
View File

@ -0,0 +1,19 @@
.rebar3
_*
.eunit
*.o
*.beam
*.plt
*.swp
*.swo
.erlang.cookie
ebin
log
erl_crash.dump
.rebar
logs
_build
.idea
*.iml
rebar3.crashdump
*~

191
apps/emqx_coap/LICENSE Normal file
View File

@ -0,0 +1,191 @@
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 2023, JianBo He <heeejianbo@gmail.com>.
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.

View File

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

Before

Width:  |  Height:  |  Size: 148 KiB

After

Width:  |  Height:  |  Size: 148 KiB

View File

@ -0,0 +1,80 @@
emqx_coap_schema {
coap {
desc {
en: """The CoAP Gateway configuration.
This gateway is implemented based on RFC-7252 and https://core-wg.github.io/coap-pubsub/draft-ietf-core-pubsub.html"""
zh: """CoAP 网关配置。
该网关的实现基于 RFC-7252 和 https://core-wg.github.io/coap-pubsub/draft-ietf-core-pubsub.html"""
}
}
coap_heartbeat {
desc {
en: """The gateway server required minimum heartbeat interval.
When connection mode is enabled, this parameter is used to set the minimum heartbeat interval for the connection to be alive"""
zh: """CoAP 网关要求客户端的最小心跳间隔时间。
当 <code>connection_required</code> 开启后,该参数用于检查客户端连接是否存活"""
}
}
coap_connection_required {
desc {
en: """Enable or disable connection mode.
Connection mode is a feature of non-standard protocols. When connection mode is enabled, it is necessary to maintain the creation, authentication and alive of connection resources"""
zh: """是否开启连接模式。
连接模式是非标准协议的功能。它维护 CoAP 客户端上线、认证、和连接状态的保持"""
}
}
coap_notify_type {
desc {
en: """The Notification Message will be delivered to the CoAP client if a new message received on an observed topic.
The type of delivered coap message can be set to:<br/>
- non: Non-confirmable;<br/>
- con: Confirmable;<br/>
- qos: Mapping from QoS type of received message, QoS0 -> non, QoS1,2 -> con"""
zh: """投递给 CoAP 客户端的通知消息类型。当客户端 Observe 一个资源(或订阅某个主题)时,网关会向客户端推送新产生的消息。其消息类型可设置为:<br/>
- non: 不需要客户端返回确认消息;<br/>
- con: 需要客户端返回一个确认消息;<br/>
- qos: 取决于消息的 QoS 等级; QoS 0 会以 `non` 类型下发QoS 1/2 会以 `con` 类型下发"""
}
}
coap_subscribe_qos {
desc {
en: """The Default QoS Level indicator for subscribe request.
This option specifies the QoS level for the CoAP Client when establishing a subscription membership, if the subscribe request is not carried `qos` option. The indicator can be set to:<br/>
- qos0, qos1, qos2: Fixed default QoS level<br/>
- coap: Dynamic QoS level by the message type of subscribe request<br/>
* qos0: If the subscribe request is non-confirmable<br/>
* qos1: If the subscribe request is confirmable"""
zh: """客户端订阅请求的默认 QoS 等级。
当 CoAP 客户端发起订阅请求时,如果未携带 `qos` 参数则会使用该默认值。默认值可设置为:<br/>
- qos0、 qos1、qos2: 设置为固定的 QoS 等级<br/>
- coap: 依据订阅操作的 CoAP 报文类型来动态决定<br/>
* 当订阅请求为 `non-confirmable` 类型时,取值为 qos0<br/>
* 当订阅请求为 `confirmable` 类型时,取值为 qos1"""
}
}
coap_publish_qos {
desc {
en: """The Default QoS Level indicator for publish request.
This option specifies the QoS level for the CoAP Client when publishing a message to EMQX PUB/SUB system, if the publish request is not carried `qos` option. The indicator can be set to:<br/>
- qos0, qos1, qos2: Fixed default QoS level<br/>
- coap: Dynamic QoS level by the message type of publish request<br/>
* qos0: If the publish request is non-confirmable<br/>
* qos1: If the publish request is confirmable"""
zh: """客户端发布请求的默认 QoS 等级。
当 CoAP 客户端发起发布请求时,如果未携带 `qos` 参数则会使用该默认值。默认值可设置为:<br>
- qos0、qos1、qos2: 设置为固定的 QoS 等级<br/>
- coap: 依据发布操作的 CoAP 报文类型来动态决定<br/>
* 当发布请求为 `non-confirmable` 类型时,取值为 qos0<br/>
* 当发布请求为 `confirmable` 类型时,取值为 qos1"""
}
}
}

View File

@ -0,0 +1,2 @@
{erl_opts, [debug_info]}.
{deps, []}.

View File

@ -0,0 +1,10 @@
{application, emqx_coap, [
{description, "CoAP Gateway"},
{vsn, "0.1.0"},
{registered, []},
{applications, [kernel, stdlib]},
{env, []},
{modules, []},
{licenses, ["Apache 2.0"]},
{links, []}
]}.

View File

@ -14,13 +14,29 @@
%% limitations under the License.
%%--------------------------------------------------------------------
-module(emqx_coap_impl).
-behaviour(emqx_gateway_impl).
%% @doc The CoAP Gateway implement
-module(emqx_coap).
-include_lib("emqx/include/logger.hrl").
-include_lib("emqx_gateway/include/emqx_gateway.hrl").
%% define a gateway named stomp
-gateway(#{
name => coap,
callback_module => ?MODULE,
config_schema_module => emqx_coap_schema
}).
%% callback_module must implement the emqx_gateway_impl behaviour
-behaviour(emqx_gateway_impl).
%% callback for emqx_gateway_impl
-export([
on_gateway_load/2,
on_gateway_update/3,
on_gateway_unload/2
]).
-import(
emqx_gateway_utils,
[
@ -30,31 +46,8 @@
]
).
%% APIs
-export([
reg/0,
unreg/0
]).
-export([
on_gateway_load/2,
on_gateway_update/3,
on_gateway_unload/2
]).
%%--------------------------------------------------------------------
%% APIs
%%--------------------------------------------------------------------
reg() ->
RegistryOptions = [{cbkmod, ?MODULE}],
emqx_gateway_registry:reg(coap, RegistryOptions).
unreg() ->
emqx_gateway_registry:unreg(coap).
%%--------------------------------------------------------------------
%% emqx_gateway_registry callbacks
%% emqx_gateway_impl callbacks
%%--------------------------------------------------------------------
on_gateway_load(

View File

@ -18,10 +18,10 @@
-behaviour(minirest_api).
-include("emqx_coap.hrl").
-include_lib("hocon/include/hoconsc.hrl").
-include_lib("typerefl/include/types.hrl").
-include_lib("emqx/include/logger.hrl").
-include("src/coap/include/emqx_coap.hrl").
%% API
-export([api_spec/0, paths/0, schema/1, namespace/0]).

View File

@ -45,8 +45,8 @@
-export_type([channel/0]).
-include("emqx_coap.hrl").
-include_lib("emqx/include/logger.hrl").
-include("src/coap/include/emqx_coap.hrl").
-include_lib("emqx/include/emqx_authentication.hrl").
-define(AUTHN, ?EMQX_AUTHENTICATION_CONFIG_ROOT_NAME_ATOM).

View File

@ -29,7 +29,7 @@
is_message/1
]).
-include("src/coap/include/emqx_coap.hrl").
-include("emqx_coap.hrl").
-include_lib("emqx/include/types.hrl").
-define(VERSION, 1).

View File

@ -20,7 +20,7 @@
-module(emqx_coap_medium).
-include("src/coap/include/emqx_coap.hrl").
-include("emqx_coap.hrl").
%% API
-export([

View File

@ -43,7 +43,7 @@
set_payload_block/3, set_payload_block/4
]).
-include("src/coap/include/emqx_coap.hrl").
-include("emqx_coap.hrl").
request(Type, Method) ->
request(Type, Method, <<>>, []).

View File

@ -16,7 +16,7 @@
-module(emqx_coap_mqtt_handler).
-include("src/coap/include/emqx_coap.hrl").
-include("emqx_coap.hrl").
-export([handle_request/4]).
-import(emqx_coap_message, [response/2, response/3]).

View File

@ -18,7 +18,7 @@
-module(emqx_coap_pubsub_handler).
-include_lib("emqx/include/emqx_mqtt.hrl").
-include("src/coap/include/emqx_coap.hrl").
-include("emqx_coap.hrl").
-export([handle_request/4]).

View File

@ -0,0 +1,95 @@
%%--------------------------------------------------------------------
%% Copyright (c) 2023 EMQ Technologies Co., Ltd. All Rights Reserved.
%%
%% 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.
%%--------------------------------------------------------------------
-module(emqx_coap_schema).
-include_lib("hocon/include/hoconsc.hrl").
-include_lib("typerefl/include/types.hrl").
-type duration() :: non_neg_integer().
-typerefl_from_string({duration/0, emqx_schema, to_duration}).
-reflect_type([duration/0]).
%% config schema provides
-export([fields/1, desc/1]).
fields(coap) ->
[
{heartbeat,
sc(
duration(),
#{
default => <<"30s">>,
desc => ?DESC(coap_heartbeat)
}
)},
{connection_required,
sc(
boolean(),
#{
default => false,
desc => ?DESC(coap_connection_required)
}
)},
{notify_type,
sc(
hoconsc:enum([non, con, qos]),
#{
default => qos,
desc => ?DESC(coap_notify_type)
}
)},
{subscribe_qos,
sc(
hoconsc:enum([qos0, qos1, qos2, coap]),
#{
default => coap,
desc => ?DESC(coap_subscribe_qos)
}
)},
{publish_qos,
sc(
hoconsc:enum([qos0, qos1, qos2, coap]),
#{
default => coap,
desc => ?DESC(coap_publish_qos)
}
)},
{mountpoint, emqx_gateway_schema:mountpoint()},
{listeners,
sc(
ref(emqx_gateway_schema, udp_listeners),
#{desc => ?DESC(udp_listeners)}
)}
] ++ emqx_gateway_schema:gateway_common_options().
desc(coap) ->
"The CoAP protocol gateway provides EMQX with the access capability of the CoAP protocol.\n"
"It allows publishing, subscribing, and receiving messages to EMQX in accordance\n"
"with a certain defined CoAP message format.";
desc(_) ->
undefined.
%%--------------------------------------------------------------------
%% helpers
sc(Type, Meta) ->
hoconsc:mk(Type, Meta).
ref(Mod, Field) ->
hoconsc:ref(Mod, Field).

View File

@ -15,10 +15,10 @@
%%--------------------------------------------------------------------
-module(emqx_coap_session).
-include("emqx_coap.hrl").
-include_lib("emqx/include/emqx.hrl").
-include_lib("emqx/include/emqx_mqtt.hrl").
-include_lib("emqx/include/logger.hrl").
-include("src/coap/include/emqx_coap.hrl").
%% API
-export([

View File

@ -29,8 +29,8 @@
-export_type([manager/0, event_result/1]).
-include("emqx_coap.hrl").
-include_lib("emqx/include/logger.hrl").
-include("src/coap/include/emqx_coap.hrl").
-type direction() :: in | out.

View File

@ -16,8 +16,8 @@
-module(emqx_coap_transport).
-include("emqx_coap.hrl").
-include_lib("emqx/include/logger.hrl").
-include("src/coap/include/emqx_coap.hrl").
-define(ACK_TIMEOUT, 2000).
-define(ACK_RANDOM_FACTOR, 1000).

View File

@ -56,6 +56,7 @@
all() -> emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) ->
application:load(emqx_coap),
ok = emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_mgmt_api_test_util:init_suite([emqx_authn, emqx_gateway]),
ok = meck:new(emqx_access_control, [passthrough, no_history, no_link]),

View File

@ -19,7 +19,7 @@
-compile(export_all).
-compile(nowarn_export_all).
-include("src/coap/include/emqx_coap.hrl").
-include("emqx_coap.hrl").
-include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl").
@ -56,6 +56,7 @@ all() ->
emqx_common_test_helpers:all(?MODULE).
init_per_suite(Config) ->
application:load(emqx_coap),
ok = emqx_common_test_helpers:load_config(emqx_gateway_schema, ?CONF_DEFAULT),
emqx_mgmt_api_test_util:init_suite([emqx_authn, emqx_gateway]),
Config.

View File

@ -1,82 +1,5 @@
emqx_gateway_schema {
coap {
desc {
en: """The CoAP Gateway configuration.
This gateway is implemented based on RFC-7252 and https://core-wg.github.io/coap-pubsub/draft-ietf-core-pubsub.html"""
zh: """CoAP 网关配置。
该网关的实现基于 RFC-7252 和 https://core-wg.github.io/coap-pubsub/draft-ietf-core-pubsub.html"""
}
}
coap_heartbeat {
desc {
en: """The gateway server required minimum heartbeat interval.
When connection mode is enabled, this parameter is used to set the minimum heartbeat interval for the connection to be alive"""
zh: """CoAP 网关要求客户端的最小心跳间隔时间。
当 <code>connection_required</code> 开启后,该参数用于检查客户端连接是否存活"""
}
}
coap_connection_required {
desc {
en: """Enable or disable connection mode.
Connection mode is a feature of non-standard protocols. When connection mode is enabled, it is necessary to maintain the creation, authentication and alive of connection resources"""
zh: """是否开启连接模式。
连接模式是非标准协议的功能。它维护 CoAP 客户端上线、认证、和连接状态的保持"""
}
}
coap_notify_type {
desc {
en: """The Notification Message will be delivered to the CoAP client if a new message received on an observed topic.
The type of delivered coap message can be set to:<br/>
- non: Non-confirmable;<br/>
- con: Confirmable;<br/>
- qos: Mapping from QoS type of received message, QoS0 -> non, QoS1,2 -> con"""
zh: """投递给 CoAP 客户端的通知消息类型。当客户端 Observe 一个资源(或订阅某个主题)时,网关会向客户端推送新产生的消息。其消息类型可设置为:<br/>
- non: 不需要客户端返回确认消息;<br/>
- con: 需要客户端返回一个确认消息;<br/>
- qos: 取决于消息的 QoS 等级; QoS 0 会以 `non` 类型下发QoS 1/2 会以 `con` 类型下发"""
}
}
coap_subscribe_qos {
desc {
en: """The Default QoS Level indicator for subscribe request.
This option specifies the QoS level for the CoAP Client when establishing a subscription membership, if the subscribe request is not carried `qos` option. The indicator can be set to:<br/>
- qos0, qos1, qos2: Fixed default QoS level<br/>
- coap: Dynamic QoS level by the message type of subscribe request<br/>
* qos0: If the subscribe request is non-confirmable<br/>
* qos1: If the subscribe request is confirmable"""
zh: """客户端订阅请求的默认 QoS 等级。
当 CoAP 客户端发起订阅请求时,如果未携带 `qos` 参数则会使用该默认值。默认值可设置为:<br/>
- qos0、 qos1、qos2: 设置为固定的 QoS 等级<br/>
- coap: 依据订阅操作的 CoAP 报文类型来动态决定<br/>
* 当订阅请求为 `non-confirmable` 类型时,取值为 qos0<br/>
* 当订阅请求为 `confirmable` 类型时,取值为 qos1"""
}
}
coap_publish_qos {
desc {
en: """The Default QoS Level indicator for publish request.
This option specifies the QoS level for the CoAP Client when publishing a message to EMQX PUB/SUB system, if the publish request is not carried `qos` option. The indicator can be set to:<br/>
- qos0, qos1, qos2: Fixed default QoS level<br/>
- coap: Dynamic QoS level by the message type of publish request<br/>
* qos0: If the publish request is non-confirmable<br/>
* qos1: If the publish request is confirmable"""
zh: """客户端发布请求的默认 QoS 等级。
当 CoAP 客户端发起发布请求时,如果未携带 `qos` 参数则会使用该默认值。默认值可设置为:<br>
- qos0、qos1、qos2: 设置为固定的 QoS 等级<br/>
- coap: 依据发布操作的 CoAP 报文类型来动态决定<br/>
* 当发布请求为 `non-confirmable` 类型时,取值为 qos0<br/>
* 当发布请求为 `confirmable` 类型时,取值为 qos1"""
}
}
lwm2m {
desc {
en: """The LwM2M Gateway configuration. This gateway only supports the v1.0.1 protocol."""

View File

@ -47,11 +47,6 @@ load_default_gateway_applications() ->
callback_module => emqx_lwm2m_impl,
config_schema_module => emqx_lwm2m_schema
},
#{
name => coap,
callback_module => emqx_coap_impl,
config_schema_module => emqx_gateway_schema
},
#{
name => exproto,
callback_module => emqx_exproto_impl,

View File

@ -64,14 +64,6 @@ roots() -> [gateway].
fields(gateway) ->
[
{coap,
sc(
ref(coap),
#{
required => {false, recursively},
desc => ?DESC(coap)
}
)},
{lwm2m,
sc(
ref(lwm2m),
@ -89,55 +81,6 @@ fields(gateway) ->
}
)}
] ++ gateway_schemas();
fields(coap) ->
[
{heartbeat,
sc(
duration(),
#{
default => <<"30s">>,
desc => ?DESC(coap_heartbeat)
}
)},
{connection_required,
sc(
boolean(),
#{
default => false,
desc => ?DESC(coap_connection_required)
}
)},
{notify_type,
sc(
hoconsc:enum([non, con, qos]),
#{
default => qos,
desc => ?DESC(coap_notify_type)
}
)},
{subscribe_qos,
sc(
hoconsc:enum([qos0, qos1, qos2, coap]),
#{
default => coap,
desc => ?DESC(coap_subscribe_qos)
}
)},
{publish_qos,
sc(
hoconsc:enum([qos0, qos1, qos2, coap]),
#{
default => coap,
desc => ?DESC(coap_publish_qos)
}
)},
{mountpoint, mountpoint()},
{listeners,
sc(
ref(udp_listeners),
#{desc => ?DESC(udp_listeners)}
)}
] ++ gateway_common_options();
fields(lwm2m) ->
[
{xml_dir,
@ -413,10 +356,6 @@ fields(dtls_opts) ->
desc(gateway) ->
"EMQX Gateway configuration root.";
desc(coap) ->
"The CoAP protocol gateway provides EMQX with the access capability of the CoAP protocol.\n"
"It allows publishing, subscribing, and receiving messages to EMQX in accordance\n"
"with a certain defined CoAP message format.";
desc(lwm2m) ->
"The LwM2M protocol gateway.";
desc(exproto) ->
@ -597,11 +536,11 @@ proxy_protocol_opts() ->
%% dynamic schemas
%% FIXME: don't hardcode the gateway names
gateway_schema(coap) -> fields(coap);
gateway_schema(lwm2m) -> fields(lwm2m);
gateway_schema(exproto) -> fields(exproto);
gateway_schema(stomp) -> emqx_stomp_schema:fields(stomp);
gateway_schema(mqttsn) -> emqx_mqttsn_schema:fields(mqttsn).
gateway_schema(mqttsn) -> emqx_mqttsn_schema:fields(mqttsn);
gateway_schema(coap) -> emqx_coap_schema:fields(coap).
gateway_schemas() ->
lists:map(

View File

@ -1,10 +1,10 @@
{application, emqx_mqttsn,
[{description, "MQTT-SN Gateway"},
{vsn, "0.1.0"},
{registered, []},
{applications, [kernel, stdlib]},
{env,[]},
{modules, []},
{licenses, ["Apache 2.0"]},
{links, []}
]}.
{application, emqx_mqttsn, [
{description, "MQTT-SN Gateway"},
{vsn, "0.1.0"},
{registered, []},
{applications, [kernel, stdlib]},
{env, []},
{modules, []},
{licenses, ["Apache 2.0"]},
{links, []}
]}.

View File

@ -1,5 +1,5 @@
{application, emqx_stomp, [
{description, "Stomp gateway"},
{description, "Stomp Gateway"},
{vsn, "0.1.0"},
{registered, []},
{applications, [kernel, stdlib]},

View File

@ -14,7 +14,7 @@
%% limitations under the License.
%%--------------------------------------------------------------------
%% @doc The Stomp Gateway implement interface
%% @doc The Stomp Gateway implement
-module(emqx_stomp).
-include_lib("emqx/include/logger.hrl").

View File

@ -281,6 +281,9 @@ defmodule EMQXUmbrella.MixProject do
emqx_authz: :permanent,
emqx_auto_subscribe: :permanent,
emqx_gateway: :permanent,
emqx_stomp: :permanent,
emqx_mqttsn: :permanent,
emqx_coap: :permanent,
emqx_exhook: :permanent,
emqx_bridge: :permanent,
emqx_rule_engine: :permanent,

View File

@ -391,6 +391,7 @@ relx_apps(ReleaseType, Edition) ->
emqx_gateway,
emqx_stomp,
emqx_mqttsn,
emqx_coap,
emqx_exhook,
emqx_bridge,
emqx_rule_engine,