Skip to content

Commit

Permalink
Make mypy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
lukipuki committed Oct 29, 2023
1 parent 97d09d5 commit c5f4d88
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion src/yaroc/clients/mqtt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import asyncio
import logging
from concurrent.futures import Future
from datetime import datetime, timedelta
from typing import Tuple

Expand Down
12 changes: 6 additions & 6 deletions src/yaroc/utils/sim7020.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _detect_mqtt_id(self) -> int | None:
return self._mqtt_id
try:
response = self.async_at.call("AT+CMQCON?", f'CMQCON: ([0-9]),1,"{self._broker_url}"')
if response.success:
if response.query is not None:
self._mqtt_id = int(response.query[0])
finally:
return self._mqtt_id
Expand All @@ -135,19 +135,19 @@ def _mqtt_connect_internal(self) -> int | None:
correct = any(line.startswith("+CEREG: 3") for line in response.full_response)
if not correct:
self.async_at.call("AT+CEREG=3")
if not response.success:
if response.query is not None:
logging.warning("Not registered yet")
return None

response = self.async_at.call("AT+CCLK?", "CCLK: (.*)")
if response.success:
if response.query is not None:
self.set_clock(response.query[0])

response = self.async_at.call(
"AT+CMQNEW?",
f"\\+CMQNEW: ([0-9]),1,{self._broker_url}",
)
if response.success:
if response.query is not None:
# CMQNEW is fine but CMQCON is not, the only solution is a disconnect
self.mqtt_disconnect(int(response.query[0]))

Expand Down Expand Up @@ -200,12 +200,12 @@ def mqtt_send(self, topic: str, message: bytes, qos: int = 0) -> bool:
self._last_success = datetime.now()
return response.success

def get_signal_info(self) -> tuple[int, str] | None:
def get_signal_info(self) -> tuple[int, int] | None:
response = self.async_at.call("AT+CENG?", "CENG: (.*)", [6, 3])
if self.async_at.last_at_response() < datetime.now() - timedelta(minutes=5):
self.power_on()
try:
if response.success:
if response.query is not None:
try:
cellid = int(response.query[1][1:-1], 16)
except Exception:
Expand Down

0 comments on commit c5f4d88

Please sign in to comment.