Skip to content

Update for FONA3G, SMS #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 67 commits into from
Jun 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
189765c
add receive_sms, RI pin
May 20, 2020
a8c3d91
working enable_sms_notification, remove property on num_sms due to st…
May 20, 2020
e7fa10b
poll RI
May 20, 2020
5f10a2d
make uart functions private, remove public in_waiting method
May 20, 2020
6ee104b
reduce filesize, fix FONA_SMS_STORAGE_INTERNAL const
May 20, 2020
ac38883
iemi->IMEI
May 20, 2020
d7d79c1
fona 3g GPS
May 21, 2020
f0fe606
reflect removed property in example
May 21, 2020
0c4f172
make fona type public property, add 3g-compatible delete_all_sms
May 21, 2020
125d2c7
update for FONA3g
May 21, 2020
4a0f498
lint & black
May 21, 2020
43f0805
fona sms use default RST pinout for shields!
May 21, 2020
0d66916
put back fona simpletest...
May 21, 2020
ef9cde0
Add FONA3G class
May 21, 2020
38d7217
add manual baudrate setting
May 21, 2020
03809b6
Make GPS getter/setter subclasses in FONA3G, remove 3G-specific if/el…
May 21, 2020
1ec7ff7
add ue_system_info for tcp/ip socket implementation
May 21, 2020
645c36a
verify GPS session within gps property instead of looking for fix
May 22, 2020
26553f0
subclass CDMA for 3G modules
May 22, 2020
f2f8461
initialize without sublcassing because it's a different __init__ process
May 22, 2020
f528713
add set_gprs for fona3g
May 22, 2020
9b5e478
add simpletest for 3g
May 22, 2020
8269cb4
refactor local_ip for SIM5320
May 22, 2020
3161a9b
cipshut->netclose
May 22, 2020
1e5f3b7
add get_host_by_name for fona3g, behaves differently than fona2g models
May 22, 2020
d47f61e
add get_socket implementation, 3g lacks cipstatus
May 22, 2020
ebecca6
add wcdma socket connect
May 22, 2020
5b912de
update example
May 22, 2020
ac0ac44
3G-compat remote ip address fetcher
May 26, 2020
0b5aba5
bring in socket_write, refactor a bit for a different expected respon…
May 26, 2020
c14c0b0
disable ciphead/cipsrip, wait for send cipsend(rx,tx), then Send ok
May 27, 2020
b8d4a2e
socket class should check module's timeout parameters instead of rely…
May 27, 2020
5d88182
network open and cipopen with correct timeouts, manually rx data, dis…
May 27, 2020
25d8d37
check for data on specific socket, update simpletest with progress
May 27, 2020
ebdc6a8
reuse fona's standard socket_available instead
May 27, 2020
808a5af
recv works :)
May 27, 2020
805c0a4
fona sock close work for 8xx and 3g
May 27, 2020
e35bdf0
remove todo, check and expect uart for CIP open
May 27, 2020
ffc167e
s/super/self
May 27, 2020
9794ff8
only set CGAUTH if authentication params are provided by user-code!
May 27, 2020
b09ac66
pylint+black 3g
May 27, 2020
e20cab1
enforce timeout in socket_write
May 27, 2020
001f689
fona passing pylinting
May 27, 2020
1eac9f7
make cipsend timeout a property
May 28, 2020
3cbb447
black and lint
May 28, 2020
cda354a
add a _readline to avoid parsing OK and failing by mistake
May 28, 2020
ae392ee
requests-like simpletest
May 28, 2020
34bfcdb
fix initialization routine to read uart once instead of twice
May 29, 2020
208d002
redundant read_line, reduce # to check uart faster
May 29, 2020
70e0362
remove sleep after ate0
May 29, 2020
ccfd9b2
readout fona3g msg, doesnt cause OK after, should be CDNSGIP: after C…
May 29, 2020
b15bc6d
split CDMA and GSM into a master Networking class which assumes the t…
May 29, 2020
6f8ebf3
fixup 3g example, need to merge into existing. add aio post type example
May 29, 2020
20b22ba
moveinto calling it cellular instead of network, network.cellular/net…
May 29, 2020
558019c
replace fona_simpletest for 3g with universal simpletest for both pla…
May 29, 2020
3423d49
initialize baudrate within fona_3g instead of user-code
May 29, 2020
0f5ee81
FONA SMS example refactored
May 29, 2020
d04e939
fona sms response example refactored for 3g
May 29, 2020
f9b1480
remove access to protected property, undefined loop variable
May 29, 2020
51129f6
linty
May 29, 2020
90ad435
black
May 29, 2020
c1ae090
dns parsing fix for fona8xx
Jun 1, 2020
c88d973
rst -> d4
Jun 1, 2020
808019e
fixup sms parsing, check ri before uart
Jun 1, 2020
4885084
add RI pin to sms_response example
Jun 1, 2020
666b48c
remove sleep, poll faster
Jun 1, 2020
c5a824a
remove cruft..
Jun 1, 2020
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
357 changes: 179 additions & 178 deletions adafruit_fona/adafruit_fona.py

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,38 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
"""
`adafruit_fona_gsm`
`adafruit_fona_network`
=================================================================================

Interface for 2G GSM cellular modems such as the Adafruit FONA808.
Interface for connecting to and interacting with GSM and CDMA cellular networks.

* Author(s): Brent Rubell

"""

# Network types
NET_GSM = 0x01
NET_CDMA = 0x02

class GSM:
"""Interface for interacting with FONA 2G GSM modems.
"""

class CELLULAR:
"""Interface for connecting to and interacting with GSM and CDMA cellular networks."""

def __init__(self, fona, apn):
"""Initializes interface with 2G GSM modem.
"""Initializes interface with cellular network.
:param adafruit_fona fona: The Adafruit FONA module we are using.
:param tuple apn: Tuple containing APN name, (optional) APN username,
and APN password.

"""
self._iface = fona
self._apn = apn
self._gsm_connected = False
self._network_connected = False
self._network_type = NET_CDMA

# Enable GPS module
self._iface.gps = True
if not self._iface.version == 0x4 or self._iface.version == 0x5:
self._network_type = NET_GSM
self._iface.gps = True

def __enter__(self):
return self
Expand All @@ -56,7 +61,7 @@ def __exit__(self, exception_type, exception_value, traceback):

@property
def imei(self):
"""Returns the GSM modem's IEMI number, as a string."""
"""Returns the modem's IEMI number, as a string."""
return self._iface.iemi

@property
Expand All @@ -66,31 +71,31 @@ def iccid(self):

@property
def is_attached(self):
"""Returns if the modem is attached to the network
and the GPS has a fix."""
if self._iface.gps == 3 and self._iface.network_status == 1:
return True
"""Returns if the modem is attached to the network."""
if self._network_type == NET_GSM:
if self._iface.gps == 3 and self._iface.network_status == 1:
return True
else: # Attach CDMA network
if self._iface.ue_system_info == 1 and self._iface.network_status == 1:
return True
return False

@property
def is_connected(self):
"""Returns if attached to GSM
and an IP Addresss was obtained.

"""
if not self._gsm_connected:
"""Returns if attached to network and an IP Addresss was obtained."""
if not self._network_connected:
return False
return True

def connect(self):
"""Connect to GSM network."""
"""Connect to cellular network."""
if self._iface.set_gprs(self._apn, True):
self._gsm_connected = True
self._network_connected = True
else:
# reset context for next connection attempt
self._iface.set_gprs(self._apn, False)

def disconnect(self):
"""Disconnect from GSM network."""
"""Disconnect from cellular network."""
self._iface.set_gprs(self._apn, False)
self._gsm_connected = False
self._network_connected = False
7 changes: 5 additions & 2 deletions adafruit_fona/adafruit_fona_socket.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@ def __init__(
raise RuntimeError("Only AF_INET family supported by cellular sockets.")
self._sock_type = type
self._buffer = b""
self._timeout = 0
if hasattr(_the_interface, "tx_timeout"):
self._timeout = _the_interface.tx_timeout
else:
self._timeout = 3000 # FONA800

self._socknum = _the_interface.get_socket()
SOCKETS.append(self._socknum)
Expand Down Expand Up @@ -157,7 +160,7 @@ def send(self, data):
:param bytes data: Desired data to send to the socket.

"""
_the_interface.socket_write(self._socknum, data)
_the_interface.socket_write(self._socknum, data, self._timeout)
gc.collect()

def recv(self, bufsize=0):
Expand Down
Loading