Skip to content

Commit

Permalink
Remove other preferred_hotspots (#1016)
Browse files Browse the repository at this point in the history
  • Loading branch information
macpie authored Oct 21, 2023
1 parent 77dd7dd commit 87af230
Showing 1 changed file with 14 additions and 55 deletions.
69 changes: 14 additions & 55 deletions src/device/router_device_routing.erl
Original file line number Diff line number Diff line change
Expand Up @@ -854,28 +854,9 @@ packet(
Msg = binary:part(Payload, {0, erlang:byte_size(Payload) - 4}),
case get_device(DevEUI, AppEUI, Msg, MIC) of
{ok, APIDevice, AppKey} ->
case router_device:preferred_hotspots(APIDevice) of
[] ->
maybe_start_worker_and_handle_join(
APIDevice, Packet, PacketTime, HoldTime, PubKeyBin, Region, AppKey, Pid
);
PreferredHotspots when is_list(PreferredHotspots) ->
case lists:member(PubKeyBin, PreferredHotspots) of
true ->
maybe_start_worker_and_handle_join(
APIDevice,
Packet,
PacketTime,
HoldTime,
PubKeyBin,
Region,
AppKey,
Pid
);
_ ->
{error, not_preferred_hotspot}
end
end;
maybe_start_worker_and_handle_join(
APIDevice, Packet, PacketTime, HoldTime, PubKeyBin, Region, AppKey, Pid
);
{error, api_not_found} ->
lager:debug(
[{app_eui, AppEUI}, {dev_eui, DevEUI}],
Expand Down Expand Up @@ -1042,39 +1023,17 @@ send_to_device_worker(
Err;
{Device1, NwkSKey, FCnt} ->
ok = router_device_stats:track_packet(Packet, PubKeyBin, Device1),
case router_device:preferred_hotspots(Device1) of
[] ->
send_to_device_worker_(
FCnt,
Packet,
PacketTime,
HoldTime,
Pid,
PubKeyBin,
Region,
Device1,
NwkSKey
);
PreferredHotspots when
is_list(PreferredHotspots)
->
case lists:member(PubKeyBin, PreferredHotspots) of
true ->
send_to_device_worker_(
FCnt,
Packet,
PacketTime,
HoldTime,
Pid,
PubKeyBin,
Region,
Device1,
NwkSKey
);
_ ->
{error, not_preferred_hotspot}
end
end
send_to_device_worker_(
FCnt,
Packet,
PacketTime,
HoldTime,
Pid,
PubKeyBin,
Region,
Device1,
NwkSKey
)
end.

send_to_device_worker_(FCnt, Packet, PacketTime, HoldTime, Pid, PubKeyBin, Region, Device, NwkSKey) ->
Expand Down

0 comments on commit 87af230

Please sign in to comment.