PreviousNext
PeerToPeer
Help > Custom DPA Handler > Events > PeerToPeer

When peer-to-peer (non-networking) packets are enabled at TR Configuration then the device raises this event when such a packet is received. Peer-to-peer packets are received by all devices receiving at the same RF channel. The peer-to-peer packets can be used to implement e.g. simple battery‑operated remote control device that is not part of the DPA network. It is highly recommended to use additional security techniques (e.g. encryption, rolling code, checksum, CRC) against packet sniffing, spoofing, and eavesdropping. As the peer-to-peer packets are not networked ones, optional addressing (_DpaParams DPA variable can be misused for this purpose) must be implemented in a custom way. It is also recommended to use the lowest possible RF output power and listen-before-talk technique to minimize the risk of RF collision that might cause the main network RF traffic to fail. The following minimalistic examples show only the basic usage.

 

Example - Transmitter

 

// Set RF mode to STD-TX

setRFmode( _TX_STD );

// Prepare default PIN

PIN = 0;

// Prepare "DPA" peer-to-peer packet

 

// DPA packet fields will be used

_DPAF = 1;

// Fill in PNUM and PCMD

_PNUM = PNUM_LEDG;

_PCMD = CMD_LED_PULSE;

// No DPA Data

_DpaDataLength = 0;

// Transmit the prepared packet

RFTXpacket();

 

Example - Handler

 

case DpaEvent_PeerToPeer:

  // Peer-to-peer "DPA" packet?

  if ( _DPAF )

    // Just execute the DPA Request locally

    DpaApiLocalRequest();

 

  return Carry;

 

☼ See example code Peer-to-Peer-Transmitter.c, CustomDpaHandler-Peer-to-Peer.c, CustomDpaHandler-PIRlighting.c for more details.