Merge pull request #5470 from lafirest/fix/emqx_coap
fix(emqx_gateway): fix some error in README and code
This commit is contained in:
commit
e80d95bd76
|
@ -38,7 +38,7 @@ gateway: {
|
|||
}
|
||||
|
||||
coap.1: {
|
||||
enable_stats: false
|
||||
enable_stats: false
|
||||
|
||||
authentication: {
|
||||
enable: true
|
||||
|
@ -52,16 +52,16 @@ gateway: {
|
|||
]
|
||||
}
|
||||
|
||||
#authentication.enable: false
|
||||
#authentication.enable: false
|
||||
|
||||
heartbeat: 30s
|
||||
notify_type: qos
|
||||
subscribe_qos: qos0
|
||||
publish_qos: qos1
|
||||
listener.udp.1: {
|
||||
bind: 5683
|
||||
heartbeat: 30s
|
||||
notify_type: qos
|
||||
subscribe_qos: qos0
|
||||
publish_qos: qos1
|
||||
listener.udp.1: {
|
||||
bind: 5683
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mqttsn.1: {
|
||||
## The MQTT-SN Gateway ID in ADVERTISE message.
|
||||
|
|
|
@ -108,10 +108,10 @@ The server manages the client through the ClientId. If the ClientId is wrong, EM
|
|||
1. Create a Connection
|
||||
|
||||
Method: POST
|
||||
URI Schema: mqtt/{+topic}{?q\*}
|
||||
URI Schema: mqtt/connection{?q\*}
|
||||
q\*:
|
||||
|
||||
- clientId := client uid
|
||||
- clientid := client uid
|
||||
- username
|
||||
- password
|
||||
|
||||
|
@ -126,10 +126,10 @@ The server manages the client through the ClientId. If the ClientId is wrong, EM
|
|||
2. Close a Connection
|
||||
|
||||
Method : DELETE
|
||||
URI Schema: mqtt/{+topic}{?q\*}
|
||||
URI Schema: mqtt/connection{?q\*}
|
||||
q\*:
|
||||
|
||||
- clientId := client uid
|
||||
- clientid := client uid
|
||||
- token
|
||||
|
||||
Resonse:
|
||||
|
@ -143,12 +143,14 @@ The server manages the client through the ClientId. If the ClientId is wrong, EM
|
|||
|
||||
### Heartbeat
|
||||
|
||||
The Coap client can maintain the "connection" with the server through the heartbeat (regardless of whether it is authenticated or not), so that the server will not release related resources
|
||||
The Coap client can maintain the "connection" with the server through the heartbeat,
|
||||
regardless of whether it is authenticated or not,
|
||||
so that the server will not release related resources
|
||||
Method : PUT
|
||||
URI Schema: mqtt/{+topic}{?q\*}
|
||||
URI Schema: mqtt/connection{?q\*}
|
||||
q\*:
|
||||
|
||||
- clientId if authenticated
|
||||
- clientid if authenticated
|
||||
- token if authenticated
|
||||
|
||||
Response:
|
||||
|
@ -166,7 +168,7 @@ CoAP gateway uses some options in query string to conversion between MQTT CoAP.
|
|||
|
||||
1. Shared Options <a id="orgc50043b"></a>
|
||||
|
||||
- clientId
|
||||
- clientid
|
||||
- token
|
||||
|
||||
2. Connect Options
|
||||
|
@ -188,9 +190,9 @@ CoAP gateway uses some options in query string to conversion between MQTT CoAP.
|
|||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="org-left">option</th>
|
||||
<th scope="col" class="org-left">value type</th>
|
||||
<th scope="col" class="org-left">default</th>
|
||||
<th scope="col" class="org-left">Option</th>
|
||||
<th scope="col" class="org-left">Type</th>
|
||||
<th scope="col" class="org-left">Default</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
|
@ -204,7 +206,7 @@ CoAP gateway uses some options in query string to conversion between MQTT CoAP.
|
|||
|
||||
<tr>
|
||||
<td class="org-left">qos</td>
|
||||
<td class="org-left">MQTT QOS</td>
|
||||
<td class="org-left">MQTT Qos</td>
|
||||
<td class="org-left">See <a href="#org0345c3e">here</a></td>
|
||||
</tr>
|
||||
|
||||
|
@ -231,16 +233,16 @@ CoAP gateway uses some options in query string to conversion between MQTT CoAP.
|
|||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="org-left">option</th>
|
||||
<th scope="col" class="org-left">value type</th>
|
||||
<th scope="col" class="org-right">default</th>
|
||||
<th scope="col" class="org-left">Option</th>
|
||||
<th scope="col" class="org-left">Type</th>
|
||||
<th scope="col" class="org-right">Default</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="org-left">qos</td>
|
||||
<td class="org-left">MQTT QOS</td>
|
||||
<td class="org-left">MQTT Qos</td>
|
||||
<td class="org-right">See <a href="#org2325c7d">here</a></td>
|
||||
</tr>
|
||||
|
||||
|
@ -260,7 +262,7 @@ CoAP gateway uses some options in query string to conversion between MQTT CoAP.
|
|||
</tbody>
|
||||
</table>
|
||||
|
||||
5. MQTT QOS <=> CoAP non/con
|
||||
5. MQTT Qos <=> CoAP non/con
|
||||
|
||||
1.notif_type
|
||||
Control the type of notify messages when the observed object has changed.Can be:
|
||||
|
@ -268,7 +270,7 @@ CoAP gateway uses some options in query string to conversion between MQTT CoAP.
|
|||
- non
|
||||
- con
|
||||
- qos
|
||||
in this value, MQTT QOS0 -> non, QOS1/QOS2 -> con
|
||||
in this value, MQTT Qos0 -> non, Qos1/Qos2 -> con
|
||||
|
||||
2.subscribe_qos <a id="org2325c7d"></a>
|
||||
Control the qos of subscribe.Can be:
|
||||
|
@ -300,7 +302,7 @@ CoAP gateway uses some options in query string to conversion between MQTT CoAP.
|
|||
|
||||
2. Session
|
||||
|
||||
Manager the "Transport Mnager" "Observe Resouces Manger" and next message id
|
||||
Manager the "Transport Manager" "Observe Resouces Manger" and next message id
|
||||
|
||||
3. Transport Mnager
|
||||
|
||||
|
|
|
@ -148,7 +148,7 @@ get_config(Key, #exec_ctx{config = Cfg}, Def) ->
|
|||
maps:get(Key, Cfg, Def).
|
||||
|
||||
result_keys() ->
|
||||
[out, reply, connection].
|
||||
[out, connection].
|
||||
|
||||
transfer_result(From, Value, Result) ->
|
||||
?TRANSFER_RESULT(From, Value, Result).
|
||||
|
@ -289,9 +289,9 @@ handle_result(out, #{out := Out}, _, Channel) ->
|
|||
handle_result(_, _, _, Channel) ->
|
||||
{ok, Channel}.
|
||||
|
||||
check_auth_state(Method, #channel{config = Cfg} = Channel) ->
|
||||
check_auth_state(Msg, #channel{config = Cfg} = Channel) ->
|
||||
#{authentication := #{enable := Enable}} = Cfg,
|
||||
check_token(Enable, Method, Channel).
|
||||
check_token(Enable, Msg, Channel).
|
||||
|
||||
check_token(true,
|
||||
#coap_message{options = Options} = Msg,
|
||||
|
|
|
@ -162,7 +162,7 @@ deliver(Delivers, Ctx, Session) ->
|
|||
end,
|
||||
lists:foldl(Fun,
|
||||
#{out => [], session => Session},
|
||||
Delivers).
|
||||
lists:reverse(Delivers)).
|
||||
|
||||
timeout(Timer, Ctx, Session) ->
|
||||
call_transport_manager(?FUNCTION_NAME, Timer, Ctx, [fun process_tm/3], Session).
|
||||
|
@ -189,8 +189,8 @@ call_transport_manager(Fun,
|
|||
Session),
|
||||
emqx_coap_channel:transfer_result(session, Session2, Result2)
|
||||
catch Type:Reason:Stack ->
|
||||
?ERROR("process transmission with, message:~p failed~n
|
||||
Type:~p,Reason:~p~n,StackTrace:~p~n", [Msg, Type, Reason, Stack]),
|
||||
?ERROR("process transmission with, message:~p failed~nType:~p,Reason:~p~n,StackTrace:~p~n",
|
||||
[Msg, Type, Reason, Stack]),
|
||||
?REPLY({error, internal_server_error}, Msg)
|
||||
end.
|
||||
|
||||
|
|
Loading…
Reference in New Issue