Function |
|
Receive RF packet to bufferRF and provide related information |
Purpose |
|
RF receiving |
Syntax |
|
bit RFRXpacket() |
Parameters |
|
– |
Return value |
|
• 1 – packet received • 0 – packet not received |
Output values |
|
• lastRSSI – the RSSI value after successful receipt. RSSI [dBm] = lastRSSI – 130. • DLEN = packet length. This variable is destroyed if the receipt is not successful. • PIN is updated according to the packet received. This variable is destroyed if the receipt is not successful. • _NTWF: valid if RFRXpacket return value == 1 only: • 1 – networking packet received • 0 – non-networking packet received • Other related networking information in the case of IQMESH. |
Preconditions |
|
• Timeout should be specified in toutRF (1 to 255) in number of 10 ms ticks or for LP and XLP modes in cycles, see IQRF OS User’s guide, RF RX and TX modes). • Peer-to-peer topology: nothing else • IQMESH: network related parameters (filtering, ...) should be predefined See IQRF OS User’s guide. |
Remarks |
|
• Unlike SPI, RF communication does not run on OS background. This function is active on foreground until the packet is received or the timeout expired. Timeout during packet receiving terminates the reception except for the Wait packet end mode – see setRFmode. • If the packet is sent when the addressee (or a routing device) is not executing this function the packet is lost. • Peer-to-peer topology: All non-networking packets in the range are received. • IQMESH: The device receives only packets intended for it and optionally non-networking packets depending on filtering in the superordinate layer (DPA). • RFRXpacket is abandoned approx. 105 ms (in LP mode) or approx. 1005 ms (in XLP mode) after the packet transmission start. • In LP and XLP modes both LEDs are switched off. • After termination in LP mode, RF IC is switched to RF ready mode. • After termination in XLP mode, RF IC is switched to RF sleep mode. • See Examples E02–RX, E03–TR, E09–LINK, and E10-RFMODE-TX.c. • Use wasRFICrestarted to fix possible RF IC silicon issue. See Errata - Workaround for sporadic RF IC failure. |
Side effects |
|
• Update PIN before every RFTXpacket followed after RFRXpacket. • The result of captureTicks is destroyed if startCapture is active on background at the same time. • System tick timing is slightly affected. • bufferRF[DLEN] and bufferRF[DLEN+1] are destroyed. • The RF circuitry wakes up (in case of sleeping). • If a packet is received the A/D converter control registers are changed. |
See also |
|
RFTXpacket, wasRFICrestarted, setRFmode, checkRF and (in case of IQMESH) also other RF functions |
Example 1 |
|
// Peer-to-peer topology toutRF = 10; // RF timeout 100 ms if (RFRXpacket()) // Try to receive RF packet. // Program stays here until the packet is received // or the timeout is expired. Packet received? { // Yes: copyBufferRF2INFO(); // Store received data PacketLength = DLEN; // and possibly other info (packet length, ...) } else { // No: ... // Timeout expired. Arrange respective operations. } |
Example 2 |
|
IQMESH: See answerSystemPacket |
Example 3 |
|
if (RFRXpacket()) { if (_ROUTEF) // Was the packet routed? { // Yes - wait for finish of routing waitNewTick(); while (RTHOPS) // RTHOPS - rest of hops { waitDelay(RTTSLOT); // RTTSLOT - timeslot RTHOPS--; // Do not answer until all hops are finished } } ... // Now the Node is allowed to answer } |