diff --git a/adafruit_magtag/network.py b/adafruit_magtag/network.py index 5a61a37..1607cee 100755 --- a/adafruit_magtag/network.py +++ b/adafruit_magtag/network.py @@ -27,8 +27,9 @@ """ +import neopixel from adafruit_portalbase.network import NetworkBase -from adafruit_magtag.wifi_module import WiFi +from adafruit_portalbase.wifi_esp32s2 import WiFi __version__ = "0.0.0-auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MagTag.git" @@ -53,8 +54,12 @@ def __init__( extract_values=True, debug=False, ): + if status_neopixel: + status_led = neopixel.NeoPixel(status_neopixel, 1, brightness=0.2) + else: + status_led = None super().__init__( - WiFi(status_neopixel=status_neopixel), + WiFi(status_led=status_led), extract_values=extract_values, debug=debug, ) diff --git a/adafruit_magtag/wifi_module.py b/adafruit_magtag/wifi_module.py deleted file mode 100755 index 84dda5c..0000000 --- a/adafruit_magtag/wifi_module.py +++ /dev/null @@ -1,105 +0,0 @@ -# SPDX-FileCopyrightText: 2017 Scott Shawcroft, written for Adafruit Industries -# SPDX-FileCopyrightText: Copyright (c) 2020 Melissa LeBlanc-Williams for Adafruit Industries -# -# SPDX-License-Identifier: MIT -""" -`adafruit_magtag.wifi_module` -================================================================================ - -Helper Library for the Adafruit MagTag. - - -* Author(s): Melissa LeBlanc-Williams - -Implementation Notes --------------------- - -**Hardware:** - -* `Adafruit MagTag `_ - -**Software and Dependencies:** - -* Adafruit CircuitPython firmware for the supported boards: - https://github.com/adafruit/circuitpython/releases - -* Adafruit's PortalBase library: https://github.com/adafruit/Adafruit_CircuitPython_PortalBase - -""" - -import gc -import ssl -import neopixel -import wifi -import socketpool -import adafruit_requests - -__version__ = "0.0.0-auto.0" -__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_MagTag.git" - - -class WiFi: - """Class representing the WiFi portion of the ESP32-S2. - - :param status_neopixel: The pin for the status NeoPixel. Use ``board.NEOPIXEL`` for the on-board - NeoPixel. Defaults to ``None``, not the status LED - - """ - - def __init__(self, *, status_neopixel=None): - - if status_neopixel: - self.neopix = neopixel.NeoPixel(status_neopixel, 1, brightness=0.2) - else: - self.neopix = None - self.neo_status(0) - self.requests = None - self._connected = False - - gc.collect() - - def connect(self, ssid, password): - """ - Connect to the WiFi Network using the information provided - - :param ssid: The WiFi name - :param password: The WiFi password - - """ - wifi.radio.connect(ssid, password) - pool = socketpool.SocketPool(wifi.radio) - self.requests = adafruit_requests.Session(pool, ssl.create_default_context()) - self._connected = True - - def neo_status(self, value): - """The status NeoPixel. - - :param value: The color to change the NeoPixel. - - """ - if self.neopix: - self.neopix.fill(value) - - @property - def is_connected(self): - """ - Return whether we have already connected since reconnections are handled automatically. - - """ - return self._connected - - @property - def ip_address(self): - """ - Return the IP Version 4 Address - - """ - return wifi.radio.ipv4_address - - @property - def enabled(self): - """ - Return whether the WiFi Radio is enabled - - """ - return wifi.radio.enabled diff --git a/docs/api.rst b/docs/api.rst index 41694b9..629953c 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -9,8 +9,5 @@ .. automodule:: adafruit_magtag.network :members: -.. automodule:: adafruit_magtag.wifi_module - :members: - .. automodule:: adafruit_magtag.peripherals :members: