Skip to content

Commit

Permalink
Merge branch 'feature/manual-at-commands' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
acmacunlay committed Oct 8, 2024
2 parents 4735981 + 1210f72 commit a1295a6
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "pywaveshare"
version = "0.5.0a0"
dependencies = ["RPi.GPIO", "pyserial"]
dependencies = ["pyserial", "RPi.GPIO", "typing-extensions"]
requires-python = ">=3.7"
authors = [{ name = "Tarek Tounsi", email = "software@tounsi.de" }]
maintainers = [
Expand Down
8 changes: 7 additions & 1 deletion src/pywaveshare/boards/sim868/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from . import config, worker
from . import config, itc, worker


class Client:
Expand All @@ -7,4 +7,10 @@ class Client:
def __init__(self, config: config.Config) -> None:
self.config = config
self.worker = worker.Worker(self.config)

def start(self) -> None:
itc.IS_WORKER_RUNNING.set()
self.worker.start()

def send_at_command(self, command: str):
pass
11 changes: 8 additions & 3 deletions src/pywaveshare/boards/sim868/itc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@

IS_WORKER_RUNNING = threading.Event()

ACQUIRE_SERIAL_OBJECT = threading.Lock()
SERIAL_LOCK = threading.Lock()
C2W_Q_LOCK = threading.Lock()
"""
If acquired, then the acquirer can to safely work on `CLIENT_TO_WORKER_Q` queue.
"""

ON_SERIAL_RX: queue.Queue[bytes] = queue.Queue()
ON_SERIAL_TX: queue.Queue[bytes] = queue.Queue()
CLIENT_TO_WORKER_Q: queue.Queue[bytes] = queue.Queue()
WORKER_TO_SERIAL_Q: queue.Queue[bytes] = queue.Queue()
SERIAL_TO_WORKER_Q: queue.Queue[bytes] = queue.Queue()
25 changes: 24 additions & 1 deletion src/pywaveshare/boards/sim868/protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,30 @@
import typing


class SupportedProtocol(abc.ABC):
class SupportedStandard(abc.ABC):
NAME: typing.Optional[str] = None

RESPONSE_PATTERN = r""


class SMS(SupportedStandard):
NAME = "SMS"

RESPONSE_PATTERN = (
r"loremipsumdolorsitamet"
r"loremipsumdolorsitamet"
r"loremipsumdolorsitamet"
r"loremipsumdolorsitamet"
r"loremipsumdolorsitamet"
r"loremipsumdolorsitamet"
r"loremipsumdolorsitamet"
)


class SupportedProtocolFactory:
pass


if __name__ == "__main__":
protocol = SMS()
print(protocol.RESPONSE_PATTERN)
11 changes: 11 additions & 0 deletions src/pywaveshare/boards/sim868/typedefs.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import typing

import typing_extensions

SMSSend = typing_extensions.TypedDict(
"SMSSend",
{
"Recipients": typing.List[str],
"Message": str,
},
)
4 changes: 2 additions & 2 deletions src/pywaveshare/boards/sim868/worker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import threading

from . import config, itc
from . import config, itc, protocols


class Worker(threading.Thread):
Expand All @@ -10,8 +10,8 @@ def __init__(self, config: config.Config) -> None:
super().__init__()

self.config = config
self.protocols = protocols.SupportedProtocolFactory()

def run(self) -> None:
itc.IS_WORKER_RUNNING.set()
while itc.IS_WORKER_RUNNING.is_set():
pass

0 comments on commit a1295a6

Please sign in to comment.