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?

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

1 Like

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.