

read the contents of the receive (RX) buffer, this is the message that was sent to this device Let's read out some information about the message (i.e., how many bytes did we receive and who sent the message) If(Pozyx.waitForFlag(POZYX_INT_STATUS_RX_DATA,50)) we wait up to 50ms to see if we have received an incoming message (if so we receive an RX_DATA interrupt) broadcast the contents of the TX buffer

Int status = Pozyx.writeTXBufferData(buffer, length) write the message to the transmit (TX) buffer check if we received a newline character and if so, broadcast the inputString. The code for the main loop is listed below: Finally, 100 bytes are reserved for the input string. Notice that the regRead function works with bytes, so we indicate that we want to read 2 bytes starting from the register address POZYX_NETWORK_ID and store those to bytes in the byte pointer. Next, the setup function reads out the 16 bit network id of the pozyx shield (this is the hexadecimal number printed on the label), and stores it in the global variable source_id. With POZYX_INT_MASK_RX_DATA interrupts will be triggered each time wireless data is received. Here, the pozyx device is configured such that it doesn't output debug data, and that it uses interrupt using interrupt pin 0. Lastly, with interrupt_pin it is possible to select between the two possible interrupt pins (digital pin 2 or 3 on the Arduino).

The events that should trigger in interrupt are configured by the interrupts parameter (more information about interrupts here). Alternatively, the interrupt mode configures the pozyx device to give an interrupt signal every time an event has occurred (this is the preferred way). Using the polling mode, the Arduino will constantly poll (ask) the Pozyx shield if anything happened. The first parameter indicates if we want debug information printed out, the second describes the mode: MODE_POLLING or MODE_INTERRUPT. This function checks that the Pozyx device is present and working correctly. The Pozyx.begin(boolean print_result, int mode, int interrupts, int interrupt_pin) function takes up to 4 parameters.

The other parameters for the serial port are default, i.e., 8bits, no parity, 1 stop bit. From the code it can be seen that the Serial port is used at 115200 baud (~= bits per second).
