Skip to content

Remove secrets usage #33

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 1 commit into from
Feb 27, 2025
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
26 changes: 11 additions & 15 deletions examples/fona_aio_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: MIT

# pylint: disable=unused-import
from os import getenv
import time
import board
import busio
Expand All @@ -13,12 +14,13 @@
import adafruit_fona.adafruit_fona_network as network
import adafruit_fona.adafruit_fona_socket as pool

# Get GPRS details and more from a secrets.py file
try:
from secrets import secrets
except ImportError:
print("GPRS secrets are kept in secrets.py, please add them there!")
raise
# Get FONA details and Adafruit IO keys, ensure these are setup in settings.toml
# (visit io.adafruit.com if you need to create an account, or if you need your Adafruit IO key.)
apn = getenv("apn")
apn_username = getenv("apn_username")
apn_password = getenv("apn_password")
aio_username = getenv("ADAFRUIT_AIO_USERNAME")
aio_key = getenv("ADAFRUIT_AIO_KEY")

# Create a serial connection for the FONA
uart = busio.UART(board.TX, board.RX)
Expand All @@ -31,9 +33,7 @@
# fona = FONA3G(uart, rst)

# Initialize cellular data network
network = network.CELLULAR(
fona, (secrets["apn"], secrets["apn_username"], secrets["apn_password"])
)
network = network.CELLULAR(fona, (apn, apn_username, apn_password))

while not network.is_attached:
print("Attaching to network...")
Expand All @@ -58,13 +58,9 @@
feed = "test"
payload = {"value": data}
response = requests.post(
"http://io.adafruit.com/api/v2/"
+ secrets["aio_username"]
+ "/feeds/"
+ feed
+ "/data",
"http://io.adafruit.com/api/v2/" + aio_username + "/feeds/" + feed + "/data",
json=payload,
headers={"X-AIO-KEY": secrets["aio_key"]},
headers={"X-AIO-KEY": aio_key},
)
print(response.json())
response.close()
Expand Down
15 changes: 6 additions & 9 deletions examples/fona_cheerlights.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: MIT

# pylint: disable=unused-import
from os import getenv
import time
import board
import busio
Expand All @@ -15,12 +16,10 @@
import adafruit_fona.adafruit_fona_network as network
import adafruit_fona.adafruit_fona_socket as pool

# Get GPRS details and more from a secrets.py file
try:
from secrets import secrets
except ImportError:
print("GPRS secrets are kept in secrets.py, please add them there!")
raise
# Get FONA details, ensure these are setup in settings.toml
apn = getenv("apn")
apn_username = getenv("apn_username")
apn_password = getenv("apn_password")

# Create a serial connection for the FONA
uart = busio.UART(board.TX, board.RX)
Expand All @@ -33,9 +32,7 @@
# fona = FONA3G(uart, rst)

# Initialize cellular data network
network = network.CELLULAR(
fona, (secrets["apn"], secrets["apn_username"], secrets["apn_password"])
)
network = network.CELLULAR(fona, (apn, apn_username, apn_password))

while not network.is_attached:
print("Attaching to network...")
Expand Down
15 changes: 6 additions & 9 deletions examples/fona_simpletest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: MIT

# pylint: disable=unused-import
from os import getenv
import time
import board
import busio
Expand All @@ -18,12 +19,10 @@
TEXT_URL = "http://wifitest.adafruit.com/testwifi/index.html"
JSON_URL = "http://api.coindesk.com/v1/bpi/currentprice/USD.json"

# Get GPRS details and more from a secrets.py file
try:
from secrets import secrets
except ImportError:
print("GPRS secrets are kept in secrets.py, please add them there!")
raise
# Get FONA details, ensure these are setup in settings.toml
apn = getenv("apn")
apn_username = getenv("apn_username")
apn_password = getenv("apn_password")

# Create a serial connection for the FONA connection
uart = busio.UART(board.TX, board.RX)
Expand All @@ -36,9 +35,7 @@
# fona = FONA3G(uart, rst)

# Initialize cellular data network
network = network.CELLULAR(
fona, (secrets["apn"], secrets["apn_username"], secrets["apn_password"])
)
network = network.CELLULAR(fona, (apn, apn_username, apn_password))

while not network.is_attached:
print("Attaching to network...")
Expand Down