Skip to content

Commit da71b5c

Browse files
committed
Add documentation about the new receive_full
function in the radio module.
1 parent 525d88c commit da71b5c

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

docs/radio.rst

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ networks.
99
The radio module is conceptually very simple:
1010

1111
* Broadcast messages are of a certain configurable length (up to 251 bytes).
12-
* Messages received are read from a queue of configurable size (the larger the queue the more RAM is used). If the queue is full, new messages are ignored.
12+
* Messages received are read from a queue of configurable size (the larger the queue the more RAM is used). If the queue is full, new messages are ignored. Reading a message removes it from the queue.
1313
* Messages are broadcast and received on a preselected channel (numbered 0-100).
1414
* Broadcasts are at a certain level of power - more power means more range.
1515
* Messages are filtered by address (like a house number) and group (like a named recipient at the specified address).
1616
* The rate of throughput can be one of three pre-determined settings.
1717
* Send and receieve bytes to work with arbitrary data.
18+
* Use `receive_full` to obtain full details about an incoming message: receiving signal strength and the device's `running_time` when the message arrived.
1819
* As a convenience for children, it's easy to send and receive messages as strings.
1920
* The default configuration is both sensible and compatible with other platforms that target the BBC micro:bit.
2021

@@ -132,6 +133,28 @@ Functions
132133

133134
A ``ValueError`` exception is raised if conversion to string fails.
134135

136+
.. py:function:: receive_full()
137+
138+
Returns a tuple containing three values representing the next incoming
139+
message on the message queue. If there are no pending messages then
140+
``None`` is returned.
141+
142+
The three values in the tuple represent:
143+
144+
* the next incoming message on the message queue as bytes.
145+
* the RSSI (signal strength): a value between 0 (strongest) and -255 (weakest) as measured in dBm.
146+
* a timestamp: the value returned by `microbit.running_time` when the message was receieved.
147+
148+
For example::
149+
150+
details = radio.receive_full()
151+
if details:
152+
msg, rssi, timestamp = details
153+
154+
This function is useful for providing information needed for triangulation
155+
and/or triliteration with other micro:bit devices.
156+
157+
135158
Examples
136159
--------
137160

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy