openroberta-lab icon indicating copy to clipboard operation
openroberta-lab copied to clipboard

Calliope: receive message string issues

Open taslior opened this issue 5 years ago • 4 comments

Describe the bug

the block "receive message 'String'" seems not to return the documented empty string if no message is inbound.

To Reproduce Run the code below

Expected behavior I am struggling with checking if a message has been received via bluetooth on the Calliope mini. According to the docs, if no message has been received, the block "receive message 'String'" is supposed to return an empty string. If I save the result of the block in a variable and check if that variable != "" I would expect the condition not to be true. Unfortunately this is not working. In the code below the LED shines green all the time. The same code on the same mini just with message = receive message 'number' and testing if message != 0 works as expected (in accordance with the documentation)

Screenshots grafik

Device information

  • Type Calliope Mini 1.3

Additional context The "receive message 'Number'" block returns on idle the number 0. It is not totally clear to me how I could distinguish between

  • no message transmitted and
  • someone is trying to send me the number 0.

taslior avatar Feb 27 '20 21:02 taslior

Yes this seems to be a problem, there is no real differentiation possible between "0" or empty values and "null" or no values at all. Our documentation is wrong for strings as well, because the empty PacketBuffer returned by the recv (see this) which we wrap in a ManagedString seems to evaluate to something (but not an empty string, null, or similar).

We should probably provide the dataReady method.

To do:

  • [x] change documentation for string to be "undefined"
  • [ ] implement "is message available" block
  • [ ] add "is message available" to wait until

boonto avatar Feb 28 '20 09:02 boonto

We added a workarround for the problem in our wiki, with which you can work until we fixed the issue. English wiki entry Deutscher Wiki Eintrag

philippmaurer avatar Mar 05 '20 15:03 philippmaurer

This is not a bug, but a "feature" of the firmware. The only way to solve this is to add the "message availabe" block.

bjost2s avatar Mar 06 '20 07:03 bjost2s

dataReady does not work. It uses queueDepth which is not changed when using MicroBitRadioDatagram.

This could be adjusted. MicroBitRadioDatagram::recv and MicroBitRadioDatagram::send should increase the queue depth.

heini208 avatar Apr 28 '23 11:04 heini208