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
intranging between 0 and 13.Ex:
config(channel=6)
-
codeair.radio.receive()[source]¶ Return the next message
stringfrom 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
Noneimmediately.- 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")