Skip to content

Commit

Permalink
Fix to include new proto env (#886)
Browse files Browse the repository at this point in the history
  • Loading branch information
macpie authored Dec 7, 2022
1 parent 2a63ea6 commit 82a506a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
{<<"hackney">>,{pkg,<<"hackney">>,<<"1.18.1">>},0},
{<<"helium_proto">>,
{git,"https://github.com/helium/proto.git",
{ref,"d4dc09d89ec4e99ab6ec9992f207e33a6d9a3e30"}},
{ref,"f1a8dd10140d67b44a8592927673f3b476eff29d"}},
0},
{<<"hpack">>,{pkg,<<"hpack_erl">>,<<"0.2.3">>},2},
{<<"httpc_aws">>,
Expand Down
17 changes: 10 additions & 7 deletions src/grpc/helium_packet_service.erl
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
init(_Rpc, Stream) ->
Stream.

-spec route(packet_router_pb:packet_router_packet_up_v1_pb(), grpcbox_stream:t()) ->
-spec route(packet_router_pb:envelope_up_v1_pb(), grpcbox_stream:t()) ->
{ok, grpcbox_stream:t()} | grpcbox_stream:grpc_error_response().
route(PacketUp, StreamState) ->
route(#envelope_up_v1_pb{data = {packet, PacketUp}}, StreamState) ->
case verify(PacketUp) of
false ->
{grpc_error, {grpcbox_stream:code_to_status(2), <<"bad signature">>}};
Expand All @@ -30,7 +30,10 @@ route(PacketUp, StreamState) ->
]),
router_metrics:function_observe('router_device_routing:handle_free_packet', Time),
{ok, StreamState}
end.
end;
route(_EnvUp, StreamState) ->
lager:warning("unknown ~p", [_EnvUp]),
{ok, StreamState}.

-spec handle_info(Msg :: any(), StreamState :: grpcbox_stream:t()) -> grpcbox_stream:t().
handle_info({send_response, Reply}, StreamState) ->
Expand Down Expand Up @@ -113,11 +116,10 @@ routing_information(<<_FType:3, _:5, DevAddr:32/integer-unsigned-little, _/binar
%% ===================================================================

-spec from_sc_packet(router_pb:blockchain_state_channel_response_v1_pb()) ->
packet_router_db:packet_router_packet_down_v1_pb().
packet_router_db:envelope_down_v1_pb().
from_sc_packet(StateChannelResponse) ->
Downlink = blockchain_state_channel_response_v1:downlink(StateChannelResponse),

#packet_router_packet_down_v1_pb{
PacketDown = #packet_router_packet_down_v1_pb{
payload = blockchain_helium_packet_v1:payload(Downlink),
rx1 = #window_v1_pb{
timestamp = blockchain_helium_packet_v1:timestamp(Downlink),
Expand All @@ -126,7 +128,8 @@ from_sc_packet(StateChannelResponse) ->
datarate = hpr_datarate(blockchain_helium_packet_v1:datarate(Downlink))
},
rx2 = rx2_window(blockchain_helium_packet_v1:rx2_window(Downlink))
}.
},
#envelope_down_v1_pb{data = {packet, PacketDown}}.

-spec hpr_datarate(unicode:chardata()) ->
packet_router_pb:'helium.data_rate'().
Expand Down

0 comments on commit 82a506a

Please sign in to comment.