diff --git a/.env-template b/.env-template index 33a7bb984..7b4c9b288 100644 --- a/.env-template +++ b/.env-template @@ -71,3 +71,6 @@ ROUTER_CHARGE_JOINS=true # Charge an org for a packet received late or replayed (default: false). ROUTER_CHARGE_LATE_PACKETS=false + +# Flag to disable preferred hotspot feature (default: false). +ROUTER_DISABLE_PREFERRED_HOTSPOT=true \ No newline at end of file diff --git a/config/sys.config.src b/config/sys.config.src index f929ed1fe..d69b4d8c6 100644 --- a/config/sys.config.src +++ b/config/sys.config.src @@ -35,6 +35,7 @@ {router, [ {devaddr_prefix, "${ROUTER_DEVADDR_PREFIX}"}, {is_chain_dead, "${ROUTER_IS_CHAIN_DEAD}"}, + {disable_preferred_hotspot, "${ROUTER_DISABLE_PREFERRED_HOTSPOT}"}, {grpc_port, ${GRPC_PORT:-8080}}, {max_v8_context, 1000}, {oui, "${ROUTER_OUI}"}, diff --git a/config/test.config b/config/test.config index b12634468..0c323a232 100644 --- a/config/test.config +++ b/config/test.config @@ -1,6 +1,7 @@ %% -*- erlang -*- [ {router, [ + {disable_preferred_hotspot, "false"}, {oui, 1}, {devaddr_prefix, "72"}, {metrics_port, 3001}, diff --git a/src/device/router_device_routing.erl b/src/device/router_device_routing.erl index 4c4ccaa91..17e99bd4f 100644 --- a/src/device/router_device_routing.erl +++ b/src/device/router_device_routing.erl @@ -572,15 +572,20 @@ maybe_multi_buy_offer(Device, PHash) -> Hotspot :: libp2p_crypto:pubkey_bin() ) -> none_preferred | preferred | not_preferred_hotspot. check_device_preferred_hotspots(Device, Hotspot) -> - case router_device:preferred_hotspots(Device) of - [] -> + case router_utils:get_env_bool(disable_preferred_hotspot, false) of + true -> none_preferred; - PreferredHotspots when is_list(PreferredHotspots) -> - case lists:member(Hotspot, PreferredHotspots) of - true -> - preferred; - _ -> - not_preferred_hotspot + false -> + case router_device:preferred_hotspots(Device) of + [] -> + none_preferred; + PreferredHotspots when is_list(PreferredHotspots) -> + case lists:member(Hotspot, PreferredHotspots) of + true -> + preferred; + _ -> + not_preferred_hotspot + end end end.