Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 37 additions & 3 deletions notecard/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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)
8 changes: 8 additions & 0 deletions test/fluent_api/test_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@
'mode': 'auto',
'apn': 'myapn.nb'
}
),
(
card.transport,
'card.transport',
{
'method': 'wifi-cell-ntn',
'allow': True
}
)
]
)
Expand Down
Loading