Source code for codex.radio

"""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.*
"""

[docs]def on(): """Enable the radio""" # Implemented in C pass
[docs]def off(): """Disable the radio""" # Implemented in C pass
[docs]def config(channel): """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)`` """ # Implemented in C pass
[docs]def send(message): """Send the `string` message over the radio.""" # Implemented in C pass
[docs]def receive(): """Return the next message `string` from the receive queue. If there is no message waiting, immediately returns `None`. """ # Implemented in C pass
[docs]def receive_full(): """ 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: tuple or None: 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`. Example: >>> message = receive_full() >>> if message: ... print(f"Message: {message[0]}, RSSI: {message[1]} dBm, Received at: {message[2]} ms") """ # Implemented in C pass