Skip to content

Commit

Permalink
Issue #597: Avoid crash during uplink
Browse files Browse the repository at this point in the history
  • Loading branch information
gotthardp committed Feb 18, 2019
1 parent cf0a736 commit 51ac448
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/lorawan_application_backend.erl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ handle_uplink0(#handler{app=AppID, parse_uplink=Parse, uplink_fields=Fields}=Han
% we have to wait for the rx quality indicators
{ok, {Handler, Vars}};
false ->
lorawan_backend_factory:uplink(AppID, Node,
lorawan_backend_factory:uplink(AppID, {Profile, Node},
data_to_fields(AppID, Parse, Vars, Data)),
{ok, undefined}
end.
Expand All @@ -63,11 +63,11 @@ handle_rxq({_Network, _Profile, #node{devaddr=DevAddr}},
_Gateways, _WillReply, #frame{port=Port}, undefined) ->
% we did already handle this uplink
lorawan_application:send_stored_frames(DevAddr, Port);
handle_rxq({_Network, #profile{app=AppID}, #node{devaddr=DevAddr}=Node},
handle_rxq({_Network, #profile{app=AppID}=Profile, #node{devaddr=DevAddr}=Node},
Gateways, _WillReply, #frame{port=Port, data=Data},
{#handler{parse_uplink=Parse, uplink_fields=Fields}, Vars}) ->
Vars2 = parse_rxq(Gateways, Fields, Vars),
lorawan_backend_factory:uplink(AppID, Node,
lorawan_backend_factory:uplink(AppID, {Profile, Node},
data_to_fields(AppID, Parse, Vars2, Data)),
lorawan_application:send_stored_frames(DevAddr, Port).

Expand Down
2 changes: 2 additions & 0 deletions src/lorawan_backend_factory.erl
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,11 @@ find_module0(Scheme, []) ->
{error, {unknown_scheme, Scheme}}.


-spec uplink(binary(), {#profile{}, #node{}} | {#profile{}, #device{}, binary()}, map()) -> ok.
uplink(App, Node, Vars) ->
send_to_connectors(App, {uplink, Node, Vars}).

-spec event(binary(), {#profile{}, #node{}} | {#profile{}, #device{}, binary()}, map()) -> ok.
event(App, Node, Vars) ->
send_to_connectors(App, {event, Node, Vars}).

Expand Down

0 comments on commit 51ac448

Please sign in to comment.