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
|
@ -108,10 +108,10 @@ The server manages the client through the ClientId. If the ClientId is wrong, EM
|
||||||
1. Create a Connection
|
1. Create a Connection
|
||||||
|
|
||||||
Method: POST
|
Method: POST
|
||||||
URI Schema: mqtt/{+topic}{?q\*}
|
URI Schema: mqtt/connection{?q\*}
|
||||||
q\*:
|
q\*:
|
||||||
|
|
||||||
- clientId := client uid
|
- clientid := client uid
|
||||||
- username
|
- username
|
||||||
- password
|
- password
|
||||||
|
|
||||||
|
@ -126,10 +126,10 @@ The server manages the client through the ClientId. If the ClientId is wrong, EM
|
||||||
2. Close a Connection
|
2. Close a Connection
|
||||||
|
|
||||||
Method : DELETE
|
Method : DELETE
|
||||||
URI Schema: mqtt/{+topic}{?q\*}
|
URI Schema: mqtt/connection{?q\*}
|
||||||
q\*:
|
q\*:
|
||||||
|
|
||||||
- clientId := client uid
|
- clientid := client uid
|
||||||
- token
|
- token
|
||||||
|
|
||||||
Resonse:
|
Resonse:
|
||||||
|
@ -143,12 +143,14 @@ The server manages the client through the ClientId. If the ClientId is wrong, EM
|
||||||
|
|
||||||
### Heartbeat
|
### 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
|
Method : PUT
|
||||||
URI Schema: mqtt/{+topic}{?q\*}
|
URI Schema: mqtt/connection{?q\*}
|
||||||
q\*:
|
q\*:
|
||||||
|
|
||||||
- clientId if authenticated
|
- clientid if authenticated
|
||||||
- token if authenticated
|
- token if authenticated
|
||||||
|
|
||||||
Response:
|
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>
|
1. Shared Options <a id="orgc50043b"></a>
|
||||||
|
|
||||||
- clientId
|
- clientid
|
||||||
- token
|
- token
|
||||||
|
|
||||||
2. Connect Options
|
2. Connect Options
|
||||||
|
@ -188,9 +190,9 @@ CoAP gateway uses some options in query string to conversion between MQTT CoAP.
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col" class="org-left">option</th>
|
<th scope="col" class="org-left">Option</th>
|
||||||
<th scope="col" class="org-left">value type</th>
|
<th scope="col" class="org-left">Type</th>
|
||||||
<th scope="col" class="org-left">default</th>
|
<th scope="col" class="org-left">Default</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
|
@ -204,7 +206,7 @@ CoAP gateway uses some options in query string to conversion between MQTT CoAP.
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="org-left">qos</td>
|
<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>
|
<td class="org-left">See <a href="#org0345c3e">here</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
@ -231,16 +233,16 @@ CoAP gateway uses some options in query string to conversion between MQTT CoAP.
|
||||||
</colgroup>
|
</colgroup>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col" class="org-left">option</th>
|
<th scope="col" class="org-left">Option</th>
|
||||||
<th scope="col" class="org-left">value type</th>
|
<th scope="col" class="org-left">Type</th>
|
||||||
<th scope="col" class="org-right">default</th>
|
<th scope="col" class="org-right">Default</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="org-left">qos</td>
|
<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>
|
<td class="org-right">See <a href="#org2325c7d">here</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
@ -260,7 +262,7 @@ CoAP gateway uses some options in query string to conversion between MQTT CoAP.
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
5. MQTT QOS <=> CoAP non/con
|
5. MQTT Qos <=> CoAP non/con
|
||||||
|
|
||||||
1.notif_type
|
1.notif_type
|
||||||
Control the type of notify messages when the observed object has changed.Can be:
|
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
|
- non
|
||||||
- con
|
- con
|
||||||
- qos
|
- 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>
|
2.subscribe_qos <a id="org2325c7d"></a>
|
||||||
Control the qos of subscribe.Can be:
|
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
|
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
|
3. Transport Mnager
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ get_config(Key, #exec_ctx{config = Cfg}, Def) ->
|
||||||
maps:get(Key, Cfg, Def).
|
maps:get(Key, Cfg, Def).
|
||||||
|
|
||||||
result_keys() ->
|
result_keys() ->
|
||||||
[out, reply, connection].
|
[out, connection].
|
||||||
|
|
||||||
transfer_result(From, Value, Result) ->
|
transfer_result(From, Value, Result) ->
|
||||||
?TRANSFER_RESULT(From, Value, Result).
|
?TRANSFER_RESULT(From, Value, Result).
|
||||||
|
@ -289,9 +289,9 @@ handle_result(out, #{out := Out}, _, Channel) ->
|
||||||
handle_result(_, _, _, Channel) ->
|
handle_result(_, _, _, Channel) ->
|
||||||
{ok, Channel}.
|
{ok, Channel}.
|
||||||
|
|
||||||
check_auth_state(Method, #channel{config = Cfg} = Channel) ->
|
check_auth_state(Msg, #channel{config = Cfg} = Channel) ->
|
||||||
#{authentication := #{enable := Enable}} = Cfg,
|
#{authentication := #{enable := Enable}} = Cfg,
|
||||||
check_token(Enable, Method, Channel).
|
check_token(Enable, Msg, Channel).
|
||||||
|
|
||||||
check_token(true,
|
check_token(true,
|
||||||
#coap_message{options = Options} = Msg,
|
#coap_message{options = Options} = Msg,
|
||||||
|
|
|
@ -162,7 +162,7 @@ deliver(Delivers, Ctx, Session) ->
|
||||||
end,
|
end,
|
||||||
lists:foldl(Fun,
|
lists:foldl(Fun,
|
||||||
#{out => [], session => Session},
|
#{out => [], session => Session},
|
||||||
Delivers).
|
lists:reverse(Delivers)).
|
||||||
|
|
||||||
timeout(Timer, Ctx, Session) ->
|
timeout(Timer, Ctx, Session) ->
|
||||||
call_transport_manager(?FUNCTION_NAME, Timer, Ctx, [fun process_tm/3], Session).
|
call_transport_manager(?FUNCTION_NAME, Timer, Ctx, [fun process_tm/3], Session).
|
||||||
|
@ -189,8 +189,8 @@ call_transport_manager(Fun,
|
||||||
Session),
|
Session),
|
||||||
emqx_coap_channel:transfer_result(session, Session2, Result2)
|
emqx_coap_channel:transfer_result(session, Session2, Result2)
|
||||||
catch Type:Reason:Stack ->
|
catch Type:Reason:Stack ->
|
||||||
?ERROR("process transmission with, message:~p failed~n
|
?ERROR("process transmission with, message:~p failed~nType:~p,Reason:~p~n,StackTrace:~p~n",
|
||||||
Type:~p,Reason:~p~n,StackTrace:~p~n", [Msg, Type, Reason, Stack]),
|
[Msg, Type, Reason, Stack]),
|
||||||
?REPLY({error, internal_server_error}, Msg)
|
?REPLY({error, internal_server_error}, Msg)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue