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

radio.RATE_250KBIT in V1 but not V2 #87

Closed
microbit-matt-hillsdon opened this issue Sep 8, 2021 · 2 comments
Closed

radio.RATE_250KBIT in V1 but not V2 #87

microbit-matt-hillsdon opened this issue Sep 8, 2021 · 2 comments
Milestone

Comments

@microbit-matt-hillsdon
Copy link
Contributor

radio.RATE_250KBIT is not defined in MicroPython for V2 but is for V1.

It's commented out in the source: https://github.com/microbit-foundation/micropython-microbit-v2/blame/eba8995843ebc7246765b364710543c9ffee344a/src/codal_port/modradio.c#L269 (and elsewhere).

It's documented in the V2 docs radio.config data_rate parameter: https://microbit-micropython.readthedocs.io/en/v2-docs/radio.html#radio.config

It looks like the relevant MODE is deprecated for nRF52. This DevZone response that Carlos found suggests it is not tested.

If it's not reasonable to support it for V2 then we should mention this in the docs for the parameter. Happy to create a PR for that but raising this for discussion first.

dpgeorge added a commit that referenced this issue Sep 20, 2021
See issue #87.

Signed-off-by: Damien George <damien@micropython.org>
@dpgeorge
Copy link
Collaborator

In a52cd59 I made it so the user can pass in a value of "2" to select 250Kbit, if they really need it to communicate with a micro:bit v1. But otherwise they shouldn't use it and so the constant radio.RATE_250KBIT is unavailable.

@microbit-carlos
Copy link
Contributor

I've tested this with a micro:bit V1.3 and V2.2 and it works!

from microbit import *
import radio

rate = radio.RATE_250KBIT if hasattr(radio, "RATE_250KBIT") else 2
radio.config(data_rate=rate)
radio.on()

while True:
    if button_a.is_pressed():
        display.show(Image.SURPRISED)
        radio.send("hello")
    else:
        received_data = radio.receive()
        if received_data:
            display.show(received_data)
        else:
            display.show(Image.HAPPY)
    sleep(500)

I've also raised this PR to remove radio.RATE_250KBIT from the docs: bbcmicrobit/micropython#731

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

3 participants