Skip to content

Commit

Permalink
check active during reconcile (#984)
Browse files Browse the repository at this point in the history
* check active during reconcile

active was only being checked during device updates

* explicitly mark devices as active in reconcile tests
  • Loading branch information
michaeldjeffrey authored Jul 27, 2023
1 parent 8b9f52b commit 8f43c26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/grpc/router_ics_eui_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,12 @@ get_local_eui_pairs(RouteID) ->
lists:filtermap(
fun(APIDevice) ->
OrgId = kvc:path([<<"organization_id">>], APIDevice),
Active = kvc:path([<<"active">>], APIDevice, false),

case lists:member(OrgId, UnfundedOrgs) of
true ->
false;
case Active andalso not lists:member(OrgId, UnfundedOrgs) of
false ->
false;
true ->
<<AppEUI:64/integer-unsigned-big>> = lorawan_utils:hex_to_binary(
kvc:path([<<"app_eui">>], APIDevice)
),
Expand Down
2 changes: 2 additions & 0 deletions test/router_ics_eui_worker_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ reconcile_ignore_unfunded_orgs_test(_Config) ->
},
JsonDevices = [
#{
<<"active">> => true,
<<"app_eui">> => lorawan_utils:binary_to_hex(router_device:app_eui(D)),
<<"dev_eui">> => lorawan_utils:binary_to_hex(router_device:dev_eui(D)),
<<"organization_id">> => maps:get(organization_id, router_device:metadata(D))
Expand Down Expand Up @@ -493,6 +494,7 @@ reconcile_test(_Config) ->
JSONDevices = lists:map(
fun(X) ->
#{
<<"active">> => true,
<<"app_eui">> => lorawan_utils:binary_to_hex(<<X:64/integer-unsigned-big>>),
<<"dev_eui">> => lorawan_utils:binary_to_hex(<<X:64/integer-unsigned-big>>)
}
Expand Down

0 comments on commit 8f43c26

Please sign in to comment.