Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
macpie committed Nov 29, 2023
1 parent cf5148c commit 7c193ff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
22 changes: 10 additions & 12 deletions src/device/router_device_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -396,22 +396,12 @@ handle_cast(
lager:info("app_eui or dev_eui changed, unsetting devaddr"),
[]
end,

BootstrappedMeta = lorawan_rxdelay:bootstrap(
maps:merge(
router_device:metadata(Device0),
router_device:metadata(APIDevice)
)
),
DeviceUpdates = [
{name, router_device:name(APIDevice)},
{dev_eui, router_device:dev_eui(APIDevice)},
{app_eui, router_device:app_eui(APIDevice)},
{devaddrs, DevAddrs},
{metadata,
lorawan_rxdelay:maybe_update(
APIDevice, router_device:metadata(BootstrappedMeta, Device0)
)},
{metadata, lorawan_rxdelay:maybe_update(APIDevice, Device0)},
{is_active, IsActive}
],

Expand Down Expand Up @@ -2195,13 +2185,21 @@ get_device(DB, CF, DeviceID) ->
{ok, APIDevice} ->
lager:info("got device: ~p", [APIDevice]),
IsActive = router_device:is_active(APIDevice),
BootstrappedMeta = lorawan_rxdelay:bootstrap(
maps:merge(
router_device:metadata(Device0),
router_device:metadata(APIDevice)
)
),
DeviceUpdates = [
{name, router_device:name(APIDevice)},
{dev_eui, router_device:dev_eui(APIDevice)},
{app_eui, router_device:app_eui(APIDevice)},
{metadata,
maps:merge(
lorawan_rxdelay:maybe_update(APIDevice, Device0),
lorawan_rxdelay:maybe_update(
APIDevice, router_device:metadata(BootstrappedMeta, Device0)
),
router_device:metadata(APIDevice)
)},
{is_active, IsActive}
Expand Down
7 changes: 3 additions & 4 deletions test/router_device_worker_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -766,10 +766,9 @@ evict_keys_join_test(Config) ->

#{} = test_utils:join_device(Config),

[
{_Pid0, {router_ics_skf_worker, update, [Updates] = _Args0}, ok},
{_Pid1, {router_ics_skf_worker, handle_cast, _Args1}, _Return1}
] = meck:history(router_ics_skf_worker),
[{_Pid0, {router_ics_skf_worker, update, [Updates] = _Args0}, ok} | _] = meck:history(
router_ics_skf_worker
),

%% Expected updates
%% 1 Add
Expand Down

0 comments on commit 7c193ff

Please sign in to comment.