Lora p2p mode header settings?

I am using LORA p2p mode in RAK 3272. Using two devices ping-pong works with the usual settings:
api.lorawan.nwm.set(0)
api.lorawan.pfreq.set(869525000)
api.lorawan.psf.set(12)
api.lorawan.pbw.set(125)
api.lorawan.pcr.set(1)
api.lorawan.ppl.set(8)
Now I want to send packets to an ESP32 with SX1262 attached using beegees SX1262 arduino library. Settings here are

#define RF_FREQUENCY 869525000
#define LORA_BANDWIDTH 0 // [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved]
#define LORA_SPREADING_FACTOR 12
#define LORA_CODINGRATE 4 // [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
#define LORA_PREAMBLE_LENGTH 8
#define LORA_SYMBOL_TIMEOUT 9
#define LORA_FIX_LENGTH_PAYLOAD_ON false
#define LORA_IQ_INVERSION_ON true
#define LORA_CRC_FLAG false

I can’t receive packets on the ESP32 side and vice versa. I do receive ‘preample’ IRQs in the Sx1262 lib but then issilence. I guess something does not match with ‘implicit header’ or ‘sync word’ or ‘crc’ or something else. What are the settings on RAK3172 side for p2p headers? Is there even a working sample for cross-platform lora p2p?

1 Like

Hi @Chris2 ,

Just a quick try, can you set the coding rate of your RAK3172 RUI3 to 3 = 4/8 to match your ESP32-SX1262’s 4:4/8?

image

2 Likes

In addition, I am not sure why you set LORA_IQ_INVERSION_ON true, I have this always set to false.

And I use LORA_SYMBOL_TIMEOUT of 0 all the time. If your preample length is 8 and your symbol timeout is 9 that will most likely not work,.

1 Like

Found the problem and/or the info. RAK p2p uses private syncword and explicit header. We use public syncword for all p2p communication to allow devices to receive LoRaWAN and p2p packets at the same time. IQ_INVERSION must be false too. Is there any chance to change syncword in RUI3 ?

I run a test this afternoon, communicating from the RAK3172 (RUI3) to a RAK11200 + RAk13300 (ESP32 and SX1262 module) and they talked to each other without any problems.

On the RAK3172 I set these parameters:

double myFreq = 916000000;
uint16_t sf = 7, bw = 125, cr = 1, preamble = 8, txPower = 22;

and initialized with

	Serial.printf("Set Node device work mode %s\r\n", api.lorawan.nwm.set(0) ? "Success" : "Fail");
	Serial.printf("Set P2P mode frequency %3.3f: %s\r\n", (myFreq / 1e6), api.lorawan.pfreq.set(myFreq) ? "Success" : "Fail");
	Serial.printf("Set P2P mode spreading factor %d: %s\r\n", sf, api.lorawan.psf.set(sf) ? "Success" : "Fail");
	Serial.printf("Set P2P mode bandwidth %d: %s\r\n", bw, api.lorawan.pbw.set(bw) ? "Success" : "Fail");
	Serial.printf("Set P2P mode code rate 4/%d: %s\r\n", (cr + 5), api.lorawan.pcr.set(0) ? "Success" : "Fail");
	Serial.printf("Set P2P mode preamble length %d: %s\r\n", preamble, api.lorawan.ppl.set(8) ? "Success" : "Fail");
	Serial.printf("Set P2P mode tx power %d: %s\r\n", txPower, api.lorawan.ptp.set(22) ? "Success" : "Fail");
	api.lorawan.registerPRecvCallback(recv_cb);
	api.lorawan.registerPSendCallback(send_cb);
	Serial.printf("P2P set Rx mode %s\r\n", api.lorawan.precv(3000) ? "Success" : "Fail");

On the ESp32 (RAK11200)

// Define LoRa parameters
#define RF_FREQUENCY 916000000	// Hz
#define TX_OUTPUT_POWER 22		// dBm
#define LORA_BANDWIDTH 0		// [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved]
#define LORA_SPREADING_FACTOR 7 // [SF7..SF12]
#define LORA_CODINGRATE 1		// [1: 4/5, 2: 4/6,  3: 4/7,  4: 4/8]
#define LORA_PREAMBLE_LENGTH 8	// Same for Tx and Rx
#define LORA_SYMBOL_TIMEOUT 0	// Symbols
#define LORA_FIX_LENGTH_PAYLOAD_ON false
#define LORA_IQ_INVERSION_ON false

and then the usual initialization with the SX126x-Arduino library

	// Initialize the Radio callbacks
	RadioEvents.TxDone = OnTxDone;
	RadioEvents.RxDone = OnRxDone;
	RadioEvents.TxTimeout = OnTxTimeout;
	RadioEvents.RxTimeout = OnRxTimeout;
	RadioEvents.RxError = OnRxError;
	RadioEvents.CadDone = NULL;
	// Initialize LoRa chip.
	lora_rak13300_init();
	// Initialize the Radio
	Radio.Init(&RadioEvents);

	// Set Radio channel
	Radio.SetChannel(RF_FREQUENCY);

	// Set Radio TX configuration
	Radio.SetTxConfig(MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
					  LORA_SPREADING_FACTOR, LORA_CODINGRATE,
					  LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
					  true, 0, 0, LORA_IQ_INVERSION_ON, TX_TIMEOUT_VALUE);

	// Set Radio RX configuration
	Radio.SetRxConfig(MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,
					  LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,
					  LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON,
					  0, true, 0, 0, LORA_IQ_INVERSION_ON, true);
1 Like

Honestly I would be amazed if you received the packets
 And as Bernd mentioned #define LORA_IQ_INVERSION_ON true is wrong too


Communication works fine now. The ‘hidden’ parameters of RUI3 are: INVIQ= false and ‘private SyncWord’ - unfortunately right the opposite of LoRaWAN :frowning:

How can I change these settings in P2P API?

(Background: We develop for an ecosystem of devices that use public sync and inviq=true for p2p communication to allow class C devices to receive LoRaWAN and P2P packets in parallel. )

Hi @Chris2

In RUI3 the IQ_INVERSION and the network type cannot be changed, there is no API call for it.
I will forward this to our R&D team, but I cannot promise whether or when it would be implemented.

Having the two API calls allows me to use the RAK3172 in our ecosystem. No problem to place some 1K or so module order or pay NRE in exchange for the two API calls.

Opened an issue with our R&D team.
They say it is not difficult, I will let you know once it’s implemented.

@Chris2

Hi Christian,

Sorry for the awful long delay. If you upgrade RAK3172 RUI3 to the latest version V4.0.5 you have two new AT commands

AT+IQINVER,RW: get or set P2P IQ inversion (1 = on, 0 = off)
AT+SYNCWORD,RW: get or set P2P syncword (0x0000 - 0xffff)

The API calls:

bool api.lora.iqInver.set(bool status);
bool api.lora.iqInver.get(void);
bool api.lora.syncword.set(uint32_t syncword); // Default is LORA_MAC_PUBLIC_SYNCWORD
uint32_t api.lora.syncword.get(void);

Example for IQ inversion:

void setup()
{
   Serial.begin(115200);
   Serial.printf("Set Node device work mode %s\r\n", api.lorawan.nwm.set(0) ? "Success" : "Fail");
   Serial.printf("Set P2P mode iqInversion %s\r\n", api.lora.iqInver.set(true) ? "Success" : "Fail");
}

void loop()
{
   Serial.printf("P2P mode iqInversion = %s\r\n", api.lora.iqInver.get()?"true":"false");
   delay(1000);
}

Example for syncword

void setup()
{
   Serial.begin(115200);
   Serial.printf("Set Node device work mode %s\r\n", api.lorawan.nwm.set(0) ? "Success" : "Fail");
   Serial.printf("Set P2P mode syncword %s\r\n", api.lora.syncword.set(LORA_MAC_PUBLIC_SYNCWORD) ? "Success" : "Fail");
}

void loop()
{
   Serial.printf("P2P mode syncword = %04x\r\n", api.lora.syncword.get());
   delay(1000);
}
1 Like

Can you tell me why is your “LORA_SYMBOL_TIMEOUT” is 0 ? in stm32 subghz example it has set to 5, what is that mean?

It depends on what you want. From the SX1262 datasheet:

image

Using a number different to 0 reduces false RX events, but it can cause RxTimeout Events.

This is my example for RAK work with Ra02 + ESP32. Hope it can help anyone same issue.

“LoRaWan P2P” is an oxymoron. It’s either LoRaWAN or LoRa P2P – the latter in your case


Hi

I’m also trying to communicate ESP32+SX1262 with RAK3172 in LORA mode.
I’m using the Radiolib library in the ESP32:

radio.setFrequency(868.8);
radio.setBandwidth(125.0);
radio.setSpreadingFactor(7); // SF7
radio.setCodingRate(5); // CR4/5
radio.setOutputPower(10);
radio.setSyncWord(0x34);
radio.setPreambleLength(8);
radio.invertIQ(false);
radio.explicitHeader();
radio.setCRC(0);

And in RAK3172:

api.lora.pfreq.set(868800000); // freq.Hz
api.lora.pbw.set(0); // 125 KHz
api.lora.psf.set(7); // SF7
api.lora.pcr.set(0); // CR5
api.lora.ptp.set(10); // 10 dBm
api.lora.ppl.set(8); // preamble length
api.lora.iqInver.set(false);
api.lora.syncword.set(LORA_MAC_PUBLIC_SYNCWORD); // 0x34
api.lora.encry.set(false);

For the information I searched it seems RAK3172 is in header explicit mode and crc disabled, can anyone confirm this?

When I send packets with the psend, nothing is received in the ESP32 (data coming from others ESP32+SX1262 are being received)

Any idea?

Thank you
Antonio

I never use the RadioLib, so I am not sure about the settings, but with ExplicitHeader on and CRC active, I can communicate over LoRa P2P with the RAK3172

Ok got it! The key was CRC=ON which for any reason I supposed it was disabled on rak3172

Thank you for your assistance!