From 6799954148903c3d160641d055dbcf7a97a3cf59 Mon Sep 17 00:00:00 2001 From: acmacunlay Date: Tue, 8 Oct 2024 23:08:29 +0800 Subject: [PATCH] WIP: Implement SMS standard --- src/pywaveshare/boards/sim868/protocols.py | 25 +++++++++++++++++++++- src/pywaveshare/boards/sim868/typedefs.py | 9 ++++++++ src/pywaveshare/boards/sim868/worker.py | 3 ++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/pywaveshare/boards/sim868/protocols.py b/src/pywaveshare/boards/sim868/protocols.py index 725465c..4c8fb30 100644 --- a/src/pywaveshare/boards/sim868/protocols.py +++ b/src/pywaveshare/boards/sim868/protocols.py @@ -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) diff --git a/src/pywaveshare/boards/sim868/typedefs.py b/src/pywaveshare/boards/sim868/typedefs.py index e69de29..4651c54 100644 --- a/src/pywaveshare/boards/sim868/typedefs.py +++ b/src/pywaveshare/boards/sim868/typedefs.py @@ -0,0 +1,9 @@ +import typing + +SMSSend = typing.TypedDict( + "SMSSend", + { + "Recipients": typing.List[str], + "Message": str, + }, +) diff --git a/src/pywaveshare/boards/sim868/worker.py b/src/pywaveshare/boards/sim868/worker.py index 6becadd..29df146 100644 --- a/src/pywaveshare/boards/sim868/worker.py +++ b/src/pywaveshare/boards/sim868/worker.py @@ -1,6 +1,6 @@ import threading -from . import config, itc +from . import config, itc, protocols class Worker(threading.Thread): @@ -10,6 +10,7 @@ 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()