diff --git a/notecard/card.py b/notecard/card.py index 4edf1af..daddf91 100644 --- a/notecard/card.py +++ b/notecard/card.py @@ -9,7 +9,6 @@ # This module contains helper methods for calling card.* Notecard API commands. # This module is optional and not required for use with the Notecard. -import notecard from notecard.validators import validate_card_object @@ -137,16 +136,51 @@ def wireless(card, mode=None, apn=None): Args: card (Notecard): The current Notecard object. - mode (string): The wireless module mode to set. + mode (string): The wireless module mode to set. Must be one of: + "-" to reset to the default mode + "auto" to perform automatic band scan mode (default) + "m" to restrict the modem to Cat-M1 + "nb" to restrict the modem to Cat-NB1 + "gprs" to restrict the modem to EGPRS apn (string): Access Point Name (APN) when using an external SIM. + Use "-" to reset to the Notecard default APN. Returns: - string: The result of the Notecard request. + dict: The result of the Notecard request containing network status and + signal information. """ req = {"req": "card.wireless"} if mode: req["mode"] = mode if apn: req["apn"] = apn + return card.Transaction(req) + + +@validate_card_object +def transport(card, method=None, allow=None): + """Configure the Notecard's connectivity method. + Args: + card (Notecard): The current Notecard object. + method (string): The connectivity method to enable. Must be one of: + "-" to reset to device default + "wifi-cell" to prioritize WiFi with cellular fallback + "wifi" to enable WiFi only + "cell" to enable cellular only + "ntn" to enable Non-Terrestrial Network mode + "wifi-ntn" to prioritize WiFi with NTN fallback + "cell-ntn" to prioritize cellular with NTN fallback + "wifi-cell-ntn" to prioritize WiFi, then cellular, then NTN + allow (bool): When True, allows adding Notes to non-compact Notefiles + while connected over a non-terrestrial network. + + Returns: + dict: The result of the Notecard request. + """ + req = {"req": "card.transport"} + if method: + req["method"] = method + if allow is not None: + req["allow"] = allow return card.Transaction(req) diff --git a/test/fluent_api/test_card.py b/test/fluent_api/test_card.py index beb246d..bb4d082 100644 --- a/test/fluent_api/test_card.py +++ b/test/fluent_api/test_card.py @@ -53,6 +53,14 @@ 'mode': 'auto', 'apn': 'myapn.nb' } + ), + ( + card.transport, + 'card.transport', + { + 'method': 'wifi-cell-ntn', + 'allow': True + } ) ] )