Skip to content

Commit 871588d

Browse files
author
brentru
committed
updates for new fona release
1 parent 5e840a4 commit 871588d

File tree

2 files changed

+22
-18
lines changed

2 files changed

+22
-18
lines changed

examples/minimqtt_adafruitio_cellular.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import busio
44
import digitalio
55
from adafruit_fona.adafruit_fona import FONA
6-
from adafruit_fona.adafruit_fona_gsm import GSM
6+
import adafruit_fona.adafruit_fona_network as network
77
import adafruit_fona.adafruit_fona_socket as socket
88

99
import adafruit_minimqtt as MQTT
@@ -54,19 +54,21 @@ def message(client, topic, message):
5454
print("New message on topic {0}: {1}".format(topic, message))
5555

5656

57-
# Initialize GSM modem
58-
gsm = GSM(fona, (secrets["apn"], secrets["apn_username"], secrets["apn_password"]))
57+
# Initialize cellular data network
58+
network = network.CELLULAR(
59+
fona, (secrets["apn"], secrets["apn_username"], secrets["apn_password"])
60+
)
5961

60-
while not gsm.is_attached:
62+
while not network.is_attached:
6163
print("Attaching to network...")
6264
time.sleep(0.5)
63-
print("Attached to network!")
65+
print("Attached!")
6466

65-
while not gsm.is_connected:
67+
while not network.is_connected:
6668
print("Connecting to network...")
67-
gsm.connect()
68-
time.sleep(5)
69-
print("Connected to network!")
69+
network.connect()
70+
time.sleep(0.5)
71+
print("Network Connected!")
7072

7173
# Initialize MQTT interface with the cellular interface
7274
MQTT.set_socket(socket, fona)

examples/minimqtt_simpletest_cellular.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import busio
44
import digitalio
55
from adafruit_fona.adafruit_fona import FONA
6-
from adafruit_fona.adafruit_fona_gsm import GSM
6+
import adafruit_fona.adafruit_fona_network as network
77
import adafruit_fona.adafruit_fona_socket as socket
88

99
import adafruit_minimqtt as MQTT
@@ -65,19 +65,21 @@ def publish(client, userdata, topic, pid):
6565
print("Published to {0} with PID {1}".format(topic, pid))
6666

6767

68-
# Initialize GSM modem
69-
gsm = GSM(fona, (secrets["apn"], secrets["apn_username"], secrets["apn_password"]))
68+
# Initialize cellular data network
69+
network = network.CELLULAR(
70+
fona, (secrets["apn"], secrets["apn_username"], secrets["apn_password"])
71+
)
7072

71-
while not gsm.is_attached:
73+
while not network.is_attached:
7274
print("Attaching to network...")
7375
time.sleep(0.5)
74-
print("Attached to network!")
76+
print("Attached!")
7577

76-
while not gsm.is_connected:
78+
while not network.is_connected:
7779
print("Connecting to network...")
78-
gsm.connect()
79-
time.sleep(5)
80-
print("Connected to network!")
80+
network.connect()
81+
time.sleep(0.5)
82+
print("Network Connected!")
8183

8284
# Initialize MQTT interface with the cellular interface
8385
MQTT.set_socket(socket, fona)

0 commit comments

Comments
 (0)