How Texting Works
The main loop in each program is constantly waiting for you to type a message and hit enter. It’s also constantly waiting for a radio message to be received. If there are no messages coming in then it will constantly be waiting for you to send one.
If a message is received and it is not empty, meaning you have gotten a new message, then a new line is started, the message is displayed by the serial write string (join(Receive: )(message)), and then it restores the Send: prompt. It then continues waiting for you to type a message and hit enter. Then, radio send string (tx) transmits that string over the radio for another micro:bit to receive and forward to its terminal.
Remember that on radio received either stores a string or None in message. If message has a string, then it’s displayed.
Did You Know?
UART — it stands for universal asynchronous receiver transmitter. UART communication is one of several common communication protocols that devices use to exchange data.
Buffers — Incoming messages to the UART are stored in a special string called a buffer that is set aside for keeping characters until you need them. The radio object also has a buffer.
TX & RX — The abbreviation tx is short for transmit. If you see tx in projects, you might also see rx, which is shorthand for receive. For example, the message variable could be named rx instead.
Dropped Packets — In its current form, the application drops packets sometimes. In other words, not every message you type will be received and displayed by the other micro:bit.