microsoft / microsoft/pxt-microbit
Can't get signal strength in onReceivedMessage
@microbit-carlos is already working on this.
Since Jun 5, 2026.
- Dominant language
- TypeScript
- Stars
- 804
- Forks
- 721
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 2
Description
Describe the bug
radio.receivedPacket(RadioPacketProperty.SignalStrength) does not work if called in a radio.onReceivedMessage() handler. This is true in the simulator and on micro:bit V2.
It does work in a radio.onReceivedNumber() handler. And once this has been trigger, calling radio.receivedPacket(RadioPacketProperty.SignalStrength) will show that same value in radio.onReceivedMessage().
To Reproduce
Steps to reproduce the behavior:
- Use the code
enum RadioMessage {
message1 = 49434
}
input.onButtonPressed(Button.A, function () {
radio.sendNumber(0)
})
input.onButtonPressed(Button.B, function () {
radio.sendMessage(RadioMessage.message1)
})
radio.onReceivedMessage(RadioMessage.message1, function () {
basic.showString("B")
basic.showNumber(radio.receivedPacket(RadioPacketProperty.SignalStrength))
})
radio.onReceivedNumber(function (receivedNumber) {
basic.showString("A")
basic.showNumber(radio.receivedPacket(RadioPacketProperty.SignalStrength))
})
radio.setGroup(1)
- Press button B
- This always show zero.
- Press button A
- This will show a signal strength
- Pressing B now will show the signal strength from the previous
onReceivedNumber
Expected behavior
Any of the radio.onReceived... methods should report the signal strength of the current packet.
micro:bit version (please complete the following information):
V2.21 hardware and the sim at https://makecode.microbit.org/#editor
Desktop (please complete the following information):
- OS: Fedora 43
- Browser: 1.19.13b (Firefox 150.0.3)
- Version [e.g. 22]
Additional context
I think this is because radio.sendMessage() and radio.onReceivedMessage(), take a different path compared to the other radio methods. On receipt of the radio packet they go through event.packetReceived() instead of datagram.packetReceived(). This triggers a MicroBitEvent for the message id. radio.receivedPacket works with the last packet received to MicroBitRadioDatagram.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.