Skip to content

Changes for the Blinka not having rtc or supervisor #9

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
Jan 14, 2021
Merged
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
18 changes: 14 additions & 4 deletions adafruit_portalbase/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@
import gc
from micropython import const
from adafruit_io.adafruit_io import IO_HTTP, AdafruitIO_RequestError
import supervisor
import rtc
from adafruit_fakerequests import Fake_Requests

try:
import supervisor
except ImportError:
supervisor = None

try:
import rtc
except ImportError:
rtc = None

try:
from secrets import secrets
Expand Down Expand Up @@ -211,7 +218,8 @@ def get_local_time(self, location=None):
now = time.struct_time(
(year, month, mday, hours, minutes, seconds, week_day, year_day, is_dst)
)
rtc.RTC().datetime = now
if rtc is not None:
rtc.RTC().datetime = now

# now clean up
response.close()
Expand Down Expand Up @@ -540,7 +548,9 @@ def _parse_data(
print("Couldn't parse json: ", response.text)
raise
except MemoryError:
supervisor.reload()
if supervisor is not None:
supervisor.reload()
raise

if content_type == CONTENT_JSON:
values = self.process_json(json_out, json_path)
Expand Down