badgeteam / ESP32-platform-firmware

Universal badge platform for ESP32 based devices! Runs on the event badges from SHA2017, HackerHotel 2019, Disobey 2019, CampZone 2019, Disobey 2020 and more!
https://badge.team
40 stars 42 forks source link

micropython (mch2022 badge) cannot import bluetooth #244

Open rambo opened 2 years ago

rambo commented 2 years ago

USB REPL:

>>> import bluetooth
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'bluetooth'
>>> import ubluetooth
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'ubluetooth'

Does not work any better in an app (not that I really expected it to)

USB console:

Starting app '/apps/python/nightshift'...
No bluetooth, trying ubluetooth
Traceback (most recent call last):
  File "boot.py", line 26, in <module>
  File "/apps/python/nightshift/__init__.py", line 4, in <module>
  File "/apps/python/nightshift/nshift.py", line 7, in <module>
ImportError: no module named 'ubluetooth'
Fatal exception in the running app!
␀ets Jul 29 2019 12:21:46

init.py:

"""Control LightMode Nighshift"""
import buttons
import mch22
from .nshift import main
import uasyncio

# Register reboot button callback
def handle_reboot(pressed):
  if pressed:
    mch22.exit_python()

buttons.attach(buttons.BTN_A,handle_reboot)

uasyncio.get_event_loop().run_until_complete(main())

nshift.py

"""BLE and NS stuff"""
import uasyncio
try:
    import bluetooth
except ImportError:
    print("No bluetooth, trying ubluetooth")
    import ubluetooth as bluetooth

async def main():
    while True:
        print("Foo")
        await uasyncio.sleep(10.0)