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

Why is async needed? #15

Open
matfed opened this issue Dec 31, 2023 · 0 comments
Open

Why is async needed? #15

matfed opened this issue Dec 31, 2023 · 0 comments

Comments

@matfed
Copy link

matfed commented Dec 31, 2023

Hello! Thanks for building this library, I finally can control 51515 MVP with a remote :)

I was wondering why Remote.connect is async as it seems to make things much more complicated.

In my project I got rid of async in Remote.connect by replacing yield with utime.sleep_ms(10):

def connect(self, address=None, timeout=5000):
        if address: self.__address = ubinascii.unhexlify(address.replace(':', str()))
        self.__ble_const = _RemoteConstant()
        self.__ble.gap_scan(timeout, 30000, 30000)
        while not self.__ble_const.enabled:
            utime.sleep_ms(10)

That simplifies the setup a lot as you don't need to use the advanced Python API. See here for the full code.

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