Skip to content

Commit

Permalink
Reorder txpk fields
Browse files Browse the repository at this point in the history
This is to allow interoperability with https://github.com/JaapBraam/LoRaWanGateway
that suffer from the issue JaapBraam/LoRaWanGateway#26
  • Loading branch information
gotthardp committed Apr 14, 2017
1 parent 3580d29 commit 3b36d1a
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/lorawan_gw_forwarder.erl
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,21 @@ get_rxpk_field(Field, List) ->


build_txpk(TxQ, RFch, Data) ->
[{modu, <<"LORA">>}, {rfch, RFch}, {ipol, true}, {size, byte_size(Data)}, {data, base64:encode(Data)} |
lists:foldl(
fun ({_, undefined}, Acc) ->
Acc;
({tmst, Time}, Acc) ->
[{imme, false}, {tmst, Time} | Acc];
({time, immediately}, Acc) ->
[{imme, true} | Acc];
({time, Time}, Acc) ->
[{imme, false}, {time, iso8601:format(Time)} | Acc];
({region, _}, Acc) ->
Acc; % internal parameter
(Elem, Acc) -> [Elem | Acc]
end,
[], lists:zip(record_info(fields, txq), tl(tuple_to_list(TxQ)))
)].
lists:foldl(
fun ({_, undefined}, Acc) ->
Acc;
({tmst, Time}, Acc) ->
[{imme, false}, {tmst, Time} | Acc];
({time, immediately}, Acc) ->
[{imme, true} | Acc];
({time, Time}, Acc) ->
[{imme, false}, {time, iso8601:format(Time)} | Acc];
({region, _}, Acc) ->
Acc; % internal parameter
(Elem, Acc) -> [Elem | Acc]
end,
[{modu, <<"LORA">>}, {rfch, RFch}, {ipol, true}, {size, byte_size(Data)}, {data, base64:encode(Data)}],
lists:zip(record_info(fields, txq), tl(tuple_to_list(TxQ)))
)].

% end of file

0 comments on commit 3b36d1a

Please sign in to comment.