From e3ddf107d9e14f7dd6e44e0c3486ded773c7996b Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Tue, 14 Apr 2026 16:42:54 -0500 Subject: [PATCH] Gate beacon coverage toggle to 5.76 GHz and above MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The estimated current coverage map is only meaningful on bands where atmospheric attenuation shapes the reach — below 5.76 GHz it's dominated by free-space loss and misleads. Disable the toggle, show a helper note explaining the limit, and guard the handle_event against clients that try to force it. --- .../live/beacon_live/show.ex | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/lib/microwaveprop_web/live/beacon_live/show.ex b/lib/microwaveprop_web/live/beacon_live/show.ex index afde66cc..9ea631f9 100644 --- a/lib/microwaveprop_web/live/beacon_live/show.ex +++ b/lib/microwaveprop_web/live/beacon_live/show.ex @@ -60,14 +60,21 @@ defmodule MicrowavepropWeb.BeaconLive.Show do
-
@@ -161,17 +168,28 @@ defmodule MicrowavepropWeb.BeaconLive.Show do |> assign(:page_title, "Beacon") |> assign(:beacon, beacon) |> assign(:show_coverage, false) + |> assign(:coverage_supported, coverage_supported?(beacon)) |> assign(:estimate, RangeEstimate.estimate(beacon))} end + # Estimated current coverage only makes sense from 5.76 GHz upward, + # where atmospheric attenuation meaningfully shapes the reach. Below + # that the free-space-loss-dominated map is misleading. + defp coverage_supported?(%{frequency_mhz: mhz}) when is_number(mhz), do: mhz >= 5760 + defp coverage_supported?(_), do: false + @impl true def handle_event("toggle_coverage", _params, socket) do - show = not socket.assigns.show_coverage + if socket.assigns.coverage_supported do + show = not socket.assigns.show_coverage - {:noreply, - socket - |> assign(:show_coverage, show) - |> push_event("toggle_coverage", %{show: show})} + {:noreply, + socket + |> assign(:show_coverage, show) + |> push_event("toggle_coverage", %{show: show})} + else + {:noreply, socket} + end end def handle_event("approve", _params, socket) do @@ -189,9 +207,13 @@ defmodule MicrowavepropWeb.BeaconLive.Show do @impl true def handle_info({:updated, %Beacon{id: id} = beacon}, %{assigns: %{beacon: %{id: id}}} = socket) do + supported = coverage_supported?(beacon) + {:noreply, socket |> assign(:beacon, beacon) + |> assign(:coverage_supported, supported) + |> assign(:show_coverage, socket.assigns.show_coverage and supported) |> assign(:estimate, RangeEstimate.estimate(beacon))} end