Skip to content

Commit deec5cf

Browse files
committed
aioservices/aiomqtt: Add re firmware file match.
1 parent 26d98b9 commit deec5cf

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

aioservices/services/aiomqtt_service.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def __init__(self, name):
4646
"topics": [],
4747
"ota_check": True,
4848
"fwfile": None,
49+
"fwf_re": True,
4950
"loglevel": "INFO",
5051
"service_logger": True,
5152
}
@@ -73,6 +74,7 @@ def __init__(self, name):
7374

7475
self._ota_check = False
7576
self._fwfile = None
77+
self._fwf_re = None
7678
self._log_idx = None
7779
self._reset_causes = {
7880
machine.PWRON_RESET: "POWER ON",
@@ -323,9 +325,14 @@ async def do_action(self, action, service):
323325
_ota_service._new_sha_check = True
324326
if self._fwfile:
325327
if self._fwfile != _ota_params["fwfile"]:
326-
if self.log:
327-
self.log.info("No new OTA update")
328-
return
328+
if not self._fwf_re:
329+
if self.log:
330+
self.log.info("No new OTA update")
331+
return
332+
elif not _ota_params["fwfile"].endswith(self._fwfile):
333+
if self.log:
334+
self.log.info("No new OTA update")
335+
return
329336
else:
330337
self._fwfile = _ota_params["fwfile"]
331338
if _ota_service._comp_sha_ota(_ota_params["sha"]):
@@ -623,6 +630,7 @@ async def task(
623630
topics=[],
624631
ota_check=True,
625632
fwfile=None,
633+
fwf_re=True,
626634
log=None,
627635
loglevel="INFO",
628636
service_logger=False,
@@ -632,7 +640,8 @@ async def task(
632640
for top in topics:
633641
self._topics.add(top)
634642
self._ota_check = ota_check
635-
self._fwfile = fwfile
643+
self._fwfile = aioctl.getenv("FWFILE", fwfile)
644+
self._fwf_re = fwf_re
636645
if isinstance(self._SERVICE_TOPIC, str):
637646
self._TASK_TOPIC = self._TASK_TOPIC.format(client_id).encode("utf-8")
638647
self._SERVICE_TOPIC = self._SERVICE_TOPIC.format(client_id).encode("utf-8")

0 commit comments

Comments
 (0)