fix(gw): fix elvis warnings
This commit is contained in:
parent
3f35604d16
commit
7f04837ad2
|
@ -40,7 +40,9 @@ gateway.coap {
|
||||||
|
|
||||||
-define(HOST, "127.0.0.1").
|
-define(HOST, "127.0.0.1").
|
||||||
-define(PORT, 5683).
|
-define(PORT, 5683).
|
||||||
-define(CONN_URI, "coap://127.0.0.1/mqtt/connection?clientid=client1&username=admin&password=public").
|
-define(CONN_URI,
|
||||||
|
"coap://127.0.0.1/mqtt/connection?clientid=client1&"
|
||||||
|
"username=admin&password=public").
|
||||||
|
|
||||||
-define(LOGT(Format, Args), ct:pal("TEST_SUITE: " ++ Format, Args)).
|
-define(LOGT(Format, Args), ct:pal("TEST_SUITE: " ++ Format, Args)).
|
||||||
|
|
||||||
|
@ -117,26 +119,40 @@ test_send_coap_request(UdpSock, Method, Content, Options, MsgId) ->
|
||||||
Request = Request0#coap_message{id = MsgId},
|
Request = Request0#coap_message{id = MsgId},
|
||||||
?LOGT("send_coap_request Request=~p", [Request]),
|
?LOGT("send_coap_request Request=~p", [Request]),
|
||||||
RequestBinary = emqx_coap_frame:serialize_pkt(Request, undefined),
|
RequestBinary = emqx_coap_frame:serialize_pkt(Request, undefined),
|
||||||
?LOGT("test udp socket send to ~p:~p, data=~p", [IpAddr, Port, RequestBinary]),
|
?LOGT("test udp socket send to ~p:~p, data=~p",
|
||||||
|
[IpAddr, Port, RequestBinary]),
|
||||||
ok = gen_udp:send(UdpSock, IpAddr, Port, RequestBinary);
|
ok = gen_udp:send(UdpSock, IpAddr, Port, RequestBinary);
|
||||||
{SchemeDiff, ChIdDiff, _, _} ->
|
{SchemeDiff, ChIdDiff, _, _} ->
|
||||||
error(lists:flatten(io_lib:format("scheme ~ts or ChId ~ts does not match with socket", [SchemeDiff, ChIdDiff])))
|
error(
|
||||||
|
lists:flatten(
|
||||||
|
io_lib:format(
|
||||||
|
"scheme ~ts or ChId ~ts does not match with socket",
|
||||||
|
[SchemeDiff, ChIdDiff])
|
||||||
|
))
|
||||||
end.
|
end.
|
||||||
|
|
||||||
test_recv_coap_response(UdpSock) ->
|
test_recv_coap_response(UdpSock) ->
|
||||||
{ok, {Address, Port, Packet}} = gen_udp:recv(UdpSock, 0, 2000),
|
{ok, {Address, Port, Packet}} = gen_udp:recv(UdpSock, 0, 2000),
|
||||||
{ok, Response, _, _} = emqx_coap_frame:parse(Packet, undefined),
|
{ok, Response, _, _} = emqx_coap_frame:parse(Packet, undefined),
|
||||||
?LOGT("test udp receive from ~p:~p, data1=~p, Response=~p", [Address, Port, Packet, Response]),
|
?LOGT("test udp receive from ~p:~p, data1=~p, Response=~p",
|
||||||
#coap_message{type = ack, method = Method, id=Id, token = Token, options = Options, payload = Payload} = Response,
|
[Address, Port, Packet, Response]),
|
||||||
?LOGT("receive coap response Method=~p, Id=~p, Token=~p, Options=~p, Payload=~p", [Method, Id, Token, Options, Payload]),
|
#coap_message{
|
||||||
|
type = ack, method = Method, id = Id,
|
||||||
|
token = Token, options = Options, payload = Payload} = Response,
|
||||||
|
?LOGT("receive coap response Method=~p, Id=~p, Token=~p, "
|
||||||
|
"Options=~p, Payload=~p", [Method, Id, Token, Options, Payload]),
|
||||||
Response.
|
Response.
|
||||||
|
|
||||||
test_recv_coap_request(UdpSock) ->
|
test_recv_coap_request(UdpSock) ->
|
||||||
case gen_udp:recv(UdpSock, 0) of
|
case gen_udp:recv(UdpSock, 0) of
|
||||||
{ok, {_Address, _Port, Packet}} ->
|
{ok, {_Address, _Port, Packet}} ->
|
||||||
{ok, Request, _, _} = emqx_coap_frame:parse(Packet, undefined),
|
{ok, Request, _, _} = emqx_coap_frame:parse(Packet, undefined),
|
||||||
#coap_message{type = con, method = Method, id=Id, token = Token, payload = Payload, options = Options} = Request,
|
#coap_message{
|
||||||
?LOGT("receive coap request Method=~p, Id=~p, Token=~p, Options=~p, Payload=~p", [Method, Id, Token, Options, Payload]),
|
type = con, method = Method, id = Id,
|
||||||
|
token = Token, payload = Payload, options = Options} = Request,
|
||||||
|
?LOGT("receive coap request Method=~p, Id=~p, "
|
||||||
|
"Token=~p, Options=~p, Payload=~p",
|
||||||
|
[Method, Id, Token, Options, Payload]),
|
||||||
Request;
|
Request;
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
?LOGT("test_recv_coap_request failed, Reason=~p", [Reason]),
|
?LOGT("test_recv_coap_request failed, Reason=~p", [Reason]),
|
||||||
|
|
Loading…
Reference in New Issue