Skip to content

Commit dbec383

Browse files
authored
Merge pull request #94 from blues/devin/1707936284-card-transport-only
feat: add card.transport method for NTN connectivity
2 parents 63e3dca + 5cc5f5f commit dbec383

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

notecard/card.py

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# This module contains helper methods for calling card.* Notecard API commands.
1010
# This module is optional and not required for use with the Notecard.
1111

12-
import notecard
1312
from notecard.validators import validate_card_object
1413

1514

@@ -137,16 +136,51 @@ def wireless(card, mode=None, apn=None):
137136
138137
Args:
139138
card (Notecard): The current Notecard object.
140-
mode (string): The wireless module mode to set.
139+
mode (string): The wireless module mode to set. Must be one of:
140+
"-" to reset to the default mode
141+
"auto" to perform automatic band scan mode (default)
142+
"m" to restrict the modem to Cat-M1
143+
"nb" to restrict the modem to Cat-NB1
144+
"gprs" to restrict the modem to EGPRS
141145
apn (string): Access Point Name (APN) when using an external SIM.
146+
Use "-" to reset to the Notecard default APN.
142147
143148
Returns:
144-
string: The result of the Notecard request.
149+
dict: The result of the Notecard request containing network status and
150+
signal information.
145151
"""
146152
req = {"req": "card.wireless"}
147153
if mode:
148154
req["mode"] = mode
149155
if apn:
150156
req["apn"] = apn
157+
return card.Transaction(req)
158+
159+
160+
@validate_card_object
161+
def transport(card, method=None, allow=None):
162+
"""Configure the Notecard's connectivity method.
151163
164+
Args:
165+
card (Notecard): The current Notecard object.
166+
method (string): The connectivity method to enable. Must be one of:
167+
"-" to reset to device default
168+
"wifi-cell" to prioritize WiFi with cellular fallback
169+
"wifi" to enable WiFi only
170+
"cell" to enable cellular only
171+
"ntn" to enable Non-Terrestrial Network mode
172+
"wifi-ntn" to prioritize WiFi with NTN fallback
173+
"cell-ntn" to prioritize cellular with NTN fallback
174+
"wifi-cell-ntn" to prioritize WiFi, then cellular, then NTN
175+
allow (bool): When True, allows adding Notes to non-compact Notefiles
176+
while connected over a non-terrestrial network.
177+
178+
Returns:
179+
dict: The result of the Notecard request.
180+
"""
181+
req = {"req": "card.transport"}
182+
if method:
183+
req["method"] = method
184+
if allow is not None:
185+
req["allow"] = allow
152186
return card.Transaction(req)

test/fluent_api/test_card.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@
5353
'mode': 'auto',
5454
'apn': 'myapn.nb'
5555
}
56+
),
57+
(
58+
card.transport,
59+
'card.transport',
60+
{
61+
'method': 'wifi-cell-ntn',
62+
'allow': True
63+
}
5664
)
5765
]
5866
)

0 commit comments

Comments
 (0)