Skip to content

Commit 3e949a4

Browse files
author
CI
committed
Sync to GitHub
1 parent e8de686 commit 3e949a4

3 files changed

Lines changed: 13 additions & 27 deletions

File tree

lib/bacnet/stack/transport/ethernet_transport.ex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,12 @@ defmodule BACnet.Stack.Transport.EthernetTransport do
222222
@doc """
223223
Checks whether the given destination is an address that needs to be routed.
224224
225-
Always returns `false` due to how Ethernet works (no routing).
225+
Returns true for any non-valid `mac_address()`, because they need
226+
to be routed by a BACnet router residing on this transport layer/network.
226227
"""
227228
@spec destination_routed?(GenServer.server(), mac_address() | term()) :: boolean()
228-
def destination_routed?(transport, _destination) when is_server(transport) do
229-
false
229+
def destination_routed?(transport, destination) when is_server(transport) do
230+
not valid_destination?(destination)
230231
end
231232

232233
@doc """

lib/bacnet/stack/transport/ipv4_transport.ex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ defmodule BACnet.Stack.Transport.IPv4Transport do
343343
"""
344344
@spec destination_routed?(GenServer.server(), iplink_address() | term()) :: boolean()
345345
def destination_routed?(transport, destination) when is_server(transport) do
346-
GenServer.call(transport, {:destination_routed?, destination})
346+
GenServer.call(transport, {:is_destination_routed, destination})
347347
end
348348

349349
@doc """
@@ -585,10 +585,10 @@ defmodule BACnet.Stack.Transport.IPv4Transport do
585585
{:reply, {state.broadcast_addr, state.local_port}, state}
586586
end
587587

588-
def handle_call({:destination_routed?, {destination, _port}}, _from, %State{} = state)
588+
def handle_call({:is_destination_routed, {destination, _port}}, _from, %State{} = state)
589589
when is_tuple(destination) and tuple_size(destination) == 4 do
590590
log_debug(fn ->
591-
"BacIPv4Transport: Received destination_routed? request for #{inspect(destination)}"
591+
"BacIPv4Transport: Received is_destination_routed request for #{inspect(destination)}"
592592
end)
593593

594594
routed =
@@ -600,9 +600,9 @@ defmodule BACnet.Stack.Transport.IPv4Transport do
600600
{:reply, routed, state}
601601
end
602602

603-
def handle_call({:destination_routed?, destination}, _from, state) do
603+
def handle_call({:is_destination_routed, destination}, _from, state) do
604604
log_debug(fn ->
605-
"BacIPv4Transport: Received (non-IP) destination_routed? request for #{inspect(destination)}"
605+
"BacIPv4Transport: Received (non-IP) is_destination_routed request for #{inspect(destination)}"
606606
end)
607607

608608
{:reply, true, state}

lib/bacnet/stack/transport/mstp_transport.ex

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -613,18 +613,20 @@ if Code.ensure_loaded?(Circuits.UART) do
613613

614614
@doc """
615615
Checks whether the given destination is an address that needs to be routed.
616+
617+
Returns true for any non-valid `destination_address()`, because they need
618+
to be routed by a BACnet router residing on this transport layer/network.
616619
"""
617620
@spec destination_routed?(GenServer.server(), destination_address() | term()) ::
618621
boolean()
619622
def destination_routed?(transport, destination) when is_server(transport) do
620-
# GenServer.call(transport, {:destination_routed?, destination})
621623
not valid_destination?(destination)
622624
end
623625

624626
@doc """
625627
Verifies whether the given destination is valid for the transport module.
626628
"""
627-
@spec valid_destination?(destination_address()) :: boolean()
629+
@spec valid_destination?(destination_address() | term()) :: boolean()
628630
def valid_destination?(destination) do
629631
is_integer(destination) and destination >= 0 and destination <= 255
630632
end
@@ -1401,23 +1403,6 @@ if Code.ensure_loaded?(Circuits.UART) do
14011403
{:reply, state.local_address, state}
14021404
end
14031405

1404-
def handle_call({:destination_routed?, destination}, _from, %State{} = state)
1405-
when is_integer(destination) do
1406-
log_debug(fn ->
1407-
"BacMstpTransport: Received destination_routed? request for #{inspect(destination)}"
1408-
end)
1409-
1410-
{:reply, not valid_destination?(destination), state}
1411-
end
1412-
1413-
def handle_call({:destination_routed?, destination}, _from, state) do
1414-
log_debug(fn ->
1415-
"BacMstpTransport: Received (non-MSTP) destination_routed? request for #{inspect(destination)}"
1416-
end)
1417-
1418-
{:reply, true, state}
1419-
end
1420-
14211406
def handle_call(
14221407
{:send, destination, send_and_wait, data, _data_length, invoke_id},
14231408
_from,

0 commit comments

Comments
 (0)