PreviousNext
DPA Peer-to-Peer
Help > DPA Peer-to-Peer

DPA Peer-to-Peer (DP2P from now) allows communicating with bonded [Ns] at the existing network in non-network mode. Unlike DSM no reset or restart of the [N] is needed. DP2P is useful for inventorying the network (e.g. localization of the [Ns] after autonetwork), device maintenance, remote control, etc. Communication runs on the network A channel and the data is encrypted by an AES-128 algorithm using an access password as a key. DP2P must be enabled in the [N] configuration to work. All packets use the _DPAF flag and DPA reserves the right to use this flag exclusively only for DP2P purposes in case of non-networking packets.

 

The DP2P protocol consists of one DP2P Request packet (it contains DPA Request that is executed at the addressed [Ns]) and then DP2P Response Handshake packets exchanged between the addressed and reachable [Ns] and the device, that sent DP2P Request.

 

The following video depicts a DPA Peer-to-Peer communication.


 10.1 DP2P Request

The DP2P Request stored at bufferRF has the following structure:

 

typedef struct

{

  uns8  Header[3];  // 0x000000

  uns8  SelectedNodes[30];

  uns8  SlotLength;

  uns8  ResponseTxPower;

  uns8  Reserved;

  uns16 HWPID;

  uns8  PDATA[sizeofBufferRF - (3+30+1+1+1)*sizeof( uns8 ) - (1)*sizeof( uns16 )];

} STRUCTATTR TDP2Prequest;

 

Header                       Must consist of 3 zeros.

SelectedNodes          Specifies addressed [Ns] that should send DP2P Response back. See identically named field at Send Selective command. Communication with prebonded [Ns] is not possible.

SlotLength                 Specifies the timeslot length for the DP2P Response Handshake. The unit is 10 ms. If the default value 0 is used then the timeslot length to accommodate common DPA Request is chosen (see table below). Other values specify a custom timeslot length when the DPA Request might take a longer time (e.g. UART Write & Read) or by contrast to shorten the timeslot if the DPA Request takes short time and its response is also short (e.g. LED Pulse).

ResponseTxPower     RF output power used to send DP2P Invite and DP2P Response by [Ns]. Valid numbers are 0-7.

HWPID                      HWPID of the DPA Request.

PDATA                      PData part of the DPA Request.

 

Also, the following variables must be correctly assigned before sending the DP2P Request:

 

_PNUM                      PNUM of the DPA Request to execute at [Ns].

_PCMD                      PCMD of the DPA Request to execute at [Ns].

DLEN                        Must equal 64.

PPAR                        Length the DPA Request data payload at the PDATA field.

 

RF mode used to send DP2P Request depends on the network type. Example of sending DP2P Request:

 

// Set RF Mode

if ( "is STD network" )

  setRFmode( _WPE | _RX_STD | _TX_STD | _STDL );

if ( "is STD+LP network" )

  setRFmode( _WPE | _RX_STD | _TX_LP );

 

// DP2P Request variable

TDP2Prequest DP2Prequest @ bufferRF;

// Prepare DPA Request

// We will read 10 bytes of EEPROM from address 1

_PNUM = PNUM_EEPROM;

_PCMD = CMD_EEPROM_READ;

_DpaMessage.MemoryRequest.Address = 1;

_DpaMessage.MemoryRequest.ReadWrite.Read.Length = 10;

// DPA request data length

PPAR = sizeof( _DpaMessage.MemoryRequest.Address ) +

       sizeof( _DpaMessage.MemoryRequest.ReadWrite.Read );

 

// Save the prepared PData of the DPA Request for later copying

copyBufferRF2INFO();

// Clear DP2Prequest (it clears the Header and SelectedNodes fields)

clearBufferRF();

// Move the saved PData of the DPA Request to the correct place at the DP2P Request

memoryOffsetTo = offsetof( TDP2Prequest, PDATA );

copyBufferINFO2RF();

 

// Select Node #2 to respond

DP2Prequest.SelectedNodes[0].2 = TRUE;

// Select Node #11 to respond

DP2Prequest.SelectedNodes[1].3 = TRUE;

// Use default timeslot length

DP2Prequest.SlotLength= 0;

// Set TX power for the DP2P Response

DP2Prequest.ResponseTxPower = TX_POWER_MAX;

// Any HWPID is OK

DP2Prequest.HWPID = HWPID_DoNotCheck;

// Set the DP2P packet length

DLEN = sizeof( DP2Prequest );

// Use Access Password for encryption

encryptByAccessPassword = TRUE;

// Encrypt the DP2P Request

encryptBufferRF( sizeof( DP2Prequest ) / 16 );

// Set RF Flags

PIN = _DPAF_MASK;

// And finally send DP2P Request

RFTXpacket();