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.

Note

You must import radio BEFORE from codex import *

  • The radio subsystem requires internal chip memory which must be “reserved” before the CodeX display is initialized, so that the display code can fallback to external RAM.

  • This does mean graphics will run a little slower when using the radio.

codex.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)

codex.radio.off()[source]

Disable the radio

codex.radio.on()[source]

Enable the radio

codex.radio.receive()[source]

Return the next message string from the receive queue. If there is no message waiting, immediately returns None.

codex.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

tuple or None

Example

>>> message = receive_full()
>>> if message:
...     print(f"Message: {message[0]}, RSSI: {message[1]} dBm, Received at: {message[2]} ms")
codex.radio.send(message)[source]

Send the string message over the radio.

Download Source