Skip to content
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

micropython (mch2022 badge) cannot import bluetooth #244

Open
rambo opened this issue Jul 25, 2022 · 0 comments
Open

micropython (mch2022 badge) cannot import bluetooth #244

rambo opened this issue Jul 25, 2022 · 0 comments

Comments

@rambo
Copy link

rambo commented Jul 25, 2022

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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant