Skip to content

Commit 58d81fa

Browse files
committed
Fixed iAm responses matching for incoming APDUs
1 parent c1f988a commit 58d81fa

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

  • thingsboard_gateway/connectors/bacnet

thingsboard_gateway/connectors/bacnet/device.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from threading import Thread
1818

1919
from bacpypes3.primitivedata import ObjectIdentifier
20+
from bacpypes3.pdu import LocalBroadcast, Address
2021

2122
from thingsboard_gateway.connectors.bacnet.bacnet_uplink_converter import AsyncBACnetUplinkConverter
2223
from thingsboard_gateway.connectors.bacnet.entities.bacnet_device_details import BACnetDeviceDetails
@@ -118,12 +119,21 @@ def is_address_match(address, pattern):
118119

119120
@staticmethod
120121
def get_address_regex(pattern):
121-
regex = escape(pattern).replace("X", r"\d")
122+
regex = ''
123+
i = 0
124+
while i < len(pattern):
125+
if pattern[i] == 'X':
126+
while i < len(pattern) and pattern[i] == 'X':
127+
i += 1
128+
regex += r'\d+'
129+
else:
130+
regex += escape(pattern[i])
131+
i += 1
122132
return f"^{regex}$"
123133

124134
@staticmethod
125135
def get_who_is_address(address):
126-
if Device.is_pattern_address(address):
136+
if 'X' in address or '*' in address:
127137
return Device.__get_broadcast_address(address)
128138
else:
129139
return address

0 commit comments

Comments
 (0)