I have commented out line 73 which causes the error. I have tried passing various parameters to the PyPortal call but still get similar error messages.
Any ideas?
- Code: Select all | TOGGLE FULL SIZE
import board
from adafruit_pyportal import PyPortal
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService
from adafruit_airlift.esp32 import ESP32
# If you are using a Metro M4 Airlift Lite, PyPortal,
# or MatrixPortal, you can use the default pin settings.
# Leave this DEFAULT line uncommented.
esp32 = ESP32() # DEFAULT
# If you are using CircuitPython 6.0.0 or earlier,
# on PyPortal and PyPortal Titano only, use the pin settings
# below. Comment out the DEFAULT line above and uncomment
# the line below. For CircuitPython 6.1.0, the pin names
# have changed for these boards, and the DEFAULT line
# above is correct.
# esp32 = ESP32(tx=board.TX, rx=board.RX)
# If you are using an AirLift FeatherWing or AirLift Bitsy Add-On,
# use the pin settings below. Comment out the DEFAULT line above
# and uncomment the lines below.
# If you are using an AirLift Breakout, check that these
# choices match the wiring to your microcontroller board,
# or change them as appropriate.
# esp32 = ESP32(
# reset=board.D12,
# gpio0=board.D10,
# busy=board.D11,
# chip_select=board.D13,
# tx=board.TX,
# rx=board.RX,
# )
# If you are using an AirLift Shield,
# use the pin settings below. Comment out the DEFAULT line above
# and uncomment the lines below.
# esp32 = ESP32(
# reset=board.D5,
# gpio0=board.D6,
# busy=board.D7,
# chip_select=board.D10,
# tx=board.TX,
# rx=board.RX,
# )
ourInt = 0
adapter = esp32.start_bluetooth()
ble = BLERadio(adapter)
uart = UARTService()
advertisement = ProvideServicesAdvertisement(uart)
message = ""
def parseMessage(theMessage):
global ourInt
ourList = theMessage.split(":")
thisInt = int(ourList[1])
ourInt = ourInt + thisInt
def sendCurrentValues():
global ourInt
theString = "abc:" + str(ourInt) + "|def:True"
uart.write(theString)
def doOtherStuff():
#print("hello")
pass
while True:
ble.start_advertising(advertisement)
print(advertisement)
print("waiting to connect")
while not ble.connected:
doOtherStuff()
print("connected: trying to read input")
while ble.connected:
ourMessageBytes = uart.readline()
ourMessage = ourMessageBytes.decode("utf-8")
if(len(ourMessage) > 0):
if(ourMessage=="update"):
sendCurrentValues()
else:
parseMessage(ourMessage)
print(ourMessage)
print("ourInt: ",ourInt)