radio
– Radio Communication¶
Radio Interface
Provides point-to-point adhoc packet communications using the 2.4GHz radio module without requiring any external Wi-Fi infrastructure.
-
codeair.radio.
config
(channel)[source]¶ Update the radio configuration. Currently the only supported parameter is channel, a keyword param which must be an
int
ranging between 0 and 13.Ex:
config(channel=6)
-
codeair.radio.
receive
()[source]¶ Return the next message
string
from the receive queue. If there is no message waiting, immediately returnsNone
.
-
codeair.radio.
receive_full
()[source]¶ Retrieve the next message from the receive queue.
This function returns a tuple containing details of the received message. If no message is available in the queue, it returns
None
immediately.- Returns
- A tuple (msg, rssi, timestamp) if a message is available, where:
msg (str): The message string, as returned by
receive()
.rssi (int): The Received Signal Strength Indication (RSSI) in dBm, indicating the strength of the received signal.
timestamp (int): The system millisecond tick count at the time the message was received and queued.
If the queue is empty, returns
None
.- Return type
Example
>>> message = receive_full() >>> if message: ... print(f"Message: {message[0]}, RSSI: {message[1]} dBm, Received at: {message[2]} ms")