PreviousNext
RFTXpacket
Help > OS functions > RF > RFTXpacket

Function

 

Send RF packet of a specified length from bufferRF.

Purpose

 

RF transmission

Syntax

 

void RFTXpacket()

Parameters

 

  –

Return value

 

  –

Output values

 

  –

Preconditions

 

•     Peer-to-peer topology:

•         PIN = 0 (Peer-to-peer)

•         DLEN = packet length in bytes (0 to 64)

•         Prepare data to send in bufferRF[0] to bufferRF[DLEN - 1] (if DLEN ≠ 0)

•         Set RF output power via  setRFpower.

•     IQMESH:

•         PIN = 0x80 (IQMESH)

•         Other network related parameters should also be specified

•     If User encryption is used, the packet length must be selected with respect to ciphertext length. See encryptBufferRF.

See IQRF OS User’s guide.

Remarks

 

•     Unlike SPI, RF communication does not run on the OS background. This function is active on foreground until the packet is sent.

•     Duration depends on packet type and user data length.

•     RFTXpacket is allowed to be called at least 5 ms after RFRXpacket. See Example 4.

•     See Examples E01–TX, E03–TR, and E09–LINK.

•     Use wasRFICrestarted to fix possible RF IC silicon issue. See Errata - Workaround for sporadic RF IC failure.

Side effects

 

•     bufferRF[DLEN] and bufferRF[DLEN+1] are destroyed

•     System tick timing is slightly affected.

•     The RF circuitry wakes up (in case of sleeping).

See also

 

RFRXpacket, wasRFICrestarted, encryptBufferRF, setRFpower, setRFmode, and (in case of IQMESH) also other RF functions

Example 1

 

   // Peer-to-peer topology

PIN=0;                // Peer-to-peer (update also after every RFRXpacket

                      // before every RFTXpacket)

setNonetMode();

bufferRF[0] = 'I';    // Data to send

bufferRF[1] = 'Q';

DLEN = 2;             // 2 B packet

RFTXpacket();         // Send the packet to all Peer-to-peer Nodes in range

                      // and to all IQMESH Nodes having set filtering off

                      // Program stays here until the packet is sent

  ...                 // and then continues

Example 2

 

   // IQMESH without routing, packet from Coordinator to Node #10

PIN = 0;              // PIN preclearing (update also after every RFRXpacket

                      // before every RFTXpacket)

setCoordinatorMode(); // The _NTWF flag (PIN.7) is set here.

bufferRF[0] = 'I';    // Data to send

bufferRF[1] = 'Q';

DLEN = 2;             // 2 B packet

RX = 10;              // Packet for Node #10

// _ROUTEF = 0;       // Routing disabled - not necessary (default by OS)

RFTXpacket();         // Send the packet to IQMESH Node #10 in this network

                      // Reception depends on the Node (its current network

                      // or filtering)


 

Example 3

 

   // IQMESH with routing

   // Packet from Coordinator to Node #10

PIN = 0;              // PIN preclearing (update also after every RFRXpacket

                       // before every RFTXpacket)

setCoordinatorMode(); // The _NTWF flag (PIN.7) is set here.

bufferRF[0] = 'I';    // Data to send

bufferRF[1] = 'Q';

DLEN = 5;             // 5 B packet

RX = 10;              // Packet for Node #10

_ROUTEF = 1;          // Routing enabled for outgoing packets

RTDEF = 1;            // SFM (Static Full MESH)

// RTDEF = 2;         // DFM (Discovered Full MESH)

RTHOPS = 10;          // 10 hops

// RTHOPS = eeReadByte[0]; // # hops = # bonded nodes

 

RTTSLOT = 2;          // Time slot = 2 ticks (20 ms is enough for DLEN=5)

RFTXpacket();         // Send the packet to IQMESH Node #10 in this network

                      // Reception depends on the Node (its current network

                      // or filtering)

Example 4

 

if (RFRXpacket());

{

     ...              // If there is no other code taking at least 5 ms,

  waitMS(5);          //    the delay must be inluded here

  RFTXpacket()

     ... 

}