text: # SPDX-FileCopyrightText: 2019 ladyada for Adafruit Industries
  # SPDX-License-Identifier: MIT
  
  import time
  import board
  import busio
  from digitalio import DigitalInOut
  import neopixel
  from adafruit_esp32spi import adafruit_esp32spi
  from adafruit_esp32spi.adafruit_esp32spi_wifimanager import ESPSPI_WiFiManager
  
  print("ESP32 SPI WPA2 Enterprise webclient test")
  
  # Get wifi details and more from a secrets.py file
  try:
      from secrets import secrets
  except ImportError:
      print("WiFi secrets are kept in secrets.py, please add them there!")
      raise
  
  # ESP32 setup
  # If your board does define the three pins listed below,
  # you can set the correct pins in the second block
  try:
      esp32_cs = DigitalInOut(board.ESP_CS)
      esp32_ready = DigitalInOut(board.ESP_BUSY)
      esp32_reset = DigitalInOut(board.ESP_RESET)
  except AttributeError:
      esp32_cs = DigitalInOut(board.D9)
      esp32_ready = DigitalInOut(board.D10)
      esp32_reset = DigitalInOut(board.D5)
  
  spi = busio.SPI(board.SCK, board.MOSI, board.MISO)
  esp = adafruit_esp32spi.ESP_SPIcontrol(spi, esp32_cs, esp32_ready, esp32_reset)
  """Use below for Most Boards"""
  status_light = neopixel.NeoPixel(
      board.NEOPIXEL, 1, brightness=0.2
  )  # Uncomment for Most Boards
  """Uncomment below for ItsyBitsy M4"""
  # status_light = dotstar.DotStar(board.APA102_SCK, board.APA102_MOSI, 1, brightness=0.2)
  wifi = ESPSPI_WiFiManager(
      esp, secrets, status_light, connection_type=ESPSPI_WiFiManager.ENTERPRISE
  )
  
  counter = 0
  
  while True:
      try:
          print("Posting data...", end="")
          data = counter
          feed = "test"
          payload = {"value": data}
          response = wifi.post(
              "https://io.adafruit.com/api/v2/"
              + secrets["aio_username"]
              + "/feeds/"
              + feed
              + "/data",
              json=payload,
              headers={"X-AIO-KEY": secrets["aio_key"]},
          )
          print(response.json())
          response.close()
          counter = counter + 1
          print("OK")
      except (ValueError, RuntimeError) as e:
          print("Failed to get data, retrying\n", e)
          wifi.reset()
          continue
      response = None
      time.sleep(15)
  